Esempio n. 1
0
        private void DeactivatePlugin(PluginBase plugin)
        {
            try
            {
                plugin.Deactivate();
            }
            catch (Exception exception)
            {
                log.Error(Resources.GuiCore_ActivatePlugins_Exception_during_plugin_gui_deactivation, exception);
            }

            plugin.Dispose();

            Plugins.Remove(plugin);
        }
Esempio n. 2
0
        /// @brief Close the plugin window and terminate the plugin instance.
        /// @details Not only close the tab window, also detach the plugin from the PropellerCPU
        /// what uses it.
        /// @param[in] sender Reference to object where event was raised.
        /// @param[in] e Event data arguments.
        private void closeActiveTab_Click(object sender, EventArgs e)
        {
            TabPage    tp = documentsTab.SelectedTab;
            PluginBase p  = (PluginBase)tp.Controls[0];

            if (p != null)          //test if cast to PluginBase works...
            {
                if (p.IsClosable)   //... so, test if we can close the tab
                {
                    if (documentsTab.SelectedIndex > 0)
                    {
                        //select the previous tab
                        documentsTab.SelectedIndex = documentsTab.SelectedIndex - 1;
                        //tab changing housekeeping for plugin close button
                        documentsTab_Click(this, e);
                        //detach the plugin from the emulator
                        this.DetachPlugin(p);
                        p.Dispose();
                    }
                    tp.Parent = null;   //delete the reference to plugin
                }
                ;
            }
        }
Esempio n. 3
0
 /// @brief Method to compile C# source code to check errors on it.
 /// Actually call a C# compiler to determine errors, using references.
 /// @param[in] sender Object who called this on event.
 /// @param[in] e `EventArgs` class with a list of argument to the event call.
 private void CheckSource_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(codeEditorView.Text))
     {
         MessageBox.Show("No source code to check. Please add code.",
                         "Plugin Editor - Check source.",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
     }
     else
     {
         string aux = null;
         if (DetectClassName(codeEditorView.Text, out aux))  //class name detected?
         {
             int i = 0;
             instanceName.Text = aux;        //show the name found in the screen field
             errorListView.Items.Clear();    //clear error list, if any
             //prepare reference list
             string[] refs = new string[referencesList.Items.Count];
             foreach (string s in referencesList.Items)
             {
                 refs[i++] = s;
             }
             try
             {
                 PluginBase plugin = ModuleCompiler.LoadModule(codeEditorView.Text, instanceName.Text, refs, null);
                 if (plugin != null)
                 {
                     ShowErrorGrid(false);    //hide the error list
                     MessageBox.Show("Plugin compiled without errors.",
                                     "Plugin Editor - Check source.",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Information);
                     plugin.Dispose();
                 }
                 else
                 {
                     ModuleCompiler.EnumerateErrors(EnumErrors);
                     ShowErrorGrid(true);    //show the error list
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Compile Error: " + ex.ToString(),
                                 "Plugin Editor - Check source.",
                                 MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
             }
         }
         else   //not detected class name
         {
             instanceName.Text = "Not found!";
             MessageBox.Show("Cannot detect main plugin class name. " +
                             "Please use \"class <YourPluginName> : PluginBase {...\" " +
                             "declaration on your source code.",
                             "Plugin Editor - Check source.",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
     }
 }