Beispiel #1
0
        private void OnItemActivated(object sender, ItemEventArgs e)
        {
            var          desc = (e.Item as PropertyPageItem).DataContext;
            PropertyPage page;

            if (_activePage != null)
            {
                if (_activePage.Guid == desc.Guid)
                {
                    return;
                }
            }
            if (!_propertyPages.TryGetValue(desc.Guid, out page))
            {
                page = desc.CreatePropertyPage(_environment);
                bool raiseElevatedChanged = false;
                if (page != null)
                {
                    var elevated = page as IElevatedExecutableDialog;
                    if (elevated != null)
                    {
                        elevated.RequireElevationChanged += OnRequireElevationChanged;
                        if (!RequireElevation && elevated.RequireElevation)
                        {
                            raiseElevatedChanged = true;
                        }
                    }
                }
                _propertyPages.Add(desc.Guid, page);
                if (raiseElevatedChanged)
                {
                    RequireElevationChanged?.Invoke(this, EventArgs.Empty);
                }
            }
            if (page != null)
            {
                page.Dock   = DockStyle.Fill;
                page.Parent = _pnlPageContainer;
                page.InvokeOnShown();
            }
            if (_activePage != null)
            {
                _activePage.Parent = null;
            }
            _activePage = page;
        }
Beispiel #2
0
 private void OnItemActivated(object sender, ItemEventArgs e)
 {
     var desc = (e.Item as PropertyPageItem).DataContext;
     PropertyPage page;
     if(_activePage != null)
     {
         if(_activePage.Guid == desc.Guid) return;
     }
     if(!_propertyPages.TryGetValue(desc.Guid, out page))
     {
         page = desc.CreatePropertyPage(_environment);
         bool raiseElevatedChanged = false;
         if(page != null)
         {
             var elevated = page as IElevatedExecutableDialog;
             if(elevated != null)
             {
                 elevated.RequireElevationChanged += OnRequireElevationChanged;
                 if(!RequireElevation && elevated.RequireElevation)
                 {
                     raiseElevatedChanged = true;
                 }
             }
         }
         _propertyPages.Add(desc.Guid, page);
         if(raiseElevatedChanged)
         {
             RequireElevationChanged.Raise(this);
         }
     }
     if(page != null)
     {
         page.Dock = DockStyle.Fill;
         page.Parent = _pnlPageContainer;
         page.InvokeOnShown();
     }
     if(_activePage != null)
     {
         _activePage.Parent = null;
     }
     _activePage = page;
 }