Exemple #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");
        }
Exemple #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 void Execute(object sender, EventArgs e)
        {
            var    fullPath   = ExtensionHelper.GetActiveProjectDirectoryPath(ServiceProvider);
            string strCmdText = "/K";

            if (!string.IsNullOrEmpty(fullPath))
            {
                var driverName = fullPath.Substring(0, 1);
                strCmdText = $"/K {driverName}: & cd {fullPath}";
            }

            System.Diagnostics.Process.Start("CMD.exe", strCmdText);
        }
Exemple #3
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);
            }
        }