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);
                }
            }
        }
Esempio n. 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)
                        {
                            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);
                }
            }
        }