private void Window_Initialized(object sender, EventArgs e) { MessageBox.Show( "Hold it right there! You don't need this tool if you have a DualShock controller! Seek help on the forums if your're not sure what to do next.", "Wait a sec'", MessageBoxButton.OK, MessageBoxImage.Exclamation); const string messageTitle = "Press button or engage axis"; const string messageTemplate = "Please press and hold {0} now and click Capture"; foreach (CaptureType type in Enum.GetValues(typeof (CaptureType))) { if (type == CaptureType.Default) continue; var diag = new TaskDialog { Buttons = { new TaskDialogButton("Capture"), new TaskDialogButton("I don't have this button/axis, skip it") }, WindowTitle = messageTitle, Content = string.Format(messageTemplate, type), MainIcon = TaskDialogIcon.Information }; _interpreterDiags.Add(type, diag); } }
private void InstallButton_OnClick(object sender, RoutedEventArgs e) { var selectedDevice = DevicesComboBox.SelectedItem as WdiUsbDevice; if (selectedDevice == null) return; var msgBox = new TaskDialog { Buttons = {new TaskDialogButton(ButtonType.Yes), new TaskDialogButton(ButtonType.No)}, WindowTitle = "I'm about to change the device driver!", Content = string.Format("You selected the device {1}{0}{0}Want me to change the driver now?", Environment.NewLine, selectedDevice), MainIcon = TaskDialogIcon.Information }; var msgResult = msgBox.ShowDialog(this); var tmpPath = Path.Combine(Path.GetTempPath(), "ScpGamepadAnalyzer"); if (msgResult.ButtonType != ButtonType.Yes) return; var result = WdiWrapper.Instance.InstallLibusbKDriver(selectedDevice.HardwareId, UsbBlankGamepad.DeviceClassGuid, tmpPath, string.Format("{0}.inf", selectedDevice.Description), _hwnd, true); if (result == WdiErrorCode.WDI_SUCCESS) { _wdiCurrent = selectedDevice; OpenDeviceButton.IsEnabled = true; new TaskDialog { Buttons = {new TaskDialogButton(ButtonType.Ok)}, WindowTitle = "Yay!", Content = "Driver changed successfully, proceed with the next step now.", MainIcon = TaskDialogIcon.Information }.ShowDialog(this); } else { new TaskDialog { Buttons = {new TaskDialogButton(ButtonType.Ok)}, WindowTitle = "Ohnoes!", Content = "It didn't work! What a shame :( Please reboot your machine, cross your fingers and try again.", MainIcon = TaskDialogIcon.Error }.ShowDialog(this); } }
private void FileDrop(object sender, DragEventArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return; var files = (string[]) e.Data.GetData(DataFormats.FileDrop); if (files[0].Split('.')[(files[0].Split('.').Length) - 1] == "jar") { var perms = Permission.GetPermissionsFromPlugin(this, files[0]); if (perms.Count > 0) { var permString = "These are this plugin's permissions: "; foreach (var perm in perms) { permString += perm.Node(); if (perm != perms[perms.Count - 1]) { permString += ", "; } } MessageBox.Show(this, permString); } } else { if (TaskDialog.OSSupportsTaskDialogs) { using (var dialog = new TaskDialog()) { dialog.WindowTitle = Properties.Resources.Error; dialog.MainInstruction = Properties.Resources.Drop_Invalid_plugin_file; dialog.Content = Properties.Resources.Drop_Invalid_plugin_file_detail; dialog.ExpandedInformation = Properties.Resources.Drop_Invalid_plugin_file_detail_expanded; dialog.Footer = Properties.Resources.Drop_Invalid_plugin_file_footer; dialog.FooterIcon = TaskDialogIcon.Information; dialog.EnableHyperlinks = true; var okButton = new TaskDialogButton(ButtonType.Ok); dialog.Buttons.Add(okButton); dialog.ShowDialog(this); } } } }
public UIDialogResult DisplayBugReportUI(Report report) { using (var dialog = new TaskDialog()) { dialog.WindowTitle = string.Format(Messages.Normal_Window_Title, report.GeneralInfo.HostApplication); dialog.Content = Messages.Normal_Window_Message; dialog.CustomMainIcon = SystemIcons.Warning; var continueButton = new TaskDialogButton("Continue"); var quitButton = new TaskDialogButton("Quit"); dialog.Buttons.Add(continueButton); dialog.Buttons.Add(quitButton); TaskDialogButton button = dialog.ShowDialog(); //if (button == continueButton) return new UIDialogResult(button == continueButton ? ExecutionFlow.ContinueExecution : ExecutionFlow.BreakExecution, SendReport); } }
public bool? AskToInstallNpeOnWindows8() { using (var dialog = new TaskDialog()) { dialog.WindowTitle = Resources.Resources.Dialog_Title; dialog.MainInstruction = "Great! You are running on Windows 8"; dialog.Content = "There is also a Windows Store app of NuGet Package Explorer that is designed to be touch friendly, fast and fluid. Do you want to install it now?"; dialog.AllowDialogCancellation = true; dialog.CenterParent = true; dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks; var yesButton = new TaskDialogButton { Text = "Yes", CommandLinkNote = "Go to the Store and install it now." }; var noButton = new TaskDialogButton { Text = "No", CommandLinkNote = "Don't bother." }; var remindButton = new TaskDialogButton("Remind me next time"); dialog.Buttons.Add(yesButton); dialog.Buttons.Add(noButton); dialog.Buttons.Add(remindButton); TaskDialogButton result = dialog.ShowDialog(); if (result == yesButton) { return true; } else if (result == noButton) { return false; } else { return null; } } }
public static void Show(Window owner, string title, string instruction, string content, string verbose, string footer, TaskDialogIcon icon) { using (var dialog = new TaskDialog()) { dialog.Width = 240; dialog.WindowTitle = title; dialog.MainInstruction = instruction; dialog.Content = content; dialog.ExpandedInformation = verbose; dialog.Footer = footer; dialog.FooterIcon = icon; dialog.EnableHyperlinks = true; var okButton = new TaskDialogButton(ButtonType.Ok); dialog.Buttons.Add(okButton); dialog.HyperlinkClicked += (sender, args) => { Process.Start(args.Href); }; dialog.ShowDialog(owner); } }
private DialogMessageResult DoOokiiMsgBox() { TaskDialog td = new TaskDialog(); if ((Buttons & DialogMessageButtons.Ok) != 0) td.Buttons.Add(new TaskDialogButton(ButtonType.Ok)); if ((Buttons & DialogMessageButtons.Cancel) != 0) td.Buttons.Add(new TaskDialogButton(ButtonType.Cancel)); if ((Buttons & DialogMessageButtons.Yes) != 0) td.Buttons.Add(new TaskDialogButton(ButtonType.Yes)); if ((Buttons & DialogMessageButtons.No) != 0) td.Buttons.Add(new TaskDialogButton(ButtonType.No)); if ((Buttons & DialogMessageButtons.Close) != 0) td.Buttons.Add(new TaskDialogButton(ButtonType.Close)); if ((Buttons & DialogMessageButtons.Retry) != 0) td.Buttons.Add(new TaskDialogButton(ButtonType.Retry)); switch (Icon) { case DialogMessageIcon.Error: td.MainIcon = TaskDialogIcon.Error; break; case DialogMessageIcon.Question: td.MainIcon = TaskDialogIcon.Warning; break; case DialogMessageIcon.Warning: td.MainIcon = TaskDialogIcon.Warning; break; case DialogMessageIcon.Information: td.MainIcon = TaskDialogIcon.Information; break; case DialogMessageIcon.Shield: td.MainIcon = TaskDialogIcon.Shield; break; } td.WindowTitle = Title; td.MainInstruction = Text; td.Content = Extra; var translation = new Dictionary<TaskDialogButton, ButtonType>(); if (ButtonExtras != null && ButtonExtras.Any()) { td.ButtonStyle = TaskDialogButtonStyle.CommandLinks; var buttonSet = td.Buttons.ToArray(); td.Buttons.Clear(); foreach (var extra in ButtonExtras) { foreach (var button in buttonSet.Where(b => b.ButtonType == extra.ButtonType)) { button.ButtonType = ButtonType.Custom; button.Text = extra.Text; button.CommandLinkNote = extra.Note; translation.Add(button, extra.ButtonType); td.Buttons.Add(button); } } foreach (var button in buttonSet.Where(b => b.ButtonType != ButtonType.Custom)) { td.Buttons.Add(button); } } TaskDialogButton result = null; if (owner == null) result = td.ShowDialog(); else { var dispatcher = owner.Dispatcher; result = (TaskDialogButton)dispatcher.Invoke( new Func<TaskDialogButton>(() => td.ShowDialog(owner)), System.Windows.Threading.DispatcherPriority.Normal); } var resultButtonType = result.ButtonType; if (resultButtonType == ButtonType.Custom) resultButtonType = translation[result]; switch (resultButtonType) { case ButtonType.Cancel: return DialogMessageResult.Cancel; case ButtonType.Close: return DialogMessageResult.Close; case ButtonType.No: return DialogMessageResult.No; case ButtonType.Ok: return DialogMessageResult.OK; case ButtonType.Retry: return DialogMessageResult.Retry; case ButtonType.Yes: return DialogMessageResult.Yes; } return DialogMessageResult.None; }
private void Window_Initialized(object sender, EventArgs e) { _hwnd = new WindowInteropHelper(this).Handle; const string messageTitle = "Press button or engage axis"; const string messageTemplate = "Please press and hold {0} now and click Capture"; foreach (CaptureType type in Enum.GetValues(typeof (CaptureType))) { if (type == CaptureType.Default) continue; var diag = new TaskDialog { Buttons = { new TaskDialogButton("Capture"), new TaskDialogButton("I don't have this button/axis, skip it") }, WindowTitle = messageTitle, Content = string.Format(messageTemplate, type), MainIcon = TaskDialogIcon.Information }; _interpreterDiags.Add(type, diag); } }
private Tuple<bool?, bool> ConfirmMoveFileUsingTaskDialog(string fileName, string targetFolder, int numberOfItemsLeft, string mainInstruction) { string content = String.Format( CultureInfo.CurrentCulture, Resources.Resources.MoveContentFileToFolderExplanation, targetFolder); var dialog = new TaskDialog { MainInstruction = mainInstruction, Content = content, WindowTitle = Resources.Resources.Dialog_Title, ButtonStyle = TaskDialogButtonStyle.CommandLinks }; if (numberOfItemsLeft > 0) { dialog.VerificationText = "Do this for the next " + numberOfItemsLeft + " file(s)."; } var moveButton = new TaskDialogButton { Text = "Yes", CommandLinkNote = "'" + fileName + "' will be added to '" + targetFolder + "' folder." }; var noMoveButton = new TaskDialogButton { Text = "No", CommandLinkNote = "'" + fileName + "' will be added to the package root." }; dialog.Buttons.Add(moveButton); dialog.Buttons.Add(noMoveButton); dialog.Buttons.Add(new TaskDialogButton(ButtonType.Cancel)); TaskDialogButton result = dialog.ShowDialog(Window.Value); bool? movingFile; if (result == moveButton) { movingFile = true; } else if (result == noMoveButton) { movingFile = false; } else { // Cancel button clicked movingFile = null; } bool remember = dialog.IsVerificationChecked; return Tuple.Create(movingFile, remember); }
private static bool? ConfirmWithCancelUsingTaskDialog(string message, string title) { using (var dialog = new TaskDialog()) { dialog.WindowTitle = Resources.Resources.Dialog_Title; dialog.MainInstruction = title; dialog.AllowDialogCancellation = true; dialog.Content = message; dialog.CenterParent = true; dialog.MainIcon = TaskDialogIcon.Warning; //dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks; var yesButton = new TaskDialogButton("Yes"); var noButton = new TaskDialogButton("No"); var cancelButton = new TaskDialogButton("Cancel"); dialog.Buttons.Add(yesButton); dialog.Buttons.Add(noButton); dialog.Buttons.Add(cancelButton); TaskDialogButton result = dialog.ShowDialog(); if (result == yesButton) { return true; } else if (result == noButton) { return false; } return null; } }
private static bool ConfirmUsingTaskDialog(string message, string title, bool isWarning) { using (var dialog = new TaskDialog()) { dialog.WindowTitle = Resources.Resources.Dialog_Title; dialog.MainInstruction = title; dialog.Content = message; dialog.AllowDialogCancellation = true; dialog.CenterParent = true; //dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks; if (isWarning) { dialog.MainIcon = TaskDialogIcon.Warning; } var yesButton = new TaskDialogButton("Yes"); var noButton = new TaskDialogButton("No"); dialog.Buttons.Add(yesButton); dialog.Buttons.Add(noButton); TaskDialogButton result = dialog.ShowDialog(); return result == yesButton; } }
private static bool ConfirmCloseEditorUsingTaskDialog(string title, string message) { using (var dialog = new TaskDialog()) { dialog.WindowTitle = Resources.Resources.Dialog_Title; dialog.MainInstruction = title; dialog.Content = message; dialog.AllowDialogCancellation = false; dialog.CenterParent = true; dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks; var yesButton = new TaskDialogButton { Text = "Yes", CommandLinkNote = "Return to package view and lose all your changes." }; var noButton = new TaskDialogButton { Text = "No", CommandLinkNote = "Stay at the metadata editor and fix the error." }; dialog.Buttons.Add(yesButton); dialog.Buttons.Add(noButton); TaskDialogButton result = dialog.ShowDialog(); return result == yesButton; } }
internal TaskDialogItemCollection(TaskDialog owner) { _owner = owner; }
public MsgBoxResult ShowTaskDialog( IWindow owner, string text, string caption, MsgBoxButton button, MsgBoxImage icon, Icon custumIcon) { return ObservableObject.CurrentDispatcher.Invoke( () => { var dialog = new TaskDialog { CenterParent = true, Content = text, ExpandFooterArea = false, ExpandedByDefault = false, MinimizeBox = false, ProgressBarStyle = ProgressBarStyle.None, WindowIcon = custumIcon, WindowTitle = caption, MainInstruction = caption, MainIcon = TranslateIcon(icon) }; TranslateButtons(button, dialog.Buttons); TaskDialogButton clickedButton = dialog.ShowDialog(owner != null ? (Window) owner .TranslateForTechnology () : null); switch (clickedButton.ButtonType) { case ButtonType.Ok: return MsgBoxResult.Ok; case ButtonType.Yes: return MsgBoxResult.Yes; case ButtonType.No: return MsgBoxResult.No; case ButtonType.Cancel: return MsgBoxResult.Cancel; case ButtonType.Close: return MsgBoxResult.Cancel; default: throw new ArgumentOutOfRangeException(); } }); }
/// <summary> /// Performs copy/move action for a file. Reports progress during transfer. /// </summary> /// <returns>Whether or not the copy/move was completed</returns> private bool CopyMoveFile(string sourcePath, string destinationPath, double baseProgress, double progressAmount) { // Check that the destination folder exists, if not create it string destDir = Path.GetDirectoryName(destinationPath); if (!Directory.Exists(destDir)) Directory.CreateDirectory(destDir); // Check if destination already exists if (!this.actionStarted && File.Exists(destinationPath)) { if (sourcePath.ToLower() == destinationPath.ToLower()) { File.Move(sourcePath, sourcePath + "-temp"); File.Move(sourcePath + "-temp", destinationPath); return true; } else { // Check if user wants to override it string ask = "Destination file '" + destinationPath + "' already existst. Queue action will overwrite it, would you like to continue?"; TaskDialog diag = new TaskDialog(); diag.VerificationText = ask; if (!this.Replace && diag.Show().ButtonType == ButtonType.Yes) { this.ActionSucess = false; this.QueueStatus = OrgQueueStatus.Cancelled; return true; } } } // Check drive space if (!CheckDriveSpace((new FileInfo(sourcePath)).Length)) return false; // Rename or move on same drive if (this.Action == OrgAction.Rename || (this.Action == OrgAction.Move && Path.GetPathRoot(sourcePath) == Path.GetPathRoot(destinationPath))) { if(File.Exists(destinationPath)) File.Delete(destinationPath); File.Move(sourcePath, destinationPath); return true; } // Create streams for reading source and writing destination FileStream sourceStream = new FileStream(sourcePath, FileMode.Open, FileAccess.Read); FileStream destinationStream = new FileStream(destinationPath, FileMode.OpenOrCreate, FileAccess.Write); // Initialize transfer variables int bytesRead = -1; long totalSize = sourceStream.Length; byte[] bytes = new byte[BUFFER_SIZE]; long totalFileRead = 0; // If resuming the operation then move streams positions if (actionStarted) { sourceStream.Position = destinationStream.Length; destinationStream.Position = destinationStream.Length; totalFileRead = destinationStream.Length; } // Set started actionStarted = true; // Transfer the file while (true) { // Check for pauses in the operation if (this.QueueStatus == OrgQueueStatus.Paused || OrgItem.QueuePaused) break; // Move data from source file to buffer, if no more data we're done! bytesRead = sourceStream.Read(bytes, 0, BUFFER_SIZE); if (bytesRead == 0) break; // Copy buffered data to destination destinationStream.Write(bytes, 0, bytesRead); // Update progress totalFileRead += bytesRead; OnProgressChange((int)(baseProgress + (double)totalFileRead / totalSize * progressAmount)); } // Close streams sourceStream.Close(); sourceStream.Dispose(); destinationStream.Flush(); destinationStream.Close(); destinationStream.Dispose(); // If operation was paused return not completed if (this.QueueStatus == OrgQueueStatus.Paused || QueuePaused) return false; // For move operation delete the source file now that it's been copied to destination if (this.Action == OrgAction.Move) File.Delete(sourcePath); // Return completed return true; }
public SpectumChoiceBox(SpectrumEntry currentSpectrum, ISpecrumProvider provider) { _currentSpectrums = currentSpectrum; _choice = currentSpectrum; var icon = RadioStreamerResources.RadioIcon; _dialog = new TaskDialog { WindowIcon = icon, MainIcon = TaskDialogIcon.Information, WindowTitle = RadioStreamerResources.SpectrumChoiceWindowLabel, MainInstruction = RadioStreamerResources.SpectrumChoiceMainInstruction }; _okButton = new TaskDialogButton(ButtonType.Ok); _dialog.Buttons.Add(_okButton); _dialog.Buttons.Add(new TaskDialogButton(ButtonType.Close)); foreach (var name in provider.SpectrumEntries) { var btn = new TaskDialogRadioButton {Text = name.Name}; _dialog.RadioButtons.Add(btn); _spectrumMapping[btn] = name; if (currentSpectrum.ID == name.ID) btn.Checked = true; } _dialog.RadioButtonClicked += DialogOnRadioButtonClicked; }