/// <summary> /// !!! 在每一次更改选择项时刷新滚动条和日历的时间跨度,以及终结旧线程,创建新的线程 /// </summary> /// <remarks></remarks> private DateSpan Refesh_FocusOn_DateSpan(Drawings_For_Rolling Selected_Drawings) { // ------------------------------------- 包含所有要进行滚动的线程的数组 // bool blnDateSpanInitialized = false; DateSpan DateSpan = new DateSpan(); // // ------------------------------------------ 标高剖面图 ClsDrawing_ExcavationElevation ele = Selected_Drawings.SectionalView; if (ele != null) { //更新滚动界面的时间跨度 DateSpan = RenewTimeSpan(ref blnDateSpanInitialized, DateSpan, ele.DateSpan); } // ------------------------------------------ 开挖平面图 ClsDrawing_PlanView Plan = Selected_Drawings.PlanView; if (Plan != null) { //更新滚动界面的时间跨度 DateSpan = RenewTimeSpan(ref blnDateSpanInitialized, DateSpan, Plan.DateSpan); } // ------------------------------------------ 监测曲线图 foreach (clsDrawing_Mnt_RollingBase Moni in Selected_Drawings.RollingMnt) { //更新滚动界面的时间跨度 DateSpan = RenewTimeSpan(ref blnDateSpanInitialized, DateSpan, Moni.DateSpan); } return(DateSpan); }
/// <summary> /// 在整个程序中的可以滚动的图表发生增加或者减少时触发的事件: /// 刷新窗口中的列表框的数据与其UI显示 /// </summary> /// <remarks></remarks> private Drawings_For_Rolling RefreshUI_RollingDrawings() { Drawings_For_Rolling SelectedDrawings = new Drawings_For_Rolling(this); // 主程序中所有可以滚动的图形的汇总() RollingEnabledDrawings RollingMethods = GlobalApplication.Application.ExposeRollingDrawings(); // ClsDrawing_PlanView plan = RollingMethods.PlanView; SelectedDrawings.PlanView = plan; CheckBox_PlanView.Tag = plan; if (plan != null) { CheckBox_PlanView.Checked = true; CheckBox_PlanView.Enabled = true; } else { CheckBox_PlanView.Checked = false; CheckBox_PlanView.Enabled = false; } // ClsDrawing_ExcavationElevation Sectional = RollingMethods.SectionalView; SelectedDrawings.SectionalView = Sectional; CheckBox_SectionalView.Tag = Sectional; if (Sectional != null) { CheckBox_SectionalView.Checked = true; CheckBox_SectionalView.Enabled = true; } else { CheckBox_SectionalView.Checked = false; CheckBox_SectionalView.Enabled = false; } // -------------- 为窗口中的控件赋值 ------------------------ // List <LstbxDisplayAndItem> listMnt = new List <LstbxDisplayAndItem>(); foreach (clsDrawing_Mnt_RollingBase M in RollingMethods.MonitorData) { listMnt.Add(new LstbxDisplayAndItem(DisplayedText: M.Chart_App_Title, Value: M)); } this.ListBoxMonitorData.DisplayMember = LstbxDisplayAndItem.DisplayMember; this.ListBoxMonitorData.DataSource = listMnt; SelectedDrawings.RollingMnt.Clear(); foreach (LstbxDisplayAndItem item in this.ListBoxMonitorData.SelectedItems) { SelectedDrawings.RollingMnt.Add((clsDrawing_Mnt_RollingBase)item.Value); } return(SelectedDrawings); }
/// <summary> /// 为每一个选择的要进行滚动的图形构造一个线程 /// </summary> /// <param name="Selected_Drawings"></param> /// <remarks></remarks> private void ConstructRollingThreads(Drawings_For_Rolling Selected_Drawings) { AbortAllThread(F_arrThread); // ------------------------------------- 包含所有要进行滚动的线程的数组 short SelectedDrawingsCount = Selected_Drawings.Count(); // F_arrThread = new Thread[SelectedDrawingsCount - 1 + 1]; F_arrThreadDelegete = new ParameterizedThreadStart[SelectedDrawingsCount - 1 + 1]; //' short btThread = (short)0; // // // ------------------------------------------ 标高剖面图 ClsDrawing_ExcavationElevation ele = Selected_Drawings.SectionalView; if (ele != null) { //为线程数组中的元素线程赋值 F_arrThreadDelegete[btThread] = new ParameterizedThreadStart(ele.Rolling); Thread thd = new Thread(F_arrThreadDelegete[btThread]); thd.Name = "滚动标高剖面图"; F_arrThread[btThread] = thd; F_arrThread[btThread].IsBackground = true; btThread++; } // ------------------------------------------ 开挖平面图 ClsDrawing_PlanView Plan = Selected_Drawings.PlanView; if (Plan != null) { //为线程数组中的元素线程赋值 F_arrThreadDelegete[btThread] = new ParameterizedThreadStart(Plan.Rolling); Thread thd = new Thread(F_arrThreadDelegete[btThread]); thd.Name = "滚动开挖平面图"; F_arrThread[btThread] = thd; F_arrThread[btThread].IsBackground = true; btThread++; } // ------------------------------------------ 监测曲线图 foreach (clsDrawing_Mnt_RollingBase Moni in Selected_Drawings.RollingMnt) { //为线程数组中的元素线程赋值 F_arrThreadDelegete[btThread] = new ParameterizedThreadStart(Moni.Rolling); Thread thd = new Thread(F_arrThreadDelegete[btThread]); thd.Name = "滚动监测曲线图"; F_arrThread[btThread] = thd; F_arrThread[btThread].IsBackground = true; btThread++; } }
/// <summary> /// 构造函数 /// </summary> /// <remarks></remarks> public frmRolling() { // This call is required by the designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. // this.FocusOn_DateSpan = null; this.F_Rollingday = DateTime.Today; CheckBox_PlanView.Enabled = false; CheckBox_SectionalView.Enabled = false; // this.F_SelectedDrawings = new Drawings_For_Rolling(this); }
//选择复选框或者列表项——更新滚动线程与窗口界面 /// <summary> /// !选择的图形发生改变时,更新滚动线程与窗口界面。 /// </summary> /// <param name="Selected_Drawings">更新后的要进行滚动的图形</param> /// <remarks>此方法不能直接Handle复选框的CheckedChanged或者列表框的SelectedIndexChanged事件, /// 因为此方法必须是在更新了Me.F_SelectedDrawings属性之后,才能去更新窗口界面。</remarks> private void SelectedRollingDrawingsChanged(Drawings_For_Rolling Selected_Drawings) { // ConstructRollingThreads(Selected_Drawings); this.FocusOn_DateSpan = Refesh_FocusOn_DateSpan(Selected_Drawings); // if (Selected_Drawings.Count() > 0) { F_blnHasDrawingToRoll = true; } else { F_blnHasDrawingToRoll = false; } RefreshUI_SelectedDrawings(F_blnHasDrawingToRoll, this.F_FocusOn_DateSpan); // }
/// <summary> /// 在此方法中,触发了滚动窗口的RollingDrawingsRefreshed事件: /// 刷新滚动窗口中的列表框的数据与其UI显示 /// </summary> /// <remarks></remarks> public void OnRollingDrawingsRefreshed() { if (this.InvokeRequired) { this.BeginInvoke(new RollingDrawingsRefreshedHandler(this.OnRollingDrawingsRefreshed)); } else { frmRolling with_1 = this; try { this.F_SelectedDrawings = RefreshUI_RollingDrawings(); SelectedRollingDrawingsChanged(this.F_SelectedDrawings); } catch (Exception ex) { MessageBox.Show("在添加或者删除程序中的图表时,滚动窗口的界面刷新出错。" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }