private Excel.Chart F_Chart; // VBConversions Note: Initial value cannot be assigned here since it is non-static. Assignment has been moved to the class constructors. /// <summary> /// 当在数据列上双击时执行相应的操作 /// </summary> /// <param name="ElementID">在图表上双击击中的对象</param> /// <param name="Arg1">所选数据系列在集合中的索引下标值,注意,第一第曲线的下标值为1,而不是0。</param> /// <param name="Arg2"></param> /// <param name="Cancel"></param> /// <remarks>要么将其删除,要么将其锁定在图表中,要么什么都不做</remarks> private void SeriesChange(int ElementID, int Arg1, int Arg2, ref bool Cancel) { if (ElementID == (int)Excel.XlChartItem.xlSeries) { Debug.Print("当前选择的曲线下标值为: " + System.Convert.ToString(Arg1)); //所选数据系列在集合中的索引下标值,注意,第一第曲线的下标值为1,而不是0 int seriesIndex = Arg1; //所选的数据系列 Excel.Series seri; Excel.SeriesCollection seriColl = this.Chart.SeriesCollection() as Excel.SeriesCollection; seri = seriColl.Item(seriesIndex); // -------- 打开处理对话框,并根据返回的不同结果来执行不同的操作 DiaFrm_LockDelete diafrm = new DiaFrm_LockDelete(); //判断要删除的曲线是否为当前滚动的曲线,有如下两种判断方法 bool blnDeletingTheRollingCurve = false; blnDeletingTheRollingCurve = seriesIndex == cst_LboundOfSeriesInCollection; //blnDeletingTheRollingCurve = (seri.Name = F_movingSeries.Name) if (F_CurvesCount == 1 || blnDeletingTheRollingCurve) { //如果图表中只有一条曲线,或者点击的正好是要正在进行滚动的曲线,那么这条曲线不能被删除 diafrm.btn2.Enabled = false; diafrm.AcceptButton = diafrm.btn1; } else //只能进行删除 { diafrm.btn1.Enabled = false; diafrm.AcceptButton = diafrm.btn2; } //在界面上取消图表对象的选择 this.Sheet_Drawing.Range["A1"].Activate(); this.Application.ScreenUpdating = false; //---------------------------------- 开始执行数据系列的添加或删除 //此数据列对应的施工日期 DateTime t_date = default(DateTime); SeriesTag SrTag = default(SeriesTag); try { SrTag = this.F_DicSeries_Tag[seriesIndex]; t_date = SrTag.ConstructionDate; } catch (Exception ex) { MessageBox.Show("提取字典中的元素出错,字典中没有此元素。" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //---------------------------------------- M_DialogResult result = default(M_DialogResult); string strPrompt = "The date value for the selected series is:" + "\r\n" + t_date.ToString(AMEApplication.DateFormat) + "\r\n" + "Choose to Lock or Delete this series..."; result = diafrm.ShowDialog(strPrompt, "Lock or Delete Series"); //---------------------------------------- switch (result) { case M_DialogResult.Delete: //删除数据系列 try { DeleteSeries(seriesIndex); } catch (Exception ex) { Debug.Print("删除数据系列出错。" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name); } break; case M_DialogResult.Lock: //添加数据系列 try { CopySeries(seriesIndex); } catch (Exception ex) { Debug.Print(ex.Message); MessageBox.Show("添加数据系列出错。" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; } this.Application.ScreenUpdating = true; } //覆盖原来的双击操作 Cancel = true; this.Sheet_Drawing.Range["A1"].Activate(); }
public void btnDelete_Click(object sender, EventArgs e) { result = Miscellaneous.M_DialogResult.Delete; this.Close(); }
public void btnIgnore_Click(object sender, EventArgs e) { result = Miscellaneous.M_DialogResult.Cancel; this.Close(); }
//点击按钮 public void btnLock_Click(object sender, EventArgs e) { result = Miscellaneous.M_DialogResult.Lock; this.Close(); }