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 m_BaseConditions = new SortedDictionary(); ///// ///// 获取所有条件 ///// //public SortedDictionary BaseConditions //{ // get => m_BaseConditions; //} ///// ///// 设置参数,子类实现即可,无须调用 ///// ///// //public virtual SortedDictionary SetConditions() //{ // return m_BaseConditions; //} #endregion /// /// 条件输入对话框的标题 /// public virtual string ConditionPanelName { get; set; } #region 查询后是否需要显示查询结果窗体 /// /// 查询后是否需要显示查询结果窗体 /// public bool IsShowResultWindow { get => m_IsShowResultWindow; set => m_IsShowResultWindow = value; } private bool m_IsShowResultWindow = true; #endregion #region 是否显示查询窗口的底部Panel,包括确定和取消按钮 /// /// 是否显示查询窗口的底部Panel,包括确定和取消按钮 /// public bool IsShowPanelFooter { get => m_isShowPanelFooter; set => m_isShowPanelFooter = value; } private bool m_isShowPanelFooter = true; #endregion #region 是否在显示查询窗口的Load中执行Btn_Ok_Click方法 /// /// 是否在显示查询窗口的Load中执行Btn_Ok_Click方法 /// public bool IsLoadBtnOKClick { get; set; } #endregion #region 条件是否有效,如果false,则不会关闭对话框 /// /// 显示查询结果窗体后是否关闭条件对话框 /// 不显示查询结果窗体,但是需要禁止关闭条件对话框,请返回null /// public bool IsConditionValid { get => isConditionValid; set => isConditionValid = value; } private bool isConditionValid = true; ///// ///// 在BtnOKCancel_Click里面判断条件是否有效,如果false,则不会关闭对话框。此处可以继承实现,根据不同的条件进行设置 ///// ///// //public virtual bool ConditionValid() //{ // return IsConditionValid; //} #endregion #region 设置大小ConditionPanel大小 private Size m_ContainerSize; /// /// 设置大小,修改条件窗口ConditionForm的大小。默认尺寸是(500,400),其中ConditionPanel的尺寸是(500,315) /// 窄尺寸宽度300 宽尺寸宽度800 特宽尺寸宽度100 /// 如果设置尺寸,需要在ConditionPanel的高度上增加85 /// /// /// protected void SetSize(int width, int height) { this.ParentChanged -= ConditionPanel_ParentChanged; this.ParentChanged += ConditionPanel_ParentChanged; m_ContainerSize = new Size(width, height); } /// /// 在父窗口发生变化时候的内容,设置父窗口的大小 /// /// /// 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 /// /// 实现此方法以进行计算 /// /// public virtual object Do(DockPanel dockPanel = null)//public virtual object Do() { throw new Exception("未实现WWPipeLine.MapTools.ConditionPanel.Do方法"); } /// /// 是否以模态形式显示查询面板 /// /// public virtual bool ShowModal() { return false; } protected ResultWindow m_ResultWindow; /// /// 创建结果窗口,大多数情况下子类无须实现 /// 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(); //} } /// /// 调用此方法实现结果的展示 /// /// /// 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(); } } /// /// 点击OK并关闭对话框后执行 /// public virtual void AfterCloseWithOK() { } /// /// 点击Cancel并关闭对话框后执行 /// public virtual void AfterCloseWithCancel() { } /// /// 关闭对话框后执行 /// 光标设置箭头光标,地图设置为漫游,地图刷新 /// 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); } } }