Наследование: XPluginBase
Пример #1
0
        public MainForm(XPlugin plugin)
        {
            InitializeComponent();
            this.plugin = plugin;

            plugin.Received += new ReceivedEventHandler(plugin_Received);
        }
Пример #2
0
        public MainForm(XPlugin plugin)
        {
            InitializeComponent();
            this.plugin = plugin;


            plugin.Received += new ReceivedEventHandler(plugin_Received);
        }
Пример #3
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstPlugins.SelectedItems.Count < 1)
            {
                return;
            }
            if (MessageBox.Show("Are you sure?\n" + lstPlugins.SelectedItems.Count + " plugin(s) will be removed.", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            foreach (ListViewItem item in lstPlugins.SelectedItems)
            {
                XPlugin plugin = (item.Tag as XPlugin);
                GlobalProperties.RawPlugins.Remove(plugin.Guid);
                GlobalProperties.InitializedPlugins.Remove(plugin.Guid);
                item.Remove();
            }
            modified = true;
            PluginHelper.pluginChanged();
        }
 void LoadPlugins()
 {
     new Thread(delegate()
     {
         for (int i = 0; i < GlobalProperties.InitializedPlugins.Count; i++)
         {
             XPlugin plugin    = GlobalProperties.InitializedPlugins.Values[i];
             ListViewItem item = new ListViewItem();
             item.Checked      = true;
             item.Text         = plugin.Name;
             item.SubItems.Add(plugin.Description);
             item.SubItems.Add(plugin.Version.ToString());
             item.SubItems.Add(plugin.Author);
             item.SubItems.Add(Functions.FormatBytes(GlobalProperties.RawPlugins.Values[i].Length));
             item.Tag = plugin;
             Invoke((MethodInvoker) delegate
             {
                 lstPlugins.Items.Add(item);
             });
         }
     }).Start();
 }
Пример #5
0
 void LoadPlugin(byte[] bytes)
 {
     new Thread(() =>
     {
         Assembly asm;
         try
         {
             asm = Assembly.Load(bytes);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         foreach (Type type in asm.GetTypes())
         {
             if (type.IsSubclassOf(typeof(XPlugin)))
             {
                 try
                 {
                     XPlugin plugin = Activator.CreateInstance(type) as XPlugin;
                     if (GlobalProperties.InitializedPlugins.ContainsKey(plugin.Guid))
                     {
                         DialogResult res = MessageBox.Show(string.Format("{0} contains the same GUID as {1}. Remove plugin and continue?", plugin.Name, GlobalProperties.InitializedPlugins[plugin.Guid].Name), "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                         if (res == System.Windows.Forms.DialogResult.No)
                         {
                             plugin = null;
                             continue;
                         }
                         else
                         {
                             GlobalProperties.RawPlugins.Remove(plugin.Guid);
                             GlobalProperties.InitializedPlugins.Remove(plugin.Guid);
                             for (int i = 0; i < lstPlugins.Items.Count; i++)
                             {
                                 bool found = false;
                                 Invoke((MethodInvoker) delegate
                                 {
                                     if ((lstPlugins.Items[i].Tag as XPlugin).Guid == plugin.Guid)
                                     {
                                         lstPlugins.Items[i].Remove();
                                         found = true;
                                     }
                                 });
                                 if (found)
                                 {
                                     break;
                                 }
                             }
                         }
                     }
                     GlobalProperties.RawPlugins.Add(plugin.Guid, bytes);
                     GlobalProperties.InitializedPlugins.Add(plugin.Guid, plugin);
                     ListViewItem item = new ListViewItem(new string[] { plugin.Name, plugin.Description, plugin.Version.ToString(), plugin.Author });
                     item.Tag          = plugin;
                     Invoke((MethodInvoker) delegate
                     {
                         lstPlugins.Items.Add(item);
                         PluginHelper.pluginChanged();
                     });
                     modified = true;
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return;
                 }
             }
         }
     }).Start();
 }
Пример #6
0
 public MainForm(XPlugin xPlugin)
 {
     InitializeComponent();
     plugin = xPlugin;
     plugin.DataReady += new DataReadyEventHandler(plugin_DataReady);
 }