void WaitForActivation(object state)
        {
            string id = state as string;

            if (!string.IsNullOrEmpty(id))
            {
                do
                {
                    System.Threading.Thread.Sleep(1000);
                } while (!ModManagement.IsActive(id));
            }
            Application.Current.Dispatcher.BeginInvoke(new Action(StartArtemis), System.Windows.Threading.DispatcherPriority.Loaded);
        }
        private void Test_Click(object sender, RoutedEventArgs e)
        {
            if (ModManagement.IsActive(Configuration.ID))
            {
                if (Locations.MessageBoxShow("This Mod is currently active.  In order to apply your changes, the Mod must first be deactivated, the re-activated.\r\n\r\nDo you wish to deactivate then re-activate this Mod for testing?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    do
                    {
                        ModManagement.DeactivateLastMod();
                    } while (ModManagement.IsActive(Configuration.ID));
                    ModManagement.NotifyMissionInstall();
                }
                else
                {
                    Locations.MessageBoxShow("Test canceled.", MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }
            }
            if (!DependentModsActive())
            {
                if (Locations.MessageBoxShow("Active Mods differ from what this Mod depends on.\r\n\r\nDo you want to deactivate these Mods and activate the dependent Mods?",
                                             MessageBoxButton.OK, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    while (ModManagement.DeactivateLastMod())
                    {
                    }
                    foreach (StringItem item in Configuration.DependsOn)
                    {
                        foreach (ModConfiguration config in InstalledModConfigurations.Current.Configurations.Configurations)
                        {
                            if (config.ID == item.Text)
                            {
                                ModManagement.Activate(config);
                            }
                        }
                    }
                    ModManagement.NotifyMissionInstall();
                }
                else
                {
                    Locations.MessageBoxShow("Test canceled.  Please change Mod dependencies to match the list of Activated Mods.", MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }
            }


            ModManagement.Activate(Configuration);
            System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(WaitForActivation), Configuration.ID);
        }
Beispiel #3
0
 private InstalledModConfigurations() : base(Locations.InstalledModDefinitionFile)
 {
     if (_log.IsDebugEnabled)
     {
         _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString());
     }
     foreach (ModConfiguration config in Configurations)
     {
         config.IsActive = ModManagement.IsActive(config.ID);
     }
     if (_log.IsDebugEnabled)
     {
         _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString());
     }
 }
Beispiel #4
0
 public static void ResetInstallation()
 {
     if (_log.IsDebugEnabled)
     {
         _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString());
     }
     FileHelper.CreatePath(Locations.InstalledModsPath);
     Current = new InstalledModConfigurations();
     if (File.Exists(Locations.InstalledModDefinitionFile))
     {
         XmlConverter.ToObject(Locations.InstalledModDefinitionFile, Current);
     }
     foreach (ModConfiguration config in Current.Configurations.Configurations)
     {
         config.IsActive = ModManagement.IsActive(config.ID);
         config.AcceptChanges();
     }
     if (_log.IsDebugEnabled)
     {
         _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString());
     }
 }