/// <summary> /// Adds the serialization plugin to the interface. /// </summary> /// <param name="plugin">The plugin.</param> private void AddSerializationPlugin(IEffectSerializationPlugin plugin) { Trace.WriteLine("Adding menu item for '" + plugin.Name + "' plugin...", "UI"); //TODO: Perhaps it would be better to load the plugins and don't add them to the uxImportMenuItem //Instead we have a simple import button, and it has the filetypes with the supported plugins. //Example: .em and .pe (or something similar) are the only visible types in the import dialog. //Doing it this way will prevent loading of dynamic menu items and fix the bug where the menu items is //still displayed even tho the load dialog has been displayed. if (plugin.DeserializeSupported) { ToolStripMenuItem item = new ToolStripMenuItem { Image = plugin.DisplayIcon.ToBitmap(), Text = plugin.DisplayName, ToolTipText = plugin.Description, Tag = plugin }; this.uxImportMenuItem.DropDownItems.Add(item); } if (plugin.SerializeSuported) { ToolStripMenuItem item = new ToolStripMenuItem { Image = plugin.DisplayIcon.ToBitmap(), Text = plugin.DisplayName, ToolTipText = plugin.Description, Tag = plugin }; this.uxExportMenuItem.DropDownItems.Add(item); } }
/// <summary> /// Handles the ItemActivate event of the uxLibraryListView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void uxLibraryListView_ItemActivate(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you wish to open this effect? Unsaved changes will be lost.", "Confirm", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { ListViewItem item = uxLibraryListView.SelectedItems[0]; IEffectSerializationPlugin plugin = item.Tag as IEffectSerializationPlugin; //string filePath = Application.StartupPath + "\\EffectLibrary\\" + item.Text; string filePath = Application.StartupPath + "\\..\\..\\..\\SpaceContentEffects\\" + item.Text; this.OnDeserialize(new SerializeEventArgs(plugin, filePath)); } }
/// <summary> /// Initializes a new instance of the <see cref="SerializeEventArgs"/> class. /// </summary> /// <param name="plugin">The plugin.</param> /// <param name="filePath">The file path.</param> public SerializeEventArgs(IEffectSerializationPlugin plugin, String filePath) : base() { this.Plugin = plugin; this.FilePath = filePath; }
/// <summary> /// Adds the serialization plugin to the interface. /// </summary> /// <param name="plugin">The plugin.</param> private void AddSerializationPlugin(IEffectSerializationPlugin plugin) { //TODO: Perhaps it would be better to load the plugins and don't add them to the uxImportMenuItem //Instead we have a simple import button, and it has the filetypes with the supported plugins. //Example: .em and .pe (or something similar) are the only visible types in the import dialog. //Doing it this way will prevent loading of dynamic menu items and fix the bug where the menu items is //still displayed even tho the load dialog has been displayed. if (plugin.DeserializeSupported) { ToolStripMenuItem item = new ToolStripMenuItem { Image = plugin.DisplayIcon.ToBitmap(), Text = plugin.DisplayName, ToolTipText = plugin.Description, Tag = plugin }; this.uxImportMenuItem.DropDownItems.Add(item); } if (plugin.SerializeSuported) { ToolStripMenuItem item = new ToolStripMenuItem { Image = plugin.DisplayIcon.ToBitmap(), Text = plugin.DisplayName, ToolTipText = plugin.Description, Tag = plugin }; this.uxExportMenuItem.DropDownItems.Add(item); } }
/// <summary> /// Initializes a new instance of the <see cref="SerializeEventArgs"/> class. /// </summary> /// <param name="plugin">The plugin.</param> /// <param name="filePath">The file path.</param> public SerializeEventArgs(IEffectSerializationPlugin plugin, String filePath) : base() { this.Plugin = plugin; this.FilePath = filePath; }