Beispiel #1
0
        public void Activate(IntPtr hWndParent, RECT[] pRect, int bModal)
        {
#if DEBUG
            if (pRect == null || pRect.Length != 1)
            {
                throw new ArgumentOutOfRangeException(nameof(pRect));
            }
#endif
            _propertyPageUI = CreatePropertyPageUI();

            var vsRect = pRect[0];
            var rect   = new Rectangle(vsRect.left, vsRect.top, vsRect.right - vsRect.left, vsRect.bottom - vsRect.top);

            var modal = bModal.ToBoolean();

            WaitForAsync(() => _propertyPageUI.ActivateAsync(hWndParent, rect, modal));
            WaitForAsync(() => _propertyPageUI.SetViewModelAsync(_propertyPageViewModel));
        }
Beispiel #2
0
        public void SetObjects(uint cObjects, object[] ppUnk)
        {
            if (cObjects == 0)
            {
                return;
            }

            if (ppUnk.Length < cObjects)
            {
                throw new ArgumentOutOfRangeException(nameof(cObjects));
            }

            ThreadHelper.ThrowIfNotOnUIThread();

            for (int i = 0; i < cObjects; i++)
            {
                var unk = ppUnk[i];

                var context = unk as IVsBrowseObjectContext;

                if (context == null && unk is IVsBrowseObject browseObject)
                {
                    int hr = browseObject.GetProjectItem(out var hierarchy, out uint itemId);

                    if (hr == VSConstants.S_OK && itemId == VSConstants.VSITEMID_ROOT)
                    {
                        if (hierarchy != null)
                        {
                            if (ErrorHandler.Succeeded(hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ExtObject, out var extObject)))
                            {
                                context = extObject as IVsBrowseObjectContext;

                                if (context == null)
                                {
                                    if (extObject is EnvDTE.Project dteProject)
                                    {
                                        context = dteProject.Object as IVsBrowseObjectContext;
                                    }
                                }
                            }
                        }
                    }
                }

                if (context != null)
                {
                    _unconfiguredProject     = context.UnconfiguredProject;
                    _projectThreadingService = _unconfiguredProject.ProjectService.Services.ThreadingPolicy;
                }
            }

            if (_unconfiguredProject == null)
            {
                throw new Exception("Couldn't find UnconfiguredProject!");
            }

            _propertyPageViewModel = CreatePropertyPageViewModel(_unconfiguredProject, _projectThreadingService);

            _propertyPageViewModel.ProjectPropertyChanged  += PropertyChanged;
            _propertyPageViewModel.ProjectPropertyChanging += PropertyChanging;

            WaitForAsync(() => _propertyPageUI.SetViewModelAsync(_propertyPageViewModel));
        }