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) {
            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;
        }
 private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry)
 {
     PropertyDescriptorCollection[] descriptorsArray = new PropertyDescriptorCollection[objs.Length];
     Attribute[] array = new Attribute[parentEntry.BrowsableAttributes.Count];
     parentEntry.BrowsableAttributes.CopyTo(array, 0);
     for (int i = 0; i < objs.Length; i++)
     {
         PropertyDescriptorCollection descriptors = tab.GetProperties(parentEntry, objs[i], array);
         if (presort)
         {
             descriptors = descriptors.Sort(MultiSelectRootGridEntry.PropertyComparer);
         }
         descriptorsArray[i] = descriptors;
     }
     ArrayList list = new ArrayList();
     PropertyDescriptor[] descriptorArray = new PropertyDescriptor[objs.Length];
     int[] numArray = new int[descriptorsArray.Length];
     for (int j = 0; j < descriptorsArray[0].Count; j++)
     {
         PropertyDescriptor descriptor = descriptorsArray[0][j];
         bool flag = descriptor.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute();
         for (int k = 1; flag && (k < descriptorsArray.Length); k++)
         {
             if (numArray[k] >= descriptorsArray[k].Count)
             {
                 flag = false;
                 break;
             }
             PropertyDescriptor descriptor2 = descriptorsArray[k][numArray[k]];
             if (descriptor.Equals(descriptor2))
             {
                 numArray[k]++;
                 if (!descriptor2.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute())
                 {
                     flag = false;
                     break;
                 }
                 descriptorArray[k] = descriptor2;
                 continue;
             }
             int num4 = numArray[k];
             descriptor2 = descriptorsArray[k][num4];
             flag = false;
             while (MultiSelectRootGridEntry.PropertyComparer.Compare(descriptor2, descriptor) <= 0)
             {
                 if (descriptor.Equals(descriptor2))
                 {
                     if (!descriptor2.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute())
                     {
                         flag = false;
                         num4++;
                     }
                     else
                     {
                         flag = true;
                         descriptorArray[k] = descriptor2;
                         numArray[k] = num4 + 1;
                     }
                     break;
                 }
                 num4++;
                 if (num4 >= descriptorsArray[k].Count)
                 {
                     break;
                 }
                 descriptor2 = descriptorsArray[k][num4];
             }
             if (!flag)
             {
                 numArray[k] = num4;
                 break;
             }
         }
         if (flag)
         {
             descriptorArray[0] = descriptor;
             list.Add(descriptorArray.Clone());
         }
     }
     return list;
 }
 internal MultiSelectRootGridEntry(PropertyGridView view, object obj, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(view, obj, baseProvider, host, tab, sortType)
 {
 }
 internal void RemoveTab(int tabIndex, bool setupToolbar)
 {
     if ((tabIndex >= this.viewTabs.Length) || (tabIndex < 0))
     {
         throw new ArgumentOutOfRangeException("tabIndex", System.Windows.Forms.SR.GetString("PropertyGridBadTabIndex"));
     }
     if (this.viewTabScopes[tabIndex] == PropertyTabScope.Static)
     {
         throw new ArgumentException(System.Windows.Forms.SR.GetString("PropertyGridRemoveStaticTabs"));
     }
     if (this.selectedViewTab == tabIndex)
     {
         this.selectedViewTab = 0;
     }
     if (!this.GetFlag(0x20) && (this.ActiveDesigner != null))
     {
         int hashCode = this.ActiveDesigner.GetHashCode();
         if (((this.designerSelections != null) && this.designerSelections.ContainsKey(hashCode)) && (((int) this.designerSelections[hashCode]) == tabIndex))
         {
             this.designerSelections.Remove(hashCode);
         }
     }
     ToolStripButton button = this.viewTabButtons[this.selectedViewTab];
     PropertyTab[] destinationArray = new PropertyTab[this.viewTabs.Length - 1];
     Array.Copy(this.viewTabs, 0, destinationArray, 0, tabIndex);
     Array.Copy(this.viewTabs, tabIndex + 1, destinationArray, tabIndex, (this.viewTabs.Length - tabIndex) - 1);
     this.viewTabs = destinationArray;
     PropertyTabScope[] scopeArray = new PropertyTabScope[this.viewTabScopes.Length - 1];
     Array.Copy(this.viewTabScopes, 0, scopeArray, 0, tabIndex);
     Array.Copy(this.viewTabScopes, tabIndex + 1, scopeArray, tabIndex, (this.viewTabScopes.Length - tabIndex) - 1);
     this.viewTabScopes = scopeArray;
     this.viewTabsDirty = true;
     if (setupToolbar)
     {
         this.SetupToolbar();
         this.selectedViewTab = -1;
         this.SelectViewTabButtonDefault(button);
     }
 }
Beispiel #6
0
        void toolbarClick(object sender, EventArgs e)
        {
            if (sender == alphButton)
            PropertySort = System.Windows.Forms.PropertySort.Alphabetical;
            else if (sender == catButton)
            PropertySort = System.Windows.Forms.PropertySort.Categorized;
            else {
            int index = toolbar.GetItemIndex ((RadioToolButton) sender) - FirstTabIndex;

            PropertyTab tab = (PropertyTab) propertyTabs[index];
            if (selectedTab == tab) return;

            selectedTab = tab;
            Populate ();
            }
        }
        internal void AddRefTab(Type tabType, Object component, PropertyTabScope type, bool setupToolbar) {
            PropertyTab tab = null;
            int tabIndex = -1;

            if (viewTabs != null) {
                // check to see if we've already got a tab of this type
                for (int i = 0; i < viewTabs.Length; i++) {
                    Debug.Assert(viewTabs[i] != null, "Null item in tab array!");
                    if (tabType == viewTabs[i].GetType()) {
                        tab = viewTabs[i];
                        tabIndex = i;
                        break;
                    }
                }
            }
            else {
                tabIndex = 0;
            }

            if (tab == null) {
                // the tabs need service providers. The one we hold onto is not good enough,
                // so try to get the one off of the component's site.
                IDesignerHost host = null;
                if (component != null && component is IComponent && ((IComponent) component).Site != null)
                    host = (IDesignerHost) ((IComponent) component).Site.GetService(typeof(IDesignerHost));

                try
                {
                    tab = CreateTab(tabType, host);
                }
                catch (Exception e)
                {
                    Debug.Fail("Bad Tab.  We're not going to show it. ", e.ToString());
                    return;
                }

                // add it at the end of the array
                if (viewTabs != null) {
                    tabIndex = viewTabs.Length;

                    // find the insertion position...special case for event's and properties
                    if (tabType == DefaultTabType) {
                        tabIndex = PROPERTIES;
                    }
                    else if (typeof(EventsTab).IsAssignableFrom(tabType)) {
                        tabIndex = EVENTS;
                    }
                    else {
                        // order tabs alphabetically, we've always got a property tab, so
                        // start after that
                        for (int i = 1; i < viewTabs.Length; i++) {

                            // skip the event tab
                            if (viewTabs[i] is EventsTab) {
                                continue;
                            }

                            if (String.Compare(tab.TabName, viewTabs[i].TabName, false, CultureInfo.InvariantCulture) < 0) {
                                tabIndex = i;
                                break;
                            }
                        }
                    }
                }

                // now add the tab to the tabs array
                PropertyTab[] newTabs = new PropertyTab[viewTabs.Length + 1];
                Array.Copy(viewTabs, 0, newTabs, 0, tabIndex);
                Array.Copy(viewTabs, tabIndex, newTabs, tabIndex + 1, viewTabs.Length - tabIndex);
                newTabs[tabIndex] = tab;
                viewTabs = newTabs;

                viewTabsDirty = true;

                PropertyTabScope[] newTabScopes = new PropertyTabScope[viewTabScopes.Length + 1];
                Array.Copy(viewTabScopes, 0, newTabScopes, 0, tabIndex);
                Array.Copy(viewTabScopes, tabIndex, newTabScopes, tabIndex + 1, viewTabScopes.Length - tabIndex);
                newTabScopes[tabIndex] = type;
                viewTabScopes = newTabScopes;

                Debug.Assert(viewTabs != null, "Tab array destroyed!");
            }

            if (tab != null && component != null) {
                try {
                    Object[] tabComps = tab.Components;
                    int oldArraySize = tabComps == null ? 0 : tabComps.Length;

                    Object[] newComps = new Object[oldArraySize + 1];
                    if (oldArraySize > 0) {
                        Array.Copy(tabComps, newComps, oldArraySize);
                    }
                    newComps[oldArraySize] = component;
                    tab.Components = newComps;
                }
                catch (Exception e) {
                    Debug.Fail("Bad tab. We're going to remove it.", e.ToString());
                    RemoveTab(tabIndex, false);
                }
            }

            if (setupToolbar) {
                SetupToolbar();
                ShowEventsButton(false);
            }
        }        
        internal void RemoveTab(int tabIndex, bool setupToolbar) {
            Debug.Assert(viewTabs != null, "Tab array destroyed!");

            if (tabIndex >= viewTabs.Length || tabIndex < 0) {
                throw new ArgumentOutOfRangeException("tabIndex", SR.GetString(SR.PropertyGridBadTabIndex));
            }

            if (viewTabScopes[tabIndex] == PropertyTabScope.Static) {
                throw new ArgumentException(SR.GetString(SR.PropertyGridRemoveStaticTabs));
            }


            if (selectedViewTab == tabIndex) {
                selectedViewTab = PROPERTIES;
            }
            
            // Remove this tab from our "last selected" group
            //
            if (!GetFlag(ReInitTab) && ActiveDesigner != null) {
               int hashCode = ActiveDesigner.GetHashCode();
               if (designerSelections != null && designerSelections.ContainsKey(hashCode) && (int)designerSelections[hashCode] == tabIndex) {
                  designerSelections.Remove(hashCode);
               }
            }

            ToolStripButton selectedButton = viewTabButtons[selectedViewTab];

            PropertyTab[] newTabs = new PropertyTab[viewTabs.Length - 1];
            Array.Copy(viewTabs, 0, newTabs, 0, tabIndex);
            Array.Copy(viewTabs, tabIndex + 1, newTabs, tabIndex, viewTabs.Length - tabIndex - 1);
            viewTabs = newTabs;

            PropertyTabScope[] newTabScopes = new PropertyTabScope[viewTabScopes.Length - 1];
            Array.Copy(viewTabScopes, 0, newTabScopes, 0, tabIndex);
            Array.Copy(viewTabScopes, tabIndex + 1, newTabScopes, tabIndex, viewTabScopes.Length - tabIndex - 1);
            viewTabScopes = newTabScopes;

            viewTabsDirty = true;

            if (setupToolbar) {
                SetupToolbar();
                selectedViewTab = -1;
                SelectViewTabButtonDefault(selectedButton);
            }
        }
Beispiel #9
0
			public PropertyToolBarButton (PropertyTab propertyTab)
			{
				if (propertyTab == null)
					throw new ArgumentNullException ("propertyTab");
				property_tab = propertyTab;
			}
Beispiel #10
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;
        }
Beispiel #11
0
			internal void InsertTab (int index, PropertyTab propertyTab, PropertyTabScope tabScope)
			{
				if (propertyTab == null)
					throw new ArgumentNullException ("propertyTab");
				
				if (!this.Contains (propertyTab.GetType ())) {
					property_tabs.Insert (index, propertyTab);
					property_tabs_scopes.Insert (index, tabScope);
				}
			}
Beispiel #12
0
		private GridEntry GetDefaultPropertyItem (GridEntry rootItem, PropertyTab propertyTab)
		{
			if (rootItem == null || rootItem.GridItems.Count == 0 || propertyTab == null)
				return null;
			object[] propertyOwners = rootItem.Values;
			if (propertyOwners == null || propertyOwners.Length == 0 || propertyOwners[0] == null)
				return null;

			GridItem defaultSelected = null;
			if (propertyOwners.Length > 1)
				defaultSelected = rootItem.GridItems[0];
			else {
				PropertyDescriptor defaultProperty = propertyTab.GetDefaultProperty (propertyOwners[0]);
				if (defaultProperty != null)
					defaultSelected = FindItem (defaultProperty.Name, rootItem);
				if (defaultSelected == null)
					defaultSelected = FindFirstPropertyItem (rootItem);
			}

			return defaultSelected as GridEntry;
		}
Beispiel #13
0
			internal PropertyTabScope GetTabScope (PropertyTab tab)
			{
				if (tab == null)
					throw new ArgumentNullException ("tab");

				int index = property_tabs.IndexOf (tab);
				if (index != -1)
					return (PropertyTabScope)property_tabs_scopes[index];
				return PropertyTabScope.Global;
			}
 internal void AddRefTab(System.Type tabType, object component, PropertyTabScope type, bool setupToolbar)
 {
     PropertyTab tab = null;
     int length = -1;
     if (this.viewTabs != null)
     {
         for (int i = 0; i < this.viewTabs.Length; i++)
         {
             if (tabType == this.viewTabs[i].GetType())
             {
                 tab = this.viewTabs[i];
                 length = i;
                 break;
             }
         }
     }
     else
     {
         length = 0;
     }
     if (tab == null)
     {
         IDesignerHost service = null;
         if (((component != null) && (component is IComponent)) && (((IComponent) component).Site != null))
         {
             service = (IDesignerHost) ((IComponent) component).Site.GetService(typeof(IDesignerHost));
         }
         try
         {
             tab = this.CreateTab(tabType, service);
         }
         catch (Exception)
         {
             return;
         }
         if (this.viewTabs != null)
         {
             length = this.viewTabs.Length;
             if (tabType == this.DefaultTabType)
             {
                 length = 0;
             }
             else if (typeof(EventsTab).IsAssignableFrom(tabType))
             {
                 length = 1;
             }
             else
             {
                 for (int j = 1; j < this.viewTabs.Length; j++)
                 {
                     if (!(this.viewTabs[j] is EventsTab) && (string.Compare(tab.TabName, this.viewTabs[j].TabName, false, CultureInfo.InvariantCulture) < 0))
                     {
                         length = j;
                         break;
                     }
                 }
             }
         }
         PropertyTab[] destinationArray = new PropertyTab[this.viewTabs.Length + 1];
         Array.Copy(this.viewTabs, 0, destinationArray, 0, length);
         Array.Copy(this.viewTabs, length, destinationArray, length + 1, this.viewTabs.Length - length);
         destinationArray[length] = tab;
         this.viewTabs = destinationArray;
         this.viewTabsDirty = true;
         PropertyTabScope[] scopeArray = new PropertyTabScope[this.viewTabScopes.Length + 1];
         Array.Copy(this.viewTabScopes, 0, scopeArray, 0, length);
         Array.Copy(this.viewTabScopes, length, scopeArray, length + 1, this.viewTabScopes.Length - length);
         scopeArray[length] = type;
         this.viewTabScopes = scopeArray;
     }
     if ((tab != null) && (component != null))
     {
         try
         {
             object[] components = tab.Components;
             int num4 = (components == null) ? 0 : components.Length;
             object[] objArray2 = new object[num4 + 1];
             if (num4 > 0)
             {
                 Array.Copy(components, objArray2, num4);
             }
             objArray2[num4] = component;
             tab.Components = objArray2;
         }
         catch (Exception)
         {
             this.RemoveTab(length, false);
         }
     }
     if (setupToolbar)
     {
         this.SetupToolbar();
         this.ShowEventsButton(false);
     }
 }
 internal void RemoveTabs(PropertyTabScope classification, bool setupToolbar)
 {
     if (classification == PropertyTabScope.Static)
     {
         throw new ArgumentException(System.Windows.Forms.SR.GetString("PropertyGridRemoveStaticTabs"));
     }
     if (((this.viewTabButtons != null) && (this.viewTabs != null)) && (this.viewTabScopes != null))
     {
         ToolStripButton button = ((this.selectedViewTab >= 0) && (this.selectedViewTab < this.viewTabButtons.Length)) ? this.viewTabButtons[this.selectedViewTab] : null;
         for (int i = this.viewTabs.Length - 1; i >= 0; i--)
         {
             if (this.viewTabScopes[i] >= classification)
             {
                 if (this.selectedViewTab == i)
                 {
                     this.selectedViewTab = -1;
                 }
                 else if (this.selectedViewTab > i)
                 {
                     this.selectedViewTab--;
                 }
                 PropertyTab[] destinationArray = new PropertyTab[this.viewTabs.Length - 1];
                 Array.Copy(this.viewTabs, 0, destinationArray, 0, i);
                 Array.Copy(this.viewTabs, i + 1, destinationArray, i, (this.viewTabs.Length - i) - 1);
                 this.viewTabs = destinationArray;
                 PropertyTabScope[] scopeArray = new PropertyTabScope[this.viewTabScopes.Length - 1];
                 Array.Copy(this.viewTabScopes, 0, scopeArray, 0, i);
                 Array.Copy(this.viewTabScopes, i + 1, scopeArray, i, (this.viewTabScopes.Length - i) - 1);
                 this.viewTabScopes = scopeArray;
                 this.viewTabsDirty = true;
             }
         }
         if (setupToolbar && this.viewTabsDirty)
         {
             this.SetupToolbar();
             this.selectedViewTab = -1;
             this.SelectViewTabButtonDefault(button);
             for (int j = 0; j < this.viewTabs.Length; j++)
             {
                 this.viewTabs[j].Components = new object[0];
             }
         }
     }
 }
 public static MultiPropertyDescriptorGridEntry[] GetMergedProperties(object[] rgobjs, GridEntry parentEntry, PropertySort sort, PropertyTab tab)
 {
     MultiPropertyDescriptorGridEntry[] entryArray = null;
     try
     {
         int length = rgobjs.Length;
         if ((sort & PropertySort.Alphabetical) != PropertySort.NoSort)
         {
             ArrayList list = GetCommonProperties(rgobjs, true, tab, parentEntry);
             MultiPropertyDescriptorGridEntry[] entryArray2 = new MultiPropertyDescriptorGridEntry[list.Count];
             for (int k = 0; k < entryArray2.Length; k++)
             {
                 entryArray2[k] = new MultiPropertyDescriptorGridEntry(parentEntry.OwnerGrid, parentEntry, rgobjs, (PropertyDescriptor[]) list[k], false);
             }
             return SortParenEntries(entryArray2);
         }
         object[] destinationArray = new object[length - 1];
         Array.Copy(rgobjs, 1, destinationArray, 0, length - 1);
         ArrayList sortedMergedEntries = GetCommonProperties(destinationArray, true, tab, parentEntry);
         ArrayList list3 = GetCommonProperties(new object[] { rgobjs[0] }, false, tab, parentEntry);
         PropertyDescriptor[] baseEntries = new PropertyDescriptor[list3.Count];
         for (int i = 0; i < list3.Count; i++)
         {
             baseEntries[i] = ((PropertyDescriptor[]) list3[i])[0];
         }
         sortedMergedEntries = UnsortedMerge(baseEntries, sortedMergedEntries);
         MultiPropertyDescriptorGridEntry[] entries = new MultiPropertyDescriptorGridEntry[sortedMergedEntries.Count];
         for (int j = 0; j < entries.Length; j++)
         {
             entries[j] = new MultiPropertyDescriptorGridEntry(parentEntry.OwnerGrid, parentEntry, rgobjs, (PropertyDescriptor[]) sortedMergedEntries[j], false);
         }
         entryArray = SortParenEntries(entries);
     }
     catch
     {
     }
     return entryArray;
 }
Beispiel #17
0
		private void SelectPropertyTab (PropertyTab propertyTab)
		{
			if (propertyTab != null && selected_tab != propertyTab) {
				foreach (object toolbarItem in toolbar.Items) {
					PropertyToolBarButton button = toolbarItem as PropertyToolBarButton;
					if (button != null && button.PropertyTab != null) {
						if (button.PropertyTab == selected_tab)
							button.Pushed = false;
						else if (button.PropertyTab == propertyTab)
							button.Pushed = true;
					}
				}
				selected_tab = propertyTab;
				PopulateGrid (selected_objects);
				SelectItemCore (null, GetDefaultPropertyItem (root_grid_item, selected_tab));
				property_grid_view.UpdateView ();
			}
		}
 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;
 }
Beispiel #19
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 PropertyTabChangedEventArgs(PropertyTab oldTab, PropertyTab newTab)
 {
     this.oldTab = oldTab;
     this.newTab = newTab;
 }
 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);
 }
        // removes all the tabs with a classification greater than or equal to the specified classification.
        // for example, removing PropertyTabScope.Document will remove PropertyTabScope.Document and PropertyTabScope.Component tabs
        internal void RemoveTabs(PropertyTabScope classification, bool setupToolbar) {
            if (classification == PropertyTabScope.Static) {
                throw new ArgumentException(SR.GetString(SR.PropertyGridRemoveStaticTabs));
            }
            
            // in case we've been disposed
            if (viewTabButtons == null || viewTabs == null || viewTabScopes == null) {
                return;
            }

            ToolStripButton selectedButton = (selectedViewTab >=0 && selectedViewTab < viewTabButtons.Length ? viewTabButtons[selectedViewTab] : null);

            for (int i = viewTabs.Length-1; i >= 0; i--) {
                if (viewTabScopes[i] >= classification) {

                    // adjust the selected view tab because we're deleting.
                    if (selectedViewTab == i) {
                        selectedViewTab = -1;
                    }
                    else if (selectedViewTab > i) {
                        selectedViewTab--;
                    }
                    
                    PropertyTab[] newTabs = new PropertyTab[viewTabs.Length - 1];
                    Array.Copy(viewTabs, 0, newTabs, 0, i);
                    Array.Copy(viewTabs, i + 1, newTabs, i, viewTabs.Length - i - 1);
                    viewTabs = newTabs;

                    PropertyTabScope[] newTabScopes = new PropertyTabScope[viewTabScopes.Length - 1];
                    Array.Copy(viewTabScopes, 0, newTabScopes, 0, i);
                    Array.Copy(viewTabScopes, i + 1, newTabScopes, i, viewTabScopes.Length - i - 1);
                    viewTabScopes = newTabScopes;

                    viewTabsDirty = true;
                }
            }

            if (setupToolbar && viewTabsDirty) {
                SetupToolbar();

                Debug.Assert(viewTabs != null && viewTabs.Length > 0, "Holy Moly!  We don't have any tabs left!");

                selectedViewTab = -1;
                SelectViewTabButtonDefault(selectedButton);

                // clear the component refs of the tabs
                for (int i = 0; i < viewTabs.Length; i++) {
                    viewTabs[i].Components = new Object[0];
                }
            }
        }
 internal SingleSelectRootGridEntry(PropertyGridView view, object value, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : this(view, value,null, baseProvider, host, tab, sortType) {
 }   
        internal void RemoveTab(Type tabType) {
            PropertyTab tab = null;
            int tabIndex = -1;
            for (int i = 0; i < viewTabs.Length; i++) {
                if (tabType == viewTabs[i].GetType()) {
                    tab = viewTabs[i];
                    tabIndex = i;
                    break;
                }
            }

            // just quit if the tab isn't present.
            if (tabIndex == -1) {
                return;
            }

            PropertyTab[] newTabs = new PropertyTab[viewTabs.Length - 1];
            Array.Copy(viewTabs, 0, newTabs, 0, tabIndex);
            Array.Copy(viewTabs, tabIndex + 1, newTabs, tabIndex, viewTabs.Length - tabIndex - 1);
            viewTabs = newTabs;

            PropertyTabScope[] newTabScopes = new PropertyTabScope[viewTabScopes.Length - 1];
            Array.Copy(viewTabScopes, 0, newTabScopes, 0, tabIndex);
            Array.Copy(viewTabScopes, tabIndex + 1, newTabScopes, tabIndex, viewTabScopes.Length - tabIndex - 1);
            viewTabScopes = newTabScopes;
            
            viewTabsDirty = true;
            SetupToolbar();
        }
 internal void RemoveTab(System.Type tabType)
 {
     int length = -1;
     for (int i = 0; i < this.viewTabs.Length; i++)
     {
         if (tabType == this.viewTabs[i].GetType())
         {
             PropertyTab tab1 = this.viewTabs[i];
             length = i;
             break;
         }
     }
     if (length != -1)
     {
         PropertyTab[] destinationArray = new PropertyTab[this.viewTabs.Length - 1];
         Array.Copy(this.viewTabs, 0, destinationArray, 0, length);
         Array.Copy(this.viewTabs, length + 1, destinationArray, length, (this.viewTabs.Length - length) - 1);
         this.viewTabs = destinationArray;
         PropertyTabScope[] scopeArray = new PropertyTabScope[this.viewTabScopes.Length - 1];
         Array.Copy(this.viewTabScopes, 0, scopeArray, 0, length);
         Array.Copy(this.viewTabScopes, length + 1, scopeArray, length, (this.viewTabScopes.Length - length) - 1);
         this.viewTabScopes = scopeArray;
         this.viewTabsDirty = true;
         this.SetupToolbar();
     }
 }
         // this returns an array list of the propertydescriptor arrays, one for each
         // component
         //
         private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry) {
             PropertyDescriptorCollection[] propCollections = new PropertyDescriptorCollection[objs.Length];
 
             Attribute[] attrs = new Attribute[parentEntry.BrowsableAttributes.Count];
             parentEntry.BrowsableAttributes.CopyTo(attrs, 0);
             
             for (int i = 0; i < objs.Length; i++) {
                 PropertyDescriptorCollection pdc = tab.GetProperties(parentEntry, objs[i], attrs);
                 if (presort) {
                     pdc = pdc.Sort(PropertyComparer);
                 }
                 propCollections[i] = pdc;
             }
             
             ArrayList mergedList = new ArrayList();
             PropertyDescriptor[] matchArray = new PropertyDescriptor[objs.Length];
 
            // 
            // Merge the property descriptors
            //
            int[] posArray = new int[propCollections.Length];
            for (int i = 0; i < propCollections[0].Count; i++) {
                PropertyDescriptor pivotDesc = propCollections[0][i];
                
                bool match = pivotDesc.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute();
                     
                for (int j = 1; match && j < propCollections.Length; j++) {
     
                    if (posArray[j] >= propCollections[j].Count) {
                        match = false;
                        break;
                    }
     
                    // check to see if we're on a match
                    //
                    PropertyDescriptor jProp = propCollections[j][posArray[j]];
                    if (pivotDesc.Equals(jProp)) {
                        posArray[j] += 1;
                        
                        if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) {
                             match = false;
                             break;
                        }
                        matchArray[j] = jProp;
                        continue;
                    }
                    
                    int jPos = posArray[j];
                    jProp = propCollections[j][jPos];
 
                    match = false;
     
                    // if we aren't on a match, check all the items until we're past
                    // where the matching item would be
                    while (PropertyComparer.Compare(jProp, pivotDesc) <= 0) {
     
                        // got a match!
                        if (pivotDesc.Equals(jProp)) {
 
                            if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) {
                               match = false;
                               jPos++;
                            }
                            else {
                               match = true;
                               matchArray[j] = jProp;
                               posArray[j] = jPos + 1;
                            }
                            break;
                        }
     
                        // try again
                        jPos++;
                        if (jPos < propCollections[j].Count) {
                            jProp = propCollections[j][jPos];
                        }
                        else {
                            break;
                        }
                    }
     
                    // if we got here, there is no match, quit for this guy
                    if (!match) {
                         posArray[j] = jPos;
                         break;
                    }
                }
     
                // do we have a match?
                if (match) {
                    matchArray[0] = pivotDesc;
                    mergedList.Add(matchArray.Clone());
                }
            }
 
            return mergedList;
         }
             public static MultiPropertyDescriptorGridEntry[] GetMergedProperties(object[] rgobjs, GridEntry parentEntry, PropertySort sort, PropertyTab tab) {

                MultiPropertyDescriptorGridEntry[] result = null;
                try {
                    int cLength = rgobjs.Length;
                    object[] rgobjArgs = new object[1];
                    
                    if((sort & PropertySort.Alphabetical) != 0) {
                        ArrayList props = GetCommonProperties(rgobjs, true, tab, parentEntry);
                        
                        MultiPropertyDescriptorGridEntry[] entries = new MultiPropertyDescriptorGridEntry[props.Count];
                        for (int i=0; i < entries.Length; i++) {
                            entries[i] = new MultiPropertyDescriptorGridEntry(parentEntry.OwnerGrid, parentEntry, rgobjs, (PropertyDescriptor[])props[i], false);
                        }
    
                        result = SortParenEntries(entries);
                    }
                    else {
                        object[] sortObjs = new object[cLength - 1];
                        Array.Copy(rgobjs, 1, sortObjs, 0, cLength - 1);
    
                        ArrayList props = GetCommonProperties(sortObjs, true, tab, parentEntry);
    
                        // this'll work for just one as well
                        ArrayList firstProps = GetCommonProperties(new object[]{rgobjs[0]}, false, tab, parentEntry);
    
                        PropertyDescriptor[] firstPds = new PropertyDescriptor[firstProps.Count];
                        for (int i = 0; i < firstProps.Count; i++) {
                            firstPds[i] = ((PropertyDescriptor[])firstProps[i])[0];
                        }
                        
                        props = UnsortedMerge(firstPds, props);
                        
                        MultiPropertyDescriptorGridEntry[] entries = new MultiPropertyDescriptorGridEntry[props.Count];
                        
                        for (int i=0; i < entries.Length; i++) {
                            entries[i] = new MultiPropertyDescriptorGridEntry(parentEntry.OwnerGrid, parentEntry, rgobjs, (PropertyDescriptor[])props[i], false);
                        }
    
                        result = SortParenEntries(entries);
                    }
                }
                catch {
                }
    
                return result;
    
            }
		public PropertyTabChangedEventArgs ( PropertyTab oldTab , PropertyTab newTab )
		{
			old_tab = oldTab;
			new_tab = newTab;
		}
Beispiel #29
0
        private void AddPropertyTab(PropertyTab tab)
        {
            RadioToolButton rtb;
            if (propertyTabs.Count == 0) {
            selectedTab = tab;
            rtb = new RadioToolButton (new GLib.SList (IntPtr.Zero), Stock.MissingImage);
            rtb.Active = true;
            }
            else
            rtb = new RadioToolButton ((RadioToolButton) toolbar.GetNthItem (propertyTabs.Count + FirstTabIndex - 1));

            //load image from PropertyTab's bitmap
            if (tab.Bitmap != null)
            rtb.IconWidget = new Gtk.Image (ImageToPixbuf (tab.Bitmap));
            else
            rtb.IconWidget = new Gtk.Image (Stock.MissingImage, IconSize.SmallToolbar);

            rtb.SetTooltip (tips, tab.TabName, null);
            rtb.Toggled += new EventHandler (toolbarClick);

            toolbar.Insert (rtb, propertyTabs.Count + FirstTabIndex);

            propertyTabs.Add(tab);
        }