コード例 #1
0
        public PluginManager()
        {
            string PluginDirectory = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName + @"\Plugins";


            if (!Directory.Exists(PluginDirectory))
            {
                if (!Utilities.IsRunAsAdmin())
                {
                    AnimaCentral.Speak("There's a problem creating the plugin folder.", "Either create your own or run me with Administrative privileges once");
                    // Launch itself as administrator
                    ProcessStartInfo proc = new ProcessStartInfo();
                    proc.UseShellExecute  = true;
                    proc.WorkingDirectory = Environment.CurrentDirectory;
                    proc.FileName         = Application.ExecutablePath;
                    proc.Verb             = "runas";

                    try
                    {
                        Process.Start(proc);
                    }
                    catch
                    {
                        // The user refused the elevation.
                        // Do nothing and return directly ...
                        return;
                    }

                    Application.Exit();  // Quit itself
                }
                Directory.CreateDirectory(PluginDirectory);
            }



            Compose(PluginDirectory);
            SeparateModules();

            foreach (IModule module in EnableModules)
            {
                module.ModuleStart();
            }

            TickTimer           = new System.Timers.Timer(Properties.CoreSettings.Default.TickInterval);
            TickTimer.AutoReset = true;
            TickTimer.Elapsed  += TickTimer_Elapsed;
            TickTimer.Start();
        }