123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using SuperMap.Mapping;
- using SuperMap.UI;
- using System;
- using System.Windows.Forms;
- using WeifenLuo.WinFormsUI.Docking;
- using WWPipeLine.MapBasic;
- using WWPipeLine.MapBasic.Conditions;
- namespace WWPipeLine.MapTools
- {
- /// <summary>
- /// 调节器
- /// </summary>
- public class Conditioner
- {
- private static Conditioner m_Instance;
- //private DockPanel m_DockPanel = ComsStatic.DockPanel;
- //private DockPanel m_DockPanel;
- //public void SetDockPanelConditioner(DockPanel dp)
- //{
- // m_DockPanel = dp;
- //}
- //private MapControl m_MapControl = ComsStatic.MapControl;
- //private MapControl m_MapControl;
- //public void SetMapControl(MapControl mapControl)
- //{
- // m_MapControl = mapControl;
- //}
- private MapEx m_MapEx;
- public void SetMapEx(MapEx mapEx)
- {
- m_MapEx = mapEx;
- }
- public static Conditioner Instance
- {
- get
- {
- if (m_Instance == null) { m_Instance = new Conditioner(); }
- return m_Instance;
- }
- }
- //private IMessageInterface m_MessageInterface = ComsStatic.MessageInterface;
- //private IMessageInterface m_MessageInterface;
- //public IMessageInterface MessageInterface { get => m_MessageInterface; set => m_MessageInterface = value; }
- /// <summary>
- /// 检查该类型的窗体,是否已经处在打开状态
- /// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- private Control OpenMapEx(Type type)
- {
- var fs = Application.OpenForms;
- foreach (Form form in fs)
- {
- if (form.GetType() == type)
- {
- return form;
- }
- var cs = form.Controls.Find(type.Name, true);
- if (cs != null && cs.Length > 0)
- return cs[0];
- }
- foreach (Control c in this.m_MapEx.Controls)
- {
- if (c.GetType() == type)
- {
- return c;
- }
- }
- return null;
- }
- public void CreateCondition(string type)
- {
- if (ComsStatic.MapControl.Map.Layers.Count == 0) { Sunny.UI.UIMessageTip.ShowError("请先打开工作空间"); return; }
-
- var conditionFullName = "WWPipeLine.MapTools.Conditions." + type + ",WWPipeLine.MapTools";
- var cond = Type.GetType(conditionFullName);
- if (cond == null) { Sunny.UI.UIMessageTip.ShowError("没有对当前按钮做相应的操作。"); return; }
- //"CreateCondition " + conditionFullName + "is Null。
- var openedControl = OpenMapEx(cond);
- if (openedControl != null)
- {
- openedControl.Focus(); return;
- }
- ConditionPanel cp = (ConditionPanel)Activator.CreateInstance(cond);
- //cp.BaseConditions.Add("IMessageInterface", this.m_MessageInterface);
- //cp.BaseConditions.Add("DockPanelConditionPanel", this.m_DockPanel);
- //cp.BaseConditions.Add("MapControlConditionPanel", this.m_MapControl);
- //cp.CreateResultWindow();
- //当点击功能菜单的RibbonButton按钮时,禁止创建结果窗体ResultWindow,为了后续的传值
- //只有当点击条件窗体ConditionForm的OK按键的时候,才创建结果窗体ResultWindow
- string formText;
- if (string.IsNullOrEmpty(cp.ConditionPanelName))
- {
- formText = "条件输入";
- }
- else
- {
- formText = cp.ConditionPanelName;
- }
- foreach (Form form in Application.OpenForms)
- {
- if (form is ConditionForm && form.Text == formText)
- {
- form.Close(); break;
- }
- }
- m_MapEx.RemoveAllToolBar();
- if (cp is BasicToolBar)
- {
- m_MapEx.AddToolBar(cp as BasicToolBar); return;
- }
- ConditionForm cf = new ConditionForm(cp)
- {
- Text = formText,
- //DockPanel = this.m_DockPanel,
- //MessageInterface = this.m_MessageInterface
- };
- if (cp.ShowModal())
- {
- cf.ShowDialog(Application.OpenForms[0]); return;
- }
- cf.Show();
- }
- }
- }
|