/// <summary> /// 保存文件 /// </summary> private void OnFileSave(object sender, EventArgs e) { DocumentForm activeDocForm = this.ActiveMdiChild as DocumentForm; if (activeDocForm == null) { return; } SharpCAD.DatabaseServices.Database db = activeDocForm.document.database; if (db.fileName == null) { SaveFileDialog savedialog = new SaveFileDialog(); savedialog.Title = GlobalData.GlobalLanguage.MenuItem_Save; savedialog.Filter = GlobalData.GlobalLanguage.Document_SaveFilter; savedialog.FilterIndex = 0; savedialog.RestoreDirectory = true; savedialog.CheckPathExists = true; savedialog.FileName = activeDocForm.Text; if (savedialog.ShowDialog() == DialogResult.OK) { string fileFullPath = savedialog.FileName; activeDocForm.SaveAs(fileFullPath, true); } } else { activeDocForm.Save(); } }
private void OpenFile(string fileFullPath) { // 检查是否已经打开 string fileFullPathLower = fileFullPath.ToLower(); foreach (Form form in this.MdiChildren) { DocumentForm childDocForm = form as DocumentForm; if (childDocForm == null) { continue; } string strDocPath = childDocForm.fileFullPath.ToLower(); if (fileFullPathLower == strDocPath) { childDocForm.Activate(); return; } } // 打开文件 DocumentForm docForm = new DocumentForm(); if (fileFullPath != null && System.IO.File.Exists(fileFullPath)) { docForm.Open(fileFullPath); } docForm.MdiParent = this; docForm.WindowState = FormWindowState.Maximized; docForm.Show(); removeMenu(); }
/// <summary> /// 空闲事件 /// </summary> private void OnIdle(object sender, EventArgs e) { DocumentForm currActiveDocForm = this.ActiveMdiChild as DocumentForm; if (currActiveDocForm != null) { currActiveDocForm.UpdateUI(); } }
private void NewFile() { DocumentForm docForm = new DocumentForm(); docForm.Text = GetNextNewFileName(); docForm.MdiParent = this; docForm.WindowState = FormWindowState.Maximized; docForm.Show(); removeMenu(); }
/// <summary> /// 子窗体激活事件 /// </summary> protected override void OnMdiChildActivate(EventArgs e) { base.OnMdiChildActivate(e); DocumentForm activeDocForm = this.ActiveMdiChild as DocumentForm; foreach (Control ctrl in Controls) { if (ctrl is ToolStripPanel) { ((ToolStripPanel)ctrl).SuspendLayout(); } } if (activeDocForm != null) { ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Edit")); ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Edit"), _toolStripMgr.GetToolStrip("Edit")); ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Draw")); ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Draw"), _toolStripMgr.GetToolStrip("Draw")); ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Modify")); ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Modify"), _toolStripMgr.GetToolStrip("Modify")); ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Layer")); ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Layer"), _toolStripMgr.GetToolStrip("Layer")); ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Property")); ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Property"), _toolStripMgr.GetToolStrip("Property")); } else { MenuStrip menuMain = _toolStripMgr.GetMenuStrip("Main", true); SetupMainMenu_Tool(menuMain); SetupMainMenu_Help(menuMain); this.MainMenuStrip = menuMain; } foreach (Control ctrl in Controls) { if (ctrl is ToolStripPanel) { ((ToolStripPanel)ctrl).ResumeLayout(); } } }
/// <summary> /// 文档窗口激活相应函数 /// </summary> private void OnDocumentFormActivated(object sender, EventArgs e) { DocumentForm docForm = MainWin.Instance.ActiveMdiChild as DocumentForm; if (docForm != null) { _docForm = docForm;; if (this.Visible) { this.ReUpdateListView(); } } else { _docForm = null; this.Hide(); } }
private string GetNextNewFileName() { string strBase = GlobalData.GlobalLanguage.Document_New; uint id = 1; foreach (Form form in this.MdiChildren) { DocumentForm docForm = form as DocumentForm; if (docForm == null) { continue; } string fileName = ""; SharpCAD.DatabaseServices.Database db = docForm.document.database; if (db.fileName != null) { fileName = System.IO.Path.GetFileNameWithoutExtension(db.fileName); } else { fileName = docForm.Text; } fileName = fileName.ToLower(); if (fileName.IndexOf(strBase) == 0) { fileName = fileName.Substring(strBase.Length); uint number = 0; if (uint.TryParse(fileName, out number)) { if (number >= id) { id = number + 1; } } } } return(string.Format("{0}{1}", strBase, id)); }
/// <summary> /// 文件另存为 /// </summary> private void OnFileSaveAs(object sender, EventArgs e) { DocumentForm activeDocForm = this.ActiveMdiChild as DocumentForm; if (activeDocForm == null) { return; } SaveFileDialog savedialog = new SaveFileDialog(); savedialog.Title = GlobalData.GlobalLanguage.MenuItem_SaveAs; savedialog.Filter = GlobalData.GlobalLanguage.Document_SaveFilter; savedialog.FilterIndex = 0; savedialog.RestoreDirectory = true; savedialog.CheckPathExists = true; savedialog.FileName = ""; if (savedialog.ShowDialog() == DialogResult.OK) { string fileFullPath = savedialog.FileName; activeDocForm.SaveAs(fileFullPath); } }
/// <summary> /// 构造函数 /// </summary> private LayersManagementForm() { InitializeComponent(); InitializeLayerListView(); this.Owner = MainWin.Instance; this.Text = GlobalData.GlobalLanguage.Document_LayerManger; this.btnModify.Text = GlobalData.GlobalLanguage.Button_Modify; this.btnAdd.Text = GlobalData.GlobalLanguage.Button_Add; this.btnDelete.Text = GlobalData.GlobalLanguage.Button_Delete; DocumentForm activeDocForm = MainWin.Instance.ActiveMdiChild as DocumentForm; if (activeDocForm != null) { _docForm = activeDocForm; } else { _docForm = null; } MainWin.Instance.MdiChildActivate += this.OnDocumentFormActivated; }