예제 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Before we get to loading the plugins, Subscribe to the message event
            Dispatch.Message     += new EventHandler <MessageEventArgs>(Dispatch_Message);
            Dispatch.MessagePump += new EventHandler <EventArgs>(Dispatch_MessagePump);
            DirectoryInfo di = new DirectoryInfo("plugins");

            if (!di.Exists)
            {
                di.Create();
                di.Refresh();
            }
            FileInfo[] dlls = di.GetFiles("*.dll", SearchOption.AllDirectories);
            foreach (FileInfo fi in dlls)
            {
                try
                {
                    IUIPlugin[] plugins = MLFI.Interfaces.Loader.Loader.LoadAndCreateInstance <IUIPlugin>(fi.FullName);
                    if (plugins.Length == 0)
                    {
                        Dispatch.AddMessage("Firmware Editor",
                                            "Successfully loaded assembly " +
                                            fi.Name +
                                            ", but the required interface (IUIPlugin) was not found.");
                        continue;
                    }
                    myPlugins.AddRange(plugins);
                }
                catch
                {
                    Dispatch.AddMessage("Firmware Editor", "A plugin failed to load due to an exception: {0}", fi.FullName);
                }
            }
#if (DEBUG)
            //Alright, Now...
            Debug.Print("Loaded {0} Plugin{1}", myPlugins.Count, myPlugins.Count == 1 ? "." : "s.");
#endif
            for (int x = 0; x < myPlugins.Count; x++)
            {
#if (DEBUG)
                Debug.WriteLine(string.Format("Plugin {0} of {1}", x + 1, myPlugins.Count));
                Debug.WriteLine("Name: " + myPlugins[x].Name);
                Debug.WriteLine("Author: " + myPlugins[x].Author);
                Debug.Write("Supported File Types: ");
                foreach (string s in myPlugins[x].SupportedTypes)
                {
                    Debug.Write(s + " ");
                }
                Debug.WriteLine("");
#endif
                //Attach the plugins menu items, And update the current type
                //This is really all we need to do.
                pluginsToolStripMenuItem.DropDownItems.AddRange(myPlugins[x].Menus);
                myPlugins[x].CurrentFileTypeCode = "NULL";
            }
            UpdateMRUMenu();
        }
예제 #2
0
        private void saveLogFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fdSaveLog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            FileInfo fi = new FileInfo(fdSaveLog.FileName);

            using (FileStream fs = fi.Open(FileMode.Create, FileAccess.Write, FileShare.None))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    for (int x = 0; x < lbMessages.Items.Count; x++)
                    {
                        sw.WriteLine((string)lbMessages.Items[x]);
                    }
                    sw.Flush();
                    sw.Close();
                }
            }
            Dispatch.AddMessage("Log", "Log file saved to: {0}", fdSaveLog.FileName);
        }
예제 #3
0
 private void clearLogToolStripMenuItem_Click(object sender, EventArgs e)
 {
     lbMessages.Items.Clear();
     Dispatch.AddMessage("Log", "Cleared.");
 }
예제 #4
0
 protected void Print(string format, params object[] args)
 {
     Dispatch.AddMessage(this.Name, format, args);
 }
예제 #5
0
 protected void Print(string message)
 {
     Dispatch.AddMessage(this.Name, message);
 }