Inheritance: LocalizableProperties, ISpecifyPropertyPages, IVsGetCfgProvider, IVsSpecifyProjectDesignerPages, EnvDTE80.IInternalExtenderProvider, IVsBrowseObject
Esempio n. 1
0
        public virtual void SetObjects(uint count, object[] punk)
        {
            if (count > 0)
            {
                if (punk[0] is ProjectConfig)
                {
                    ArrayList configs = new ArrayList();

                    for (int i = 0; i < count; i++)
                    {
                        ProjectConfig config = (ProjectConfig)punk[i];

                        if (this.project == null)
                        {
                            this.project = config.ProjectMgr;
                        }

                        configs.Add(config);
                    }

                    this.projectConfigs = (ProjectConfig[])configs.ToArray(typeof(ProjectConfig));
                }
                else if (punk[0] is NodeProperties)
                {
                    if (this.project == null)
                    {
                        this.project = (punk[0] as NodeProperties).Node.ProjectMgr;
                    }

                    System.Collections.Generic.Dictionary <string, ProjectConfig> configsMap = new System.Collections.Generic.Dictionary <string, ProjectConfig>();

                    for (int i = 0; i < count; i++)
                    {
                        NodeProperties property = (NodeProperties)punk[i];
                        IVsCfgProvider provider;
                        ErrorHandler.ThrowOnFailure(property.Node.ProjectMgr.GetCfgProvider(out provider));
                        uint[] expected = new uint[1];
                        ErrorHandler.ThrowOnFailure(provider.GetCfgs(0, null, expected, null));
                        if (expected[0] > 0)
                        {
                            ProjectConfig[] configs = new ProjectConfig[expected[0]];
                            uint[]          actual  = new uint[1];
                            ErrorHandler.ThrowOnFailure(provider.GetCfgs(expected[0], configs, actual, null));

                            foreach (ProjectConfig config in configs)
                            {
                                if (!configsMap.ContainsKey(config.ConfigName))
                                {
                                    configsMap.Add(config.ConfigName, config);
                                }
                            }
                        }
                    }

                    if (configsMap.Count > 0)
                    {
                        if (this.projectConfigs == null)
                        {
                            this.projectConfigs = new ProjectConfig[configsMap.Keys.Count];
                        }
                        configsMap.Values.CopyTo(this.projectConfigs, 0);
                    }
                }
            }
            else
            {
                this.project = null;
            }

            if (this.active && this.project != null)
            {
                UpdateObjects();
            }
        }
 /// <summary>
 /// Initializes new instance of OANestedProjectProperties object based on specified ProjectNode.
 /// </summary>
 internal OANestedProjectProperties(NodeProperties nodeProperties)
     : base(nodeProperties)
 {
     this.AddProperties();
 }
Esempio n. 3
0
        public virtual void SetObjects(uint count, object[] punk)
        {
            if (punk == null)
            {
                return;
            }

            if (count > 0)
            {
                if (punk[0] is ProjectConfig pconfig)
                {
                    ArrayList configs = new ArrayList();

                    for (int i = 0; i < count; i++)
                    {
                        ProjectConfig config = (ProjectConfig)punk[i];

                        if (this.project == null || (this.project != pconfig.ProjectMgr))
                        {
                            UnRegisterProjectEvents();
                            this.project = config.ProjectMgr;
                            RegisterProjectEvents();
                        }

                        configs.Add(config);
                    }

                    this.projectConfigs = (ProjectConfig[])configs.ToArray(typeof(ProjectConfig));
                }

                else if (punk[0] is NodeProperties props)
                {
                    if (this.project == null || (this.project != props.Node.ProjectMgr))
                    {
                        UnRegisterProjectEvents();
                        this.project = props.Node.ProjectMgr;
                        RegisterProjectEvents();
                    }

                    var configsMap = new Dictionary <string, IVsProjectCfg2>();
                    ThreadHelper.JoinableTaskFactory.Run(async delegate
                    {
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                        for (int i = 0; i < count; i++)
                        {
                            NodeProperties property = (NodeProperties)punk[i];
                            IVsCfgProvider provider;
                            ErrorHandler.ThrowOnFailure(property.Node.ProjectMgr.GetCfgProvider(out provider));
                            uint[] expected = new uint[1];
                            ErrorHandler.ThrowOnFailure(provider.GetCfgs(0, null, expected, null));
                            if (expected[0] > 0)
                            {
                                ProjectConfig[] configs = new ProjectConfig[expected[0]];
                                uint[] actual           = new uint[1];
                                provider.GetCfgs(expected[0], configs, actual, null);

                                foreach (ProjectConfig config in configs)
                                {
                                    if (!configsMap.ContainsKey(config.ConfigName))
                                    {
                                        configsMap.Add(config.ConfigName, config);
                                    }
                                }
                            }
                        }
                    });
                    if (configsMap.Count > 0)
                    {
                        if (this.projectConfigs == null)
                        {
                            this.projectConfigs = new ProjectConfig[configsMap.Keys.Count];
                        }
                        configsMap.Values.CopyTo(this.projectConfigs, 0);
                    }
                }
            }
            else
            {
                this.project = null;
            }

            if (this.active && this.project != null)
            {
                UpdateObjects();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Resets the Node properties for file node item.
        /// </summary>
        protected void ResetProperties()
        {
            bool changed = false;

            if (IsNonMemberItem)
            {
                if (!(_currentNodeProperties is NemerleFileNodeNonMemberProperties))
                {
                    _currentNodeProperties = new NemerleFileNodeNonMemberProperties(this);
                    changed = true;
                }
            }
            else
            {
                if (!(_currentNodeProperties is NemerleFileNodeProperties))
                {
                    _currentNodeProperties = new NemerleFileNodeProperties(this);
                    changed = true;
                }
            }

            if (changed)
                OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_BrowseObject, 0);
        }
Esempio n. 5
0
        /// <summary>
        /// The environment calls this to set the currently selected objects that the property page should show.
        /// </summary>
        /// <param name="count">The count of elements in <paramref name="punk"/>.</param>
        /// <param name="punk">An array of <b>IUnknown</b> objects to show in the property page.</param>
        /// <remarks>
        /// We are supposed to cache these objects until we get another call with <paramref name="count"/> = 0.
        /// Also, the environment is supposed to call this before calling <see cref="IPropertyPage2.Activate"/>,
        /// but like all things when interacting with Visual Studio, don't trust that and code defensively.
        /// </remarks>
        void IPropertyPage.SetObjects(uint count, object[] punk)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (count == 0)
            {
                if (this.project != null)
                {
                    //this.project.OutputTypeChanged -= this.HandleOutputTypeChanged;
                    this.project.OnProjectPropertyChanged -= Project_OnProjectPropertyChanged;
                    this.project = null;
                }

                return;
            }

            if (punk[0] is ProjectConfig)
            {
                List <XProjectConfig> configs = new List <XProjectConfig>();

                for (int i = 0; i < count; i++)
                {
                    XProjectConfig config = (XProjectConfig)punk[i];

                    if (this.project == null)
                    {
                        this.project = config.ProjectMgr as XProjectNode;
                        this.project.OnProjectPropertyChanged += Project_OnProjectPropertyChanged;
                    }

                    configs.Add(config);
                }

                this.projectConfigs = configs.ToArray();
            }
            else if (punk[0] is NodeProperties)
            {
                if (this.project == null)
                {
                    this.project = (punk[0] as NodeProperties).Node.ProjectMgr as XProjectNode;
                    this.project.OnProjectPropertyChanged += Project_OnProjectPropertyChanged;
                }

                Dictionary <string, XProjectConfig> configsMap = new Dictionary <string, XProjectConfig>();

                for (int i = 0; i < count; i++)
                {
                    NodeProperties property = (NodeProperties)punk[i];
                    IVsCfgProvider provider;
                    ErrorHandler.ThrowOnFailure(property.Node.ProjectMgr.GetCfgProvider(out provider));
                    uint[] expected = new uint[1];
                    ErrorHandler.ThrowOnFailure(provider.GetCfgs(0, null, expected, null));
                    if (expected[0] > 0)
                    {
                        XProjectConfig[] configs = new XProjectConfig[expected[0]];
                        uint[]           actual  = new uint[1];
                        int hr = provider.GetCfgs(expected[0], configs, actual, null);
                        if (hr != 0)
                        {
                            Marshal.ThrowExceptionForHR(hr);
                        }

                        foreach (XProjectConfig config in configs)
                        {
                            if (!configsMap.ContainsKey(config.ConfigName))
                            {
                                configsMap.Add(config.ConfigName, config);
                            }
                        }
                    }
                }

                if (configsMap.Count > 0)
                {
                    if (this.projectConfigs == null)
                    {
                        this.projectConfigs = new XProjectConfig[configsMap.Keys.Count];
                    }

                    configsMap.Values.CopyTo(this.projectConfigs, 0);
                }
            }

            if (this.active && this.project != null)
            {
                this.PropertyPagePanel.BindProperties();
                this.IsDirty = false;
            }
        }
Esempio n. 6
0
 public NemerleOAProperties(NodeProperties target)
     : base(target)
 {
 }