Esempio n. 1
0
		private void RefreshToolbar (PropertyTabCollection tabs)
		{
			EnsurePropertiesTab ();

			toolbar.SuspendLayout ();
			toolbar.Items.Clear ();
			toolbar_imagelist.Images.Clear ();

			int imageIndex = 0;
			toolbar.Items.Add (categorized_toolbarbutton);
			toolbar_imagelist.Images.Add (categorized_image);
			categorized_toolbarbutton.ImageIndex = imageIndex;
			imageIndex++;
			toolbar.Items.Add (alphabetic_toolbarbutton);
			toolbar_imagelist.Images.Add (alphabetical_image);
			alphabetic_toolbarbutton.ImageIndex = imageIndex;
			imageIndex++;
			toolbar.Items.Add (separator_toolbarbutton);
			if (tabs != null && tabs.Count > 0) {
				foreach (PropertyTab tab in tabs) {
					PropertyToolBarButton button = new PropertyToolBarButton (tab);
					toolbar.Items.Add (button);
					if (tab.Bitmap != null) {
						tab.Bitmap.MakeTransparent ();
						toolbar_imagelist.Images.Add (tab.Bitmap);
						button.ImageIndex = imageIndex;
						imageIndex++;
					}
					if (tab == selected_tab)
						button.Pushed = true;
				}
				toolbar.Items.Add (new PropertyToolBarSeparator ());
			}

			toolbar.Items.Add (propertypages_toolbarbutton);
			toolbar_imagelist.Images.Add (propertypages_image);
			propertypages_toolbarbutton.ImageIndex = imageIndex;
			
			toolbar.ResumeLayout ();
		}
Esempio n. 2
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);
		}
Esempio n. 3
0
		private void toolbar_Clicked (PropertyToolBarButton button)
		{
			if (button == null) 
				return;

			if (button == alphabetic_toolbarbutton) {
				this.PropertySort = PropertySort.Alphabetical;
				alphabetic_toolbarbutton.Pushed = true;
				categorized_toolbarbutton.Pushed = false;
			} else if (button == categorized_toolbarbutton) {
				this.PropertySort = PropertySort.CategorizedAlphabetical;
				categorized_toolbarbutton.Pushed = true;
				alphabetic_toolbarbutton.Pushed = false;
			} else {
				if (button.Enabled)
					SelectPropertyTab (button.PropertyTab);
			}
		}