/// <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) { try { IVsHierarchy hierarchy = null; uint itemid = VSConstants.VSITEMID_NIL; if (!TsWspHelpers.IsSingleProjectItemSelection(out hierarchy, out itemid)) { return; } var vsProject = (IVsProject)hierarchy; // get the name of the item string itemFullPath = null; if (ErrorHandler.Failed(vsProject.GetMkDocument(itemid, out itemFullPath))) { return; } TypeScriptCompiler.Compile(itemFullPath); } catch (Exception ex) { Logger.Log(ex); } }
private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { // get the menu that fired the event var menuCommand = sender as OleMenuCommand; if (menuCommand != null) { // start by assuming that the menu will not be shown menuCommand.Visible = false; menuCommand.Enabled = false; IVsHierarchy hierarchy = null; uint itemid = VSConstants.VSITEMID_NIL; if (!TsWspHelpers.IsSingleProjectItemSelection(out hierarchy, out itemid)) { return; } // Get the file path string itemFullPath = null; ((IVsProject)hierarchy).GetMkDocument(itemid, out itemFullPath); if (!TsWspHelpers.IsTypescriptFile(itemFullPath)) { return; } menuCommand.Visible = true; menuCommand.Enabled = true; } }
private void CreateAdornments(ITextDocument document, IWpfTextView textView) { string fileName = document.FilePath; { var item = TsWspPackage.DTE.Solution.FindProjectItem(fileName); if (item == null || item.ContainingProject == null) return; try { if (TsWspHelpers.HasParentTypescriptFile(fileName)) { GeneratedAdornment generated = new GeneratedAdornment(textView, _isVisible, _initOpacity); } } catch (Exception ex) { Logger.Log(ex); } } }