private void OpenSequenceFromFile(string filename) { Cursor.Current = Cursors.WaitCursor; try { IEditorUserInterface editor = EditorService.Instance.CreateEditor(filename); if (editor == null) { Logging.Error("Can't find an appropriate editor to open file " + filename); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Can't find an editor to open this file type. (\"" + Path.GetFileName(filename) + "\")", "Error opening file", false, false); messageBox.ShowDialog(); } else { _OpenEditor(editor); } } catch (Exception ex) { Logging.Error("Error trying to open file '" + filename + "': ", ex); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Error trying to open file '" + filename + "'.", "Error opening file", false, false); messageBox.ShowDialog(); } }
private void initializeEditorTypes() { ToolStripMenuItem item; foreach (KeyValuePair <Guid, string> typeId_FileTypeName in ApplicationServices.GetAvailableModules <ISequenceTypeModuleInstance>()) { item = new ToolStripMenuItem(typeId_FileTypeName.Value); ISequenceTypeModuleDescriptor descriptor = ApplicationServices.GetModuleDescriptor(typeId_FileTypeName.Key) as ISequenceTypeModuleDescriptor; if (descriptor.CanCreateNew) { item.Tag = descriptor.FileExtension; item.Click += (sender, e) => { ToolStripMenuItem menuItem = sender as ToolStripMenuItem; string fileType = (string)menuItem.Tag; IEditorUserInterface editor = EditorService.Instance.CreateEditor(fileType); if (editor == null) { VixenSystem.Logging.Error("Can't find an appropriate editor to open file of type " + fileType); MessageBox.Show("Can't find an editor to open this file type. (\"" + fileType + "\")", "Error opening file", MessageBoxButtons.OK); } else { _OpenEditor(editor); } }; contextMenuStripNewSequence.Items.Add(item); } } }
private bool _CloseEditor(IEditorUserInterface editor) { if (editor.IsModified) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Save changes to the sequence?", "Save Changes?", true, true); messageBox.ShowDialog(); if (messageBox.DialogResult == DialogResult.Cancel) { return(false); } if (messageBox.DialogResult == DialogResult.OK) { editor.Save(); } } if (_openEditors.Contains(editor)) { _openEditors.Remove(editor); } _activeEditor = null; AddSequenceToRecentList(editor.Sequence.FilePath); editor.Activated -= editorUI_Activated; editor.Closing -= editorUI_Closing; //editor.Dispose(); //editor = null; return(true); }
private bool _CloseEditor(IEditorUserInterface editor) { if (editor.IsModified) { DialogResult result = MessageBox.Show("Save changes to the sequence?", "Save Changes?", MessageBoxButtons.YesNoCancel); if (result == System.Windows.Forms.DialogResult.Cancel) { return(false); } if (result == System.Windows.Forms.DialogResult.Yes) { editor.Save(); } } if (_openEditors.Contains(editor)) { _openEditors.Remove(editor); Form editorForm = editor as Form; editor.Dispose(); } AddSequenceToRecentList(editor.Sequence.FilePath); return(true); }
private void _OpenEditor(IEditorUserInterface editorUI) { _openEditors.Add(editorUI); editorUI.Closing += editorUI_Closing; editorUI.Activated += editorUI_Activated; editorUI.StartEditor(); }
private IEditorUserInterface _GetEditorUI(IEditorModuleDescriptor descriptor) { if (descriptor != null) { IEditorModuleInstance module = base.Get(descriptor.TypeId); IEditorUserInterface moduleUI = Activator.CreateInstance(descriptor.EditorUserInterfaceClass) as IEditorUserInterface; moduleUI.OwnerModule = module; return(moduleUI); } return(null); }
void editorUI_Closing(object sender, System.ComponentModel.CancelEventArgs e) { IEditorUserInterface editor = (sender as IEditorUserInterface); if (!_CloseEditor(editor)) { e.Cancel = true; } else { editor.EditorClosing(); } }
private void _OpenEditor(IEditorUserInterface editorUI) { _openEditors.Add(editorUI); editorUI.Closing += (sender, e) => { if (!_CloseEditor(sender as IEditorUserInterface)) { e.Cancel = true; } }; editorUI.Activated += (sender, e) => { _activeEditor = sender as IEditorUserInterface; }; editorUI.Start(); }
private void OpenSequenceFromFile(string filename) { try { IEditorUserInterface editor = EditorService.Instance.CreateEditor(filename); if (editor == null) { VixenSystem.Logging.Error("Can't find an appropriate editor to open file " + filename); MessageBox.Show("Can't find an editor to open this file type. (\"" + Path.GetFileName(filename) + "\")", "Error opening file", MessageBoxButtons.OK); } else { _OpenEditor(editor); } } catch (Exception ex) { VixenSystem.Logging.Error("Error trying to open file '" + filename + "': ", ex); MessageBox.Show("Error trying to open file '" + filename + "'.", "Error opening file", MessageBoxButtons.OK); } }
public IEditorUserInterface CreateEditor(string sequenceFilePath) { // Create or load a sequence. ISequence sequence; if (File.Exists(sequenceFilePath)) { sequence = SequenceService.Instance.Load(sequenceFilePath); } else { sequence = SequenceService.Instance.CreateNew(sequenceFilePath); } if (sequence == null) { return(null); } // Get the editor. IEditorUserInterface editor = null; EditorModuleManagement manager = Modules.GetManager <IEditorModuleInstance, EditorModuleManagement>(); if (manager != null) { editor = manager.Get(sequence.GetType()); } if (editor != null) { // Get any editor module data from the sequence. //...serious LoD violation... sequence.SequenceData.LocalDataSet.AssignModuleTypeData(editor.OwnerModule); // Assign the sequence to the editor. editor.Sequence = sequence; } return(editor); }
private void initializeEditorTypes() { ToolStripMenuItem item; foreach ( KeyValuePair <Guid, string> typeId_FileTypeName in ApplicationServices.GetAvailableModules <ISequenceTypeModuleInstance>()) { item = new ToolStripMenuItem(typeId_FileTypeName.Value); ISequenceTypeModuleDescriptor descriptor = ApplicationServices.GetModuleDescriptor(typeId_FileTypeName.Key) as ISequenceTypeModuleDescriptor; if (descriptor.CanCreateNew) { item.Tag = descriptor.FileExtension; item.Click += (sender, e) => { ToolStripMenuItem menuItem = sender as ToolStripMenuItem; string fileType = (string)menuItem.Tag; IEditorUserInterface editor = EditorService.Instance.CreateEditor(fileType); if (editor == null) { Logging.Error("Can't find an appropriate editor to open file of type " + fileType); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Can't find an editor to open this file type. (\"" + fileType + "\")", "Error opening file", false, false); messageBox.ShowDialog(); } else { _OpenEditor(editor); } }; contextMenuStripNewSequence.Items.Add(item); } } }
void editorUI_Activated(object sender, EventArgs e) { _activeEditor = sender as IEditorUserInterface; }
private bool _CloseEditor(IEditorUserInterface editor) { if (editor.IsModified) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Save changes to the sequence?", "Save Changes?", true, true); messageBox.ShowDialog(); if (messageBox.DialogResult == DialogResult.Cancel) return false; if (messageBox.DialogResult == DialogResult.OK) editor.Save(); } if (_openEditors.Contains(editor)) { _openEditors.Remove(editor); } _activeEditor= null; AddSequenceToRecentList(editor.Sequence.FilePath); editor.Activated-= editorUI_Activated; editor.Closing -= editorUI_Closing; //editor.Dispose(); //editor = null; return true; }
private void _OpenEditor(IEditorUserInterface editorUI) { _openEditors.Add(editorUI); editorUI.Closing +=editorUI_Closing; editorUI.Activated +=editorUI_Activated; editorUI.StartEditor(); }
private bool _CloseEditor(IEditorUserInterface editor) { if (editor.IsModified) { DialogResult result = MessageBox.Show("Save changes to the sequence?", "Save Changes?", MessageBoxButtons.YesNoCancel); if (result == System.Windows.Forms.DialogResult.Cancel) return false; if (result == System.Windows.Forms.DialogResult.Yes) editor.Save(); } if (_openEditors.Contains(editor)) { _openEditors.Remove(editor); Form editorForm = editor as Form; editor.Dispose(); } AddSequenceToRecentList(editor.Sequence.FilePath); return true; }
private void _OpenEditor(IEditorUserInterface editorUI) { _openEditors.Add(editorUI); editorUI.Closing += (sender, e) => { if(!_CloseEditor(sender as IEditorUserInterface)) { e.Cancel = true; } }; editorUI.Activated += (sender, e) => { _activeEditor = sender as IEditorUserInterface; }; editorUI.Start(); }