/// <summary> /// Handles the <see cref="PluginManagerVM.ImportFailed"/> event of the view model. /// </summary> /// <remarks> /// This displays a simple error message. /// </remarks> /// <param name="sender">The object that raised the event.</param> /// <param name="e">An <see cref="ImportFailedEventArgs"/> describing the event arguments.</param> private void ViewModel_ImportFailed(object sender, ImportFailedEventArgs e) { if (InvokeRequired) { Invoke((Action <object, ImportFailedEventArgs>)ViewModel_ImportFailed, sender, e); return; } BeginInvoke(new MethodInvoker(() => { if (string.IsNullOrEmpty(e.Filename)) { Trace.TraceError("Failed to import the load order from the clipboard."); } else { Trace.TraceError("Failed to import the load order from: {0}", e.Filename); } Trace.Indent(); Trace.TraceError("Reason: {0}", e.Message); if (e.Error != null) { TraceUtil.TraceException(e.Error); } Trace.Unindent(); })); string message = "An error was encountered while trying to import the load order." + Environment.NewLine + Environment.NewLine + e.Message + Environment.NewLine; ExtendedMessageBox.Show(this, message, Application.ProductName, null, MessageBoxButtons.OK, MessageBoxIcon.Error); }
/// <summary> /// Checks if the CategoryManager has been properly initialized. /// </summary> public void CheckCategoryManager() { if (!this.CategoryManager.IsValidPath) { string strMessage = "You currently don't have any file categories setup."; strMessage += Environment.NewLine + "Would you like NMM to organise your mods based on the categories the Nexus sites use (YES), or would you like to organise your categories yourself (NO)?"; strMessage += Environment.NewLine + Environment.NewLine + "Note: If you choose to use Nexus categories you can still create your own categories and move your files around them. This initial Nexus setup is just a template for you to use."; DialogResult Result = ExtendedMessageBox.Show(null, strMessage, "Category setup", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.Yes) { this.CategoryManager.LoadCategories(ModManager.CurrentGameModeDefaultCategories); if (!OfflineMode) { CheckForUpdates(true); } } else { this.CategoryManager.LoadCategories(String.Empty); SwitchModsToCategory(0); } } else { this.CategoryManager.LoadCategories(String.Empty); } }
/// <summary> /// Handles the <see cref="PluginManagerVM.ExportFailed"/> event of the view model. /// </summary> /// <remarks> /// This displays a simple error message. /// </remarks> /// <param name="sender">The object that raised the event.</param> /// <param name="e">An <see cref="ExportFailedEventArgs"/> describing the event arguments.</param> private void ViewModel_ExportFailed(object sender, ExportFailedEventArgs e) { if (InvokeRequired) { Invoke((Action <object, ExportFailedEventArgs>)ViewModel_ExportFailed, sender, e); return; } BeginInvoke(new MethodInvoker(() => { if (string.IsNullOrEmpty(e.Filename)) { Trace.TraceError("Failed to export the current load order to the clipboard"); } else { Trace.TraceError("Failed to export the current load order to: {0}", e.Filename); } Trace.Indent(); Trace.TraceError("Reason: {0}", e.Message); if (e.Error != null) { TraceUtil.TraceException(e.Error); } Trace.Unindent(); })); string message = "An error was encountered trying to export the current load order." + Environment.NewLine + Environment.NewLine + "Full details are available in the trace log."; string details = "<b>Error:</b> " + e.Message; ExtendedMessageBox.Show(this, message, Application.ProductName, details, MessageBoxButtons.OK, MessageBoxIcon.Error); }
/// <summary> /// Hanldes the <see cref="Control.MouseClick"/> event of the controls. /// </summary> /// <param name="sender">The object that raised the event.</param> /// <param name="e">An <see cref="MouseEventArgs"/> describing the event arguments.</param> private void ActivateModsMonitorControl_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { ContextMenu m = new ContextMenu(); m.MenuItems.Clear(); m.MenuItems.Add(new MenuItem("Copy to clipboard", new EventHandler(cmsContextMenu_Copy))); m.Show((Control)(sender), e.Location); } else if (e.Button == MouseButtons.Left) { ListViewItem lvItem = lvwActiveTasks.GetItemAt(e.X, e.Y); if (lvItem == null) return; ListViewItem.ListViewSubItem subItem = lvItem.GetSubItemAt(e.X, e.Y); if (subItem == null) return; if (subItem.Name == "?") { if (subItem.Text != string.Empty) { if((m_strPopupErrorMessageType == "Error") || (String.IsNullOrEmpty(m_strPopupErrorMessageType))) ExtendedMessageBox.Show(this, subItem.Text, "Failed", m_strDetailsErrorMessageType, MessageBoxButtons.OK, MessageBoxIcon.Error); else if(m_strPopupErrorMessageType == "Warning") ExtendedMessageBox.Show(this, subItem.Text, "Warning", m_strDetailsErrorMessageType, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
/// <summary> /// Checks to see if a sandbox is interfering with dynamic code generation. /// </summary> /// <param name="environmentInfo">The application's envrionment info.</param> /// <returns><c>true</c> if the check passed; /// <c>false</c> otherwise.</returns> protected bool SandboxCheck(EnvironmentInfo environmentInfo) { try { new XmlSerializer(typeof(WindowPositions)); } catch (InvalidOperationException) { const string message = "{0} has detected that it is running in a sandbox.{1}" + "The sandbox is preventing {0} from performing{1}" + "important operations. Please run {0} again,{1}" + "without the sandbox."; const string details = "This error commonly occurs on computers running Comodo Antivirus.<br/>" + "If you are running Comodo or any antivirus, please add {0} and its folders to the exception list.<br/><br/>"; ExtendedMessageBox.Show(null, string.Format(message, environmentInfo.Settings.ModManagerName, Environment.NewLine), "Sandbox Detected", string.Format(details, environmentInfo.Settings.ModManagerName), MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } catch (System.Runtime.InteropServices.ExternalException) { const string message = "{0} has detected that it is running in a sandbox.{1}" + "The sandbox is preventing {0} from performing{1}" + "important operations. Please run {0} again,{1}" + "without the sandbox."; const string details = "This error commonly occurs on computers running Zone Alarm.<br/>" + "If you are running Zone Alarm or any similar security suite, please add {0} and its folders to the exception list.<br/><br/>"; ExtendedMessageBox.Show(null, string.Format(message, environmentInfo.Settings.ModManagerName, Environment.NewLine), "Sandbox Detected", string.Format(details, environmentInfo.Settings.ModManagerName), MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } return(true); }
/// <summary> /// Confirms whether a file system item should be made writable. /// </summary> /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param> /// <param name="p_strFileSystemItemPath">The path of the file system item to be made writable</param> /// <param name="p_booRememberSelection">Whether to remember the selection.</param> /// <returns><c>true</c> if the file system item should be made writable; /// <c>false</c> otherwise.</returns> private bool ConfirmMakeWritable(IEnvironmentInfo p_eifEnvironmentInfo, string p_strFileSystemItemPath, out bool p_booRememberSelection) { if (InvokeRequired) { bool booRemember = false; bool booResult = false; Invoke((MethodInvoker)(() => booResult = ConfirmMakeWritable(p_eifEnvironmentInfo, p_strFileSystemItemPath, out booRemember))); p_booRememberSelection = booRemember; return(booResult); } return(ExtendedMessageBox.Show(this, String.Format("'{0}' is read-only, so it can't be managed by {1}. Would you like to make it not read-only?", p_strFileSystemItemPath, p_eifEnvironmentInfo.Settings.ModManagerName), "Read Only", MessageBoxButtons.YesNo, MessageBoxIcon.Question, out p_booRememberSelection) == DialogResult.Yes); }
private void button3_Click(object sender, EventArgs e) { ExtendedDialogResult LobjResult = ExtendedMessageBox.Show("Hello World - Are you ok?", "The Office Context", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, "Do not show this message again."); if (LobjResult.Result == DialogResult.OK && LobjResult.IsChecked) { // do something } }
private async void InstallBthHostOnClick(object sender, RoutedEventArgs e) { MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; var rebootRequired = false; uint result = 0; var bhInfPath = Path.Combine(GlobalConfiguration.AppDirectory, "WinUSB", "BluetoothHost.inf"); MainBusyIndicator.SetContentThreadSafe(Properties.Resources.BluetoothSetupInstalling); await Task.Run(() => result = Difx.Instance.Install(bhInfPath, DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT | DifxFlags.DRIVER_PACKAGE_FORCE, out rebootRequired)); MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; // ERROR_NO_SUCH_DEVINST = 0xE000020B if (result != 0 && result != 0xE000020B) { // display error message ExtendedMessageBox.Show(this, Properties.Resources.SetupFailedTitle, Properties.Resources.SetupFailedInstructions, Properties.Resources.SetupFailedContent, string.Format(Properties.Resources.SetupFailedVerbose, new Win32Exception(Marshal.GetLastWin32Error()), Marshal.GetLastWin32Error()), Properties.Resources.SetupFailedFooter, TaskDialogIcon.Error); return; } // display success message ExtendedMessageBox.Show(this, Properties.Resources.SetupSuccessTitle, Properties.Resources.BluetoothSetupSuccessInstruction, Properties.Resources.SetupSuccessContent, string.Empty, string.Empty, TaskDialogIcon.Information); // display reboot required message if (rebootRequired) { MessageBox.Show(this, Properties.Resources.RebootRequiredContent, Properties.Resources.RebootRequiredTitle, MessageBoxButton.OK, MessageBoxImage.Warning); } }
/// <summary> /// Displays an extended message box. /// </summary> /// <param name="p_strMessage">The message to display.</param> /// <param name="p_strCaption">The caption of the message box.</param> /// <param name="p_strDetails">The details to display.</param> /// <param name="p_mbbButtons">The buttons to show on the message box.</param> /// <param name="p_mbiIcon">The icon to show on the message box.</param> /// <returns>The <see cref="DialogResult"/> corressponding to the button pushed on the message box.</returns> public DialogResult ShowExtendedMessageBox(string p_strMessage, string p_strCaption, string p_strDetails, MessageBoxButtons p_mbbButtons, MessageBoxIcon p_mbiIcon) { DialogResult drsResult = DialogResult.None; try { new PermissionSet(PermissionState.Unrestricted).Assert(); SyncContext.Send(x => drsResult = ExtendedMessageBox.Show(null, p_strMessage, p_strCaption, p_strDetails, p_mbbButtons, p_mbiIcon), null); } finally { PermissionSet.RevertAssert(); } return(drsResult); }
private void Column_Click(object sender, CellClickEventArgs e) { if (e.Column == tlcRevert) { ModProfile Profile = (ModProfile)e.Model; if ((Profile.BackupDate != "") && (Profile.IsEdited)) { string strRevertWarning = "If you click YES, any changes you've made to this profile will be deleted and the profile will revert back to its original settings." + Environment.NewLine + "If you click NO, the current profile won't be touched and a new profile will be made with the original settings." + Environment.NewLine + "If you click CANCEL, this window will close and nothing will happen." + Environment.NewLine; DialogResult drResult = ExtendedMessageBox.Show(this, strRevertWarning, "Revert", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); } } }
/// <summary> /// Displays a message. /// </summary> /// <param name="p_vwmMessage">The properties of the message to dislpay.</param> /// <returns>The return value of the displayed message.</returns> private object ShowMessage(ViewMessage p_vwmMessage) { if (InvokeRequired) { return(Invoke((ShowMessageDelegate)ShowMessage, p_vwmMessage)); } if (String.IsNullOrEmpty(p_vwmMessage.Details)) { bool booFound = true; MessageBoxButtons mbbOptions = MessageBoxButtons.OK; switch (p_vwmMessage.Options) { case ExtendedMessageBoxButtons.Abort | ExtendedMessageBoxButtons.Retry | ExtendedMessageBoxButtons.Ignore: mbbOptions = MessageBoxButtons.AbortRetryIgnore; break; case ExtendedMessageBoxButtons.OK: mbbOptions = MessageBoxButtons.OK; break; case ExtendedMessageBoxButtons.OK | ExtendedMessageBoxButtons.Cancel: mbbOptions = MessageBoxButtons.OKCancel; break; case ExtendedMessageBoxButtons.Retry | ExtendedMessageBoxButtons.Cancel: mbbOptions = MessageBoxButtons.RetryCancel; break; case ExtendedMessageBoxButtons.Yes | ExtendedMessageBoxButtons.No: mbbOptions = MessageBoxButtons.YesNo; break; case ExtendedMessageBoxButtons.Yes | ExtendedMessageBoxButtons.No | ExtendedMessageBoxButtons.Cancel: mbbOptions = MessageBoxButtons.YesNoCancel; break; default: booFound = false; break; } if (booFound) { return(MessageBox.Show(this, p_vwmMessage.Message, p_vwmMessage.Title, mbbOptions, p_vwmMessage.MessageType)); } } return(ExtendedMessageBox.Show(this, p_vwmMessage.Message, p_vwmMessage.Title, p_vwmMessage.Details, p_vwmMessage.Options, p_vwmMessage.MessageType)); }
private void button1_Click(object sender, EventArgs e) { ExtendedDialogResult LobjResult = ExtendedMessageBox.Show(textBox1.Text, textBox2.Text, (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), comboBox1.Text), (MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), comboBox2.Text), textBoxCheck.Text, new Hyperlink(textBox4.Text, textBox3.Text), textBox5.Text, trackBar1.Value); textBoxResult.Text = "You clicked: " + LobjResult.Result.ToString() + (!string.IsNullOrEmpty(textBoxCheck.Text) ? "\r\nAnd the Checkbox was " + (LobjResult.IsChecked ? "checked" : "unchecked") : "") + (LobjResult.TimedOut?"\r\nAnd the dialog timed out on its own.":""); }
/// <summary> /// Handles the <see cref="PluginManagerVM.ImportSucceeded"/> event of the view model. /// </summary> /// <remarks> /// This displays a simple success message. /// </remarks> /// <param name="sender">The object that raised the event.</param> /// <param name="e">An <see cref="EventArgs{String}"/> describing the event arguments.</param> private void ViewModel_ImportSucceeded(object sender, ImportSucceededEventArgs e) { if (InvokeRequired) { Invoke((Action <object, ImportSucceededEventArgs>)ViewModel_ImportSucceeded, sender, e); return; } System.Text.StringBuilder sbMessage = new System.Text.StringBuilder(); string strDetails; sbMessage.Append("The load order was successfully imported from"); FormatPluginCountsReport(e, ref sbMessage, out strDetails); ExtendedMessageBox.Show(this, sbMessage.ToString(), ViewModel.Settings.ModManagerName, strDetails, ExtendedMessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <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> /// Checks if the ReadMe Manager has been properly initialized. /// </summary> public void CheckReadMeManager() { if ((this.ModManager.ManagedMods.Count > 0) && (!this.ModManager.ReadMeManager.IsInitialized)) { string strMessage = string.Empty; if (ModManager.ReadMeManager.IsXMLCorrupt) { strMessage = "An error occurred loading the ReadMeManager.xml file." + Environment.NewLine + Environment.NewLine; } strMessage += "NMM needs to setup the Readme Manager, this could take a few minutes depending on the number of mods and archive sizes."; strMessage += Environment.NewLine + "Do you want to perform the Readme Manager startup scan?"; strMessage += Environment.NewLine + Environment.NewLine + "Note: if choose not to, you will be able to perform a scan by selecting any number of mods, and choosing 'Readme Scan' in the right-click menu."; if (ExtendedMessageBox.Show(null, strMessage, "Readme Manager Setup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SetupReadMeManager(ModManager.ManagedMods.ToList <IMod>()); } } }
/// <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); } }
/// <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); } }
private void InstallBthHostOnClick(object sender, RoutedEventArgs e) { var bthResult = WdiErrorCode.WDI_SUCCESS; var bthToInstall = BluetoothStackPanelDefault.Children.Cast <TextBlock>() .Select(c => c.Tag) .Cast <WdiDeviceInfo>() .ToList(); if (bthToInstall.Any()) { bthResult = DriverInstaller.InstallBluetoothHost(bthToInstall.First(), _hWnd); } // display success or failure message if (bthResult == WdiErrorCode.WDI_SUCCESS) { ExtendedMessageBox.Show(this, Properties.Resources.BthInstOk_Title, Properties.Resources.BthInstOk_Instruction, Properties.Resources.BthInstOk_Content, Properties.Resources.BthInstOk_Verbose, Properties.Resources.BthInstOk_Footer, TaskDialogIcon.Information); } else { ExtendedMessageBox.Show(this, Properties.Resources.DsInstError_Title, Properties.Resources.DsInstError_Instruction, Properties.Resources.DsInstError_Content, string.Format(Properties.Resources.DsInstError_Verbose, WdiWrapper.Instance.GetErrorMessage(bthResult), bthResult), Properties.Resources.DsInstError_Footer, TaskDialogIcon.Error); } }
/// <summary> /// Handles the <see cref="PluginManagerVM.ExportSucceeded"/> event of the view model. /// </summary> /// <remarks> /// This displays a simple success message. /// </remarks> /// <param name="sender">The object that raised the event.</param> /// <param name="e">An <see cref="EventArgs{String}"/> describing the event arguments.</param> private void ViewModel_ExportSucceeded(object sender, ExportSucceededEventArgs e) { if (InvokeRequired) { Invoke((Action <object, ExportSucceededEventArgs>)ViewModel_ExportSucceeded, sender, e); return; } string message = "The current load order was successfully exported to"; if (string.IsNullOrEmpty(e.Filename)) { message += " the clipboard."; } else { message += ":" + Environment.NewLine + Environment.NewLine + e.Filename; } string details = string.Format("{0} {1} successfully exported.", e.ExportedPluginCount, (e.ExportedPluginCount == 1) ? "plugin was" : "plugins were"); ExtendedMessageBox.Show(this, message, ViewModel.Settings.ModManagerName, details.ToString(), ExtendedMessageBoxButtons.OK, MessageBoxIcon.Information); }
private async void InstallVBusOnClick(object sender, RoutedEventArgs e) { MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; var failed = false; var rebootRequired = false; await Task.Run(() => { string devPath = string.Empty, instanceId = string.Empty; try { var busInfPath = Path.Combine( GlobalConfiguration.AppDirectory, "ScpVBus", Environment.Is64BitOperatingSystem ? "amd64" : "x86", "ScpVBus.inf"); Log.DebugFormat("ScpVBus.inf path: {0}", busInfPath); // check for existence of Scp VBus if (!Devcon.Find(Settings.Default.VirtualBusClassGuid, ref devPath, ref instanceId)) { MainBusyIndicator.SetContentThreadSafe(Properties.Resources.VirtualBusSetupAddingDriverStore); // if not detected, install Inf-file in Windows Driver Store if (Devcon.Install(busInfPath, ref rebootRequired)) { Log.Info("Virtual Bus Driver pre-installed in Windows Driver Store successfully"); MainBusyIndicator.SetContentThreadSafe(Properties.Resources.VirtualBusSetupCreating); // create pseudo-device so the bus driver can attach to it later if (Devcon.Create("System", new Guid("{4D36E97D-E325-11CE-BFC1-08002BE10318}"), "root\\ScpVBus\0\0")) { Log.Info("Virtual Bus Created"); } else { Log.Fatal("Virtual Bus Device creation failed"); failed = true; } } else { Log.FatalFormat("Virtual Bus Driver pre-installation failed with Win32 error {0}", (uint)Marshal.GetLastWin32Error()); failed = true; } } MainBusyIndicator.SetContentThreadSafe(Properties.Resources.VirtualBusSetupInstalling); // install Virtual Bus driver var result = Difx.Instance.Install(busInfPath, DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT | DifxFlags.DRIVER_PACKAGE_FORCE, out rebootRequired); if (result != 0) { failed = true; } } catch (Exception ex) { Log.ErrorFormat("Error during installation: {0}", ex); } }); MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; // display error message if (failed) { ExtendedMessageBox.Show(this, Properties.Resources.SetupFailedTitle, Properties.Resources.SetupFailedInstructions, Properties.Resources.SetupFailedContent, string.Format(Properties.Resources.SetupFailedVerbose, new Win32Exception(Marshal.GetLastWin32Error()), Marshal.GetLastWin32Error()), Properties.Resources.SetupFailedFooter, TaskDialogIcon.Error); return; } // display success message ExtendedMessageBox.Show(this, Properties.Resources.SetupSuccessTitle, Properties.Resources.VirtualBusSetupSuccessInstruction, Properties.Resources.SetupSuccessContent, string.Empty, string.Empty, TaskDialogIcon.Information); // display reboot required message if (rebootRequired) { MessageBox.Show(this, Properties.Resources.RebootRequiredContent, Properties.Resources.RebootRequiredTitle, MessageBoxButton.OK, MessageBoxImage.Warning); } }
/// <summary> /// Performs the update. /// </summary> /// <returns><c>true</c> if the update completed successfully; /// <c>false</c> otherwise.</returns> public override bool Update() { Trace.TraceInformation("Checking for new client version..."); Trace.Indent(); SetProgressMaximum(2); SetMessage(String.Format("Checking for new {0} version...", EnvironmentInfo.Settings.ModManagerName)); string strDownloadUri = String.Empty; Version verNew = GetNewProgrammeVersion(out strDownloadUri); SetProgress(1); if (CancelRequested) { Trace.Unindent(); return(CancelUpdate()); } if (verNew == new Version("69.69.69.69")) { SetMessage("Could not get version information from the update server."); return(false); } StringBuilder stbPromptMessage = new StringBuilder(); DialogResult drResult = DialogResult.No; if ((verNew > new Version(ProgrammeMetadata.VersionString)) && !String.IsNullOrEmpty(strDownloadUri)) { stbPromptMessage.AppendFormat("A new version of {0} is available ({1}).{2}Would you like to download and install it?", EnvironmentInfo.Settings.ModManagerName, verNew, Environment.NewLine).AppendLine(); stbPromptMessage.AppendLine(); stbPromptMessage.AppendLine(); stbPromptMessage.AppendLine("NOTE: You can find the change log for the new release here:"); stbPromptMessage.AppendLine(NexusLinks.ReleasesLegacy); try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbPromptMessage.ToString(), "New version available", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); } } catch { } if (drResult == DialogResult.Cancel) { Trace.Unindent(); return(CancelUpdate()); } SetMessage(String.Format("Downloading new {0} version...", EnvironmentInfo.Settings.ModManagerName)); string strNewInstaller = string.Empty; try { strNewInstaller = DownloadFile(new Uri(String.Format(strDownloadUri))); } catch (FileNotFoundException) { StringBuilder stbAVMessage = new StringBuilder(); stbAVMessage.AppendLine("Unable to find the installer to download:"); stbAVMessage.AppendLine("this could be caused by a network issue or by your Firewall."); stbAVMessage.AppendLine("As a result you won't be able to automatically update the program."); stbAVMessage.AppendLine(); stbAVMessage.AppendFormat("You can download the update manually from:"); stbAVMessage.AppendLine(NexusLinks.ReleasesLegacy); try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbAVMessage.ToString(), "Unable to update", MessageBoxButtons.OK, MessageBoxIcon.Information); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); } } catch { } Trace.Unindent(); return(CancelUpdate()); } SetProgress(2); if (CancelRequested) { Trace.Unindent(); return(CancelUpdate()); } if (!String.IsNullOrEmpty(strNewInstaller)) { string strOldPath = strNewInstaller; strNewInstaller = Path.Combine(Path.GetTempPath(), Path.GetFileName(strNewInstaller)); FileUtil.ForceDelete(strNewInstaller); try { File.Move(strOldPath, strNewInstaller); } catch (FileNotFoundException) { StringBuilder stbAVMessage = new StringBuilder(); stbAVMessage.AppendLine("Unable to find the downloaded update:"); stbAVMessage.AppendLine("this could be caused by a network issue or by your anti-virus software deleting it falsely flagging the installer as a virus."); stbAVMessage.AppendLine("As a result you won't be able to automatically update the program."); stbAVMessage.AppendLine(); stbAVMessage.AppendFormat("To fix this issue you need to add {0}'s executable and all its folders to your", EnvironmentInfo.Settings.ModManagerName).AppendLine(); stbAVMessage.AppendLine("anti-virus exception list. You can also download the update manually from:"); stbAVMessage.AppendLine(NexusLinks.ReleasesLegacy); try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbAVMessage.ToString(), "Unable to update", MessageBoxButtons.OK, MessageBoxIcon.Information); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); } } catch { } Trace.Unindent(); return(CancelUpdate()); } SetMessage("Launching installer..."); ProcessStartInfo psiInfo = new ProcessStartInfo(strNewInstaller); Process.Start(psiInfo); Trace.Unindent(); return(true); } } else if (!m_booIsAutoCheck) { stbPromptMessage.AppendFormat("{0} is already up to date.", EnvironmentInfo.Settings.ModManagerName).AppendLine(); stbPromptMessage.AppendLine(); stbPromptMessage.AppendLine(); stbPromptMessage.AppendLine("NOTE: You can find the release notes, planned features and past versions here:"); stbPromptMessage.AppendLine(NexusLinks.ReleasesLegacy); try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbPromptMessage.ToString(), "Up to date", MessageBoxButtons.OK, MessageBoxIcon.Information); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); } } catch { } } SetMessage(String.Format("{0} is already up to date.", EnvironmentInfo.Settings.ModManagerName)); SetProgress(2); Trace.Unindent(); return(true); }
private async void InstallBthHostOnClick(object sender, RoutedEventArgs e) { MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; var rebootRequired = false; uint result = 0; var bhInfPath = Path.Combine(GlobalConfiguration.AppDirectory, "WinUSB", "BluetoothHost.inf"); var supportedBluetoothDevices = IniConfig.Instance.BthDongleDriver.HardwareIds; var regex = new Regex("VID_([0-9A-Z]{4})&PID_([0-9A-Z]{4})", RegexOptions.IgnoreCase); // Use Self-Signed Drivers? if (_viewModel.SelfSignedDriversBthEnabled) { var usbDevices = WdiWrapper.Instance.UsbDeviceList.ToList(); await Task.Run(() => { foreach ( var usbDevice in usbDevices.Where( d => supportedBluetoothDevices.Any(s => s.Contains(regex.Match(d.HardwareId).Value)) && !string.IsNullOrEmpty(d.CurrentDriver) && d.CurrentDriver.Equals("BTHUSB")) ) { MainBusyIndicator.SetContentThreadSafe(Properties.Resources.BluetoothSetupInstalling); DriverInstaller.InstallBluetoothHost(usbDevice, force: _viewModel.ForceInstallBthEnabled); } }); } else { MainBusyIndicator.SetContentThreadSafe(Properties.Resources.BluetoothSetupInstalling); await Task.Run(() => result = Difx.Instance.Install(bhInfPath, DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT | DifxFlags.DRIVER_PACKAGE_FORCE, out rebootRequired)); } MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; // ERROR_NO_SUCH_DEVINST = 0xE000020B if (result != 0 && result != 0xE000020B) { // display error message ExtendedMessageBox.Show(this, Properties.Resources.SetupFailedTitle, Properties.Resources.SetupFailedInstructions, Properties.Resources.SetupFailedContent, string.Format(Properties.Resources.SetupFailedVerbose, new Win32Exception(Marshal.GetLastWin32Error()), Marshal.GetLastWin32Error()), Properties.Resources.SetupFailedFooter, TaskDialogIcon.Error); return; } // display success message ExtendedMessageBox.Show(this, Properties.Resources.SetupSuccessTitle, Properties.Resources.BluetoothSetupSuccessInstruction, Properties.Resources.SetupSuccessContent, string.Empty, string.Empty, TaskDialogIcon.Information); // display reboot required message if (rebootRequired) { MessageBox.Show(this, Properties.Resources.RebootRequiredContent, Properties.Resources.RebootRequiredTitle, MessageBoxButton.OK, MessageBoxImage.Warning); } }
private async void InstallDsOnClick(object sender, RoutedEventArgs routedEventArgs) { MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; var rebootRequired = false; var failed = false; uint result = 0; var ds3InfPath = Path.Combine(GlobalConfiguration.AppDirectory, "WinUSB", "Ds3Controller.inf"); var ds4InfPath = Path.Combine(GlobalConfiguration.AppDirectory, "WinUSB", "Ds4Controller.inf"); MainBusyIndicator.SetContentThreadSafe(Properties.Resources.DualShockSetupInstalling3); await Task.Run(() => result = Difx.Instance.Install(ds3InfPath, DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT | DifxFlags.DRIVER_PACKAGE_FORCE, out rebootRequired)); // ERROR_NO_SUCH_DEVINST = 0xE000020B if (result != 0 && result != 0xE000020B) { failed = true; ExtendedMessageBox.Show(this, Properties.Resources.SetupFailedTitle, Properties.Resources.SetupFailedInstructions, Properties.Resources.SetupFailedContent, string.Format(Properties.Resources.SetupFailedVerbose, new Win32Exception(Marshal.GetLastWin32Error()), Marshal.GetLastWin32Error()), Properties.Resources.SetupFailedFooter, TaskDialogIcon.Error); } MainBusyIndicator.SetContentThreadSafe(Properties.Resources.DualShockSetupInstalling4); await Task.Run(() => result = Difx.Instance.Install(ds4InfPath, DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT | DifxFlags.DRIVER_PACKAGE_FORCE, out rebootRequired)); // ERROR_NO_SUCH_DEVINST = 0xE000020B if (result != 0 && result != 0xE000020B) { failed = true; ExtendedMessageBox.Show(this, Properties.Resources.SetupFailedTitle, Properties.Resources.SetupFailedInstructions, Properties.Resources.SetupFailedContent, string.Format(Properties.Resources.SetupFailedVerbose, new Win32Exception(Marshal.GetLastWin32Error()), Marshal.GetLastWin32Error()), Properties.Resources.SetupFailedFooter, TaskDialogIcon.Error); } MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; if (!failed) { ExtendedMessageBox.Show(this, Properties.Resources.SetupSuccessTitle, Properties.Resources.DualShockSetupSuccessInstruction, Properties.Resources.SetupSuccessContent, string.Empty, string.Empty, TaskDialogIcon.Information); } if (rebootRequired) { MessageBox.Show(this, Properties.Resources.RebootRequiredContent, Properties.Resources.RebootRequiredTitle, MessageBoxButton.OK, MessageBoxImage.Warning); } }
public override bool CheckSecondaryUninstall(string p_strFileName) { if (p_strFileName.Contains("content.xml")) { try { var xdocContentXml = XDocument.Load(Path.Combine(InstallationPath, p_strFileName)); var strModName = xdocContentXml.Root.Attribute("name").Value; var strSaveAttribute = xdocContentXml.Root.Attribute("save"); string strSaveValue = null; if (strSaveAttribute != null) { strSaveValue = strSaveAttribute.Value; } if (string.IsNullOrEmpty(strSaveValue) || strSaveValue.Equals("true") || strSaveValue.Equals("1")) { DialogResult drResult = DialogResult.None; try { ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, string.Format( "The author of the {0} mod has chosen that his mod should get recorded in your save games.\nIf you played the game while this mod was active, your save files may no longer work.\nDo you want to continue?", strModName), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { var thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); if (drResult == DialogResult.No) { return(true); } } } catch (Exception) { drResult = MessageBox.Show(string.Format( "The author of the {0} mod has choosen that his mod should get recorded in your save games.\nIf you played the game while this mod was active, your save files may no longer work.\nDo you want to continue?", strModName), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (drResult == DialogResult.No) { return(true); } } } } catch { return(true); } } return(false); }
/// <summary> /// Performs the update. /// </summary> /// <returns><c>true</c> if the update completed successfully; /// <c>false</c> otherwise.</returns> public override bool Update() { Trace.TraceInformation("Checking for new client version..."); Trace.Indent(); SetProgressMaximum(2); SetMessage(String.Format("Checking for new {0} version...", EnvironmentInfo.Settings.ModManagerName)); string strDownloadUri = String.Empty; Version verNew = GetNewProgrammeVersion(out strDownloadUri); SetProgress(1); if (CancelRequested) { Trace.Unindent(); return(CancelUpdate()); } if (verNew == new Version("69.69.69.69")) { SetMessage("Could not get version information from the update server."); return(false); } StringBuilder stbPromptMessage = new StringBuilder(); DialogResult drResult = DialogResult.No; string strReleaseNotes = String.Empty; if ((verNew > new Version(ProgrammeMetadata.VersionString)) && !String.IsNullOrEmpty(strDownloadUri)) { string strCheckDownloadedInstaller = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Temp", Path.GetFileName(strDownloadUri)); stbPromptMessage.AppendFormat("A new version of {0} is available ({1}).{2}Would you like to download and install it?", EnvironmentInfo.Settings.ModManagerName, verNew, Environment.NewLine).AppendLine(); stbPromptMessage.AppendLine(); stbPromptMessage.AppendLine(); stbPromptMessage.AppendLine("Below you can find the change log for the new release:"); try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_strURI); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); StreamReader readStream = null; if (response.CharacterSet == null) { readStream = new StreamReader(receiveStream); } else { readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet)); } strReleaseNotes = readStream.ReadToEnd(); response.Close(); readStream.Close(); } } catch { strReleaseNotes = "Unable to retrieve the Release Notes."; } try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbPromptMessage.ToString(), "New version available", strReleaseNotes, 700, 450, MessageBoxButtons.OKCancel, MessageBoxIcon.Question); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); } } catch { } if (drResult == DialogResult.Cancel) { Trace.Unindent(); return(CancelUpdate()); } if (File.Exists(strCheckDownloadedInstaller)) { SetMessage("Launching installer..."); ProcessStartInfo psiInfo = new ProcessStartInfo(strCheckDownloadedInstaller); Process.Start(psiInfo); Trace.Unindent(); return(true); } SetMessage(String.Format("Downloading new {0} version...", EnvironmentInfo.Settings.ModManagerName)); string strNewInstaller = string.Empty; try { strNewInstaller = DownloadFile(new Uri(String.Format(strDownloadUri))); } catch (FileNotFoundException) { StringBuilder stbAVMessage = new StringBuilder(); stbAVMessage.AppendLine("Unable to find the installer to download:"); stbAVMessage.AppendLine("this could be caused by a network issue or by your Firewall."); stbAVMessage.AppendLine("As a result you won't be able to automatically update the program."); stbAVMessage.AppendLine(); stbAVMessage.AppendFormat("You can download the update manually from:"); stbAVMessage.AppendLine("http://skyrim.nexusmods.com/mods/modmanager/"); try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbAVMessage.ToString(), "Unable to update", MessageBoxButtons.OK, MessageBoxIcon.Information); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); } } catch { } Trace.Unindent(); return(CancelUpdate()); } SetProgress(2); if (CancelRequested) { Trace.Unindent(); return(CancelUpdate()); } if (!String.IsNullOrEmpty(strNewInstaller)) { string strOldPath = strNewInstaller; strNewInstaller = Path.Combine(Path.GetTempPath(), Path.GetFileName(strNewInstaller)); FileUtil.ForceDelete(strNewInstaller); try { File.Move(strOldPath, strNewInstaller); } catch (FileNotFoundException) { StringBuilder stbAVMessage = new StringBuilder(); stbAVMessage.AppendLine("Unable to find the downloaded update:"); stbAVMessage.AppendLine("this could be caused by a network issue or by your anti-virus software deleting it falsely flagging the installer as a virus."); stbAVMessage.AppendLine("As a result you won't be able to automatically update the program."); stbAVMessage.AppendLine(); stbAVMessage.AppendFormat("To fix this issue you need to add {0}'s executable and all its folders to your", EnvironmentInfo.Settings.ModManagerName).AppendLine(); stbAVMessage.AppendLine("anti-virus exception list. You can also download the update manually from:"); stbAVMessage.AppendLine("http://skyrim.nexusmods.com/mods/modmanager/"); try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbAVMessage.ToString(), "Unable to update", MessageBoxButtons.OK, MessageBoxIcon.Information); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); } } catch { } Trace.Unindent(); return(CancelUpdate()); } SetMessage("Launching installer..."); ProcessStartInfo psiInfo = new ProcessStartInfo(strNewInstaller); Process.Start(psiInfo); Trace.Unindent(); return(true); } } else if (!m_booIsAutoCheck) { stbPromptMessage.AppendFormat("{0} is already up to date.", EnvironmentInfo.Settings.ModManagerName).AppendLine(); stbPromptMessage.AppendLine(); stbPromptMessage.AppendLine(); stbPromptMessage.AppendLine("NOTE: You can find the release notes, planned features and past versions here:"); stbPromptMessage.AppendLine("http://forums.nexusmods.com/index.php?/topic/896029-nexus-mod-manager-release-notes/"); try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbPromptMessage.ToString(), "Up to date", MessageBoxButtons.OK, MessageBoxIcon.Information); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); } } catch { } } SetMessage(String.Format("{0} is already up to date.", EnvironmentInfo.Settings.ModManagerName)); SetProgress(2); Trace.Unindent(); return(true); }
/// <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); } }
private void InstallDsOnClick(object sender, RoutedEventArgs routedEventArgs) { WdiErrorCode ds3Result = WdiErrorCode.WDI_SUCCESS, ds4Result = WdiErrorCode.WDI_SUCCESS; var ds3SToInstall = DualShockStackPanelHidUsb.Children.Cast <TextBlock>() .Select(c => c.Tag) .Cast <WdiDeviceInfo>() .Where(d => d.VendorId == _hidUsbDs3.VendorId && d.ProductId == _hidUsbDs3.ProductId) .ToList(); if (ds3SToInstall.Any()) { ds3Result = DriverInstaller.InstallDualShock3Controller(ds3SToInstall.First(), _hWnd); } var ds4SToInstall = DualShockStackPanelHidUsb.Children.Cast <TextBlock>() .Select(c => c.Tag) .Cast <WdiDeviceInfo>() .Where(d => d.VendorId == _hidUsbDs4.VendorId && d.ProductId == _hidUsbDs4.ProductId) .ToList(); if (ds4SToInstall.Any()) { ds4Result = DriverInstaller.InstallDualShock4Controller(ds4SToInstall.First(), _hWnd); } // display success or failure message if (ds3Result == WdiErrorCode.WDI_SUCCESS && ds4Result == WdiErrorCode.WDI_SUCCESS) { ExtendedMessageBox.Show(this, Properties.Resources.DsInstOk_Title, Properties.Resources.DsInstOk_Instruction, Properties.Resources.DsInstOk_Content, Properties.Resources.DsInstOk_Verbose, Properties.Resources.DsInstOk_Footer, TaskDialogIcon.Information); } else { if (ds3Result != WdiErrorCode.WDI_SUCCESS) { ExtendedMessageBox.Show(this, Properties.Resources.DsInstError_Title, Properties.Resources.DsInstError_Instruction, Properties.Resources.DsInstError_Content, string.Format(Properties.Resources.DsInstError_Verbose, WdiWrapper.Instance.GetErrorMessage(ds3Result), ds3Result), Properties.Resources.DsInstError_Footer, TaskDialogIcon.Error); return; } if (ds4Result != WdiErrorCode.WDI_SUCCESS) { ExtendedMessageBox.Show(this, Properties.Resources.DsInstError_Title, Properties.Resources.DsInstError_Instruction, Properties.Resources.DsInstError_Content, string.Format(Properties.Resources.DsInstError_Verbose, WdiWrapper.Instance.GetErrorMessage(ds4Result), ds4Result), Properties.Resources.DsInstError_Footer, TaskDialogIcon.Error); } } }
/// <summary> /// Performs the update. /// </summary> /// <returns><c>true</c> if the update completed successfully; /// <c>false</c> otherwise.</returns> public override bool Update() { Trace.TraceInformation("Checking for new client version..."); Trace.Indent(); SetProgressMaximum(2); SetMessage($"Checking for new {CommonData.ModManagerName} version..."); var currentVersion = new Version(CommonData.VersionString); var releaseInformation = GetReleaseInformation(); var newVersion = releaseInformation.Item1; var downloadUrl = releaseInformation.Item2; SetProgress(1); if (CancelRequested) { Trace.Unindent(); return(CancelUpdate()); } if (newVersion == null || string.IsNullOrEmpty(downloadUrl)) { SetMessage("Could not get version information from the update server."); return(false); } var dialogResult = DialogResult.No; if (newVersion > currentVersion) { string releaseNotes; var checkDownloadedInstaller = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Temp", Path.GetFileName(downloadUrl)); var promptMessage = $"A new version of {CommonData.ModManagerName} is available ({newVersion}).{Environment.NewLine}" + $"Would you like to download and install it?{Environment.NewLine}{Environment.NewLine}" + "Below you can find the change log for the new release:"; try { releaseNotes = ConstructChangeLog(currentVersion, newVersion); } catch { releaseNotes = "Unable to retrieve change log."; } DisplayDialog(() => dialogResult = ExtendedMessageBox.Show(null, promptMessage, "New version available", releaseNotes, 700, 450, ExtendedMessageBoxButtons.Backup, MessageBoxIcon.Question)); switch (dialogResult) { case DialogResult.Cancel: Trace.Unindent(); return(CancelUpdate()); case DialogResult.Yes: _updateManager.CreateBackup(); break; } if (File.Exists(checkDownloadedInstaller)) { SetMessage("Launching installer..."); var processStartInfo = new ProcessStartInfo(checkDownloadedInstaller); Process.Start(processStartInfo); Trace.Unindent(); return(true); } SetMessage($"Downloading new {CommonData.ModManagerName} version..."); string newInstaller; try { newInstaller = DownloadFile(new Uri(string.Format(downloadUrl))); } catch (FileNotFoundException) { var avMessage = $"Unable to find the installer to download:{Environment.NewLine}" + $"This could be caused by a network issue or by your Firewall.{Environment.NewLine}{Environment.NewLine}" + $"As a result you won't be able to automatically update the program.{Environment.NewLine}{Environment.NewLine}" + $"You can download the update manually from:{Environment.NewLine}{Links.Instance.Releases}"; DisplayDialog(() => dialogResult = ExtendedMessageBox.Show(null, avMessage, "Unable to update", MessageBoxButtons.OK, MessageBoxIcon.Information)); Trace.Unindent(); return(CancelUpdate()); } SetProgress(2); if (CancelRequested) { Trace.Unindent(); return(CancelUpdate()); } if (!string.IsNullOrEmpty(newInstaller)) { var oldPath = newInstaller; newInstaller = Path.Combine(Path.GetTempPath(), Path.GetFileName(newInstaller)); FileUtil.ForceDelete(newInstaller); try { File.Move(oldPath, newInstaller); } catch (FileNotFoundException) { var avMessage = $"Unable to find the downloaded update:{Environment.NewLine}" + $"This could be caused by a network issue or by your anti-virus software deleting it falsely flagging the installer as a virus.{Environment.NewLine}" + $"As a result you won't be able to automatically update the program.{Environment.NewLine}{Environment.NewLine}" + $"To fix this issue you need to add {CommonData.ModManagerName}'s executable and all its folders to your{Environment.NewLine}" + $"anti-virus exception list. You can also download the update manually from:{Environment.NewLine}{Links.Instance.Releases}"; DisplayDialog(() => dialogResult = ExtendedMessageBox.Show(null, avMessage, "Unable to update", MessageBoxButtons.OK, MessageBoxIcon.Information)); Trace.Unindent(); return(CancelUpdate()); } SetMessage("Launching installer..."); var psiInfo = new ProcessStartInfo(newInstaller); Process.Start(psiInfo); Trace.Unindent(); return(true); } } else if (!_isAutomaticCheck) { var promptMessage = $"{CommonData.ModManagerName} is already up to date.{Environment.NewLine}{Environment.NewLine}" + $"NOTE: You can find the release notes and past versions here:{Environment.NewLine}{Links.Instance.Releases}"; DisplayDialog(() => ExtendedMessageBox.Show(null, promptMessage, "Up to date", MessageBoxButtons.OK, MessageBoxIcon.Information)); } SetMessage($"{CommonData.ModManagerName} is already up to date."); SetProgress(2); Trace.Unindent(); return(true); }
/// <summary> /// This lets the user know a problem has occurred, and logs the exception. /// </summary> /// <param name="ex">The exception that is being handled.</param> private static void HandleException(Exception ex) { HeaderlessTextWriterTraceListener htlListener = (HeaderlessTextWriterTraceListener)Trace.Listeners["DefaultListener"]; DialogResult drResult = DialogResult.No; Trace.WriteLine(""); Trace.TraceError("Tracing an Unhandled Exception:"); TraceUtil.TraceException(ex); if (!htlListener.TraceIsForced) { htlListener.SaveToFile(); } StringBuilder stbPromptMessage = new StringBuilder(); stbPromptMessage.AppendFormat("{0} has encountered an error and needs to close.", EnvironmentInfo.Settings.ModManagerName).AppendLine(); stbPromptMessage.AppendLine("A Trace Log file was created at:"); stbPromptMessage.AppendLine(htlListener.FilePath); stbPromptMessage.AppendLine("Before reporting the issue, don't close this window and check for a fix here (you can close it afterwards):"); stbPromptMessage.AppendLine(NexusLinks.FAQs); stbPromptMessage.AppendLine("If you can't find a solution, please make a bug report and attach the TraceLog file here:"); stbPromptMessage.AppendLine(NexusLinks.Issues); stbPromptMessage.AppendLine(Environment.NewLine + "Do you want to open the TraceLog folder?"); try { //the extended message box contains an activex control wich must be run in an STA thread, // we can't control what thread this gets called on, so create one if we need to string strException = "The following information is in the Trace Log:" + Environment.NewLine + TraceUtil.CreateTraceExceptionString(ex); ThreadStart actShowMessage = () => drResult = ExtendedMessageBox.Show(null, stbPromptMessage.ToString(), "Error", strException, MessageBoxButtons.YesNo, MessageBoxIcon.Information); ApartmentState astState = ApartmentState.Unknown; Thread.CurrentThread.TrySetApartmentState(astState); if (astState == ApartmentState.STA) { actShowMessage(); } else { Thread thdMessage = new Thread(actShowMessage); thdMessage.SetApartmentState(ApartmentState.STA); thdMessage.Start(); thdMessage.Join(); if (drResult == DialogResult.Yes) { try { System.Diagnostics.Process prc = new System.Diagnostics.Process(); prc.StartInfo.FileName = Path.GetDirectoryName(htlListener.FilePath); prc.Start(); } catch { } } } } catch { //backup, in case on extended message box starts to act up MessageBox.Show(stbPromptMessage.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void InstallWindowsServiceOnClick(object sender, RoutedEventArgs e) { MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; var failed = false; var rebootRequired = false; await Task.Run(() => { try { MainBusyIndicator.SetContentThreadSafe(Properties.Resources.ServiceSetupInstalling); IDictionary state = new Hashtable(); var service = new AssemblyInstaller(Path.Combine(GlobalConfiguration.AppDirectory, "ScpService.exe"), null); state.Clear(); service.UseNewContext = true; service.Install(state); service.Commit(state); if (StartService(Settings.Default.ScpServiceName)) { Log.InfoFormat("{0} started", Settings.Default.ScpServiceName); } else { rebootRequired = true; } } catch (Win32Exception w32Ex) { switch (w32Ex.NativeErrorCode) { case 1073: // ERROR_SERVICE_EXISTS Log.Info("Service already exists"); break; default: Log.ErrorFormat("Win32-Error during installation: {0}", w32Ex); failed = true; break; } } catch (InvalidOperationException iopex) { Log.ErrorFormat("Error during installation: {0}", iopex.Message); failed = true; } catch (Exception ex) { Log.ErrorFormat("Error during installation: {0}", ex); failed = true; } }); MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy; // display error message if (failed) { ExtendedMessageBox.Show(this, Properties.Resources.SetupFailedTitle, Properties.Resources.SetupFailedInstructions, Properties.Resources.SetupFailedContent, string.Format(Properties.Resources.SetupFailedVerbose, new Win32Exception(Marshal.GetLastWin32Error()), Marshal.GetLastWin32Error()), Properties.Resources.SetupFailedFooter, TaskDialogIcon.Error); return; } // display success message ExtendedMessageBox.Show(this, Properties.Resources.SetupSuccessTitle, Properties.Resources.ServiceSetupSuccessInstruction, Properties.Resources.ServiceSetupSuccessContent, string.Empty, string.Empty, TaskDialogIcon.Information); // display reboot required message if (rebootRequired) { MessageBox.Show(this, Properties.Resources.RebootRequiredContent, Properties.Resources.RebootRequiredTitle, MessageBoxButton.OK, MessageBoxImage.Warning); } }