ErrorMarkerCommand.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //======================================================================
  2. //
  3. //
  4. //
  5. // CLR 版本: 4.0.30319.1
  6. // 命名空间: Tofly.DataEditUI
  7. // 类 名: ErrorMarkerCommand
  8. // 创 建 人: 汤云伟
  9. // 创建时间: 2017/02/27 20:50:00
  10. // 修 改 人:
  11. // 修改时间:
  12. //
  13. //======================================================================
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Text;
  17. using System.Linq;
  18. using Tofly.Core.Context.Support;
  19. using Tofly.Core.Context;
  20. using Tofly.Core.ServiceLocator;
  21. using Tofly.CoreUI.Plot;
  22. using Tofly.CoreUI.Control;
  23. using Tofly.CoreUI.Message;
  24. using Tofly.CoreUI.Win.Form.Forms;
  25. using Tofly.CoreUI.Utils;
  26. using Tofly.Data.Metadata;
  27. using Tofly.GIS.Display;
  28. using Tofly.GISUI.Content;
  29. using Tofly.GISUI.Controls;
  30. using Tofly.GIS.Geometry;
  31. using Tofly.GIS.Carto;
  32. using Tofly.GIS.SpatialDatabase;
  33. using Tofly.GIS.Util;
  34. using Tofly.DataEditUI.Properties;
  35. using Tofly.GISUI.Plugin;
  36. using Tofly.Data.General;
  37. using Tofly.DataEdit.Util;
  38. namespace Tofly.DataEditUI
  39. {
  40. /// <summary>
  41. /// 查看错误标记
  42. /// </summary>
  43. [PluginComponentAttribute((long)Core.SysRegist.ModuleKey.Edit, PluginGISType.ArcGIS, GroupName = "编辑", Caption = "错误标记", Describe = "查看错误标记", IsCreate = true, States = Tofly.CoreUI.Control.Status.STATE_2D)]
  44. [Tofly.Core.Stereotype.Component(IsSingleton = "false", Name = "Tofly.DataEditUI.ErrorMarkerCommand")]
  45. public class ErrorMarkerCommand : GISPluginButtonBase
  46. {
  47. /// <summary>
  48. /// 错误标记管理窗口
  49. /// </summary>
  50. private IForm _frmErrorMarker;
  51. public ErrorMarkerCommand()
  52. {
  53. this.Enable = true;
  54. }
  55. public override void Create(IPluginContent content)
  56. {
  57. base.Create(content);
  58. }
  59. public override void Click()
  60. {
  61. try
  62. {
  63. if (this._frmErrorMarker == null)
  64. {
  65. Tofly.Data.UserInfo __uinfoCurrent = ServiceLocatorFactory.ServiceLocator.GetInstance<Tofly.Data.UserInfo>(ServiceLocatorKeys.UserInfo);
  66. ConnectionInfo __connInfo = new ConnectionInfo(__uinfoCurrent.ConnctionInfo);
  67. IWorkspaceFactory __uwsFactory = ContextRegistry.GetContext().GetObject("WorkspaceFactory_GIS") as IWorkspaceFactory;
  68. __connInfo.WorkspaceType = WorkspaceType.Oracle;
  69. IWorkspace __wsProcessing = __uwsFactory.CreateWorkspace(__connInfo);
  70. this._frmErrorMarker = ContextRegistry.GetContext().GetObject("Tofly.DataEditUI.Win.FormErrorMarker", new object[] { __wsProcessing, this.content }) as IForm;
  71. this._frmErrorMarker.FormClosedEvent += (fs) =>
  72. {
  73. this._frmErrorMarker = null;
  74. };
  75. System.Drawing.Rectangle __rectMapcontrol = new System.Drawing.Rectangle();
  76. GISUI.Utils.WindowStateHelper.GetWindowRect(new IntPtr(this.Mapcontrol.hWnd), ref __rectMapcontrol);
  77. this._frmErrorMarker.FormStartPosition = FormStartPositionType.Manual;
  78. this._frmErrorMarker.LocationTop = __rectMapcontrol.Top + 5;
  79. this._frmErrorMarker.LocationLeft = __rectMapcontrol.Left + 5;
  80. }
  81. if (this._frmErrorMarker.Visible == false)
  82. {
  83. this._frmErrorMarker.Show(this.content.PluginMainForm);
  84. }
  85. else
  86. {
  87. this._frmErrorMarker.FormWindowState = FormWindowState.Normal; //恢复窗口状态
  88. }
  89. }
  90. catch(System.Exception ex)
  91. {
  92. this._frmErrorMarker = null;
  93. MessageManager.Show("打开失败: " + ex.Message, "查看错误标记");
  94. }
  95. }
  96. }
  97. }