GetSelectedItems() public static method

public static GetSelectedItems ( ) : IEnumerable
return IEnumerable
Example #1
0
        private void AddCommandToFile(object sender, EventArgs e)
        {
            OleMenuCommand button = (OleMenuCommand)sender;
            var            item   = ProjectHelpers.GetSelectedItems().FirstOrDefault();

            if (item == null || item.FileCount == 0)
            {
                return;
            }

            string file = item.FileNames[1];
            bool   isSolution;
            string configPath  = GetConfigPath(item, out isSolution);
            bool   configExist = File.Exists(configPath);

            JObject json = CommandHelpers.GetJsonContent(configPath, file);

            ProjectHelpers.CheckFileOutOfSourceControl(configPath);
            File.WriteAllText(configPath, json.ToString(), new UTF8Encoding(false));

            if (!configExist)
            {
                AddFileToProject(item, isSolution, configPath);
                _dte.ItemOperations.OpenFile(configPath);
                _dte.ExecuteCommand("SolutionExplorer.SyncWithActiveDocument");
                _dte.ExecuteCommand("SolutionExplorer.SyncWithActiveDocument");
            }

            OpenTaskRunnerExplorer();
            _dte.StatusBar.Text = $"File successfully added to {Constants.FILENAME}";
        }
Example #2
0
        private void BeforeQueryStatus(object sender, EventArgs e)
        {
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Enabled = button.Visible = false;

            var item = ProjectHelpers.GetSelectedItems().FirstOrDefault();

            if (item == null || item.FileCount == 0)
            {
                return;
            }

            string file = item.FileNames[1];

            button.Enabled = button.Visible = CommandHelpers.IsFileSupported(file);
        }