123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- using System;
- using System.Data;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Windows.Forms;
- using WeifenLuo.WinFormsUI.Docking;
- using WWPipeLine.MapBasic.Results;
- using SuperMap.Mapping;
- using SuperMap.UI;
- using SuperMap.Data;
- using Sunny.UI;
- namespace WWPipeLine.MapBasic.Conditions
- {
- public class ConditionPanel : Sunny.UI.UIPanel
- {
- #region BaseConditions的设置和获取
- //protected SortedDictionary<string, object> m_BaseConditions = new SortedDictionary<string, object>();
- ///// <summary>
- ///// 获取所有条件
- ///// </summary>
- //public SortedDictionary<string, object> BaseConditions
- //{
- // get => m_BaseConditions;
- //}
- ///// <summary>
- ///// 设置参数,子类实现即可,无须调用
- ///// </summary>
- ///// <returns></returns>
- //public virtual SortedDictionary<string, object> SetConditions()
- //{
- // return m_BaseConditions;
- //}
- #endregion
- /// <summary>
- /// 条件输入对话框的标题
- /// </summary>
- public virtual string ConditionPanelName { get; set; }
- #region 查询后是否需要显示查询结果窗体
- /// <summary>
- /// 查询后是否需要显示查询结果窗体
- /// </summary>
- public bool IsShowResultWindow { get => m_IsShowResultWindow; set => m_IsShowResultWindow = value; }
- private bool m_IsShowResultWindow = true;
- #endregion
- #region 是否显示查询窗口的底部Panel,包括确定和取消按钮
- /// <summary>
- /// 是否显示查询窗口的底部Panel,包括确定和取消按钮
- /// </summary>
- public bool IsShowPanelFooter { get => m_isShowPanelFooter; set => m_isShowPanelFooter = value; }
- private bool m_isShowPanelFooter = true;
- #endregion
- #region 是否在显示查询窗口的Load中执行Btn_Ok_Click方法
- /// <summary>
- /// 是否在显示查询窗口的Load中执行Btn_Ok_Click方法
- /// </summary>
- public bool IsLoadBtnOKClick { get; set; }
- #endregion
- #region 条件是否有效,如果false,则不会关闭对话框
- /// <summary>
- /// 显示查询结果窗体后是否关闭条件对话框
- /// <para>不显示查询结果窗体,但是需要禁止关闭条件对话框,请返回null</para>
- /// </summary>
- public bool IsConditionValid { get => isConditionValid; set => isConditionValid = value; }
- private bool isConditionValid = true;
- ///// <summary>
- ///// 在BtnOKCancel_Click里面判断条件是否有效,如果false,则不会关闭对话框。此处可以继承实现,根据不同的条件进行设置
- ///// </summary>
- ///// <returns></returns>
- //public virtual bool ConditionValid()
- //{
- // return IsConditionValid;
- //}
- #endregion
- #region 设置大小ConditionPanel大小
- private Size m_ContainerSize;
- /// <summary>
- /// 设置大小,修改条件窗口ConditionForm的大小。默认尺寸是(500,400),其中ConditionPanel的尺寸是(500,315)
- /// <para>窄尺寸宽度300 宽尺寸宽度800 特宽尺寸宽度100</para>
- /// <para>如果设置尺寸,需要在ConditionPanel的高度上增加85</para>
- /// </summary>
- /// <param name="width"></param>
- /// <param name="height"></param>
- protected void SetSize(int width, int height)
- {
- this.ParentChanged -= ConditionPanel_ParentChanged;
- this.ParentChanged += ConditionPanel_ParentChanged;
- m_ContainerSize = new Size(width, height);
- }
- /// <summary>
- /// 在父窗口发生变化时候的内容,设置父窗口的大小
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ConditionPanel_ParentChanged(object sender, EventArgs e)
- {
- Control topParent = this;
- while (!(topParent is Form))
- {
- topParent = topParent.Parent;
- if (topParent == null) break;
- }
- if (topParent == null) return;
- topParent.Size = this.m_ContainerSize;
- }
- #endregion
- /// <summary>
- /// 实现此方法以进行计算
- /// </summary>
- /// <param name="dockPanel"></param>
- public virtual object Do(DockPanel dockPanel = null)//public virtual object Do()
- {
- throw new Exception("未实现WWPipeLine.MapTools.ConditionPanel.Do方法");
- }
- /// <summary>
- /// 是否以模态形式显示查询面板
- /// </summary>
- /// <returns></returns>
- public virtual bool ShowModal()
- {
- return false;
- }
- protected ResultWindow m_ResultWindow;
- /// <summary>
- /// 创建结果窗口,大多数情况下子类无须实现
- /// </summary>
- protected virtual void CreateResultWindow()
- {
- var conditionFullName = this.GetType().FullName.Replace(".Conditions.", ".Results.") + ",WWPipeLine.MapTools";
- var type = Type.GetType(conditionFullName);
- if (type == null)
- {
- //Commons.LogHelper.Warn(conditionFullName + "CreateResultWindow 创建结果面板时未找到结果面板,使用RWWithDataGridView");
- type = Type.GetType("WWPipeLine.MapBasic.Results.RWWithDataGridView,WWPipeLine.MapBasic");
- }
- //if (type == null && !this.GetType().FullName.Contains("Statistics"))
- //{
- // Commons.LogHelper.Warn(conditionFullName + "CreateResultWindow 创建结果面板时未找到结果面板,使用RWWithDataGridView");
- // type = Type.GetType("WWPipeLine.MapBasic.Results.RWWithDataGridView,WWPipeLine.MapBasic");
- //}
- //else if (type == null)
- //{
- // Commons.LogHelper.Warn(conditionFullName + "CreateResultWindow 创建结果面板时未找到结果面板,使用Statics.RWWithChartBar");
- // type = Type.GetType("WWPipeLine.MapBasic.Results.RWWithChartBar,WWPipeLine.MapBasic");
- //}
- m_ResultWindow = (ResultWindow)Activator.CreateInstance(type);
- //if (this.m_BaseConditions.ContainsKey("SelectLayerNameConditionPanel"))
- //{
- // m_ResultWindow.FindLayerName = m_BaseConditions["SelectLayerNameConditionPanel"].ToString();
- //}
- }
- /// <summary>
- /// 调用此方法实现结果的展示
- /// </summary>
- /// <param name="data"></param>
- /// <param name="ds"></param>
- public virtual void ShowResult(object data, DockPanel dp = null, string resultForm = "执行结果")
- {
- CreateResultWindow();
- if (m_ResultWindow == null)
- {
- Commons.LogHelper.Warn(resultForm + " ShowResult m_ResultWindow == null 显示结果时未找到结果面板"); return;
- }
- bool reShow = false;
- if (m_ResultWindow.IsDisposed)
- {
- reShow = true;
- CreateResultWindow();
- }
- m_ResultWindow.TabText = resultForm;
- m_ResultWindow.Text = resultForm;
- m_ResultWindow.ShowData(data);
- if (!reShow && m_ResultWindow.Visible) return;
- if (dp != null)
- {
- m_ResultWindow.Show(dp, DockState.DockRight);
- }
- else
- {
- m_ResultWindow.Show();
- }
- }
- /// <summary>
- /// 点击OK并关闭对话框后执行
- /// </summary>
- public virtual void AfterCloseWithOK() { }
- /// <summary>
- /// 点击Cancel并关闭对话框后执行
- /// </summary>
- public virtual void AfterCloseWithCancel() { }
- /// <summary>
- /// 关闭对话框后执行
- /// <para> 光标设置箭头光标,地图设置为漫游,地图刷新</para>
- /// </summary>
- public virtual void AfterClose()
- {
- MapControl.Map.TrackingLayer.Clear();
- //MapControl.Map.RefreshTrackingLayer();
- MapControl.Action = SuperMap.UI.Action.Select;
- MapControl.Action = SuperMap.UI.Action.Pan;
- MapControl.Map.Refresh();
- }
- //protected IMessageInterface MessageInterface
- //{
- // get
- // {
- // if (this.BaseConditions.ContainsKey("IMessageInterface"))
- // return BaseConditions["IMessageInterface"] as IMessageInterface;
- // else
- // return null;
- // }
- //}
- //protected DockPanel DockPanelConditionPanel
- //{
- // get
- // {
- // if (this.BaseConditions.ContainsKey("DockPanelConditionPanel"))
- // return BaseConditions["DockPanelConditionPanel"] as DockPanel;
- // else
- // return null;
- // }
- //}
- //protected MapControl MapControl
- //{
- // get
- // {
- // if (this.BaseConditions.ContainsKey("MapControlConditionPanel"))
- // return BaseConditions["MapControlConditionPanel"] as MapControl;
- // else
- // return null;
- // }
- //}
- protected MapControl MapControl
- {
- get => ComsStatic.MapControl;
- }
- //protected string SelectLayerNameConditionPanel
- //{
- // get
- // {
- // if (this.BaseConditions.ContainsKey("SelectLayerNameConditionPanel"))
- // return BaseConditions["SelectLayerNameConditionPanel"] as string;
- // else
- // return null;
- // }
- //}
- //protected DatasetVector dvJSLK_cp
- //{
- // get => ComsStatic.dvJSLK;
- //}
- //protected EditHistory m_EditHistory = null;
- //public EditHistory EditHistory { get => m_EditHistory; set => m_EditHistory = value; }
- //public void EditHistoryUndo()
- //{
- // while (m_EditHistory.CanUndo)
- // {
- // m_EditHistory.Undo();
- // }
- //}
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // ConditionPanel
- //
- this.AutoSize = true;
- this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
- this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.Name = "ConditionPanel";
- this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
- this.Size = new System.Drawing.Size(87, 95);
- this.Style = Sunny.UI.UIStyle.Gray;
- this.ResumeLayout(false);
- }
- }
- }
|