protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint cmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (cmdGroup == VsMenus.guidStandardCommandSet2K)
            {
                switch ((VsCommands2K)cmd)
                {
                case (VsCommands2K)XVsConstants.CommandExploreFolderInWindows:
                    XHelperMethods.ExploreFolderInWindows(this.ProjectFolder);
                    return(VSConstants.S_OK);

                case VsCommands2K.SLNREFRESH:
                    XHelperMethods.RefreshProject(this);
                    return(VSConstants.S_OK);
                }
            }

            if (cmdGroup == VsMenus.guidStandardCommandSet97)
            {
                switch ((VsCommands)cmd)
                {
                case VsCommands.Refresh:
                    XHelperMethods.RefreshProject(this);
                    return(VSConstants.S_OK);

                case VsCommands.F1Help:
                    // Prevent VS from showing keyword help
                    return(VSConstants.S_OK);
                }
            }

            return(base.ExecCommandOnNode(cmdGroup, cmd, cmdexecopt, pvaIn, pvaOut));
        }
        /// <summary>
        /// Sets the value of an MSBuild project property.
        /// </summary>
        /// <param name="propertyName">The name of the property to change.</param>
        /// <param name="propertyValue">The value to assign the property.</param>
        /// <param name="condition">The condition to use on the property. Corresponds to the Condition attribute of the Property element.</param>
        public virtual void SetProjectProperty(string propertyName, string propertyValue, string condition)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            XHelperMethods.VerifyStringArgument(propertyName, "propertyName");

            if (propertyValue == null)
            {
                propertyValue = String.Empty;
            }

            // see if the value is the same as what's already in the project so we
            // know whether to actually mark the project file dirty or not
            string oldValue = this.GetProjectProperty(propertyName, true);

            if (!string.Equals(oldValue, propertyValue, StringComparison.Ordinal))
            {
                // check out the project file
                if (this.ProjectMgr != null && !this.ProjectMgr.QueryEditProjectFile(false))
                {
                    throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
                }

                // Use condition!
                this.BuildProject.SetProperty(propertyName, propertyValue); //, condition);

                // refresh the cached values
                this.SetCurrentConfiguration();
                this.SetProjectFileDirty(true);
            }
            this.RaiseProjectPropertyChanged(propertyName, oldValue, propertyValue);
        }
        public static string GetRelativePath(string basePath, string subPath)
        {
            VerifyStringArgument(basePath, "basePath");
            VerifyStringArgument(subPath, "subPath");

            if (!Path.IsPathRooted(basePath))
            {
                throw new ArgumentException("The 'basePath' is not rooted.");
            }

            if (!Path.IsPathRooted(subPath))
            {
                return(subPath);
            }

            if (!String.Equals(Path.GetPathRoot(basePath), Path.GetPathRoot(subPath), StringComparison.OrdinalIgnoreCase))
            {
                // both paths have different roots so we can't make them relative
                return(subPath);
            }

            // Url.MakeRelative method requires the base path to be ended with a '\' if it is a folder,
            // otherwise it considers it as a file so we need to make sure that the folder path is right
            basePath = XHelperMethods.EnsureTrailingDirectoryChar(basePath.Trim());

            Url url = new Url(basePath);

            return(url.MakeRelative(new Url(subPath)));
        }
        int IProjectSourceNode.IncludeInProject(bool recursive)
        {
            if (this.ProjectMgr == null || this.ProjectMgr.IsClosed)
            {
                return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
            }
            else if (!this.IsNonMemberItem)
            {
                return(VSConstants.S_OK); // do nothing, just ignore it.
            }
            ThreadHelper.ThrowIfNotOnUIThread();

            using (XHelperMethods.NewWaitCursor())
            {
                // Check out the project file.
                if (!this.ProjectMgr.QueryEditProjectFile(false))
                {
                    throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
                }

                // make sure that all parent folders are included in the project
                XHelperMethods.EnsureParentFolderIncluded(this);

                // now add this node to the project.
                this.AddToMSBuild(recursive);
                this.ReDraw(UIHierarchyElement.Icon);

                // refresh property browser...
                XHelperMethods.RefreshPropertyBrowser();
            }

            return(VSConstants.S_OK);
        }
        // =========================================================================================
        // Methods
        // =========================================================================================

        /// <summary>
        /// Entry point for all property validation in  projects.
        /// </summary>
        /// <param name="propertyName">Name of the property being validated. (The name in the project file, not the localized name.)</param>
        /// <param name="value">Property value to be validated.</param>
        public static void ValidateProperty(string propertyName, string value)
        {
            XHelperMethods.VerifyNonNullArgument(propertyName, "propertyName");
            XHelperMethods.VerifyNonNullArgument(value, "value");

            switch (propertyName)
            {
            case XProjectFileConstants.Cultures:
                ValidateCultures(propertyName, value);
                break;

            case XProjectFileConstants.OutputName:
                ValidateFilename(propertyName, value);
                break;

            case XProjectFileConstants.IntermediateOutputPath:
            case XProjectFileConstants.OutputPath:
                ValidatePath(propertyName, value);
                break;

            case XProjectFileConstants.IncludeSearchPaths:
                ValidatePath(propertyName, value);
                break;

            case XProjectFileConstants.ReferencePaths:
                ValidatePath(propertyName, value);
                break;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Normalizes a text-field property value by trimming whitespace.
        /// Subclasses may override to do additional normalization.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="value">Property value entered by the user.</param>
        /// <returns>Normalized property value.</returns>
        public virtual string Normalize(string propertyName, string value)
        {
            XHelperMethods.VerifyStringArgument(propertyName, "propertyName");
            XHelperMethods.VerifyNonNullArgument(value, "value");

            return(value.Trim());
        }
Beispiel #7
0
        /// <summary>
        /// Instructs the property page to process the keystroke described in <paramref name="pMsg"/>.
        /// </summary>
        /// <param name="msg">Describes the keystroke to process.</param>
        /// <returns>
        /// <list type="table">
        /// <item><term>S_OK</term><description>The property page handles the accelerator.</description></item>
        /// <item><term>S_FALSE</term><description>The property page handles accelerators, but this one was not useful to it.</description></item>
        /// <item><term>E_NOTIMPL</term><description>The proeprty page does not handle accelerators.</description></item>
        /// </list>
        /// </returns>
        int IPropertyPage.TranslateAccelerator(MSG[] msg)
        {
            XHelperMethods.VerifyNonNullArgument(msg, "msg");

            // Always return S_FALSE otherwise we hijack all of the accelerators even for the menus
            return(VSConstants.S_FALSE);
        }
        /// <summary>
        /// When building with only a xsproj in the solution, the SolutionX variables are not
        /// defined, so we have to define them here.
        /// </summary>
        /// <param name="project">The project where the properties are defined.</param>
        internal static void DefineSolutionProperties(ProjectNode project)
        {
            IVsSolution solution = XHelperMethods.GetService <IVsSolution, SVsSolution>(project.Site);
            object      solutionPathObj;

            ThreadHelper.ThrowIfNotOnUIThread();

            ErrorHandler.ThrowOnFailure(solution.GetProperty((int)__VSPROPID.VSPROPID_SolutionFileName, out solutionPathObj));
            string           solutionPath = (string)solutionPathObj;
            XPackageSettings settings     = XPackageSettings.Instance;
            string           devEnvDir    = XHelperMethods.EnsureTrailingDirectoryChar(Path.GetDirectoryName(settings.DevEnvPath));

            string[][] properties = new string[][]
            {
                new string[] { XProjectFileConstants.DevEnvDir, devEnvDir },
                new string[] { XProjectFileConstants.SolutionPath, solutionPath },
                new string[] { XProjectFileConstants.SolutionDir, XHelperMethods.EnsureTrailingDirectoryChar(Path.GetDirectoryName(solutionPath)) },
                new string[] { XProjectFileConstants.SolutionExt, Path.GetExtension(solutionPath) },
                new string[] { XProjectFileConstants.SolutionFileName, Path.GetFileName(solutionPath) },
                new string[] { XProjectFileConstants.SolutionName, Path.GetFileNameWithoutExtension(solutionPath) },
            };

            foreach (string[] property in properties)
            {
                string propertyName  = property[0];
                string propertyValue = property[1];

                project.BuildProject.SetGlobalProperty(propertyName, propertyValue);
            }
        }
Beispiel #9
0
        protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint cmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (cmdGroup == VsPkgMenus.guidStandardCommandSet2K)
            {
                switch ((VsCommands2K)cmd)
                {
                case VsCommands2K.INCLUDEINPROJECT:
                    return(((IProjectSourceNode)this).IncludeInProject());

                case VsCommands2K.EXCLUDEFROMPROJECT:
                    return(((IProjectSourceNode)this).ExcludeFromProject());

                case VsCommands2K.SLNREFRESH:
                    XHelperMethods.RefreshProject(this);
                    return(VSConstants.S_OK);
                }
            }

            if (cmdGroup == VsPkgMenus.guidStandardCommandSet97)
            {
                switch ((VsCommands)cmd)
                {
                case VsCommands.Refresh:
                    XHelperMethods.RefreshProject(this);
                    return(VSConstants.S_OK);
                }
            }

            return(base.ExecCommandOnNode(cmdGroup, cmd, cmdexecopt, pvaIn, pvaOut));
        }
Beispiel #10
0
        protected virtual int IncludeInProject()
        {
            XProjectNode projectNode = this.ProjectMgr as XProjectNode;

            if (projectNode == null || projectNode.IsClosed)
            {
                return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
            }
            else if (!this.IsNonMemberItem)
            {
                return(VSConstants.S_OK); // do nothing, just ignore it.
            }

            using (XHelperMethods.NewWaitCursor())
            {
                // Check out the project file.
                if (!projectNode.QueryEditProjectFile(false))
                {
                    throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
                }

                for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling)
                {
                    IProjectSourceNode node = child as IProjectSourceNode;
                    if (node != null)
                    {
                        int result = node.IncludeInProject();
                        if (result != VSConstants.S_OK)
                        {
                            return(result);
                        }
                    }
                }


                // make sure that all parent folders are included in the project
                XHelperMethods.EnsureParentFolderIncluded(this);
                ThreadHelper.ThrowIfNotOnUIThread();

                // now add this node to the project.
                this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, false);
                this.ItemNode = projectNode.CreateMsBuildFileProjectElement(this.Url);
                this.ProjectMgr.Tracker.OnItemAdded(this.Url, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);

                // notify others
                ////projectNode.OnItemAdded(this.Parent, this);
                this.ReDraw(UIHierarchyElement.Icon);     // We have to redraw the icon of the node as it is now a member of the project and should be drawn using a different icon.
                this.ReDraw(UIHierarchyElement.SccState); // update the SCC state icon.

                this.ResetProperties();

                this.SetSpecialProperties();    // allows to set generators etc.

                // refresh property browser...
                XHelperMethods.RefreshPropertyBrowser();
            }

            return(VSConstants.S_OK);
        }
Beispiel #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XPropertyPagePanel"/> class.
        /// </summary>
        /// <param name="parentPropertyPage">The parent property page to which this is bound.</param>
        public XPropertyPagePanel(XPropertyPage parentPropertyPage)
        {
            this.parentPropertyPage = parentPropertyPage;
            this.InitializeComponent();

            this.Font      = XHelperMethods.GetDialogFont();
            this.ForeColor = XHelperMethods.GetVsColor(XHelperMethods.Vs2010Color.VSCOLOR_BUTTONTEXT);
        }
Beispiel #12
0
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="XBuildEventEditorForm"/> class.
        /// </summary>
        public XBuildEventEditorForm(IServiceProvider serviceProvider)
        {
            this.serviceProvider = serviceProvider;
            this.InitializeComponent();

            this.Font = XHelperMethods.GetDialogFont();

            //this.BackColor = XHelperMethods.GetVsColor(XHelperMethods.Vs2010Color.VSCOLOR_BUTTONFACE);
            XHelperMethods.SetControlTreeColors(this);
        }
        /// <summary>
        /// Resets the control colors when the system colors change
        /// </summary>
        /// <param name="e">The object representing the event   </param>
        protected override void OnSystemColorsChanged(EventArgs e)
        {
            base.OnSystemColorsChanged(e);

            // This sets the background control for all this control and all of its children
            //this.BackColor = XHelperMethods.GetVsColor(XHelperMethods.Vs2010Color.VSCOLOR_BUTTONFACE);

            // The forecolor has to be set explicitly for each control
            XHelperMethods.SetControlTreeColors(this);
        }
Beispiel #14
0
        protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result)
        {
            int returnCode;

            if (XHelperMethods.QueryStatusOnProjectSourceNode(this, cmdGroup, cmd, ref result, out returnCode))
            {
                return(returnCode);
            }

            return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result));
        }
Beispiel #15
0
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="XPackageSettings"/> class.
        /// </summary>
        /// <param name="serviceProvider">The <see cref="IServiceProvider"/> to use.</param>
        public XPackageSettings(IServiceProvider serviceProvider)
        {
            XHelperMethods.VerifyNonNullArgument(serviceProvider, "serviceProvider");
            ThreadHelper.ThrowIfNotOnUIThread();

            if (serviceProvider != null)
            {
                // get the Visual Studio registry root
                ILocalRegistry3 localRegistry = XHelperMethods.GetService <ILocalRegistry3, SLocalRegistry>(serviceProvider);
                ErrorHandler.ThrowOnFailure(localRegistry.GetLocalRegistryRoot(out this.visualStudioRegistryRoot));
            }
            Instance = this;
        }
        /// <summary>
        /// Gets the file system entries of a folder and its all sub-folders with relative path.
        /// </summary>
        /// <param name="baseFolder">Base folder.</param>
        /// <param name="filter">Filter to be used. default is "*"</param>
        /// <param name="fileList">Files list containing the relative file paths.</param>
        /// <param name="folderList">Folders list containing the relative folder paths.</param>
        private static void GetRelativeFileSystemEntries(string baseFolder, string filter, IList <string> fileList, IList <string> folderList)
        {
            if (baseFolder == null)
            {
                throw new ArgumentNullException("baseFolder");
            }

            if (String.IsNullOrEmpty(filter))
            {
                filter = "*";  // include all files and folders
            }

            if (fileList != null)
            {
                string[] fileEntries = Directory.GetFiles(baseFolder, filter, SearchOption.AllDirectories);
                foreach (string file in fileEntries)
                {
                    FileInfo fileInfo = new FileInfo(file);
                    if ((fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        continue;
                    }

                    string fileRelativePath = XHelperMethods.GetRelativePath(baseFolder, file);
                    if (!String.IsNullOrEmpty(fileRelativePath))
                    {
                        fileList.Add(fileRelativePath);
                    }
                }
            }

            if (folderList != null)
            {
                string[] folderEntries = Directory.GetDirectories(baseFolder, filter, SearchOption.AllDirectories);
                foreach (string folder in folderEntries)
                {
                    DirectoryInfo folderInfo = new DirectoryInfo(folder);
                    if ((folderInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        continue;
                    }

                    string folderRelativePath = XHelperMethods.GetRelativePath(baseFolder, folder);
                    if (!String.IsNullOrEmpty(folderRelativePath))
                    {
                        folderList.Add(folderRelativePath);
                    }
                }
            }
        }
Beispiel #17
0
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Creates a new project property object.
        /// </summary>
        /// <param name="project">Project that owns the property.</param>
        /// <param name="propertyName">Name of the property.</param>
        public ProjectProperty(XProjectNode project, string propertyName, bool perConfig)
        {
            XHelperMethods.VerifyNonNullArgument(project, "project");
            XHelperMethods.VerifyNonNullArgument(propertyName, "propertyName");

            this.project      = project;
            this.propertyName = propertyName;

            this.perUser          = ProjectProperty.PerUserProperties.Contains(propertyName);
            this.perConfig        = perConfig;
            this.allowVariables   = ProjectProperty.AllowVariablesProperties.Contains(propertyName);
            this.list             = ProjectProperty.ListProperties.Contains(propertyName);
            this.endOfProjectFile = ProjectProperty.EndOfProjectFileProperties.Contains(propertyName);
        }
        internal static void RemoveNonMemberItems(XProjectNode project)
        {
            IList <HierarchyNode> nodeList = new List <HierarchyNode>();

            XHelperMethods.FindNodes(nodeList, project, XProjectMembers.IsNodeNonMemberItem, null);
            ThreadHelper.ThrowIfNotOnUIThread();
            for (int index = nodeList.Count - 1; index >= 0; index--)
            {
                HierarchyNode node   = nodeList[index];
                HierarchyNode parent = node.Parent;

                node.OnItemDeleted();
                parent.RemoveChild(node);
            }
        }
        private void AddFolderButton_Click(object sender, EventArgs e)
        {
            string folder = XHelperMethods.EnsureTrailingDirectoryChar(this.folderTextBox.Text);

            if (this.pathsListBox.FindStringExact(folder) == ListBox.NoMatches)
            {
                CancelEventArgs ce = new CancelEventArgs();
                this.OnFolderValidating(ce);
                if (!ce.Cancel)
                {
                    this.folderTextBox.Text         = folder;
                    this.pathsListBox.SelectedIndex = this.pathsListBox.Items.Add(folder);
                    this.OnFoldersChanged(EventArgs.Empty);
                }
            }
        }
        /// <summary>
        /// Gets the font provided by the VS environment for dialog UI.
        /// </summary>
        /// <returns>Dialog font, or null if it is not available.</returns>
        public static Font GetDialogFont()
        {
            IUIHostLocale uiHostLocale = XHelperMethods.GetServiceNoThrow <IUIHostLocale, IUIHostLocale>(AsyncProjectPackage.Instance);

            ThreadHelper.ThrowIfNotOnUIThread();

            if (uiHostLocale != null)
            {
                UIDLGLOGFONT[] pLOGFONT = new UIDLGLOGFONT[1];
                if (uiHostLocale.GetDialogFont(pLOGFONT) == 0)
                {
                    return(Font.FromLogFont(pLOGFONT[0]));
                }
            }

            return(null);
        }
        /// <summary>
        /// Finds child nodes under the parent node and places them in the currentList.
        /// </summary>
        /// <param name="currentList">List to be populated with the nodes.</param>
        /// <param name="parent">Parent node under which the nodes should be searched.</param>
        /// <param name="filter">Filter to be used while selecting the node.</param>
        /// <param name="criteria">Criteria to be used by the filter.</param>
        public static void FindNodes(IList <HierarchyNode> currentList, HierarchyNode parent, XNodeFilter filter, object criteria)
        {
            Utilities.ArgumentNotNull("currentList", currentList);
            Utilities.ArgumentNotNull("parent", parent);
            Utilities.ArgumentNotNull("filter", filter);


            for (HierarchyNode child = parent.FirstChild; child != null; child = child.NextSibling)
            {
                if (filter(child, criteria))
                {
                    currentList.Add(child);
                }

                XHelperMethods.FindNodes(currentList, child, filter, criteria);
            }
        }
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="XSharpBuildMacros"/> class.
        /// </summary>
        /// <param name="project">The project from which to read the properties.</param>
        public XBuildMacroCollection(ProjectNode project)
        {
            XHelperMethods.VerifyNonNullArgument(project, "project");

            // get the global SolutionX properties
            XBuildMacroCollection.DefineSolutionProperties(project);
            foreach (string globalMacroName in globalMacroNames)
            {
                string property = null;
                project.BuildProject.GlobalProperties.TryGetValue(globalMacroName, out property);
                if (null == property)
                {
                    this.list.Add(globalMacroName, "*Undefined*");
                }
                else
                {
                    this.list.Add(globalMacroName, property);
                }
            }
            // we need to call GetTargetPath first so that TargetDir and TargetPath are resolved correctly
            ConfigCanonicalName configCanonicalName;

            if (!Utilities.TryGetActiveConfigurationAndPlatform(project.Site, project, out configCanonicalName))
            {
                throw new InvalidOperationException();
            }
            BuildResult res = project.Build(configCanonicalName, XProjectFileConstants.GetTargetPath);

            // get the ProjectX and TargetX variables
            foreach (string macroName in macroNames)
            {
                string value;
                ThreadHelper.ThrowIfNotOnUIThread();
                if (res.ProjectInstance != null)
                {
                    value = res.ProjectInstance.GetPropertyValue(macroName);
                }
                else
                {
                    value = project.GetProjectProperty(macroName);
                }

                this.list.Add(macroName, value);
            }
        }
        private void GenerateButtonImages()
        {
            Color grayColor = SystemColors.ControlDark;

            this.highContrastMode = SystemInformation.HighContrast;

            if (this.highContrastMode)
            {
                grayColor = SystemColors.Control;
            }

            this.moveUpImage       = XHelperMethods.MapBitmapColor(this.moveUpOriginalImage, Color.Black, SystemColors.ControlText);
            this.moveUpGrayImage   = XHelperMethods.MapBitmapColor(this.moveUpOriginalImage, Color.Black, grayColor);
            this.moveDownImage     = XHelperMethods.MapBitmapColor(this.moveDownOriginalImage, Color.Black, SystemColors.ControlText);
            this.moveDownGrayImage = XHelperMethods.MapBitmapColor(this.moveDownOriginalImage, Color.Black, grayColor);
            this.deleteImage       = XHelperMethods.MapBitmapColor(this.deleteOriginalImage, Color.Black, SystemColors.ControlText);
            this.deleteGrayImage   = XHelperMethods.MapBitmapColor(this.deleteOriginalImage, Color.Black, grayColor);
        }
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            string folder        = XHelperMethods.EnsureTrailingDirectoryChar(this.folderTextBox.Text);
            int    selectedIndex = this.pathsListBox.SelectedIndex;

            if (this.pathsListBox.SelectedItem.ToString() != folder)
            {
                CancelEventArgs ce = new CancelEventArgs();
                this.OnFolderValidating(ce);
                if (!ce.Cancel)
                {
                    this.pathsListBox.Items[selectedIndex] = folder;
                    if (this.FoldersChanged != null)
                    {
                        this.FoldersChanged(this, new EventArgs());
                    }
                }
            }
        }
        /// <summary>
        /// Refreshes the data in the property browser
        /// </summary>
        internal static void RefreshPropertyBrowser()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsUIShell vsuiShell = AsyncProjectPackage.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell;

            if (vsuiShell == null)
            {
                string message = XHelperMethods.SafeStringFormat(CultureInfo.CurrentUICulture, Resources.GetString(Resources.CannotGetService), typeof(IVsUIShell).Name);
                throw new InvalidOperationException(message);
            }
            else
            {
                int hr = vsuiShell.RefreshPropertyBrowser(0);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
            }
        }
Beispiel #26
0
        /// <summary>
        /// The environment calls this to get the parameters to describe the property page.
        /// </summary>
        /// <param name="pageInfos">The parameters are returned in this one-sized array.</param>
        void IPropertyPage.GetPageInfo(PROPPAGEINFO[] pageInfos)
        {
            XHelperMethods.VerifyNonNullArgument(pageInfos, "pageInfos");

            if (this.PropertyPagePanel == null)
            {
                this.PropertyPagePanel = this.CreatePropertyPagePanel();
            }

            PROPPAGEINFO info = new PROPPAGEINFO();

            info.cb            = (uint)Marshal.SizeOf(typeof(PROPPAGEINFO));
            info.dwHelpContext = 0;
            info.pszDocString  = null;
            info.pszHelpFile   = null;
            info.pszTitle      = this.PageName;
            info.SIZE.cx       = this.PropertyPagePanel.Width;
            info.SIZE.cy       = this.PropertyPagePanel.Height;
            pageInfos[0]       = info;
            this.propPageInfo  = info;
        }
Beispiel #27
0
        protected override int QueryStatusOnNode(Guid guidCmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result)
        {
            if (VsPkgMenus.guidStandardCommandSet97 == guidCmdGroup && this.IsNonMemberItem)
            {
                switch ((VsCommands)cmd)
                {
                case VsCommands.ViewCode:
                    result = QueryStatusResult.NOTSUPPORTED;
                    return((int)OleConstants.MSOCMDERR_E_NOTSUPPORTED);
                }
            }

            int returnCode;

            if (XHelperMethods.QueryStatusOnProjectSourceNode(this, guidCmdGroup, cmd, ref result, out returnCode))
            {
                return(returnCode);
            }

            return(base.QueryStatusOnNode(guidCmdGroup, cmd, pCmdText, ref result));
        }
Beispiel #28
0
        // =========================================================================================
        // Methods
        // =========================================================================================

        /// <summary>
        /// Sets the node property.
        /// </summary>
        /// <param name="propid">Property id.</param>
        /// <param name="value">Property value.</param>
        /// <returns>Returns success or failure code.</returns>
        public override int SetProperty(int propid, object value)
        {
            int         result;
            __VSHPROPID id = (__VSHPROPID)propid;

            switch (id)
            {
            case __VSHPROPID.VSHPROPID_IsNonMemberItem:
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                bool boolValue;
                CCITracing.TraceCall(this.ID + "," + id.ToString());
                if (Boolean.TryParse(value.ToString(), out boolValue))
                {
                    this.isNonMemberItem = boolValue;

                    // Reset exclude from scc
                    this.ExcludeNodeFromScc = this.IsNonMemberItem;
                }
                else
                {
                    XHelperMethods.TraceFail("Could not parse the IsNonMemberItem property value.");
                }

                result = VSConstants.S_OK;
                break;

            default:
                ThreadHelper.ThrowIfNotOnUIThread();
                result = base.SetProperty(propid, value);
                break;
            }

            return(result);
        }
Beispiel #29
0
        /// <summary>
        /// Sets the expanded state of the folder.
        /// </summary>
        /// <param name="expanded">Flag that indicates the expanded state of the folder.
        /// This should be 'true' for expanded and 'false' for collapsed state.</param>
        protected void SetExpanded(bool expanded)
        {
            this.IsExpanded = expanded;
            ThreadHelper.ThrowIfNotOnUIThread();
            this.SetProperty((int)__VSHPROPID.VSHPROPID_Expanded, expanded);

            // If we are in automation mode then skip the ui part
            if (!Utilities.IsInAutomationFunction(this.ProjectMgr.Site))
            {
                IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer);
                if (null != uiWindow)
                {
                    ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.ProjectMgr, this.ID, expanded ? EXPANDFLAGS.EXPF_ExpandFolder : EXPANDFLAGS.EXPF_CollapseFolder));
                }

                // then post the expand command to the shell. Folder verification and creation will
                // happen in the setlabel code...
                IVsUIShell shell = XHelperMethods.GetService <IVsUIShell, SVsUIShell>(this.ProjectMgr.Site);

                object dummy    = null;
                Guid   cmdGroup = VsMenus.guidStandardCommandSet97;
                ErrorHandler.ThrowOnFailure(shell.PostExecCommand(ref cmdGroup, (uint)(expanded ? VsCommands.Expand : VsCommands.Collapse), 0, ref dummy));
            }
        }
        protected internal int ToggleShowAllFiles()
        {
            if (this.ProjectMgr == null || this.ProjectMgr.IsClosed)
            {
                return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
            }

            using (XHelperMethods.NewWaitCursor())
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                this.showAllFilesEnabled = !this.showAllFilesEnabled; // toggle the flag

                if (this.showAllFilesEnabled)
                {
                    XProjectMembers.AddNonMemberItems(this);
                }
                else
                {
                    XProjectMembers.RemoveNonMemberItems(this);
                }
            }

            return(VSConstants.S_OK);
        }