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
- {
-
-
-
- public class Conditioner
- {
- private static Conditioner m_Instance;
-
-
-
-
-
-
-
-
-
-
-
-
- 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 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; }
-
- var openedControl = OpenMapEx(cond);
- if (openedControl != null)
- {
- openedControl.Focus(); return;
- }
- ConditionPanel cp = (ConditionPanel)Activator.CreateInstance(cond);
-
-
-
-
-
-
- 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,
-
-
- };
- if (cp.ShowModal())
- {
- cf.ShowDialog(Application.OpenForms[0]); return;
- }
- cf.Show();
- }
- }
- }
|