private void DisplayErrorWindow() { try { UIUpdater.InvokeAsync(new Action(() => { var window = new EncodingErrorView(ItemsCollector.GetDocumentsToEncode()); window.ShowDialog(); })).SafeFireAndForget(); } catch (Exception) { } }
public void VisibilityOnBeforeCommand(object sender, EventArgs e) { if (sender is OleMenuCommand == false) { return; } var command = (OleMenuCommand)sender; var itemsCollector = new ItemsCollector(ScriptConstants.kAcceptedFileExtensions); itemsCollector.CollectSelectedProjectItems(); command.Enabled = itemsCollector.HaveItems; }
public void VisibilityOnBeforeCommand(object sender, EventArgs e) { if (sender is OleMenuCommand == false) { return; } var command = (OleMenuCommand)sender; var itemsCollector = new ItemsCollector(); itemsCollector.CollectSelectedProjectItems(); command.Enabled = !itemsCollector.IsEmpty; }
private void DisplayErrorWindow() { try { UIUpdater.InvokeAsync(new Action(() => { var itemsCollector = new ItemsCollector(); var window = new EncodingErrorView(itemsCollector.GetDocumentsToEncode()); window.ShowDialog(); })).SafeFireAndForget(); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected IEnumerable <IItem> CollectSelectedItems(List <string> aAcceptedExtensionTypes = null) { mItemsCollector = new ItemsCollector(Package, aAcceptedExtensionTypes); mItemsCollector.CollectSelectedFiles(DTEObj, ActiveWindowProperties.GetProjectItemOfActiveWindow(DTEObj)); return(mItemsCollector.GetItems); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { //mCommandsController.Running = true; System.Threading.Tasks.Task.Run(() => { GeneralOptions generalOptions = (GeneralOptions)mPackage.GetDialogPage(typeof(GeneralOptions)); TidyOptions tidyPage = (TidyOptions)mPackage.GetDialogPage(typeof(TidyOptions)); ScriptBuiler scriptBuilder = new ScriptBuiler(); scriptBuilder.ConstructParameters(generalOptions, tidyPage, mVsEdition, mVsVersion); mItemsCollector = new ItemsCollector(mPackage); mItemsCollector.CollectSelectedFiles(mDte); mOutputManager = new OutputManager(mDte); PowerShellWrapper powerShell = new PowerShellWrapper(); powerShell.DataHandler += mOutputManager.OutputDataReceived; powerShell.DataErrorHandler += mOutputManager.OutputDataErrorReceived; mFileWatcher = new FileChangerWatcher(); try { mDte.Documents.SaveAll(); if (kVs15Version == mVsVersion) { Vs15SolutionLoader solutionLoader = new Vs15SolutionLoader(mPackage); solutionLoader.EnsureSolutionProjectsAreLoaded(); } using (var guard = new SilentFileChangerGuard()) { if (tidyPage.Fix) { WatchFiles(); SilentFiles(guard); } mOutputManager.Clear(); mOutputManager.Show(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kStart} {OutputWindowConstants.kTidyCodeCommand}\n"); foreach (var item in mItemsCollector.GetItems) { string script = scriptBuilder.GetScript(item.Item1, item.Item1.GetName()); powerShell.Invoke(script); if (mOutputManager.MissingLlvm) { mOutputManager.AddMessage(ErrorParserConstants.kMissingLlvmMessage); break; } } if (!mOutputManager.EmptyBuffer) { mOutputManager.AddMessage(String.Join("\n", mOutputManager.Buffer)); } if (!mOutputManager.MissingLlvm) { mOutputManager.Show(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kDone} {OutputWindowConstants.kTidyCodeCommand}\n"); } if (mOutputManager.HasErrors) { mErrorsManager.AddErrors(mOutputManager.Errors); } } } catch (Exception exception) { VsShellUtilities.ShowMessageBox(mPackage, exception.Message, "Error", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } });//.ContinueWith(tsk => mCommandsController.AfterExecute()); ; }
protected IEnumerable <IItem> CollectSelectedItems(bool aClangFormatFlag = false, List <string> aAcceptedExtensionTypes = null) { mItemsCollector = new ItemsCollector(aAcceptedExtensionTypes); mItemsCollector.CollectSelectedFiles(ActiveWindowProperties.GetProjectItemOfActiveWindow(), aClangFormatFlag); return(mItemsCollector.GetItems); }
protected List <IItem> CollectSelectedItems() { mItemsCollector = new ItemsCollector(Package); mItemsCollector.CollectSelectedFiles(DTEObj, ActiveWindowProperties.GetProjectItemOfActiveWindow(DTEObj)); return(mItemsCollector.GetItems); }