public static void ShowAlert(this Dispatcher dispatcher, string title, string message, string action, bool actionIsCommand = false, Action callback = null) { var dialog = new TaskDialog { MainIcon = TaskDialogIcon.Information, WindowTitle = UISettings.Configurator, MainInstruction = title, Content = message }; var ok = new TaskDialogButton { Text = action }; if (actionIsCommand) { dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks; } dialog.Buttons.Add(ok); dispatcher?.Invoke(() => { dialog.ShowDialog(); dialog.Dispose(); callback?.Invoke(); }); }
public void Close() { try { if (TaskDialog.IsPlatformSupported && modernDialog != null) { modernDialog.Close(); } else if (defaultDialog != null) { defaultDialog.Close(); } } catch (InvalidOperationException) { modernDialog.Dispose(); } }
public static void ShowAlert(this Dispatcher dispatcher, string title, string message) { var dialog = new TaskDialog { MainIcon = TaskDialogIcon.Information, WindowTitle = UISettings.Configurator, MainInstruction = title, Content = message }; var ok = new TaskDialogButton(ButtonType.Ok); dialog.Buttons.Add(ok); dispatcher?.Invoke(() => { dialog.ShowDialog(); dialog.Dispose(); }); }
public static void ShowLoadingMessage() { var dialog = new TaskDialog { MainIcon = TaskDialogIcon.Information, WindowTitle = UISettings.Configurator, MainInstruction = UISettings.ServiceNotRunning, Content = UISettings.WaitForService }; var ok = new TaskDialogButton(ButtonType.Ok); dialog.Buttons.Add(ok); Application.Current.Dispatcher?.Invoke(() => { dialog.ShowDialog(); dialog.Dispose(); }); }
/// <summary> /// Disposes the _dialog /// </summary> public void Dispose() { _dialog.Dispose(); }
/// <summary> /// Comando ejecutado desde la aplicación de Autodesk Revit /// </summary> /// <param name="commandData">Información sobre la aplicación que lanzó el comando.</param> /// <param name="message">Mensaje especial. No nos interesa.</param> /// <param name="elements">Elementos seleccionados. No nos interesa.</param> /// <returns>Éxito, Fracaso o "Cancelado" según como salieron las cosas</returns> public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; Document activeDoc = app.ActiveUIDocument.Document; while (true) { TaskDialog mainDialog = new TaskDialog("Revit Extractor") { MainInstruction = "Bienvenidos!", MainContent = "Ingresa los archivos Excel y Project de tu proyecto" }; bool ready = true; string excelDialog; if (string.Equals(excelPath, "")) { ready = false; excelDialog = "Selecciona archivo Excel"; } else { excelDialog = "EXCEL: " + Path.GetFileNameWithoutExtension(excelPath) + ". ¿Escoger otro?"; } mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, excelDialog); string projectDialog; if (string.Equals(projectPath, "")) { ready = false; projectDialog = "Selecciona archivo Project"; } else { projectDialog = "PROJECT: " + Path.GetFileNameWithoutExtension(projectPath) + ". ¿Escoger otro?"; } mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, projectDialog); if (ready) { mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, "Exportar"); } TaskDialogResult dialogResult = mainDialog.Show(); mainDialog.Dispose(); switch (dialogResult) { case TaskDialogResult.CommandLink1: excelPath = ChooseFile("Excel files|*.xlsm;xls"); break; case TaskDialogResult.CommandLink2: projectPath = ChooseFile("Project files|*.mpp"); break; case TaskDialogResult.CommandLink3: return(ExtractAndTransform(excelPath, projectPath, activeDoc)); case TaskDialogResult.Close: return(Result.Cancelled); default: return(Result.Failed); } } }
/// <summary> /// The Vm_DeleteZipFileRequested. /// </summary> /// <param name="sender">The sender<see cref="object"/>.</param> /// <param name="e">The e<see cref="EventArgs"/>.</param> private void Vm_DeleteZipFileRequested(object sender, EventArgs e) { var a = Assembly.GetExecutingAssembly(); var st = a.GetManifestResourceStream("PluginManager.Wpf.Resources.qmark.ico"); var qmark = new Icon(st); st.Dispose(); var win = new TaskDialog() { WindowTitle = "Delete Requested", MainIcon = TaskDialogIcon.Custom, CustomMainIcon = qmark }; var rb1 = new TaskDialogRadioButton() { Text = "Only delete the zip file." }; var rb2 = new TaskDialogRadioButton() { Text = "Only delete the database record." }; var rb3 = new TaskDialogRadioButton() { Text = "Delete both record and file.", Checked = true }; var bt1 = new TaskDialogButton(ButtonType.Cancel); var bt2 = new TaskDialogButton(ButtonType.Ok); win.RadioButtons.Add(rb1); win.RadioButtons.Add(rb2); win.RadioButtons.Add(rb3); win.Buttons.Add(bt1); win.Buttons.Add(bt2); win.Content = "What do you want to delete?"; var result = win.ShowDialog(); qmark.Dispose(); win.Dispose(); rb1.Dispose(); rb2.Dispose(); rb3.Dispose(); bt1.Dispose(); bt2.Dispose(); if (result == null || result.ButtonType == ButtonType.Cancel) { result.Dispose(); return; } result.Dispose(); var vm = sender as ZipFileViewModel; Debug.Assert(vm != null); var option = win.RadioButtons[0].Checked ? 1 : win.RadioButtons[1].Checked ? 2 : 3; switch (option) { case 1: if (!DeleteZipFile(vm)) { MessageBox.Show($"Unable to delete {vm.Filename}.", "Exception"); } break; case 2: DeleteRecord(vm); break; case 3: if (!DeleteZipFile(vm)) { var dr = MessageBox.Show($"Unable to delete {vm.Filename}. Do you want to delete the record anyway?", "Exception", MessageBoxButton.YesNo); if (dr != MessageBoxResult.Yes) { return; } } DeleteRecord(vm); break; default: throw new ArgumentException("Invalid radio button."); } }
/// <summary> /// The Vm_DeleteSelectedZipFilesRequested. /// </summary> /// <param name="sender">The sender<see cref="object"/>.</param> /// <param name="e">The e<see cref="EventArgs"/>.</param> private void Vm_DeleteSelectedZipFilesRequested(object sender, EventArgs e) { var vm = DataContext as MainViewModel; var count = vm.SelectedZipFilesCollection.Count; var message = $"You have {count} zip file(s) selected and have initiated the delete function. What do you want to do?"; var a = Assembly.GetExecutingAssembly(); var st = a.GetManifestResourceStream("PluginManager.Wpf.Resources.qmark.ico"); var qmark = new Icon(st); var win = new TaskDialog() { WindowTitle = "Delete Requested", MainIcon = TaskDialogIcon.Custom, Content = message, CustomMainIcon = qmark }; var rb1 = new TaskDialogRadioButton() { Text = "Only delete zip files." }; var rb2 = new TaskDialogRadioButton() { Text = "Only delete database records." }; var rb3 = new TaskDialogRadioButton() { Text = "Delete both records and files.", Checked = true }; var btn1 = new TaskDialogButton(ButtonType.Cancel); var btn2 = new TaskDialogButton(ButtonType.Ok); win.RadioButtons.Add(rb1); win.RadioButtons.Add(rb2); win.RadioButtons.Add(rb3); win.Buttons.Add(btn1); win.Buttons.Add(btn2); var result = win.ShowDialog(); win.Dispose(); qmark.Dispose(); rb1.Dispose(); rb2.Dispose(); rb3.Dispose(); btn1.Dispose(); btn2.Dispose(); st.Dispose(); if (result == null || result.ButtonType == ButtonType.Cancel) { result.Dispose(); return; } result.Dispose(); // #Switch var option = win.RadioButtons[0].Checked ? 1 : win.RadioButtons[1].Checked ? 2 : 3; var selectedZips = new List <ZipFileViewModel>(vm.SelectedZipFilesCollection); foreach (var item in selectedZips) { switch (option) { case 1: if (!DeleteZipFile(item)) { MessageBox.Show($"Unable to delete {item.Filename}.", "Exception"); } break; case 2: DeleteRecord(item); break; case 3: if (!DeleteZipFile(item)) { var dr = MessageBox.Show($"Unable to delete {item.Filename}. Do you want to delete the record anyway?", "Exception", MessageBoxButton.YesNo); if (dr != MessageBoxResult.Yes) { continue; } } DeleteRecord(item); break; default: throw new ArgumentException("Invalid radio button."); } } }