public override IMyGenDocument Open(IMyGenerationMDI mdi, FileInfo file, params string[] args) { TemplateEditor edit = null; if (file.Exists) { bool isopen = mdi.IsDocumentOpen(file.FullName); if (!isopen) { edit = new TemplateEditor(mdi); edit.FileOpen(file.FullName); } else { edit = mdi.FindDocument(file.FullName) as TemplateEditor; if (edit != null) { edit.Activate(); } } } return edit; }
private TemplateEditor OpenTemplateEditor(string filename) { TemplateEditor edit = null; if (File.Exists(filename)) { bool isopen = IsTemplateOpen(filename); if (!isopen) { edit = new TemplateEditor(this); edit.FileOpen(filename); edit.Show(dockManager); } else { edit = GetTemplateEditor(filename); edit.Activate(); } } else { edit = OpenTemplateEditor(); } return edit; }
private void RefreshTemplateEditor(string uniqueId) { foreach (DockContent cont in dockManager.Contents) { if (cont is TemplateEditor) { TemplateEditor editor = cont as TemplateEditor; if (uniqueId.ToLower() == editor.UniqueID.ToLower()) { if (MessageBox.Show(this, "Template [" + editor.Title + "] has been updated outside of the Template Editor.\r\nWould you like to refresh it?", "Refresh Updated Template?", MessageBoxButtons.YesNo) == DialogResult.Yes) { string filename = editor.CompleteFilePath; editor.Close(); if (File.Exists(filename)) { editor = new TemplateEditor(this); editor.FileOpen(filename); editor.Show(dockManager); } } break; } } } }
public object PerformMdiFuntion(IMyGenContent sender, string function, params object[] args) { if (function.Equals("getstaticdbroot", StringComparison.CurrentCultureIgnoreCase)) { return MetaDataBrowser.StaticMyMetaObj; } else if (function.Equals("showoledbdialog", StringComparison.CurrentCultureIgnoreCase) && args.Length == 1) { return BrowseOleDbConnectionString(args[0].ToString()); } else if (function.Equals("executionqueuestart", StringComparison.CurrentCultureIgnoreCase)) { this.toolStripStatusQueue.Visible = true; timerImgAnimate.Start(); } else if (function.Equals("executionqueueupdate", StringComparison.CurrentCultureIgnoreCase)) { if (ZeusProcessManager.ProcessCount == 0) { timerImgAnimate.Stop(); this.toolStripStatusQueue.Visible = false; } else if (ZeusProcessManager.ProcessCount > 0) { this.toolStripStatusQueue.Visible = true; timerImgAnimate.Start(); } } else if (function.Equals("showerrordetail", StringComparison.CurrentCultureIgnoreCase) && args.Length >= 1) { if (args[0] is List<IMyGenError>) { List<IMyGenError> errors = args[0] as List<IMyGenError>; ErrorDetailDockContent.Update(errors[0]); if (this.ErrorDetailDockContent.IsHidden) { this.ErrorDetailDockContent.Show(this.dockPanel); } else { this.ErrorDetailDockContent.Activate(); } } } else if (function.Equals("navigatetotemplateerror", StringComparison.CurrentCultureIgnoreCase) && args.Length >= 1) { if (args[0] is IMyGenError) { IMyGenError error = args[0] as IMyGenError; TemplateEditor edit = null; if (string.IsNullOrEmpty(error.SourceFile)) { //it's a new unsaved template bool isopen = this.IsDocumentOpen(error.TemplateIdentifier); if (isopen) { edit = this.FindDocument(error.TemplateIdentifier) as TemplateEditor; edit.Activate(); } } else { FileInfo file = new FileInfo(error.TemplateFileName); if (file.Exists) { bool isopen = this.IsDocumentOpen(file.FullName); if (!isopen) { edit = new TemplateEditor(this); edit.FileOpen(file.FullName); } else { edit = this.FindDocument(file.FullName) as TemplateEditor; if (edit != null) { edit.Activate(); } } } } if (edit != null) { edit.NavigateTo(error); } } } else if (function.Equals("getmymetadbdriver", StringComparison.CurrentCultureIgnoreCase)) { return DefaultSettings.Instance.DbDriver; } else if (function.Equals("getmymetaconnection", StringComparison.CurrentCultureIgnoreCase)) { return DefaultSettings.Instance.ConnectionString; } else if (function.Equals("openfile", StringComparison.CurrentCultureIgnoreCase) && args.Length == 1) { if (args[0] is List<FileInfo>) { List<FileInfo> files = args[0] as List<FileInfo>; foreach (FileInfo fi in files) { Zeus.WindowsTools.LaunchFile(fi.FullName.ToString()); } } else if (args[0] is FileInfo) { FileInfo file = args[0] as FileInfo; Zeus.WindowsTools.LaunchFile(file.FullName); } else if (args[0] is String) { Zeus.WindowsTools.LaunchFile(args[0].ToString()); } } return null; }