public GridEntry Restore(PropertyGridView gridView)
            {
                gridView.RestoreHierarchyState(_expandedState);
                GridEntry entry = gridView.FindEquivalentGridEntry(_selectedItemTree);

                if (entry is null)
                {
                    return(null);
                }

                gridView.SelectGridEntry(entry, pageIn: true);

                int delta = gridView._selectedRow - _itemRow;

                if (delta != 0 && gridView.ScrollBar.Visible)
                {
                    if (_itemRow < gridView._visibleRows)
                    {
                        delta += gridView.GetScrollOffset();

                        if (delta < 0)
                        {
                            delta = 0;
                        }
                        else if (delta > gridView.ScrollBar.Maximum)
                        {
                            delta = gridView.ScrollBar.Maximum - 1;
                        }

                        gridView.SetScrollOffset(delta);
                    }
                }

                return(entry);
            }
Ejemplo n.º 2
0
		public PropertyGridViewProvider (PropertyGridView propertyGridView)
			: base (propertyGridView)
		{
			view = propertyGridView;
			propertyGrid = Helper.GetPrivateField<PropertyGrid> (
				typeof (PropertyGridView), view,
				"property_grid");
		}
            public GridViewListBox(PropertyGridView gridView)
            {
                ArgumentNullException.ThrowIfNull(gridView);

                IntegralHeight          = false;
                _owningPropertyGridView = gridView;
                base.BackColor          = gridView.BackColor;
            }
            /// <summary>
            ///  Constructs the new instance of GridViewListBoxAccessibleObject.
            /// </summary>
            /// <param name="owningGridViewListBox">The owning GridViewListBox.</param>
            public GridViewListBoxAccessibleObject(GridViewListBox owningGridViewListBox) : base(owningGridViewListBox)
            {
                if (owningGridViewListBox.OwningPropertyGridView is null)
                {
                    throw new ArgumentNullException(nameof(owningGridViewListBox.OwningPropertyGridView));
                }

                _owningPropertyGridView = owningGridViewListBox.OwningPropertyGridView;
            }
 internal SingleSelectRootGridEntry(
     PropertyGridView view,
     object value,
     IServiceProvider baseProvider,
     IDesignerHost host,
     PropertyTab tab,
     PropertySort sortType) : this(view, value, null, baseProvider, host, tab, sortType)
 {
 }
            public MouseHook(Control control, IMouseHookClient client, PropertyGridView gridView)
            {
                _control  = control;
                _gridView = gridView;
                _client   = client;
#if DEBUG
                _callingStack = Environment.StackTrace;
#endif
            }
Ejemplo n.º 7
0
        public DropDownButtonAccessibleObject(DropDownButton owningDropDownButton) : base(owningDropDownButton)
        {
            _owningDropDownButton = owningDropDownButton;
            _owningPropertyGrid   = owningDropDownButton.Parent as PropertyGridView;

            if (owningDropDownButton.IsHandleCreated)
            {
                UseStdAccessibleObjects(owningDropDownButton.Handle);
            }
        }
            public GridViewListBox(PropertyGridView gridView)
            {
                if (gridView == null)
                {
                    throw new ArgumentNullException(nameof(gridView));
                }

                base.IntegralHeight     = false;
                _owningPropertyGridView = gridView;
                base.BackColor          = gridView.BackColor;
            }
 internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(gridEntryHost.OwnerGrid, parent)
 {
     this.host              = host;
     this.gridEntryHost     = gridEntryHost;
     this.baseProvider      = baseProvider;
     this.tab               = tab;
     this.objValue          = value;
     this.objValueClassName = TypeDescriptor.GetClassName(this.objValue);
     this.IsExpandable      = true;
     base.PropertySort      = sortType;
     this.InternalExpanded  = true;
 }
 internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(gridEntryHost.OwnerGrid, parent)
 {
     this.host = host;
     this.gridEntryHost = gridEntryHost;
     this.baseProvider = baseProvider;
     this.tab = tab;
     this.objValue = value;
     this.objValueClassName = TypeDescriptor.GetClassName(this.objValue);
     this.IsExpandable = true;
     base.PropertySort = sortType;
     this.InternalExpanded = true;
 }
 internal override void EditPropertyValue(PropertyGridView iva)
 {
     base.EditPropertyValue(iva);
     if (!this.IsValueEditable)
     {
         RefreshPropertiesAttribute attribute = (RefreshPropertiesAttribute) this.propertyInfo.Attributes[typeof(RefreshPropertiesAttribute)];
         if ((attribute != null) && !attribute.RefreshProperties.Equals(RefreshProperties.None))
         {
             this.GridEntryHost.Refresh((attribute != null) && attribute.Equals(RefreshPropertiesAttribute.All));
         }
     }
 }
Ejemplo n.º 12
0
 internal override void EditPropertyValue(PropertyGridView iva)
 {
     base.EditPropertyValue(iva);
     if (!this.IsValueEditable)
     {
         RefreshPropertiesAttribute attribute = (RefreshPropertiesAttribute)this.propertyInfo.Attributes[typeof(RefreshPropertiesAttribute)];
         if ((attribute != null) && !attribute.RefreshProperties.Equals(RefreshProperties.None))
         {
             this.GridEntryHost.Refresh((attribute != null) && attribute.Equals(RefreshPropertiesAttribute.All));
         }
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Invokes the type editor for editing this item.
        /// </summary>
        internal override void EditPropertyValue(PropertyGridView iva)
        {
            base.EditPropertyValue(iva);

            if (!IsValueEditable)
            {
                RefreshPropertiesAttribute refreshAttr = (RefreshPropertiesAttribute)propertyInfo.Attributes[typeof(RefreshPropertiesAttribute)];
                if ((refreshAttr != null && !refreshAttr.RefreshProperties.Equals(RefreshProperties.None)))
                {
                    this.GridEntryHost.Refresh(refreshAttr != null && refreshAttr.Equals(RefreshPropertiesAttribute.All));
                }
            }
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         host          = null;
         baseProvider  = null;
         tab           = null;
         gridEntryHost = null;
         changeService = null;
     }
     this.objValue    = null;
     this.propDefault = null;
     base.Dispose(disposing);
 }
Ejemplo n.º 15
0
 internal DropDownHolder(PropertyGridView gridView) : base()
 {
     ShowInTaskbar   = false;
     ControlBox      = false;
     MinimizeBox     = false;
     MaximizeBox     = false;
     Text            = string.Empty;
     FormBorderStyle = FormBorderStyle.None;
     AutoScaleMode   = AutoScaleMode.None; // children may scale, but we won't interfere.
     _mouseHook      = new(this, this, gridView);
     Visible         = false;
     _gridView       = gridView;
     BackColor       = _gridView.BackColor;
 }
        internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType)
            : base(parent)
        {
            Debug.Assert(value != null, "Can't browse a null object!");
            this.host          = host;
            this.gridEntryHost = gridEntryHost;
            this.baseProvider  = baseProvider;
            this.tab           = tab;
            this.objValue      = value;

            this.IsExpandable = true;
            // default to categories
            this.PropertySort     = sortType;
            this.InternalExpanded = true;
        }
Ejemplo n.º 17
0
        internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType)
        : base(gridEntryHost.OwnerGrid, parent) {
            Debug.Assert(value != null,"Can't browse a null object!");
            this.host = host;
            this.gridEntryHost = gridEntryHost;
            this.baseProvider = baseProvider;
            this.tab = tab;
            this.objValue = value;
            this.objValueClassName = TypeDescriptor.GetClassName(this.objValue);

            this.IsExpandable = true;
            // default to categories
            this.PropertySort = sortType;
            this.InternalExpanded = true;
        }
        protected virtual void NotifyParentChange(GridEntry ge)
        {
            // now see if we need to notify the parent(s) up the chain
            while (ge != null &&
                   ge is PropertyDescriptorGridEntry &&
                   ((PropertyDescriptorGridEntry)ge).propertyInfo.Attributes.Contains(NotifyParentPropertyAttribute.Yes))
            {
                // find the next parent property with a differnet value owner
                object owner = ge.GetValueOwner();

                // Fix for Dev10 bug 584323:
                // when owner is an instance of a value type,
                // we can't just use == in the following while condition testing
                bool isValueType = owner.GetType().IsValueType;

                // find the next property descriptor with a different parent
                while (!(ge is PropertyDescriptorGridEntry) ||
                       isValueType ? owner.Equals(ge.GetValueOwner()) : owner == ge.GetValueOwner())
                {
                    ge = ge.ParentGridEntry;
                    if (ge == null)
                    {
                        break;
                    }
                }

                // fire the change on that owner
                if (ge != null)
                {
                    owner = ge.GetValueOwner();

                    IComponentChangeService changeService = ComponentChangeService;

                    if (changeService != null)
                    {
                        changeService.OnComponentChanging(owner, ((PropertyDescriptorGridEntry)ge).propertyInfo);
                        changeService.OnComponentChanged(owner, ((PropertyDescriptorGridEntry)ge).propertyInfo, null, null);
                    }

                    ge.ClearCachedValues(false); //clear the value so it paints correctly next time.
                    PropertyGridView gv = this.GridEntryHost;
                    if (gv != null)
                    {
                        gv.InvalidateGridEntryValue(ge);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType)
            : base(gridEntryHost.OwnerGrid, parent)
        {
            Debug.Assert(value is not null, "Can't browse a null object!");
            this.host          = host;
            this.gridEntryHost = gridEntryHost;
            this.baseProvider  = baseProvider;
            this.tab           = tab;
            objValue           = value;
            objValueClassName  = TypeDescriptor.GetClassName(objValue);

            IsExpandable = true;
            // default to categories
            PropertySort     = sortType;
            InternalExpanded = true;
        }
Ejemplo n.º 20
0
            private UiaCore.IRawElementProviderFragment GetFirstChild()
            {
                if (_owningPropertyDescriptorGridEntry is null)
                {
                    return(null);
                }

                if (_owningPropertyDescriptorGridEntry.ChildCount > 0)
                {
                    return(_owningPropertyDescriptorGridEntry.Children[0].AccessibilityObject);
                }

                PropertyGridView propertyGridView = GetPropertyGridView();

                if (propertyGridView is null)
                {
                    return(null);
                }

                GridEntry selectedGridEntry = propertyGridView.SelectedGridEntry;

                if (_owningPropertyDescriptorGridEntry == selectedGridEntry)
                {
                    if (selectedGridEntry.Enumerable &&
                        propertyGridView.DropDownVisible &&
                        propertyGridView.DropDownControlHolder?.Component == propertyGridView.DropDownListBox)
                    {
                        return(propertyGridView.DropDownListBoxAccessibleObject);
                    }

                    if (propertyGridView.DropDownVisible && propertyGridView.DropDownControlHolder is not null)
                    {
                        return(propertyGridView.DropDownControlHolder.AccessibilityObject);
                    }

                    if (propertyGridView.IsEditTextBoxCreated)
                    {
                        return(propertyGridView.EditAccessibleObject);
                    }
                }

                return(null);
            }
Ejemplo n.º 21
0
            private void ExpandOrCollapse()
            {
                if (!GetPropertyGridView().IsHandleCreated)
                {
                    return;
                }

                PropertyGridView propertyGridView = GetPropertyGridView();

                if (propertyGridView is null)
                {
                    return;
                }

                int row = propertyGridView.GetRowFromGridEntry(_owningPropertyDescriptorGridEntry);

                if (row != -1)
                {
                    propertyGridView.PopupDialog(row);
                }
            }
Ejemplo n.º 22
0
        internal SingleSelectRootGridEntry(
            PropertyGridView ownerGridView,
            object target,
            IServiceProvider baseProvider,
            IDesignerHost host,
            PropertyTab ownerTab,
            PropertySort sortType)
            : base(ownerGridView.OwnerGrid, parent: null)
        {
            Debug.Assert(target is not null, "Can't browse a null object!");
            _host           = host;
            _ownerGridView  = ownerGridView;
            _baseProvider   = baseProvider;
            _ownerTab       = ownerTab;
            Target          = target;
            _valueClassName = TypeDescriptor.GetClassName(Target);

            IsExpandable = true;

            // Default to categories.
            _propertySort    = sortType;
            InternalExpanded = true;
        }
Ejemplo n.º 23
0
            private UiaCore.IRawElementProviderFragment GetLastChild()
            {
                if (_owningPropertyDescriptorGridEntry is null)
                {
                    return(null);
                }

                if (_owningPropertyDescriptorGridEntry.ChildCount > 0)
                {
                    return(_owningPropertyDescriptorGridEntry.Children[_owningPropertyDescriptorGridEntry.ChildCount - 1].AccessibilityObject);
                }

                PropertyGridView propertyGridView = GetPropertyGridView();

                if (propertyGridView is null)
                {
                    return(null);
                }

                GridEntry selectedGridEntry = propertyGridView.SelectedGridEntry;

                if (_owningPropertyDescriptorGridEntry == selectedGridEntry)
                {
                    if (selectedGridEntry.Enumerable && propertyGridView.DropDownButton.Visible)
                    {
                        return(propertyGridView.DropDownButton.AccessibilityObject);
                    }

                    if (propertyGridView.IsEditTextBoxCreated)
                    {
                        return(propertyGridView.EditAccessibleObject);
                    }
                }

                return(null);
            }
Ejemplo n.º 24
0
		public PropertyGridListItemChildProvider (PropertyGridListItemProvider itemProvider,
		                                          PropertyGridView view)
			: base (null)
		{
			this.itemProvider = itemProvider;
			this.propertyGrid = itemProvider.PropertyGridViewProvider.PropertyGrid;
			this.view = view;
		}
Ejemplo n.º 25
0
		public PropertyGridListItemValueProvider (PropertyGridListItemProvider itemProvider,
		                                          PropertyGridView view)
			: base (itemProvider, view)
		{
		}
 public GridViewTextBox(PropertyGridView gridView)
 {
     PropertyGridView = gridView;
     _mouseHook       = new MouseHook(this, this, gridView);
 }
Ejemplo n.º 27
0
        public PropertyGrid()  {

            onComponentAdd = new ComponentEventHandler(OnComponentAdd);
            onComponentRemove = new ComponentEventHandler(OnComponentRemove);
            onComponentChanged = new ComponentChangedEventHandler(OnComponentChanged);

            SuspendLayout();
            AutoScaleMode = AutoScaleMode.None;

            if (!isScalingInitialized) {
                if (DpiHelper.IsScalingRequired) {
                    normalButtonSize = DpiHelper.LogicalToDeviceUnits(DEFAULT_NORMAL_BUTTON_SIZE);
                    largeButtonSize = DpiHelper.LogicalToDeviceUnits(DEFAULT_LARGE_BUTTON_SIZE);
                }
                isScalingInitialized = true;
            }
           
            try
            {
                gridView = CreateGridView(null);
                gridView.TabStop = true;
                gridView.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
                gridView.MouseDown += new MouseEventHandler(this.OnChildMouseDown);
                gridView.TabIndex = 2;

                separator1 = CreateSeparatorButton();
                separator2 = CreateSeparatorButton();

                toolStrip = new ToolStrip();
                toolStrip.SuspendLayout();
                toolStrip.ShowItemToolTips = true;
                toolStrip.AccessibleName = SR.GetString(SR.PropertyGridToolbarAccessibleName);
                toolStrip.AccessibleRole = AccessibleRole.ToolBar;
                toolStrip.TabStop = true;
                toolStrip.AllowMerge = false;

                // This caption is for testing.
                toolStrip.Text = "PropertyGridToolBar";

                // LayoutInternal handles positioning, and for perf reasons, we manually size.
                toolStrip.Dock = DockStyle.None;
                toolStrip.AutoSize = false;
                toolStrip.TabIndex = 1;
                toolStrip.ImageScalingSize = normalButtonSize;

                // parity with the old... 
                toolStrip.CanOverflow = false;


                // hide the grip but add in a few more pixels of padding.
                toolStrip.GripStyle = ToolStripGripStyle.Hidden;
                Padding toolStripPadding = toolStrip.Padding;
                toolStripPadding.Left = 2;
                toolStrip.Padding = toolStripPadding;
                SetToolStripRenderer();


                // always add the property tab here
                AddRefTab(DefaultTabType, null, PropertyTabScope.Static, true);

                doccomment = new DocComment(this);
                doccomment.SuspendLayout();
                doccomment.TabStop = false;
                doccomment.Dock = DockStyle.None;
                doccomment.BackColor = SystemColors.Control;
                doccomment.ForeColor = SystemColors.ControlText;
                doccomment.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
                doccomment.MouseDown += new MouseEventHandler(this.OnChildMouseDown);



                hotcommands = new HotCommands(this);
                hotcommands.SuspendLayout();
                hotcommands.TabIndex = 3;
                hotcommands.Dock = DockStyle.None;
                SetHotCommandColors(false);
                hotcommands.Visible = false;
                hotcommands.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
                hotcommands.MouseDown += new MouseEventHandler(this.OnChildMouseDown);
              
                Controls.AddRange(new Control[] { doccomment, hotcommands, gridView, toolStrip });

                SetActiveControlInternal(gridView);
                toolStrip.ResumeLayout(false);  // SetupToolbar should perform the layout
                SetupToolbar();
                this.PropertySort = PropertySort.Categorized | PropertySort.Alphabetical;
                this.Text = "PropertyGrid";
                SetSelectState(0);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally {
                if (doccomment != null) {
                    doccomment.ResumeLayout(false);
                }
                if (hotcommands != null) {
                    hotcommands.ResumeLayout(false);
                }
                ResumeLayout(true);
            }
        }
Ejemplo n.º 28
0
        /// <include file='doc\GridEntry.uex' path='docs/doc[@for="GridEntry.Create"]/*' />
        /// <devdoc>
        /// Create the base prop entries given an object or set of objects
        /// </devdoc>
        internal static IRootGridEntry Create(PropertyGridView view, object[] rgobjs, IServiceProvider baseProvider, IDesignerHost currentHost, PropertyTab tab, PropertySort initialSortType) {
            IRootGridEntry pe = null;

            if (rgobjs == null || rgobjs.Length == 0) {
                return null;
            }

            try
            {
                if (rgobjs.Length == 1)
                {
                    pe = new SingleSelectRootGridEntry(view, rgobjs[0], baseProvider, currentHost, tab, initialSortType);
                }
                else
                {
                    pe = new MultiSelectRootGridEntry(view, rgobjs, baseProvider, currentHost, tab, initialSortType);
                }
            }
            catch (Exception e)
            {
                //Debug.fail("Couldn't create a top-level GridEntry");
                Debug.Fail(e.ToString());
                throw;
            }
            return pe;
        }
 public GridViewEditAccessibleObject(GridViewEdit owner) : base(owner)
 {
     propertyGridView = owner.psheet;
 }
Ejemplo n.º 30
0
		public PropertyGrid ()
		{
			selected_objects = new object[0];
			property_tabs = new PropertyTabCollection(this);

			line_color = SystemColors.ScrollBar;
			category_fore_color = line_color;
			commands_visible = false;
			commands_visible_if_available = false;
			property_sort = PropertySort.CategorizedAlphabetical;
			property_grid_view = new PropertyGridView(this);

			splitter = new Splitter();
			splitter.Dock = DockStyle.Bottom;

			help_panel = new Panel();
			help_panel.Dock = DockStyle.Bottom;
			//help_panel.DockPadding.All = 3;
			help_panel.Height = 50;
			help_panel.BackColor = SystemColors.Control;


			help_title_label = new Label();
			help_title_label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
			help_title_label.Name = "help_title_label";
			help_title_label.Font = new Font(this.Font,FontStyle.Bold);
			help_title_label.Location = new Point(2,2);
			help_title_label.Height = 17;
			help_title_label.Width = help_panel.Width - 4;

			
			help_description_label = new Label();
			help_description_label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
			help_description_label.AutoEllipsis = true;
			help_description_label.AutoSize = false;
			help_description_label.Font = this.Font;
			help_description_label.Location = new Point(2,help_title_label.Top+help_title_label.Height);
			help_description_label.Width = help_panel.Width - 4;
			help_description_label.Height = help_panel.Height - help_description_label.Top - 2;

			help_panel.Controls.Add(help_description_label);
			help_panel.Controls.Add(help_title_label);
			help_panel.Paint+=new PaintEventHandler(help_panel_Paint);

			toolbar = new PropertyToolBar();
			toolbar.Dock = DockStyle.Top;
			categorized_toolbarbutton = new PropertyToolBarButton ();
			categorized_toolbarbutton.Pushed = true;
			alphabetic_toolbarbutton = new PropertyToolBarButton ();
			propertypages_toolbarbutton = new PropertyToolBarButton ();
			separator_toolbarbutton = new PropertyToolBarSeparator ();
			ContextMenu context_menu = new ContextMenu();
			context_menu_default_location = Point.Empty;

			categorized_image = new Bitmap (typeof (PropertyGrid), "propertygrid-categorized.png");
			alphabetical_image = new Bitmap (typeof (PropertyGrid), "propertygrid-alphabetical.png");
			propertypages_image = new Bitmap (typeof (PropertyGrid), "propertygrid-propertypages.png");

			toolbar_imagelist = new ImageList();
			toolbar_imagelist.ColorDepth = ColorDepth.Depth32Bit;
			toolbar_imagelist.ImageSize = new System.Drawing.Size(16, 16);
			toolbar_imagelist.TransparentColor = System.Drawing.Color.Transparent;

			toolbar.Appearance = ToolBarAppearance.Flat;
			toolbar.AutoSize = false;
			
			toolbar.ImageList = toolbar_imagelist;
			toolbar.Location = new System.Drawing.Point(0, 0);
			toolbar.ShowToolTips = true;
			toolbar.Size = new System.Drawing.Size(256, 27);
			toolbar.TabIndex = 0;

			toolbar.Items.AddRange (new ToolStripItem [] {categorized_toolbarbutton,
								      alphabetic_toolbarbutton,
								      new PropertyToolBarSeparator (),
								      propertypages_toolbarbutton});
			//toolbar.ButtonSize = new System.Drawing.Size (20, 20);
			categorized_toolbarbutton.Click += new EventHandler (toolbarbutton_clicked);
			alphabetic_toolbarbutton.Click += new EventHandler (toolbarbutton_clicked);
			propertypages_toolbarbutton.Click += new EventHandler (toolbarbutton_clicked);

			categorized_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
			categorized_toolbarbutton.ToolTipText = Locale.GetText ("Categorized");

			alphabetic_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
			alphabetic_toolbarbutton.ToolTipText = Locale.GetText ("Alphabetic");

			propertypages_toolbarbutton.Enabled = false;
			propertypages_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
			propertypages_toolbarbutton.ToolTipText = "Property Pages";

			properties_tab = CreatePropertyTab (this.DefaultTabType);
			selected_tab = properties_tab;
			RefreshToolbar (property_tabs);
			
			reset_menuitem = context_menu.MenuItems.Add("Reset");
			reset_menuitem.Click +=new EventHandler(OnResetPropertyClick);
			context_menu.MenuItems.Add("-");
			description_menuitem = context_menu.MenuItems.Add("Description");
			description_menuitem.Click += new EventHandler(OnDescriptionClick);
			description_menuitem.Checked = this.HelpVisible;
			this.ContextMenu = context_menu;
			toolbar.ContextMenu = context_menu;
			
			BorderHelperControl helper = new BorderHelperControl ();
			helper.Dock = DockStyle.Fill;
			helper.Controls.Add (property_grid_view);
			
			this.Controls.Add(helper);
			this.Controls.Add(toolbar);
			this.Controls.Add(splitter);
			this.Controls.Add(help_panel);
			this.Name = "PropertyGrid";
			this.Size = new System.Drawing.Size(256, 400);
		}
 public MouseHookObject(PropertyGridView.MouseHook parent)
 {
     this.reference = new WeakReference(parent, false);
 }
Ejemplo n.º 32
0
 internal MultiSelectRootGridEntry(PropertyGridView view, object obj, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType)
     : base(view, obj, baseProvider, host, tab, sortType)
 {
 }
 public MouseHook(Control control, PropertyGridView.IMouseHookClient client, PropertyGridView gridView)
 {
     this.control = control;
     this.gridView = gridView;
     this.client = client;
 }
 public GridViewListBox(PropertyGridView gridView)
 {
     base.IntegralHeight = false;
 }
 public GridEntry Restore(PropertyGridView gridView)
 {
     gridView.RestoreHierarchyState(this.expandedState);
     GridEntry gridEntry = gridView.FindEquivalentGridEntry(this.selectedItemTree);
     if (gridEntry != null)
     {
         gridView.SelectGridEntry(gridEntry, true);
         int cOffset = gridView.selectedRow - this.itemRow;
         if (((cOffset == 0) || !gridView.ScrollBar.Visible) || (this.itemRow >= gridView.visibleRows))
         {
             return gridEntry;
         }
         cOffset += gridView.GetScrollOffset();
         if (cOffset < 0)
         {
             cOffset = 0;
         }
         else if (cOffset > gridView.ScrollBar.Maximum)
         {
             cOffset = gridView.ScrollBar.Maximum - 1;
         }
         gridView.SetScrollOffset(cOffset);
     }
     return gridEntry;
 }
Ejemplo n.º 36
0
        /// <summary>
        ///     Navigates code to the given event.
        /// </summary>
        protected bool ViewEvent(object obj, string newHandler, EventDescriptor eventdesc, bool alwaysNavigate)
        {
            object value = GetPropertyValueCore(obj);

            string handler = value as string;

            if (handler == null && value != null && TypeConverter != null && TypeConverter.CanConvertTo(typeof(string)))
            {
                handler = TypeConverter.ConvertToString(value);
            }

            if (newHandler == null && !string.IsNullOrEmpty(handler))
            {
                newHandler = handler;
            }
            else if (handler == newHandler && !string.IsNullOrEmpty(newHandler))
            {
                return(true);
            }

            IComponent component = obj as IComponent;

            if (component == null && propertyInfo is MergePropertyDescriptor)
            {
                // It's possible that multiple objects are selected, and we're trying to create an event for each of them
                //
                Array objArray = obj as Array;
                if (objArray != null && objArray.Length > 0)
                {
                    component = objArray.GetValue(0) as IComponent;
                }
            }

            if (component == null)
            {
                return(false);
            }

            if (propertyInfo.IsReadOnly)
            {
                return(false);
            }

            if (eventdesc == null)
            {
                if (eventBindings == null)
                {
                    eventBindings = (IEventBindingService)GetService(typeof(IEventBindingService));
                }
                if (eventBindings != null)
                {
                    eventdesc = eventBindings.GetEvent(propertyInfo);
                }
            }

            IDesignerHost       host  = this.DesignerHost;
            DesignerTransaction trans = null;

            try {
                // This check can cause exceptions if the event has unreferenced dependencies, which we want to cath.
                // This must be done before the transaction is started or the commit/cancel will also throw.
                if (eventdesc.EventType == null)
                {
                    return(false);
                }

                if (host != null)
                {
                    string compName = component.Site != null ? component.Site.Name : component.GetType().Name;
                    trans = DesignerHost.CreateTransaction(string.Format(SR.WindowsFormsSetEvent, compName + "." + this.PropertyName));
                }

                if (eventBindings == null)
                {
                    ISite site = component.Site;
                    if (site != null)
                    {
                        eventBindings = (IEventBindingService)site.GetService(typeof(IEventBindingService));
                    }
                }

                if (newHandler == null && eventBindings != null)
                {
                    newHandler = eventBindings.CreateUniqueMethodName(component, eventdesc);
                }


                if (newHandler != null)
                {
                    // now walk through all the matching methods to see if this one exists.
                    // if it doesn't we'll wanna show code.
                    //
                    if (eventBindings != null)
                    {
                        bool methodExists = false;
                        foreach (string methodName in eventBindings.GetCompatibleMethods(eventdesc))
                        {
                            if (newHandler == methodName)
                            {
                                methodExists = true;
                                break;
                            }
                        }
                        if (!methodExists)
                        {
                            alwaysNavigate = true;
                        }
                    }

                    try {
                        propertyInfo.SetValue(obj, newHandler);
                    } catch (InvalidOperationException ex) {
                        if (trans != null)
                        {
                            trans.Cancel();
                            trans = null;
                        }

                        if (this.GridEntryHost != null && this.GridEntryHost is PropertyGridView)
                        {
                            PropertyGridView pgv = this.GridEntryHost as PropertyGridView;
                            pgv.ShowInvalidMessage(newHandler, obj, ex);
                        }

                        return(false);
                    }
                }

                if (alwaysNavigate && eventBindings != null)
                {
                    targetBindingService = eventBindings;
                    targetComponent      = component;
                    targetEventdesc      = eventdesc;
                    Application.Idle    += new EventHandler(PropertyDescriptorGridEntry.ShowCodeIdle);
                }
            }
            catch {
                if (trans != null)
                {
                    trans.Cancel();
                    trans = null;
                }
                throw;
            }
            finally {
                if (trans != null)
                {
                    trans.Commit();
                }
            }
            return(true);
        }
 internal static IRootGridEntry Create(PropertyGridView view, object[] rgobjs, IServiceProvider baseProvider, IDesignerHost currentHost, PropertyTab tab, System.Windows.Forms.PropertySort initialSortType)
 {
     IRootGridEntry entry = null;
     if ((rgobjs == null) || (rgobjs.Length == 0))
     {
         return null;
     }
     try
     {
         if (rgobjs.Length == 1)
         {
             return new SingleSelectRootGridEntry(view, rgobjs[0], baseProvider, currentHost, tab, initialSortType);
         }
         entry = new MultiSelectRootGridEntry(view, rgobjs, baseProvider, currentHost, tab, initialSortType);
     }
     catch (Exception)
     {
         throw;
     }
     return entry;
 }
 internal DropDownHolder(PropertyGridView psheet)
 {
     base.ShowInTaskbar = false;
     base.ControlBox = false;
     base.MinimizeBox = false;
     base.MaximizeBox = false;
     this.Text = "";
     base.FormBorderStyle = FormBorderStyle.None;
     base.AutoScaleMode = AutoScaleMode.None;
     this.mouseHook = new PropertyGridView.MouseHook(this, this, psheet);
     base.Visible = false;
     this.gridView = psheet;
     this.BackColor = this.gridView.BackColor;
 }
 internal virtual void EditPropertyValue(PropertyGridView iva)
 {
     if (this.UITypeEditor != null)
     {
         try
         {
             object propertyValue = this.PropertyValue;
             object obj3 = this.UITypeEditor.EditValue(this, this, propertyValue);
             if (!this.Disposed)
             {
                 if ((obj3 != propertyValue) && this.IsValueEditable)
                 {
                     iva.CommitValue(this, obj3);
                 }
                 if (this.InternalExpanded)
                 {
                     PropertyGridView.GridPositionData data = this.GridEntryHost.CaptureGridPositionData();
                     this.InternalExpanded = false;
                     this.RecreateChildren();
                     data.Restore(this.GridEntryHost);
                 }
                 else
                 {
                     this.RecreateChildren();
                 }
             }
         }
         catch (Exception exception)
         {
             IUIService service = (IUIService) this.GetService(typeof(IUIService));
             if (service != null)
             {
                 service.ShowError(exception);
             }
             else
             {
                 RTLAwareMessageBox.Show(this.GridEntryHost, exception.Message, System.Windows.Forms.SR.GetString("PBRSErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1, 0);
             }
         }
     }
 }
Ejemplo n.º 40
0
        /// <include file='doc\GridEntry.uex' path='docs/doc[@for="GridEntry.EditPropertyValue"]/*' />
        /// <devdoc>
        /// Invokes the type editor for editing this item.
        /// </devdoc>
        internal virtual void EditPropertyValue(PropertyGridView iva) {
            if (UITypeEditor != null) {
                try {
                    // this is another icky part.  since edit value can push a modal loop
                    // there is a chance that this gridentry will be zombied before
                    // it returns.  make sure we're not disposed.
                    //
                    object originalValue = this.PropertyValue;
                    object value = UITypeEditor.EditValue(this, (IServiceProvider)(ITypeDescriptorContext)this, originalValue);

                    if (Disposed) {
                        return;
                    }

                    // Push the new value back into the property
                    if (value != originalValue && this.IsValueEditable) {
                        iva.CommitValue(this, value);
                    }

                    if (this.InternalExpanded) {
                        // QFE#3299: If edited property is expanded to show sub-properties, then we want to
                        // preserve the expanded states of it and all of its descendants. RecreateChildren()
                        // has logic that is supposed to do this, but which is fundamentally flawed.
                        PropertyGridView.GridPositionData positionData = GridEntryHost.CaptureGridPositionData();
                        this.InternalExpanded = false;
                        RecreateChildren();
                        positionData.Restore(GridEntryHost);
                    }
                    else {
                        // If edited property has no children or is collapsed, don't need to preserve expanded states.
                        // This limits the scope of the above QFE fix to just those cases where it is actually required.
                        RecreateChildren();
                    }
                }
                catch (Exception e)
                {
                    IUIService uiSvc = (IUIService)GetService(typeof(IUIService));
                    if (uiSvc != null)
                    {
                        uiSvc.ShowError(e);
                    }
                    else
                    {
                        RTLAwareMessageBox.Show(GridEntryHost, e.Message, SR.GetString(SR.PBRSErrorTitle), MessageBoxButtons.OK,
                                MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
                    }
                }
            }
        }
Ejemplo n.º 41
0
 internal DropDownHolder(PropertyGridView psheet)
 : base() {
    this.ShowInTaskbar = false;
    this.ControlBox = false;
    this.MinimizeBox = false;
    this.MaximizeBox = false;
    this.Text = "";
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.AutoScaleMode = AutoScaleMode.None; // children may scale, but we won't interfere.
    mouseHook = new MouseHook(this, this, psheet);
    Visible = false;
    gridView = psheet;
    this.BackColor = gridView.BackColor;
 }
Ejemplo n.º 42
0
 public GridViewTextBoxAccessibleObject(GridViewTextBox owner) : base(owner)
 {
     _owningPropertyGridView = owner.PropertyGridView;
     _textProvider           = new TextBoxBaseUiaTextProvider(owner);
     UseTextProviders(_textProvider, _textProvider);
 }
Ejemplo n.º 43
0
 public GridViewListBox(PropertyGridView gridView) {
     base.IntegralHeight = false;
     base.BackColor = gridView.BackColor;
 }
Ejemplo n.º 44
0
		internal PropertyGridCategoryProvider (PropertyGridViewProvider prov, PropertyGridView grid, PGI.CategoryGridEntry entry)
			: base (prov, grid, entry)
		{
			this.entry = entry;
		}
Ejemplo n.º 45
0
 public GridViewEdit(PropertyGridView psheet) {
     this.psheet = psheet;
     mouseHook = new MouseHook(this, this, psheet);
 }
Ejemplo n.º 46
0
 protected override void Dispose(bool disposing) {
     if (disposing) {
         host = null;
         baseProvider = null;
         tab = null;
         gridEntryHost = null;
         changeService = null;
     }
     this.objValue = null;
     this.objValueClassName = null;
     this.propDefault = null;
     base.Dispose(disposing);
 }
Ejemplo n.º 47
0
 public MouseHook(Control control, IMouseHookClient client, PropertyGridView gridView) {
    this.control = control;
    this.gridView = gridView;
    this.client = client;
    #if DEBUG
    callingStack = Environment.StackTrace;
    #endif
 }       
Ejemplo n.º 48
0
 internal SingleSelectRootGridEntry(PropertyGridView view, object value, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : this(view, value,null, baseProvider, host, tab, sortType) {
 }   
Ejemplo n.º 49
0
 /// <include file='doc\PropertyGridView.uex' path='docs/doc[@for="PropertyGridView.PropertyGridViewAccessibleObject.PropertyGridViewAccessibleObject"]/*' />
 /// <devdoc>
 ///     Construct a PropertyGridViewAccessibleObject
 /// </devdoc>
 public PropertyGridViewAccessibleObject(PropertyGridView owner) : base(owner) {
 }
Ejemplo n.º 50
0
		public PropertyGridListItemProvider (PropertyGridViewProvider viewProvider,
		                                     PropertyGridView view,
		                                     GridEntry entry) 
			: base (viewProvider, viewProvider, view, entry)
		{
			this.viewProvider = viewProvider;
			this.view = view;
			this.entry = entry;

			this.viewProvider.ToString ();
		}
Ejemplo n.º 51
0
 public GridPositionData(PropertyGridView gridView) {
     selectedItemTree = gridView.GetGridEntryHierarchy(gridView.selectedGridEntry);
     expandedState = gridView.SaveHierarchyState(gridView.topLevelGridEntries);
     itemRow = gridView.selectedRow;
     itemCount = gridView.totalProps;
 }
 public GridPositionData(PropertyGridView gridView)
 {
     _selectedItemTree = GetGridEntryHierarchy(gridView._selectedGridEntry);
     _expandedState    = gridView.SaveHierarchyState(gridView.TopLevelGridEntries);
     _itemRow          = gridView._selectedRow;
 }
Ejemplo n.º 53
0
            public GridEntry Restore(PropertyGridView gridView) {
                    gridView.RestoreHierarchyState(expandedState);
                    GridEntry entry = gridView.FindEquivalentGridEntry(selectedItemTree);

                    if (entry != null) {
                        gridView.SelectGridEntry(entry, true);
                        
                        int delta = gridView.selectedRow - itemRow;
                        if (delta != 0 && gridView.ScrollBar.Visible) {
                            if (itemRow < gridView.visibleRows) {
                                delta += gridView.GetScrollOffset();
                                
                                if (delta < 0) {
                                    delta = 0;
                                }
                                else if (delta > gridView.ScrollBar.Maximum) {
                                    delta = gridView.ScrollBar.Maximum - 1;
                                }
                                gridView.SetScrollOffset(delta);
                            }
                            
                        }
                    }
                    return entry;
            }
 internal MultiSelectRootGridEntry(PropertyGridView view, object obj, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(view, obj, baseProvider, host, tab, sortType)
 {
 }
 public GridViewTextBoxAccessibleObject(GridViewTextBox owner) : base(owner)
 {
     _owningPropertyGridView = owner.PropertyGridView;
 }
Ejemplo n.º 56
0
 /// <summary>
 ///  Construct a PropertyGridViewAccessibleObject
 /// </summary>
 public PropertyGridViewAccessibleObject(PropertyGridView owner, PropertyGrid parentPropertyGrid) : base(owner)
 {
     _owningPropertyGridView = owner;
     _parentPropertyGrid     = parentPropertyGrid;
 }
Ejemplo n.º 57
0
 /// <include file='doc\PropertyDescriptorGridEntry.uex' path='docs/doc[@for="PropertyDescriptorGridEntry.EditPropertyValue"]/*' />
 /// <devdoc>
 /// Invokes the type editor for editing this item.
 /// </devdoc>
 internal override void EditPropertyValue(PropertyGridView iva) {            
     base.EditPropertyValue(iva);
     
     if (!IsValueEditable) {
        RefreshPropertiesAttribute refreshAttr = (RefreshPropertiesAttribute)propertyInfo.Attributes[typeof(RefreshPropertiesAttribute)];
        if ((refreshAttr != null && !refreshAttr.RefreshProperties.Equals(RefreshProperties.None))) {
              this.GridEntryHost.Refresh(refreshAttr != null && refreshAttr.Equals(RefreshPropertiesAttribute.All));
        }
     }
 }