Example #1
0
        //protected override void OnClick(EventArgs e)
        //{
        //    base.OnClick(e);

        //    MessageBox.Show("chufa  click");
        //}

        protected override void OnMouseClick(MouseEventArgs e)
        {
            #region 左键判断是否在关闭区域
            if (e.Button == MouseButtons.Left)
            {
                Point     p = e.Location;
                Rectangle r = GetTabRect(this.SelectedIndex);
                r.Offset(r.Width - iconWidth - 3, 2);
                r.Width  = iconWidth;
                r.Height = iconHeight;
                if (r.Contains(p)) //点击特定区域时才发生
                {
                    string temp = this.SelectedTab.Text;
                    if (temp[temp.Length - 5] == '*')//有变化才保存
                    {
                        //确认是否保存VSD文档到ft_doc_Path
                        DialogResult response = MessageBox.Show("是否保存故障树" + this.SelectedTab.Name + "到图形文件", "请确认", MessageBoxButtons.YesNoCancel,
                                                                MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                        if (response == System.Windows.Forms.DialogResult.Yes)//确认保存
                        {
                            //axDrawingControl1.Document.SaveAs(GlobalVariables.ft_doc_Path + axDrawingControl1.Document.Title + ".vsd");//保存当前文档到文件夹
                            //string datetime = DateTime.Now.ToString();//获取当前时间
                            //helpTool.saveVsdDB(axDrawingControl1.Document.Title, datetime);//保存vsd文档到数据库
                            //helpTool.setDatetimeToXml(axDrawingControl1.Document.Title, datetime);//如果信息已存在则将xml中的日期更新,如果不存在直接插入
                            //this.SelectedTab.Text = temp.Substring(0, temp.Length - 5) + "   ";//保存后取消星号标志,还原为没变化的时候的样式
                        }
                        else if (response == System.Windows.Forms.DialogResult.Cancel) //点击取消或者关闭
                        {
                            return;                                                    //直接退出,撤销这次关闭程序的事件。
                        }
                    }
                    if (this.TabCount == 1)//是最后一个选项卡,直接关闭父界面,即画图界面
                    {
                        //father.DisposeForTabControl(true);
                        ModelDesignProject.RemoveDataSource(this.SelectedTab.Name.Split(SysConstManage.Underline)[0]);
                        this.TabPages.Remove(this.SelectedTab);
                    }
                    else//不是最后一个
                    {
                        this.TabPages.Remove(this.SelectedTab);
                    }
                }
            }
            #endregion
        }