public void Refresh(bool reloadShortcut = true) { // If the shortcuts have been modified, ask to save them if (this.shortcutsDirty && reloadShortcut) { VSConstants.MessageBoxResult result = this.ShowMessageBox(Resources.ShortcutsChanged, OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL); switch (result) { case VSConstants.MessageBoxResult.IDCANCEL: return; case VSConstants.MessageBoxResult.IDYES: this.SaveShortcuts(); break; } } // Recreate file system to ensure that the required files exist CreateFileSystem(); MacroFSNode.RefreshTree(); this.LoadShortcuts(); }
public void ConfirmRestartingVisualStudioToTakeEffect_should_show_the_message_to_message_box( [Values(MachineWideProcesses.Installing, MachineWideProcesses.Uninstalling)] MachineWideProcesses mwProc, [Values(VSConstants.MessageBoxResult.IDYES, VSConstants.MessageBoxResult.IDNO)] VSConstants.MessageBoxResult response) { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var vm = new PrigViewModel(); vm.BeginMachineWideProcessProgress(mwProc); vm.MessageBoxParameter.Subscribe(_ => _.Result = response); // Act var result = vm.ConfirmRestartingVisualStudioToTakeEffect(); // Assert Assert.AreEqual(response == VSConstants.MessageBoxResult.IDYES, result); var msgBox = vm.MessageBoxParameter.Value; Assert.AreEqual(OLEMSGBUTTON.OLEMSGBUTTON_YESNO, msgBox.Button); Assert.AreEqual(OLEMSGICON.OLEMSGICON_WARNING, msgBox.Icon); Assert.IsNotNullOrEmpty(msgBox.Text); }
public bool Confirm(string message) { return(_joinableTaskFactory.Run(async() => { await _joinableTaskFactory.SwitchToMainThreadAsync(); VSConstants.MessageBoxResult result = ShowMessageBox(message, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_YESNO, VSConstants.MessageBoxResult.IDYES); return result == VSConstants.MessageBoxResult.IDYES; })); }
private async Task ShowMessageAsync() { await VS.Notifications.SetStatusbarTextAsync("Test"); var text = await VS.Notifications.GetStatusbarTextAsync(); await VS.Notifications.SetStatusbarTextAsync(text + " OK"); var ex = new Exception(nameof(TestExtension)); await ex.LogAsync(); VSConstants.MessageBoxResult button = VS.Notifications.ShowMessage("message", "title"); Debug.WriteLine(button); }
private void button1_Click(object sender, RoutedEventArgs e) { ThreadHelper.JoinableTaskFactory.Run(async delegate { await VS.Notifications.SetStatusbarTextAsync("Test"); var text = await VS.Notifications.GetStatusbarTextAsync(); await VS.Notifications.SetStatusbarTextAsync(text + " OK"); var ex = new Exception(nameof(TestExtension)); await ex.LogAsync(); VSConstants.MessageBoxResult button = VS.Notifications.ShowMessage("message", "title"); Debug.WriteLine(button); }); }
private async Task ShowMessageAsync() { await VS.StatusBar.ShowMessageAsync("Test"); string text = await VS.StatusBar.GetMessageAsync(); await VS.StatusBar.ShowMessageAsync(text + " OK"); Exception ex = new Exception(nameof(TestExtension)); await ex.LogAsync(); VSConstants.MessageBoxResult button = await VS.MessageBox.ShowAsync("message", "title"); Debug.WriteLine(button); }
private async Task ShowMessageAsync() { var rating = new RatingPrompt("SteveCadwallader.CodeMaidVS2022", Vsix.Name); await rating.PromptAsync(); await VS.StatusBar.ShowMessageAsync("Test"); string?text = await VS.StatusBar.GetMessageAsync(); await VS.StatusBar.ShowMessageAsync(text + " OK"); Exception ex = new Exception(nameof(TestExtension)); await ex.LogAsync(); VSConstants.MessageBoxResult button = await VS.MessageBox.ShowAsync("message", "title"); Debug.WriteLine(button); }
public void ConfirmRemovingPrigAssembly_should_show_the_message_to_message_box( [Values(VSConstants.MessageBoxResult.IDYES, VSConstants.MessageBoxResult.IDNO)] VSConstants.MessageBoxResult response) { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var deletionalInclude = fixture.Create <string>(); var vm = new PrigViewModel(); vm.MessageBoxParameter.Subscribe(_ => _.Result = response); // Act var result = vm.ConfirmRemovingPrigAssembly(deletionalInclude); // Assert Assert.AreEqual(response == VSConstants.MessageBoxResult.IDYES, result); var msgBox = vm.MessageBoxParameter.Value; Assert.AreEqual(OLEMSGBUTTON.OLEMSGBUTTON_YESNO, msgBox.Button); Assert.AreEqual(OLEMSGICON.OLEMSGICON_QUERY, msgBox.Icon); Assert.IsNotNullOrEmpty(msgBox.Text); }
private void TreeViewItem_Drop(object sender, DragEventArgs e) { e.Effects = DragDropEffects.None; e.Handled = true; // Get target node TreeViewItem targetItem = this.GetNearestContainer(e.OriginalSource as UIElement); MacroFSNode target = targetItem.Header as MacroFSNode; if (e.Data.GetDataPresent(typeof(MacroFSNode)) && this.isDragging) { // Get dragged node MacroFSNode dragged = e.Data.GetData(typeof(MacroFSNode)) as MacroFSNode; if (target != null && dragged != null && target != dragged) { if (!target.IsDirectory) { target = target.Parent; } Manager.Instance.MoveItem(dragged, target); } } else if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] droppedFiles = e.Data.GetData(DataFormats.FileDrop, true) as string[]; if (!target.IsDirectory) { target = target.Parent; } foreach (string s in droppedFiles) { string filename = Path.GetFileNameWithoutExtension(s); // If the file is a macro file if (Path.GetExtension(s) == ".js") { string destPath = Path.Combine(target.FullPath, filename + ".js"); VSConstants.MessageBoxResult result = VSConstants.MessageBoxResult.IDYES; if (File.Exists(destPath)) { string message = string.Format(VSMacros.Resources.DragDropFileExists, filename); result = Manager.Instance.ShowMessageBox(message, OLEMSGBUTTON.OLEMSGBUTTON_YESNO); } if (result == VSConstants.MessageBoxResult.IDYES) { File.Copy(s, destPath, true); } } else if (Path.GetExtension(s) == "") { string destPath = Path.Combine(target.FullPath, filename); VSConstants.MessageBoxResult result = VSConstants.MessageBoxResult.IDYES; if (Directory.Exists(destPath)) { string message = string.Format(VSMacros.Resources.DragDropFileExists, filename); result = Manager.Instance.ShowMessageBox(message, OLEMSGBUTTON.OLEMSGBUTTON_YESNO); } if (result == VSConstants.MessageBoxResult.IDYES) { Manager.DirectoryCopy(s, destPath, true); } } } // Unset IsTreeViewItemDropOver for target MacrosControl.SetIsTreeViewItemDropOver(targetItem, false); MacroFSNode.RefreshTree(target); } this.isDragging = false; }
private VSConstants.MessageBoxResult ShowMessageBox(string message, OLEMSGICON icon, OLEMSGBUTTON button, VSConstants.MessageBoxResult defaultResult = VSConstants.MessageBoxResult.IDOK) { if (VsShellUtilities.IsInAutomationFunction(_asyncPackage)) { return(defaultResult); } return((VSConstants.MessageBoxResult)VsShellUtilities.ShowMessageBox(_asyncPackage, message, null, icon, button, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST)); }