Example #1
0
        private async void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            var selectedFile = string.IsNullOrEmpty(ActiveDocumentFullPath) ? ExtensionHelper.GetSelectedFile(ServiceProvider) : ActiveDocumentFullPath;

            var command = sender as OleMenuCommand;

            command.Visible = command.Enabled = string.IsNullOrEmpty(selectedFile) == false &&
                                                selectedFile.EndsWith(".ts") || selectedFile.EndsWith(".html");
        }
Example #2
0
        /// <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 async void Execute(object sender, EventArgs e)
        {
            var selectedFile         = string.IsNullOrEmpty(ActiveDocumentFullPath) ? ExtensionHelper.GetSelectedFile(ServiceProvider) : ActiveDocumentFullPath;
            var redirecExtension     = Path.GetExtension(selectedFile);
            var redirecExtensionPath = Path.GetDirectoryName(selectedFile) + "\\" + Path.GetFileNameWithoutExtension(selectedFile) +
                                       (Path.GetExtension(selectedFile).ToLower() == ".ts" ? ".html" : ".ts");

            if (File.Exists(redirecExtensionPath))
            {
                VsShellUtilities.OpenDocument(this.package, redirecExtensionPath);
            }
        }