年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

300 lines
13 KiB

6 months ago
using DevExpress.XtraBars;
using DevExpress.XtraBars.Docking;
using DevExpress.XtraBars.Docking2010.Views.Tabbed;
using DevExpress.XtraBars.Localization;
using DevExpress.XtraBars.Ribbon;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Display;
using KGIS.Framework.Core.Services;
using KGIS.Framework.DevLocalizationCHS;
using KGIS.Framework.Maps;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using Kingo.PluginServiceInterface;
using System;
using System.Configuration;
using System.Drawing;
using System.Windows.Forms;
using UIShell.OSGi;
namespace Kingo.PlatformPlugin
{
public partial class FrmMain : RibbonForm, KGIS.Framework.Platform.Interface.IProgress, IFormMain
{
private static FrmMain _mainForm;
public RibbonControl RibControl { get; private set; }
public DockManager dockManager { get; private set; }
public TabbedView tabbedView { get; private set; }
public BarEditItem WorkPath { get; private set; }
private Timer timerResize = new Timer();
private Timer LicTimer = new Timer();
public static FrmMain GetInstance(IBundleContext context)
{
return _mainForm ?? (_mainForm = new FrmMain());
}
public FrmMain()
{
InitializeComponent();
string SystemName = "数 据";
switch (Platform.Instance.SystemType)
{
case SystemTypeEnum.DTBJK:
SystemName = "单 图 斑";
break;
case SystemTypeEnum.YCLJK:
SystemName = "图斑预处理";
break;
case SystemTypeEnum.WYZS:
SystemName = "单图斑质检";
break;
case SystemTypeEnum.RCBGJK:
SystemName = "日 常 变 更";
break;
case SystemTypeEnum.NDBGJK:
SystemName = "年 度 变 更";
break;
}
RibControl = rbMenuCtrl;
dockManager = dockManager1;
tabbedView = tabbedView1;
WorkPath = workPath;
rbMenuCtrl.ApplicationDocumentCaption = string.Format(ConfigurationManager.AppSettings.Get("APPName"), SystemName).Replace(" ", "");
this.Text = "";
Platform.Instance.Progress = this;
}
private void FrmMain_Load(object sender, EventArgs e)
{
timerResize.Interval = 1000;
timerResize.Tick += TimerResize_Tick;
timerResize.Start();
if (RunIDService2.Instance.ExpirationTime != null)
{
TimeSpan ts = ((DateTime)RunIDService2.Instance.ExpirationTime).Subtract(DateTime.Now);
licState.EditValue = string.Format("剩余{0}天{1}小时{2}分到期!", ts.Days, ts.Hours, ts.Minutes);
}
LicTimer.Interval = 60000;// 300000;
LicTimer.Tick += (s, e1) =>
{
this.Invoke((Action)delegate ()
{
string jkrjSQ = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath(), "jkrj.lic");
if (System.IO.File.Exists(jkrjSQ) && RunIDService2.Instance.UpdateLic())
{
licState.BeginUpdate();
if (RunIDService2.Instance.ExpirationTime != null)
{
TimeSpan ts = ((DateTime)RunIDService2.Instance.ExpirationTime).Subtract(DateTime.Now);
licState.EditValue = string.Format("剩余{0}天{1}小时{2}分到期!", ts.Days, ts.Hours, ts.Minutes);
}
else
{
licState.EditValue = "未授权";
MessageBox.Show("软件授权验证未通过,程序即将退出!");
EngineEditor editor = new EngineEditorClass();
if (editor.EditState == esriEngineEditState.esriEngineStateEditing)
{
editor.StopEditing(true);
}
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" });
//System.Environment.Exit(0);
Application.ExitThread();
Application.Exit();
}
licState.EndUpdate();
}
});
};
LicTimer.Start();
this.Icon = new Icon(string.Format("{0}.ico", Platform.Instance.SystemType.ToString()));
BarLocalizer.Active = new DxperienceXtraBarsLocalizationCHS();
DockManagerLocalizer.Active = new DxperienceXtraDockManagerLocalizationCHS();
DevExpress.XtraGrid.Localization.GridLocalizer.Active = new DxperienceXtraGridLocalizationCHS();
//ShowFilePath();
}
private void TimerResize_Tick(object sender, EventArgs e)
{
timerResize.Stop();
this.OnResize(e);
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "InitProject" });
ProjectInfo ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
if (ProInfo != null)
{
if (ProInfo.ProjType == EnumProjType.BHTBTQ && Platform.Instance.SystemType != SystemTypeEnum.BGFWCG
|| ProInfo.ProjType != EnumProjType.BHTBTQ && Platform.Instance.SystemType == SystemTypeEnum.BGFWCG)
{
ClearData();
LogAPI.Debug("工程类型与当前软件类型不匹配,将会导致功能不可用,请正确打开工程类型!");
KGIS.Framework.Utils.Helper.MessageHelper.ShowError("当前工程类型与当前软件类型不匹配,将会导致一些功能不可正常使用,请重新正确打开工程类型!");
return;
}
}
if (ProInfo != null && ProInfo.ProjType == EnumProjType.BHTBTQ && Platform.Instance.SystemType == SystemTypeEnum.BGFWCG)
{
//添加作业区标注
MarkLayer();
IUcZYQMagrHelper ucZYQMagrHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcZYQMagrHelper>();
if (ucZYQMagrHelper != null)
{
ucZYQMagrHelper.UpdataData();
}
IUcMulitMapControlHelper ucMulitMapControlHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcMulitMapControlHelper>();
if (ucMulitMapControlHelper != null)
{
ucMulitMapControlHelper.InitView();
ucMulitMapControlHelper.MarkLabelLayer();
if (ucMulitMapControlHelper.CurrentGeometry != null && !ucMulitMapControlHelper.CurrentGeometry.IsEmpty)
ucMulitMapControlHelper.SetMask(ucMulitMapControlHelper.CurrentGeometry);
}
}
}
private void ClearData()
{
MapsManager.Instance.MapService.getAxMapControl().ClearLayers();
if (Platform.Instance.SystemType == SystemTypeEnum.BGFWCG)
{
IUcZYQMagrHelper ucZYQMagrHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcZYQMagrHelper>();
if (ucZYQMagrHelper != null)
{
ucZYQMagrHelper.ClearData();
}
IUcMulitMapControlHelper ucMulitMapControlHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcMulitMapControlHelper>();
if (ucMulitMapControlHelper != null)
{
ucMulitMapControlHelper.ClearData();
}
}
}
private void MarkLayer()
{
try
{
IFeatureLayer pFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("ZYQ");
if (pFeatureLayer == null) return;
IGeoFeatureLayer pGeoLayer = pFeatureLayer as IGeoFeatureLayer;
IRgbColor pColor = new RgbColorClass() { Red = 85, Blue = 105, Green = 255 };
stdole.IFontDisp pFont = new stdole.StdFont()
{
Name = "宋体",
//Bold = true
} as stdole.IFontDisp;
ITextSymbol pTextSymbol = new TextSymbolClass()
{
Color = pColor,
Font = pFont,
Size = 8
};
IBasicOverposterLayerProperties pBasicOverLayerPro = new BasicOverposterLayerPropertiesClass();
pBasicOverLayerPro.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
pBasicOverLayerPro.GenerateUnplacedLabels = true;
pBasicOverLayerPro.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;
ILabelEngineLayerProperties pLableEngine = new LabelEngineLayerPropertiesClass()
{
Symbol = pTextSymbol,
IsExpressionSimple = true
};
IOverposterLayerProperties2 pOverLayerProper = pBasicOverLayerPro as IOverposterLayerProperties2;
pOverLayerProper.TagUnplaced = true;//设置该属性,目的是不被其他element遮挡
pLableEngine.BasicOverposterLayerProperties = pBasicOverLayerPro;
IAnnotateLayerProperties pAnnoPros = pLableEngine as IAnnotateLayerProperties;
pGeoLayer.AnnotationProperties.Add(pAnnoPros);
pGeoLayer.DisplayAnnotation = true;
AxMapControl axMapControl1 = MapsManager.Instance.MapService.getAxMapControl();
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, axMapControl1.Extent);
}
catch (Exception ex)
{
LogAPI.Debug("设置标注时发生异常,异常信息如下:" + ex);
return;
}
}
private void FrmMain_Shown(object sender, EventArgs e)
{
//BUG-03468 打开软件首页后,点击里面的模块后,软件首页不要放在桌面最上层
this.Activate();
}
public void CloseProgressBar()
{
try
{
this.Enabled = true;
if (splashScreenManager.IsSplashFormVisible)
{
splashScreenManager.CloseWaitForm();
splashScreenManager.WaitForSplashFormClose();//王欢 2018-11-17 splashScreenManager占用问题
}
}
catch (Exception ex)
{
LogAPI.Debug("关闭进度条异常:" + ex.Message);
}
}
private void ShowFilePath()
{
try
{
if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + "ProjectPath.xml"))
{
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "ProjectPath.xml");
System.Xml.XmlNode root = xmlDoc.SelectSingleNode("Root/File");
if (root == null) return;
string filePath = root.Attributes[0].Value;
if (true == string.IsNullOrEmpty(filePath) || false == System.IO.File.Exists(filePath))
{
return;
}
workPath.EditValue = System.IO.Path.GetDirectoryName(filePath);
}
}
catch (Exception ex)
{
LogAPI.Debug("读取文件异常:" + ex.Message);
}
}
public void SetWorkPath(string path)
{
if (!string.IsNullOrEmpty(path))
{
workPath.EditValue = path;
}
}
public void ShowProgressBar(string message = "", int CountProgress = 0, int currentProgress = 0, string caption = "提示")
{
}
public void UpdateProgressBarMessage(string message = "", int CountProgress = 0, int currentProgress = 0, string caption = "提示")
{
}
public void SetStateMsg(string pMsg)
{
// string.Format("X:{0:F3} Y:{1:F3} Unit {2}", o.mapX, o.mapY, Platform.Instance.MapsService.getAxMapControl().Map.MapUnits);
toolStripStatusLabel1.Text = pMsg;
}
public void SetLocationInfo(string pLocation)
{
this.labCurrentLocation.Text = pLocation;
}
}
}