/// <inheritdoc />
        /// <summary>
        ///     Called when [execute].
        /// </summary>
        /// <param name="command">The command.</param>
        protected override void OnExecute(OleMenuCommand command)
        {
            if (Package.Dte.SelectedItems.Count == 0)
            {
                return;
            }

            var paths = new HashSet <string>();

            foreach (var selectedItem in UIHierarchyHelper.GetSelectedUIHierarchyItems(Package))
            {
                if (selectedItem.Object is EnvDTE.ProjectItem projectItem)
                {
                    paths.Add(projectItem.Document?.FullName ??
                              projectItem.Properties?.Item("FullPath").Value.ToString());
                }

                if (selectedItem.Object is EnvDTE.Project project)
                {
                    paths.Add(project.FullName);
                }

                if (selectedItem.Object is Solution solution)
                {
                    paths.Add(solution.FullName);
                }
            }

            var groupedPaths = paths.GroupBy(Path.GetDirectoryName);

            foreach (var path in groupedPaths)
            {
                WindowsExplorerHelper.FilesOrFolders(path);
            }
        }
Exemple #2
0
        /// <inheritdoc />
        /// <summary>
        ///     Called when [execute].
        /// </summary>
        /// <param name="command">The command.</param>
        protected override void OnExecute(OleMenuCommand command)
        {
            if (Package.Dte.SelectedItems.Count == 0)
            {
                return;
            }

            var paths = new HashSet <string>();

            foreach (SelectedItem selectedItem in Package.Dte.SelectedItems)
            {
                var project = selectedItem.Project;
                if (project != null)
                {
                    paths.Add(project.GetOutputFilePath());
                }
                else
                {
                    var projectItem = selectedItem.ProjectItem;
                    if (projectItem?.ContainingProject == null)
                    {
                        continue;
                    }

                    paths.Add(projectItem.ContainingProject.GetOutputFilePath());
                }
            }

            var groupedPaths = paths.GroupBy(Path.GetDirectoryName);

            foreach (var path in groupedPaths)
            {
                WindowsExplorerHelper.FilesOrFolders(path);
            }
        }
Exemple #3
0
        public MainWindowViewModel()
        {
            var windowsExplorerHelper = new WindowsExplorerHelper();

            this.Config           = Config.Load();
            this.IsPopupOpen      = false;
            this.AvailableActions = new ObservableCollection <IAction>();
            this._providers       = new List <IActionProvider>();
            this._providers.Add(new LocalProgramsActionProvider());
            this._providers.Add(new CalculatorActionProvider());
            this._providers.Add(new CurrencyConverterActionProvider());
            this._providers.Add(new MiscActionProvider(windowsExplorerHelper, new PromptService()));
            foreach (var provider in this._providers)
            {
                provider.Initialize(this.Config);
            }
        }
        private void OnFilePathValueMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Right)
            {
                var groupedPaths = new[] { _labelFilePath.Value }.GroupBy(Path.GetDirectoryName);
                foreach (var path in groupedPaths)
                {
                    WindowsExplorerHelper.FilesOrFolders(path);
                }
                return;
            }

            if (e.ChangedButton == MouseButton.Left)
            {
                Clipboard.SetData(DataFormats.Text, _labelFilePath.Value);
            }
        }
Exemple #5
0
 public MiscActionProvider(WindowsExplorerHelper windowsExplorerHelper, IPromptService promptService)
 {
     this._windowsExplorerHelper = windowsExplorerHelper;
     this._promptService         = promptService;
 }