/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_btsTask">The task whose status is to be displayed by this list
		/// view item.</param>
		public ActivateModsListViewItem(IBackgroundTaskSet p_btsTask, ActivateModsMonitorControl p_amcControl)
		{
			m_amcControl = p_amcControl;
			Task = p_btsTask;

			ListViewSubItem lsiSubItem = SubItems[0];
			lsiSubItem.Name = "ModName";

			if (p_btsTask.GetType() == typeof(ModUninstaller))
				lsiSubItem.Text = ((ModUninstaller)p_btsTask).ModName;
			else if (p_btsTask.GetType() == typeof(ModInstaller))
				lsiSubItem.Text = ((ModInstaller)p_btsTask).ModName;
			else if (p_btsTask.GetType() == typeof(ModUpgrader))
				lsiSubItem.Text = ((ModUpgrader)p_btsTask).ModName;
		
			lsiSubItem = SubItems.Add(new ListViewSubItem());
			lsiSubItem.Name = "Status";
			lsiSubItem.Text = "Queued";
			p_btsTask.IsQueued = true;

			lsiSubItem = SubItems.Add(new ListViewSubItem());
			lsiSubItem.Name = "Operation";
			lsiSubItem.Text = "";		

			lsiSubItem = SubItems.Add(new ListViewSubItem());
			lsiSubItem.Name = "Progress";

			lsiSubItem = SubItems.Add(new ListViewSubItem());
			lsiSubItem.Name = "?";

			m_booRemovable = true;
			p_btsTask.TaskStarted += new EventHandler<EventArgs<IBackgroundTask>>(TaskSet_TaskSetStarted);

			p_btsTask.TaskSetCompleted += new EventHandler<TaskSetCompletedEventArgs>(TaskSet_TaskSetCompleted);
		}
Ejemplo n.º 2
0
        private void TaskSet_TaskSetCompleted(object sender, TaskSetCompletedEventArgs e)
        {
            m_btsRunningTask = null;

            if (QueuedTasks.Count > 0)
            {
                m_btsRunningTask = QueuedTasks.First();
                QueuedTasks.Remove(m_btsRunningTask);
                if (m_btsRunningTask.GetType() == typeof(ModInstaller))
                {
                    ((ModInstaller)m_btsRunningTask).Install();
                }
                else if (m_btsRunningTask.GetType() == typeof(ModUninstaller))
                {
                    ((ModUninstaller)m_btsRunningTask).Install();
                }
                else if (m_btsRunningTask.GetType() == typeof(ModUpgrader))
                {
                    ((ModUpgrader)m_btsRunningTask).Install();
                }
            }
            else
            if (EmptyQueue != null)
            {
                EmptyQueue(this, new EventArgs());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the <see cref="IBackgroundTaskSet.TaskSetCompleted"/> event of script executors.
        /// </summary>
        /// <remarks>
        /// This unwires our listeners from the executor.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="TaskSetCompletedEventArgs"/> describing the event arguments.</param>
        private void ScriptExecutor_TaskSetCompleted(object sender, TaskSetCompletedEventArgs e)
        {
            IBackgroundTaskSet btsExecutor = (IBackgroundTaskSet)sender;

            btsExecutor.TaskStarted      -= ScriptExecutor_TaskStarted;
            btsExecutor.TaskSetCompleted -= ScriptExecutor_TaskSetCompleted;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deletes the given mod.
 /// </summary>
 /// <param name="p_modMod">The mod to activate.</param>
 public void DeleteMod(IMod p_modMod)
 {
     if (p_modMod != null)
     {
         IBackgroundTaskSet btsInstall = ModManager.DeleteMod(p_modMod, ModManager.ActiveMods);
         DeletingMod(this, new EventArgs <IBackgroundTaskSet>(btsInstall));
     }
 }
        /// <summary>
        /// Deactivates the given mod.
        /// </summary>
        /// <param name="p_modMod">The mod to deactivate.</param>
        protected void DeactivateMod(IMod p_modMod)
        {
            IBackgroundTaskSet btsUninstall = ModManager.DeactivateMod(p_modMod, ModManager.ActiveMods);

            if (btsUninstall != null)
            {
                ModManager.ActivateModsMonitor.AddActivity(btsUninstall);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Deactivates the given mod.
        /// </summary>
        /// <param name="p_modMod">The mod to deactivate.</param>
        protected void DeactivateMod(IMod p_modMod)
        {
            IBackgroundTaskSet btsUninstall = ModManager.DeactivateMod(p_modMod, ModManager.ActiveMods);

            if (btsUninstall != null)
            {
                ModManager.ActivateModsMonitor.AddActivity(btsUninstall);
            }
            //ChangingModActivation(this, new EventArgs<IBackgroundTaskSet>(btsUninstall));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Deactivates the given mod.
        /// </summary>
        /// <param name="p_modMod">The mod to deactivate.</param>
        public void DeactivateMod(IMod p_modMod)
        {
            VirtualModActivator.DisableMod(p_modMod);

            IBackgroundTaskSet btsUninstall = ModManager.DeactivateMod(p_modMod, ModManager.ActiveMods);

            if (btsUninstall != null)
            {
                ModManager.ModActivationMonitor.AddActivity(btsUninstall);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Deactivates the given mod.
 /// </summary>
 /// <param name="p_modMod">The mod to deactivate.</param>
 protected void DeactivateMods(List <IMod> p_lstMod)
 {
     foreach (IMod modMod in p_lstMod)
     {
         IBackgroundTaskSet btsUninstall = ModManager.DeactivateMod(modMod, ModManager.ActiveMods);
         if (btsUninstall != null)
         {
             ModManager.ModActivationMonitor.AddActivity(btsUninstall);
         }
     }
 }
Ejemplo n.º 9
0
        private void RemoveSelectedTask()
        {
            string strTaskName = GetSelectedTask();

            ViewModel.RemoveSelectedTask(strTaskName);
            if (QueuedTasks.Count > 0)
            {
                m_btsRunningTask = QueuedTasks.First();
                QueuedTasks.Remove(m_btsRunningTask);
            }
        }
        /// <summary>
        /// Upgrades the given fomods.
        /// </summary>
        /// <param name="p_lstModsToUpgrade">The list of fomods to upgrade.</param>
        private void Upgrade(object p_lstModsToUpgrade)
        {
            IList <IMod> lstModsToUpgrade = (IList <IMod>)p_lstModsToUpgrade;

            foreach (IMod modUpgrade in lstModsToUpgrade)
            {
                IBackgroundTaskSet btsReactivation = ModManager.ReactivateMod(modUpgrade, m_dlgOverwriteConfirmation);
                btsReactivation.TaskStarted += new EventHandler <EventArgs <IBackgroundTask> >(Reactivation_TaskStarted);
                btsReactivation.Wait();
            }
        }
Ejemplo n.º 11
0
        private void TaskSet_TaskSetCompleted(object sender, TaskSetCompletedEventArgs e)
        {
            if ((ListView != null) && ListView.InvokeRequired)
            {
                ListView.Invoke((Action <IBackgroundTaskSet, TaskSetCompletedEventArgs>)TaskSet_TaskSetCompleted, sender, e);
                return;
            }

            bool booComplete = false;
            bool booSuccess  = false;

            IBackgroundTaskSet btsExecutor = (IBackgroundTaskSet)sender;

            booSuccess = e.Success;
            if (btsExecutor.GetType() == typeof(ModInstaller))
            {
                booComplete = ((ModInstaller)btsExecutor).IsCompleted;
            }
            else if (btsExecutor.GetType() == typeof(ModUninstaller))
            {
                booComplete = ((ModUninstaller)btsExecutor).IsCompleted;
            }
            else if (btsExecutor.GetType() == typeof(ModUpgrader))
            {
                booComplete = ((ModUpgrader)btsExecutor).IsCompleted;
            }

            if (booComplete)
            {
                if (!booSuccess)
                {
                    SubItems["Status"].Text   = e.Message;
                    SubItems["Progress"].Text = "";
                }
                else
                {
                    SubItems["Status"].Text   = "Complete";
                    SubItems["Progress"].Text = "100%";
                }
            }
            else
            {
                SubItems["Status"].Text   = e.Message;
                SubItems["Progress"].Text = "";
            }


            m_booRemovable = true;
        }
        private void TaskSet_TaskSetCompleted(object sender, TaskSetCompletedEventArgs e)
        {
            ModInstallerBase mibModInstaller;

            try
            {
                mibModInstaller              = (ModInstallerBase)sender;
                m_strPopupErrorMessage       = mibModInstaller.PopupErrorMessage;
                m_strPopupErrorMessageType   = mibModInstaller.PopupErrorMessageType;
                m_strDetailsErrorMessageType = mibModInstaller.DetailsErrorMessage;
            }
            catch { }

            IBackgroundTaskSet btsCompletedTask = null;

            if (sender != null)
            {
                btsCompletedTask = (IBackgroundTaskSet)sender;
            }

            if ((ViewModel.RunningTask == null) || (ViewModel.RunningTask == btsCompletedTask))
            {
                ViewModel.RunningTask = null;

                if (QueuedTasks.Count > 0)
                {
                    ViewModel.RunningTask = QueuedTasks.First();
                    QueuedTasks.Remove(ViewModel.RunningTask);
                    if (ViewModel.RunningTask.GetType() == typeof(ModInstaller))
                    {
                        ((ModInstaller)ViewModel.RunningTask).Install();
                    }
                    else if (ViewModel.RunningTask.GetType() == typeof(ModUninstaller))
                    {
                        ((ModUninstaller)ViewModel.RunningTask).Install();
                    }
                    else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
                    {
                        ((ModUpgrader)ViewModel.RunningTask).Install();
                    }
                }
                else
                if (EmptyQueue != null)
                {
                    EmptyQueue(this, new EventArgs());
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Activates the given mod.
        /// </summary>
        /// <param name="p_modMod">The mod to activate.</param>
        public void ActivateMod(IMod p_modMod)
        {
            string strErrorMessage = ModManager.RequiredToolErrorMessage;

            if (String.IsNullOrEmpty(strErrorMessage))
            {
                IBackgroundTaskSet btsInstall = ModManager.ActivateMod(p_modMod, ConfirmModUpgrade, ConfirmItemOverwrite, ModManager.ActiveMods);
                if (btsInstall != null)
                {
                    ModManager.ActivateModsMonitor.AddActivity(btsInstall);
                }
            }
            else
            {
                ExtendedMessageBox.Show(ParentForm, strErrorMessage, "Required Tool not present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        /// <summary>
        /// A simple constructor that initializes the object with the given values.
        /// </summary>
        /// <param name="p_btsTask">The task whose status is to be displayed by this list
        /// view item.</param>
        public ActivateModsListViewItem(IBackgroundTaskSet p_btsTask, ActivateModsMonitorControl p_amcControl)
        {
            m_amcControl = p_amcControl;
            Task         = p_btsTask;

            ListViewSubItem lsiSubItem = SubItems[0];

            lsiSubItem.Name = "ModName";

            if (p_btsTask.GetType() == typeof(ModUninstaller))
            {
                lsiSubItem.Text = ((ModUninstaller)p_btsTask).ModName;
            }
            else if (p_btsTask.GetType() == typeof(ModInstaller))
            {
                lsiSubItem.Text = ((ModInstaller)p_btsTask).ModName;
            }
            else if (p_btsTask.GetType() == typeof(ModUpgrader))
            {
                lsiSubItem.Text = ((ModUpgrader)p_btsTask).ModName;
            }

            lsiSubItem         = SubItems.Add(new ListViewSubItem());
            lsiSubItem.Name    = "Status";
            lsiSubItem.Text    = "Queued";
            p_btsTask.IsQueued = true;

            lsiSubItem      = SubItems.Add(new ListViewSubItem());
            lsiSubItem.Name = "Operation";
            lsiSubItem.Text = "";

            lsiSubItem      = SubItems.Add(new ListViewSubItem());
            lsiSubItem.Name = "Progress";

            lsiSubItem      = SubItems.Add(new ListViewSubItem());
            lsiSubItem.Name = "?";

            m_booRemovable         = true;
            p_btsTask.TaskStarted += new EventHandler <EventArgs <IBackgroundTask> >(TaskSet_TaskSetStarted);

            p_btsTask.TaskSetCompleted += new EventHandler <TaskSetCompletedEventArgs>(TaskSet_TaskSetCompleted);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Deactivates the given mod.
        /// </summary>
        /// <param name="p_modMod">The mod to deactivate.</param>
        protected void DeactivateMods(List <IMod> p_lstMod)
        {
            string strErrorMessage = ModManager.RequiredToolErrorMessage;

            if (String.IsNullOrEmpty(strErrorMessage))
            {
                foreach (IMod modMod in p_lstMod)
                {
                    IBackgroundTaskSet btsUninstall = ModManager.DeactivateMod(modMod, ModManager.ActiveMods);
                    if (btsUninstall != null)
                    {
                        ModManager.ActivateModsMonitor.AddActivity(btsUninstall);
                    }
                }
            }
            else
            {
                ExtendedMessageBox.Show(ParentForm, strErrorMessage, "Required Tool not present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Activates the given mod.
        /// </summary>
        /// <param name="p_lstMod">The mods to activate.</param>
        public void ActivateMods(List <IMod> p_lstMod)
        {
            if (VirtualModActivator.MultiHDMode && !UacUtil.IsElevated)
            {
                MessageBox.Show("It looks like MultiHD mode is enabled but you're not running NMM as Administrator, you will be unable to install/activate mods or switch profiles." + Environment.NewLine + Environment.NewLine + "Close NMM and run it as Administrator to fix this.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string strMessage;
            bool   booRequiresConfig = ModManager.GameMode.RequiresExternalConfig(out strMessage);

            if (booRequiresConfig)
            {
                ExtendedMessageBox.Show(this.ParentForm, strMessage, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            string strErrorMessage = ModManager.RequiredToolErrorMessage;

            if (String.IsNullOrEmpty(strErrorMessage))
            {
                foreach (IMod modMod in p_lstMod)
                {
                    if (!ActiveMods.Contains(modMod))
                    {
                        IBackgroundTaskSet btsInstall = ModManager.ActivateMod(modMod, ConfirmModUpgrade, ConfirmItemOverwrite, ModManager.ActiveMods);
                        if (btsInstall != null)
                        {
                            ModManager.ModActivationMonitor.AddActivity(btsInstall);
                        }
                    }
                    else
                    {
                        EnableMod(modMod);
                    }
                }
            }
            else
            {
                ExtendedMessageBox.Show(ParentForm, strErrorMessage, "Required Tool not present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        /// <summary>
        /// Adds the given <see cref="BasicInstallTask"/> to the view's list. If the <see cref="BasicInstallTask"/>
        /// already exists in the list, nothing is done.
        /// </summary>
        /// <param name="p_tskTask">The <see cref="BasicInstallTask"/> to add to the view's list.</param>
        protected void AddTaskToList(IBackgroundTaskSet p_tskTask)
        {
            foreach (ModActivationMonitorListViewItem lviExisitingTask in lvwActiveTasks.Items)
            {
                if (lviExisitingTask.Task == p_tskTask)
                {
                    return;
                }
            }

            if (ViewModel.RunningTask != null)
            {
                if (p_tskTask.GetType() == typeof(ModInstaller))
                {
                    foreach (IBackgroundTaskSet iBk in QueuedTasks)
                    {
                        if (iBk.GetType() == typeof(ModInstaller))
                        {
                            if (((ModInstaller)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
                            {
                                if (((ModInstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUninstaller))
                        {
                            if (((ModUninstaller)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
                            {
                                if (((ModUninstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUpgrader))
                        {
                            if (((ModUpgrader)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
                            {
                                if (((ModUpgrader)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                    }

                    if (ViewModel.RunningTask.GetType() == typeof(ModInstaller))
                    {
                        if ((((ModInstaller)ViewModel.RunningTask).ModFileName == ((ModInstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTask(((ModInstaller)p_tskTask));
                            return;
                        }
                    }
                    else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
                    {
                        if ((((ModUpgrader)ViewModel.RunningTask).ModFileName == ((ModInstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTask(((ModInstaller)p_tskTask));
                            return;
                        }
                    }
                }
                else if (p_tskTask.GetType() == typeof(ModUninstaller))
                {
                    foreach (IBackgroundTaskSet iBk in QueuedTasks)
                    {
                        if (iBk.GetType() == typeof(ModInstaller))
                        {
                            if (((ModInstaller)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
                            {
                                if (((ModInstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUninstaller))
                        {
                            if (((ModUninstaller)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
                            {
                                if (((ModUninstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUpgrader))
                        {
                            if (((ModUpgrader)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
                            {
                                if (((ModUpgrader)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                    }

                    if (ViewModel.RunningTask.GetType() == typeof(ModUninstaller))
                    {
                        if ((((ModUninstaller)ViewModel.RunningTask).ModFileName == ((ModUninstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUn(((ModUninstaller)p_tskTask));
                            return;
                        }
                    }
                    else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
                    {
                        if ((((ModUpgrader)ViewModel.RunningTask).ModFileName == ((ModUninstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUn(((ModUninstaller)p_tskTask));
                            return;
                        }
                    }
                }
                else if (p_tskTask.GetType() == typeof(ModUpgrader))
                {
                    foreach (IBackgroundTaskSet iBk in QueuedTasks)
                    {
                        if (iBk.GetType() == typeof(ModInstaller))
                        {
                            if (((ModInstaller)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
                            {
                                if (((ModInstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUninstaller))
                        {
                            if (((ModUninstaller)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
                            {
                                if (((ModUninstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUpgrader))
                        {
                            if (((ModUpgrader)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
                            {
                                if (((ModUpgrader)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                    }

                    if (ViewModel.RunningTask.GetType() == typeof(ModInstaller))
                    {
                        if ((((ModInstaller)ViewModel.RunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
                            return;
                        }
                    }
                    else if (ViewModel.RunningTask.GetType() == typeof(ModUninstaller))
                    {
                        if ((((ModUninstaller)ViewModel.RunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
                            return;
                        }
                    }
                    else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
                    {
                        if ((((ModUpgrader)ViewModel.RunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
                            return;
                        }
                    }
                }
            }

            p_tskTask.TaskSetCompleted += new EventHandler <TaskSetCompletedEventArgs>(TaskSet_TaskSetCompleted);
            ModActivationMonitorListViewItem lviActivation = new ModActivationMonitorListViewItem(p_tskTask, this);

            UpdateBottomBarFeedback(lviActivation, new EventArgs());
            lvwActiveTasks.Items.Add(lviActivation);

            try
            {
                lviActivation.EnsureVisible();
            }
            catch { }

            if ((ViewModel.RunningTask == null) || (ViewModel.RunningTask.IsCompleted))
            {
                ViewModel.RunningTask = p_tskTask;
                if (ViewModel.RunningTask.GetType() == typeof(ModInstaller))
                {
                    ((ModInstaller)ViewModel.RunningTask).Install();
                }
                else if (ViewModel.RunningTask.GetType() == typeof(ModUninstaller))
                {
                    ((ModUninstaller)ViewModel.RunningTask).Install();
                }
                else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
                {
                    ((ModUpgrader)ViewModel.RunningTask).Install();
                }
            }
            else
            {
                QueuedTasks.Add(p_tskTask);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds the given <see cref="BasicInstallTask"/> to the view's list. If the <see cref="BasicInstallTask"/>
        /// already exists in the list, nothing is done.
        /// </summary>
        /// <param name="p_tskTask">The <see cref="BasicInstallTask"/> to add to the view's list.</param>
        protected void AddTaskToList(IBackgroundTaskSet p_tskTask)
        {
            foreach (ActivateModsListViewItem lviExisitingTask in lvwActiveTasks.Items)
            {
                if (lviExisitingTask.Task == p_tskTask)
                {
                    return;
                }
            }

            if (m_btsRunningTask != null)
            {
                if (p_tskTask.GetType() == typeof(ModInstaller))
                {
                    foreach (IBackgroundTaskSet iBk in QueuedTasks)
                    {
                        if (iBk.GetType() == typeof(ModInstaller))
                        {
                            if (((ModInstaller)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
                            {
                                if (((ModInstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUninstaller))
                        {
                            if (((ModUninstaller)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
                            {
                                if (((ModUninstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUpgrader))
                        {
                            if (((ModUpgrader)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
                            {
                                if (((ModUpgrader)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                    }

                    if (m_btsRunningTask.GetType() == typeof(ModInstaller))
                    {
                        if ((((ModInstaller)m_btsRunningTask).ModFileName == ((ModInstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTask(((ModInstaller)p_tskTask));
                            return;
                        }
                    }
                    else if (m_btsRunningTask.GetType() == typeof(ModUninstaller))
                    {
                        if ((((ModUninstaller)m_btsRunningTask).ModFileName == ((ModInstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTask(((ModInstaller)p_tskTask));
                            return;
                        }
                    }
                    else if (m_btsRunningTask.GetType() == typeof(ModUpgrader))
                    {
                        if ((((ModUpgrader)m_btsRunningTask).ModFileName == ((ModInstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTask(((ModInstaller)p_tskTask));
                            return;
                        }
                    }
                }
                else if (p_tskTask.GetType() == typeof(ModUninstaller))
                {
                    foreach (IBackgroundTaskSet iBk in QueuedTasks)
                    {
                        if (iBk.GetType() == typeof(ModInstaller))
                        {
                            if (((ModInstaller)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
                            {
                                if (((ModInstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUninstaller))
                        {
                            if (((ModUninstaller)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
                            {
                                if (((ModUninstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUpgrader))
                        {
                            if (((ModUpgrader)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
                            {
                                if (((ModUpgrader)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                    }

                    if (m_btsRunningTask.GetType() == typeof(ModInstaller))
                    {
                        if ((((ModInstaller)m_btsRunningTask).ModFileName == ((ModUninstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUn(((ModUninstaller)p_tskTask));
                            return;
                        }
                    }
                    else if (m_btsRunningTask.GetType() == typeof(ModUninstaller))
                    {
                        if ((((ModUninstaller)m_btsRunningTask).ModFileName == ((ModUninstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUn(((ModUninstaller)p_tskTask));
                            return;
                        }
                    }
                    else if (m_btsRunningTask.GetType() == typeof(ModUpgrader))
                    {
                        if ((((ModUpgrader)m_btsRunningTask).ModFileName == ((ModUninstaller)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUn(((ModUninstaller)p_tskTask));
                            return;
                        }
                    }
                }
                else if (p_tskTask.GetType() == typeof(ModUpgrader))
                {
                    foreach (IBackgroundTaskSet iBk in QueuedTasks)
                    {
                        if (iBk.GetType() == typeof(ModInstaller))
                        {
                            if (((ModInstaller)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
                            {
                                if (((ModInstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUninstaller))
                        {
                            if (((ModUninstaller)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
                            {
                                if (((ModUninstaller)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                        else if (iBk.GetType() == typeof(ModUpgrader))
                        {
                            if (((ModUpgrader)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
                            {
                                if (((ModUpgrader)iBk).IsQueued)
                                {
                                    booQueued = true;
                                }
                            }
                        }
                    }

                    if (m_btsRunningTask.GetType() == typeof(ModInstaller))
                    {
                        if ((((ModInstaller)m_btsRunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
                            return;
                        }
                    }
                    else if (m_btsRunningTask.GetType() == typeof(ModUninstaller))
                    {
                        if ((((ModUninstaller)m_btsRunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
                            return;
                        }
                    }
                    else if (m_btsRunningTask.GetType() == typeof(ModUpgrader))
                    {
                        if ((((ModUpgrader)m_btsRunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
                        {
                            booQueued = false;
                            m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
                            return;
                        }
                    }
                }
            }

            p_tskTask.TaskSetCompleted += new EventHandler <TaskSetCompletedEventArgs>(TaskSet_TaskSetCompleted);
            ActivateModsListViewItem lviActivation = new ActivateModsListViewItem(p_tskTask, this);

            lvwActiveTasks.Items.Add(lviActivation);

            if ((m_btsRunningTask == null) || (m_btsRunningTask.IsCompleted))
            {
                m_btsRunningTask = p_tskTask;
                if (m_btsRunningTask.GetType() == typeof(ModInstaller))
                {
                    ((ModInstaller)m_btsRunningTask).Install();
                }
                else if (m_btsRunningTask.GetType() == typeof(ModUninstaller))
                {
                    ((ModUninstaller)m_btsRunningTask).Install();
                }
                else if (m_btsRunningTask.GetType() == typeof(ModUpgrader))
                {
                    ((ModUpgrader)m_btsRunningTask).Install();
                }
            }
            else
            {
                QueuedTasks.Add(p_tskTask);
            }
        }
Ejemplo n.º 19
0
		/// <summary>
		/// Adds a task to the monitor.
		/// </summary>
		/// <param name="p_tskTask">The task to monitor.</param>
		public void AddActivity(IBackgroundTaskSet p_bstTask)
		{
			m_oclTasks.Add(p_bstTask);
		}
		/// <summary>
		/// Waits for the task set to complete, and notifies listeners of any task started by the set.
		/// </summary>
		/// <param name="p_btsTaskSet">The task set for which to wait.</param>
		/// <param name="p_booHookTaskStarted">Whether or not to attach a listener to the <see cref="IBackgroundTaskSet.TaskStarted"/> event.</param>
		protected void WaitForSet(IBackgroundTaskSet p_btsTaskSet, bool p_booHookTaskStarted)
		{
			if (p_booHookTaskStarted)
				p_btsTaskSet.TaskStarted += new EventHandler<EventArgs<IBackgroundTask>>(TaskSet_TaskStarted);
			p_btsTaskSet.TaskSetCompleted += new EventHandler<TaskSetCompletedEventArgs>(TaskSet_TaskSetCompleted);
			m_areTaskWait.Reset();
			if (!p_btsTaskSet.IsCompleted)
				m_areTaskWait.WaitOne();
			p_btsTaskSet.TaskSetCompleted -= new EventHandler<TaskSetCompletedEventArgs>(TaskSet_TaskSetCompleted);
			if (p_booHookTaskStarted)
				p_btsTaskSet.TaskStarted -= new EventHandler<EventArgs<IBackgroundTask>>(TaskSet_TaskStarted);
		}
Ejemplo n.º 21
0
        /// <summary>
        /// Activates the given mod.
        /// </summary>
        /// <param name="p_lstMod">The mods to activate.</param>
        public void ActivateMods(List <IMod> p_lstMod)
        {
            if (VirtualModActivator.MultiHDMode && !UacUtil.IsElevated)
            {
                MessageBox.Show("It looks like MultiHD mode is enabled but you're not running NMM as Administrator, you will be unable to install/activate mods or switch profiles." + Environment.NewLine + Environment.NewLine + "Close NMM and run it as Administrator to fix this.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string strMessage;
            bool   booRequiresConfig = ModManager.GameMode.RequiresExternalConfig(out strMessage);

            if (booRequiresConfig)
            {
                ExtendedMessageBox.Show(this.ParentForm, strMessage, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            string strErrorMessage = ModManager.RequiredToolErrorMessage;

            if (string.IsNullOrEmpty(strErrorMessage))
            {
                foreach (IMod modMod in p_lstMod)
                {
                    if (!ActiveMods.Contains(modMod))
                    {
                        ModMatcher mmcMatcher    = new ModMatcher(ModManager.InstallationLog.ActiveMods, true);
                        IMod       modOldVersion = mmcMatcher.FindAlternateVersion(modMod, true);

                        if (modOldVersion != null)
                        {
                            string strUpgradeMessage = "A different version of {0} has been detected. The installed version is {1}, the new version is {2}. Would you like to upgrade?" + Environment.NewLine + "Selecting No will install the new Mod normally.";
                            strUpgradeMessage = String.Format(strUpgradeMessage, modOldVersion.ModName, modOldVersion.HumanReadableVersion, modMod.HumanReadableVersion);
                            switch (MessageBox.Show(strUpgradeMessage, "Upgrade", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                            {
                            case DialogResult.Yes:
                                ReinstallMod(modOldVersion, modMod);
                                break;

                            case DialogResult.No:
                                IBackgroundTaskSet btsInstall = ModManager.ActivateMod(modMod, ConfirmModUpgrade, ConfirmItemOverwrite, ModManager.ActiveMods);
                                if (btsInstall != null)
                                {
                                    ModManager.ModActivationMonitor.AddActivity(btsInstall);
                                }
                                break;

                            case DialogResult.Cancel:
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            IBackgroundTaskSet btsInstall = ModManager.ActivateMod(modMod, ConfirmModUpgrade, ConfirmItemOverwrite, ModManager.ActiveMods);
                            if (btsInstall != null)
                            {
                                ModManager.ModActivationMonitor.AddActivity(btsInstall);
                            }
                        }
                    }
                    else
                    {
                        EnableMod(modMod);
                    }
                }
            }
            else
            {
                ExtendedMessageBox.Show(ParentForm, strErrorMessage, "Required Tool not present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Adds a task to the monitor.
 /// </summary>
 /// <param name="p_tskTask">The task to monitor.</param>
 public void AddActivity(IBackgroundTaskSet p_bstTask)
 {
     m_oclTasks.Add(p_bstTask);
 }
		/// <summary>
		/// Adds the given <see cref="BasicInstallTask"/> to the view's list. If the <see cref="BasicInstallTask"/>
		/// already exists in the list, nothing is done.
		/// </summary>
		/// <param name="p_tskTask">The <see cref="BasicInstallTask"/> to add to the view's list.</param>
		protected void AddTaskToList(IBackgroundTaskSet p_tskTask)
		{
			foreach (ActivateModsListViewItem lviExisitingTask in lvwActiveTasks.Items)
				if (lviExisitingTask.Task == p_tskTask)
					return;

			if (ViewModel.RunningTask != null)
			{
				if (p_tskTask.GetType() == typeof(ModInstaller))
				{
					foreach (IBackgroundTaskSet iBk in QueuedTasks)
					{
						if (iBk.GetType() == typeof(ModInstaller))
						{
							if (((ModInstaller)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
								if (((ModInstaller)iBk).IsQueued)
									booQueued = true;
						}
						else if (iBk.GetType() == typeof(ModUninstaller))
						{
							if (((ModUninstaller)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
								if (((ModUninstaller)iBk).IsQueued)
									booQueued = true;
						}
						else if (iBk.GetType() == typeof(ModUpgrader))
						{
							if (((ModUpgrader)iBk).ModFileName == ((ModInstaller)p_tskTask).ModFileName)
								if (((ModUpgrader)iBk).IsQueued)
									booQueued = true;
						}
					}

					if (ViewModel.RunningTask.GetType() == typeof(ModInstaller))
					{
						if ((((ModInstaller)ViewModel.RunningTask).ModFileName == ((ModInstaller)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTask(((ModInstaller)p_tskTask));
							return;
						}
					}
					else if (ViewModel.RunningTask.GetType() == typeof(ModUninstaller))
					{
						if ((((ModUninstaller)ViewModel.RunningTask).ModFileName == ((ModInstaller)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTask(((ModInstaller)p_tskTask));
							return;
						}
					}
					else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
					{
						if ((((ModUpgrader)ViewModel.RunningTask).ModFileName == ((ModInstaller)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTask(((ModInstaller)p_tskTask));
							return;
						}
					} 
				}
				else if(p_tskTask.GetType() == typeof(ModUninstaller))
				{
					foreach (IBackgroundTaskSet iBk in QueuedTasks)
					{
						if (iBk.GetType() == typeof(ModInstaller))
						{
							if (((ModInstaller)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
								if (((ModInstaller)iBk).IsQueued)
									booQueued = true;
						}
						else if (iBk.GetType() == typeof(ModUninstaller))
						{
							if (((ModUninstaller)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
								if (((ModUninstaller)iBk).IsQueued)
									booQueued = true;
						}
						else if (iBk.GetType() == typeof(ModUpgrader))
						{
							if (((ModUpgrader)iBk).ModFileName == ((ModUninstaller)p_tskTask).ModFileName)
								if (((ModUpgrader)iBk).IsQueued)
									booQueued = true;
						}
					}

					if (ViewModel.RunningTask.GetType() == typeof(ModInstaller))
					{
						if ((((ModInstaller)ViewModel.RunningTask).ModFileName == ((ModUninstaller)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTaskUn(((ModUninstaller)p_tskTask));
							return;
						}
					}
					else if (ViewModel.RunningTask.GetType() == typeof(ModUninstaller))
					{
						if ((((ModUninstaller)ViewModel.RunningTask).ModFileName == ((ModUninstaller)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTaskUn(((ModUninstaller)p_tskTask));
							return;
						}
					}
					else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
					{
						if ((((ModUpgrader)ViewModel.RunningTask).ModFileName == ((ModUninstaller)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTaskUn(((ModUninstaller)p_tskTask));
							return;
						}
					}
				}
				else if (p_tskTask.GetType() == typeof(ModUpgrader))
				{
					foreach (IBackgroundTaskSet iBk in QueuedTasks)
					{
						if (iBk.GetType() == typeof(ModInstaller))
						{
							if (((ModInstaller)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
								if (((ModInstaller)iBk).IsQueued)
									booQueued = true;
						}
						else if (iBk.GetType() == typeof(ModUninstaller))
						{
							if (((ModUninstaller)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
								if (((ModUninstaller)iBk).IsQueued)
									booQueued = true;
						}
						else if (iBk.GetType() == typeof(ModUpgrader))
						{
							if (((ModUpgrader)iBk).ModFileName == ((ModUpgrader)p_tskTask).ModFileName)
								if (((ModUpgrader)iBk).IsQueued)
									booQueued = true;
						}
					}

					if (ViewModel.RunningTask.GetType() == typeof(ModInstaller))
					{
						if ((((ModInstaller)ViewModel.RunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
							return;
						}
					}
					else if (ViewModel.RunningTask.GetType() == typeof(ModUninstaller))
					{
						if ((((ModUninstaller)ViewModel.RunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
							return;
						}
					}
					else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
					{
						if ((((ModUpgrader)ViewModel.RunningTask).ModFileName == ((ModUpgrader)p_tskTask).ModFileName) || booQueued)
						{
							booQueued = false;
							m_vmlViewModel.RemoveUselessTaskUpg(((ModUpgrader)p_tskTask));
							return;
						}
					}
				}
			}

			p_tskTask.TaskSetCompleted += new EventHandler<TaskSetCompletedEventArgs>(TaskSet_TaskSetCompleted);
			ActivateModsListViewItem lviActivation = new ActivateModsListViewItem(p_tskTask, this);
			UpdateBottomBarFeedback(lviActivation, new EventArgs());
			lvwActiveTasks.Items.Add(lviActivation);

			lviActivation.EnsureVisible();

			if ((ViewModel.RunningTask == null) || (ViewModel.RunningTask.IsCompleted))
			{
				ViewModel.RunningTask = p_tskTask;
				if (ViewModel.RunningTask.GetType() == typeof(ModInstaller))
					((ModInstaller)ViewModel.RunningTask).Install();
				else if (ViewModel.RunningTask.GetType() == typeof(ModUninstaller))
					((ModUninstaller)ViewModel.RunningTask).Install();
				else if (ViewModel.RunningTask.GetType() == typeof(ModUpgrader))
					((ModUpgrader)ViewModel.RunningTask).Install();
			}
			else
			{
				QueuedTasks.Add(p_tskTask);
			}
		}