Beispiel #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>());
        }
Beispiel #5
0
        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;
            }
        }
Beispiel #6
0
        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];
        }
Beispiel #7
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;
        }
Beispiel #8
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 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);
        }
Beispiel #13
0
 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))
 {
 }
Beispiel #18
0
        private static IEnumerable<UIHierarchyItem> GetSelectedUIHierarchyItems(VCFileUtilsPackage package)
        {
            UIHierarchy solutionExplorer = GetSolutionExplorer(package);

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

            return ((object[])solutionExplorer.SelectedItems)
                .Cast<UIHierarchyItem>();
        }
Beispiel #19
0
 public OrganizeOnDiskCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDOrganizeOnDisk))
 {
 }
Beispiel #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))
 {
 }
Beispiel #23
0
 private static UIHierarchy GetSolutionExplorer(VCFileUtilsPackage package)
 {
     try
     {
         return package.IDE.ToolWindows.SolutionExplorer;
     }
     catch (InvalidOperationException)
     {
         return null;
     }
 }
Beispiel #24
0
 public ReAddFilesCommand(VCFileUtilsPackage package)
     : base(package, new CommandID(GuidList.GuidCommandSet, (int)CmdIDList.CmdIDReAddFiles))
 {
 }
Beispiel #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))
 {
 }