Exemple #1
0
        protected BaseCommand(VCFileUtilsPackage package, CommandID id)
            : base(BaseCommand_Execute, id)
        {
            Package = package;

            BeforeQueryStatus += BaseCommand_BeforeQueryStatus;
        }
        protected BaseCommand(VCFileUtilsPackage package, CommandID id)
            : base(BaseCommand_Execute, id)
        {
            Package = package;

            BeforeQueryStatus += BaseCommand_BeforeQueryStatus;
        }
 private static UIHierarchy GetSolutionExplorer(VCFileUtilsPackage package)
 {
     try
     {
         return(package.IDE.ToolWindows.SolutionExplorer);
     }
     catch (InvalidOperationException)
     {
         return(null);
     }
 }
        private static IEnumerable <UIHierarchyItem> GetSelectedUIHierarchyItems(VCFileUtilsPackage package)
        {
            UIHierarchy solutionExplorer = GetSolutionExplorer(package);

            if (solutionExplorer == null)
            {
                return(new UIHierarchyItem[0]);
            }

            return(((object[])solutionExplorer.SelectedItems)
                   .Cast <UIHierarchyItem>());
        }
        public static IEnumerable<VCFileWrapper> GetSelectedFiles(VCFileUtilsPackage package)
        {
            foreach (var item in GetSelectedItems(package))
            {
                if (item is VCFileWrapper)
                    yield return (item as VCFileWrapper);

                if (item is ContainerWrapper)
                    foreach (var child in (item as ContainerWrapper).GetFilesRecursive())
                        yield return child;
            }
        }
        public static VCProjectWrapper GetProjectOfSelection(VCFileUtilsPackage package)
        {
            var projects = GetSelectedItems(package)
                .Select(item => item.ContainingProject)
                .ToList();

            if (projects.Count() == 0)
                return null;

            if (projects.Any(project => !project.Equals(projects[0])))
                return null;

            return projects[0];
        }
        public static string GetSelectedDirectory(VCFileUtilsPackage package)
        {
            var selection = GetSelectedItems(package)
                .ToList();

            if (selection.Count() != 1)
                return null;

            if (selection[0] is VCProjectWrapper)
                return (selection[0] as VCProjectWrapper).GetProjectRoot();

            if (selection[0] is VCFilterWrapper)
                return selection[0].FullPath;

            return null;
        }
        public static IEnumerable<VCProjectItemWrapper> GetSelectedItems(VCFileUtilsPackage package)
        {
            foreach (var item in GetSelectedUIHierarchyItems(package))
            {
                VCProjectItem vcProjectItem = null;

                if (item.Object is ProjectItem)
                    vcProjectItem = (item.Object as ProjectItem).Object as VCProjectItem;

                if (item.Object is Project)
                    vcProjectItem = (item.Object as Project).Object as VCProjectItem;

                if (vcProjectItem != null)
                    yield return WrapperFactory.FromVCProjectItem(vcProjectItem);
            }
        }
        public static IEnumerable <VCFileWrapper> GetSelectedFiles(VCFileUtilsPackage package)
        {
            foreach (var item in GetSelectedItems(package))
            {
                if (item is VCFileWrapper)
                {
                    yield return(item as VCFileWrapper);
                }

                if (item is ContainerWrapper)
                {
                    foreach (var child in (item as ContainerWrapper).GetFilesRecursive())
                    {
                        yield return(child);
                    }
                }
            }
        }
        public static VCProjectWrapper GetProjectOfSelection(VCFileUtilsPackage package)
        {
            var projects = GetSelectedItems(package)
                           .Select(item => item.ContainingProject)
                           .ToList();

            if (projects.Count() == 0)
            {
                return(null);
            }

            if (projects.Any(project => !project.Equals(projects[0])))
            {
                return(null);
            }

            return(projects[0]);
        }
        public static IEnumerable <VCProjectItemWrapper> GetSelectedItems(VCFileUtilsPackage package)
        {
            foreach (var item in GetSelectedUIHierarchyItems(package))
            {
                VCProjectItem vcProjectItem = null;

                if (item.Object is ProjectItem)
                {
                    vcProjectItem = (item.Object as ProjectItem).Object as VCProjectItem;
                }

                if (item.Object is Project)
                {
                    vcProjectItem = (item.Object as Project).Object as VCProjectItem;
                }

                if (vcProjectItem != null)
                {
                    yield return(WrapperFactory.FromVCProjectItem(vcProjectItem));
                }
            }
        }
        public static string GetSelectedDirectory(VCFileUtilsPackage package)
        {
            var selection = GetSelectedItems(package)
                            .ToList();

            if (selection.Count() != 1)
            {
                return(null);
            }

            if (selection[0] is VCProjectWrapper)
            {
                return((selection[0] as VCProjectWrapper).GetProjectRoot());
            }

            if (selection[0] is VCFilterWrapper)
            {
                return(selection[0].FullPath);
            }

            return(null);
        }
 public static IEnumerable<VCProjectWrapper> GetSelectedProjects(VCFileUtilsPackage package)
 {
     return GetSelectedItems(package)
         .Where(item => item is VCProjectWrapper)
         .Cast<VCProjectWrapper>();
 }
 public SetProjectRootCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDSetProjectRoot))
 {
 }
 public OrganizeInProjectCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDOrganizeInProject))
 {
 }
 public static IEnumerable <VCProjectWrapper> GetSelectedProjects(VCFileUtilsPackage package)
 {
     return(GetSelectedItems(package)
            .Where(item => item is VCProjectWrapper)
            .Cast <VCProjectWrapper>());
 }
 public ReAddFilesCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDReAddFiles))
 {
 }
        private static IEnumerable<UIHierarchyItem> GetSelectedUIHierarchyItems(VCFileUtilsPackage package)
        {
            UIHierarchy solutionExplorer = GetSolutionExplorer(package);

            if (solutionExplorer == null)
                return new UIHierarchyItem[0];

            return ((object[])solutionExplorer.SelectedItems)
                .Cast<UIHierarchyItem>();
        }
Exemple #19
0
 public OrganizeOnDiskCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDOrganizeOnDisk))
 {
 }
Exemple #20
0
 public RemoveEmptyFiltersCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDRemoveEmptyFilters))
 {
 }
 public OrganizeOnDiskCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDOrganizeOnDisk))
 {
 }
 public SetProjectRootCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDSetProjectRoot))
 {
 }
 private static UIHierarchy GetSolutionExplorer(VCFileUtilsPackage package)
 {
     try
     {
         return package.IDE.ToolWindows.SolutionExplorer;
     }
     catch (InvalidOperationException)
     {
         return null;
     }
 }
Exemple #24
0
 public ReAddFilesCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDReAddFiles))
 {
 }
Exemple #25
0
 public OrganizeInProjectCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDOrganizeInProject))
 {
 }
 public RemoveEmptyFiltersCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDRemoveEmptyFilters))
 {
 }