//创建窗体对象的静态方法 public static NewProjectInterface InstanceObject() { if (_instance == null) { _instance = new NewProjectInterface(); } return(_instance); }
private void newBtn_Click(object sender, EventArgs e) { NewProjectInterface NewProject = NewProjectInterface.InstanceObject(); NewProject.Focus(); NewProject.MyLoadPreparePageEvents += new NewProjectInterface.LoadPreparePageEvents(LoadPreparePage); NewProject.SetInitBtn += new System.Action <object>(InitialInterface_SetBtn); NewProject.Show(); }
/// <summary> /// 设置按钮是否可用 ,打开文件前,部分按钮不可用 /// </summary> /// <param name="sender"></param> private void InitialInterface_SetBtn(object sender) { if (sender is ProNameList) { ProNameList proNameList = (ProNameList)sender; if (proNameList.IsOpen) { MessageBox.Show("成功载入文件,选项已解锁,请继续操作"); this.preBtn.Enabled = true; this.preBtn.BackColor = SystemColors.ActiveCaption; this.nodeBtn.Enabled = true; this.nodeBtn.BackColor = SystemColors.ActiveCaption; this.analysisBtn.Enabled = true; this.analysisBtn.BackColor = SystemColors.ActiveCaption; this.printBtn.Enabled = true; this.printBtn.BackColor = SystemColors.ActiveCaption; this.导出ToolStripMenuItem1.Enabled = true; this.节点划分ToolStripMenuItem1.Enabled = true; this.项目准备ToolStripMenuItem1.Enabled = true; this.hazop分析ToolStripMenuItem1.Enabled = true; } } if (sender is NewProjectInterface) { NewProjectInterface proNameList = (NewProjectInterface)sender; if (proNameList.IsNew) { this.preBtn.Enabled = true; this.preBtn.BackColor = SystemColors.ActiveCaption; this.nodeBtn.Enabled = true; this.nodeBtn.BackColor = SystemColors.ActiveCaption; this.analysisBtn.Enabled = true; this.analysisBtn.BackColor = SystemColors.ActiveCaption; this.printBtn.Enabled = true; this.printBtn.BackColor = SystemColors.ActiveCaption; this.导出ToolStripMenuItem1.Enabled = true; this.节点划分ToolStripMenuItem1.Enabled = true; this.项目准备ToolStripMenuItem1.Enabled = true; this.hazop分析ToolStripMenuItem1.Enabled = true; } } }
//窗体关闭事件 private void NewProjectInterface_FormClosing(object sender, FormClosingEventArgs e) { _instance = null; }