コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        private void _OpenEditor(IEditorUserInterface editorUI)
        {
            _openEditors.Add(editorUI);
            editorUI.Closing   += editorUI_Closing;
            editorUI.Activated += editorUI_Activated;

            editorUI.StartEditor();
        }
コード例 #6
0
ファイル: EditorModuleManagement.cs プロジェクト: ctmal/vixen
 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);
 }
コード例 #7
0
        void editorUI_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            IEditorUserInterface editor = (sender as IEditorUserInterface);

            if (!_CloseEditor(editor))
            {
                e.Cancel = true;
            }
            else
            {
                editor.EditorClosing();
            }
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
                }
            }
        }
コード例 #12
0
ファイル: VixenApplication.cs プロジェクト: naztrain/vixen
 void editorUI_Activated(object sender, EventArgs e)
 {
     _activeEditor = sender as IEditorUserInterface;
 }
コード例 #13
0
ファイル: VixenApplication.cs プロジェクト: naztrain/vixen
        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;
        }
コード例 #14
0
ファイル: VixenApplication.cs プロジェクト: naztrain/vixen
        private void _OpenEditor(IEditorUserInterface editorUI)
        {
            _openEditors.Add(editorUI);
            editorUI.Closing +=editorUI_Closing;
            editorUI.Activated +=editorUI_Activated;

            editorUI.StartEditor();
        }
コード例 #15
0
 void editorUI_Activated(object sender, EventArgs e)
 {
     _activeEditor = sender as IEditorUserInterface;
 }
コード例 #16
0
        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;
        }
コード例 #17
0
        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();
        }