Beispiel #1
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 MenuItemCallback(object sender, EventArgs e)
        {
            TridionVSRazorExtensionPackage package = ((TridionVSRazorExtensionPackage)this.ServiceProvider);

            package.InitApplication();

            DTE      applicationObject = package.ApplicationObject;
            Solution solution          = package.Solution;
            Project  project           = package.Project;

            if (solution != null && project != null && applicationObject.SelectedItems != null)
            {
                foreach (SelectedItem item in applicationObject.SelectedItems)
                {
                    if (!item.Name.EndsWith(".cshtml") && !item.Name.IsAllowedMimeType())
                    {
                        MessageBox.Show("Item '" + item.ProjectItem.FileNames[0] + "' is not supported.", "Wrong Operation", MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                }

                var files = applicationObject.SelectedItems.Cast <SelectedItem>().Where(item => item.Name.EndsWith(".cshtml") || item.Name.IsAllowedMimeType()).Select(item => item.ProjectItem.FileNames[0]);
                MainService.ProcessFiles(files.ToArray(), project);
            }
        }
Beispiel #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 MenuItemCallback(object sender, EventArgs e)
        {
            TridionVSRazorExtensionPackage package = ((TridionVSRazorExtensionPackage)this.ServiceProvider);

            package.InitApplication();

            MappingWindow window = new MappingWindow();

            window.RootPath = Path.GetDirectoryName(MainService.Project.FileName);
            window.ShowDialog();
        }
Beispiel #3
0
        private void BeforeQueryStatus(object sender, EventArgs eventArgs)
        {
            TridionVSRazorExtensionPackage package = ((TridionVSRazorExtensionPackage)this.ServiceProvider);
            DTE applicationObject = package.ApplicationObject;

            var menuCommand = sender as OleMenuCommand;

            if (menuCommand != null)
            {
                menuCommand.Visible = true;
                if (applicationObject.SelectedItems != null)
                {
                    foreach (SelectedItem item in applicationObject.SelectedItems)
                    {
                        if (!item.Name.EndsWith(".cshtml") && !item.Name.IsAllowedMimeType())
                        {
                            menuCommand.Visible = false;
                        }
                    }
                }
            }
        }