private int splitter_location;
private int open_grid_item_count = -1;
private int skipped_grid_items;\r
- private Form dropdown_form;\r
+ private PropertyGridDropDown dropdown_form;\r
+ private bool dropdown_form_showing;\r
private Form dialog_form;\r
- private ListBox listBox;\r
private VScrollBar vbar;\r
#endregion\r
\r
grid_textbox.DropDownButtonClicked +=new EventHandler(DropDownButtonClicked);\r
grid_textbox.DialogButtonClicked +=new EventHandler(DialogButtonClicked);\r
\r
- dropdown_form = new Form();\r
- dropdown_form.FormBorderStyle = FormBorderStyle.None;\r
- dropdown_form.Deactivate +=new EventHandler(dropdown_form_Deactivate);\r
+ \r
+ dropdown_form = new PropertyGridDropDown();\r
+ dropdown_form.FormBorderStyle = FormBorderStyle.None;
+ dropdown_form.ShowInTaskbar = false;
\r
dialog_form = new Form();\r
//dialog_form.FormBorderStyle = FormBorderStyle.None;\r
\r
- listBox = new ListBox();\r
- listBox.Dock = DockStyle.Fill;\r
- listBox.SelectedIndexChanged +=new EventHandler(listBox_SelectedIndexChanged);\r
- dropdown_form.Controls.Add(listBox);\r
+ \r
\r
grid_textbox.Visible = true;\r
grid_textbox.Font = this.Font;//new Font(this.Font,FontStyle.Bold);\r
}\r
}\r
\r
- private void DrawGridItem (GridItem grid_item, PaintEventArgs pevent, int depth, ref int yLoc) \r
+ private void DrawGridItemLabel(GridItem grid_item, PaintEventArgs pevent, Rectangle rect)\r
{\r
- // left column\r
- pevent.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (property_grid.LineColor), 0,yLoc,V_INDENT, ROW_HEIGHT);\r
+ int x = rect.X+1;\r
+ if (grid_item.Parent != null && grid_item.Parent.GridItemType != GridItemType.Category)\r
+ x += V_INDENT;\r
\r
- if (grid_item.Expandable) \r
- {\r
- grid_item.PlusMinusBounds = DrawPlusMinus(pevent, 3, yLoc+3, grid_item.Expanded, grid_item.GridItemType == GridItemType.Category);\r
- }\r
- \r
+ Font font = this.Font;\r
+ Brush brush = SystemBrushes.WindowText;\r
if (grid_item.GridItemType == GridItemType.Category)\r
{\r
- pevent.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (property_grid.LineColor), depth*V_INDENT,yLoc,ClientRectangle.Width-(depth*V_INDENT), ROW_HEIGHT);\r
+ font = new Font(font, FontStyle.Bold);\r
+ brush = SystemBrushes.ControlDark;\r
}\r
- \r
+\r
if (grid_item == property_grid.SelectedGridItem && grid_item.GridItemType != GridItemType.Category)\r
{\r
- pevent.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (Color.Blue), new Rectangle(V_INDENT,yLoc, splitter_location-V_INDENT, ROW_HEIGHT));\r
+ pevent.Graphics.FillRectangle (SystemBrushes.Highlight, rect);\r
// Label\r
- pevent.Graphics.DrawString(grid_item.Label,this.Font,SystemBrushes.Window,new RectangleF(1+depth*V_INDENT,yLoc+2, splitter_location-(5+depth*V_INDENT), ROW_HEIGHT-4));\r
- \r
- grid_textbox.Location = new Point(splitter_location+1, yLoc);\r
- grid_textbox.Size = new Size(ClientRectangle.Width-splitter_location,ROW_HEIGHT);\r
- }\r
- else\r
- {\r
- Font font = this.Font;\r
- Brush brush = SystemBrushes.WindowText;\r
- if (grid_item.GridItemType == GridItemType.Category)\r
- {\r
- font = new Font(font, FontStyle.Bold);\r
- brush = SystemBrushes.ControlDark;\r
- }\r
- // Label\r
- pevent.Graphics.DrawString(grid_item.Label,font,brush,new RectangleF(1+depth*V_INDENT,yLoc+2, splitter_location-(5+depth*V_INDENT), ROW_HEIGHT-4));\r
+ brush = SystemBrushes.HighlightText;\r
}\r
+\r
+ \r
+ pevent.Graphics.DrawString(grid_item.Label,font,brush,new Rectangle(x, rect.Y + 2,x-rect.X+rect.Width,rect.Height-2));\r
+ }\r
+\r
+ private void DrawGridItemValue(GridItem grid_item, PaintEventArgs pevent, Rectangle rect)\r
+ {\r
// Value\r
if (grid_item.PropertyDescriptor != null)\r
{\r
{\r
grid_textbox.DropDownButtonVisible = false;\r
grid_textbox.DialogButtonVisible = false;\r
- listBox.Items.Clear();\r
if (editor != null) \r
{\r
UITypeEditorEditStyle style = editor.GetEditStyle();\r
}\r
}\r
else \r
- {\r
+ {
+ try
+ {\r
if (grid_item.PropertyDescriptor.Converter.GetStandardValuesSupported()) \r
{\r
- foreach (object obj in grid_item.PropertyDescriptor.Converter.GetStandardValues())\r
- listBox.Items.Add(obj);\r
+ \r
grid_textbox.DropDownButtonVisible = true;\r
grid_textbox.ReadOnly = true;
}\r
+ }
+ catch (Exception ex)
+ {
+ }
}\r
}\r
\r
int xLoc = splitter_location+1;\r
if (paintsValue)\r
{\r
- pevent.Graphics.DrawRectangle(ThemeEngine.Current.ResPool.GetPen(Color.Black), splitter_location+2,yLoc+2, 20, ROW_HEIGHT-4);\r
+ pevent.Graphics.DrawRectangle(ThemeEngine.Current.ResPool.GetPen(Color.Black), splitter_location+2,rect.Y+2, 20, ROW_HEIGHT-4);\r
try\r
{\r
- editor.PaintValue(grid_item.Value, pevent.Graphics, new Rectangle(splitter_location+3,yLoc+3, 19, ROW_HEIGHT-5));\r
+ editor.PaintValue(grid_item.Value, pevent.Graphics, new Rectangle(splitter_location+3,rect.Y+3, 19, ROW_HEIGHT-5));\r
}\r
catch (Exception ex)\r
{\r
+ System.Console.WriteLine(ex.Message);\r
// design time stuff is not playing nice\r
}\r
xLoc += 27;\r
}\r
\r
+ Font font = this.Font;\r
+ try {
string value = grid_item.PropertyDescriptor.Converter.ConvertToString(grid_item.Value);\r
- pevent.Graphics.DrawString(value,this.Font,SystemBrushes.WindowText,new RectangleF(xLoc,yLoc+2, ClientRectangle.Width-(xLoc), ROW_HEIGHT-4));\r
+ if (grid_item.PropertyDescriptor.CanResetValue(property_grid.SelectedObject))\r
+ font = new Font(font, FontStyle.Bold);\r
+
+ pevent.Graphics.DrawString(value,font,SystemBrushes.WindowText,new RectangleF(xLoc,rect.Y+2, ClientRectangle.Width-(xLoc), ROW_HEIGHT));\r
+\r
+}
+ catch (Exception e)
+ {
+ }
+ if (grid_item == property_grid.SelectedGridItem && grid_item.GridItemType != GridItemType.Category)\r
+ {\r
+ grid_textbox.Location = new Point(xLoc, rect.Top);\r
+ grid_textbox.Size = new Size(ClientRectangle.Width-xLoc,ROW_HEIGHT);\r
+ }\r
+ }\r
+ }\r
+\r
+ private void DrawGridItem (GridItem grid_item, PaintEventArgs pevent, int depth, ref int yLoc) \r
+ {\r
+ if (yLoc > -ROW_HEIGHT && yLoc < ClientRectangle.Height)\r
+ {\r
+ \r
+ // left column\r
+ pevent.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (property_grid.LineColor), 0,yLoc,V_INDENT, ROW_HEIGHT);\r
+\r
+ if (grid_item.Expandable) \r
+ {\r
+ grid_item.PlusMinusBounds = DrawPlusMinus(pevent, 3, yLoc+3, grid_item.Expanded, grid_item.GridItemType == GridItemType.Category);\r
+ }\r
+ \r
+ if (grid_item.GridItemType == GridItemType.Category)\r
+ {\r
+ pevent.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (property_grid.LineColor), depth*V_INDENT,yLoc,ClientRectangle.Width-(depth*V_INDENT), ROW_HEIGHT);\r
+ }\r
+\r
+ DrawGridItemLabel(grid_item, pevent, new Rectangle(V_INDENT,yLoc, splitter_location-V_INDENT, ROW_HEIGHT));\r
+ DrawGridItemValue(grid_item, pevent, new Rectangle(splitter_location+2,yLoc, ClientRectangle.Width-splitter_location-2, ROW_HEIGHT));\r
+ \r
+ \r
+ \r
}\r
grid_item.Top = yLoc;
yLoc += ROW_HEIGHT;
\r
private void dropdown_form_Deactivate (object sender, EventArgs e) \r
{\r
+ dropdown_form_showing = false;\r
dropdown_form.Hide();\r
+ //dropdown_form = new Form();\r
}\r
\r
private void listBox_SelectedIndexChanged (object sender, EventArgs e) \r
if (this.property_grid.SelectedGridItem != null) {\r
PropertyDescriptor desc = property_grid.SelectedGridItem.PropertyDescriptor;\r
if (desc != null) {\r
- SetPropertyValue(listBox.SelectedItem);\r
+ SetPropertyValue(((ListBox)sender).SelectedItem);\r
}\r
}\r
dropdown_form.Hide();\r
+ //dropdown_form = new Form();\r
Refresh();\r
}\r
\r
\r
private void DropDownButtonClicked (object sender, EventArgs e) \r
{\r
- if (listBox.Items.Count > 0)\r
+ if (property_grid.SelectedGridItem.PropertyDescriptor.GetEditor(typeof(UITypeEditor)) == null)\r
{\r
+ //dropdown_form.FormBorderStyle = FormBorderStyle.None;\r
+ dropdown_form.Deactivate +=new EventHandler(dropdown_form_Deactivate);\r
+ ListBox listBox = new ListBox();\r
+ listBox.Dock = DockStyle.Fill;\r
+ listBox.SelectedIndexChanged +=new EventHandler(listBox_SelectedIndexChanged);\r
+ foreach (object obj in property_grid.SelectedGridItem.PropertyDescriptor.Converter.GetStandardValues())\r
+ listBox.Items.Add(obj);\r
+ dropdown_form.Controls.Clear();\r
+ dropdown_form.Controls.Add(listBox);\r
dropdown_form.Location = PointToScreen(new Point(grid_textbox.Location.X,grid_textbox.Location.Y+ROW_HEIGHT));\r
dropdown_form.Width = grid_textbox.Width;\r
dropdown_form.Show();\r
UITypeEditor editor = (UITypeEditor)property_grid.SelectedGridItem.PropertyDescriptor.GetEditor(typeof(UITypeEditor));\r
System.ComponentModel.Design.ServiceContainer service_container = new System.ComponentModel.Design.ServiceContainer();\r
service_container.AddService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService), this);\r
- editor.EditValue(null, service_container,property_grid.SelectedGridItem.Value);\r
+ SetPropertyValue(editor.EditValue(null, service_container,property_grid.SelectedGridItem.Value));\r
}\r
}\r
\r
{\r
//dialog_form.Location = PointToScreen(new Point(grid_textbox.Location.X,grid_textbox.Location.Y+ROW_HEIGHT));\r
//dropdown_form.Width = grid_textbox.Width;\r
- dialog_form.ShowDialog(this);\r
+ dialog_form.Show();\r
}\r
\r
private void HandleScroll(object sender, ScrollEventArgs e)\r
{\r
- if (e.NewValue < 0)\r
+ if (e.NewValue <= 0)\r
{\r
e.NewValue = 0;\r
if (e.NewValue == vbar.Value)return;\r
{\r
case ScrollEventType.SmallDecrement:\r
XplatUI.ScrollWindow(Handle, 0, ROW_HEIGHT, false);\r
+ grid_textbox.Top += ROW_HEIGHT;\r
Invalidate(new Rectangle(0,0,ClientRectangle.Width,ROW_HEIGHT));\r
break;\r
case ScrollEventType.SmallIncrement:\r
XplatUI.ScrollWindow(Handle, 0, -ROW_HEIGHT, false);\r
+ grid_textbox.Top -= ROW_HEIGHT;\r
Invalidate(new Rectangle(0,ClientRectangle.Bottom-ROW_HEIGHT,ClientRectangle.Width,ROW_HEIGHT));\r
break;\r
case ScrollEventType.LargeDecrement:\r
// clip.Union(new Rectangle(0,property_grid.SelectedGridItem.Top, ClientRectangle.Width, ROW_HEIGHT));\r
\r
if (e.NewSelection.PropertyDescriptor != null)\r
+ {\r
grid_textbox.Text = e.NewSelection.PropertyDescriptor.Converter.ConvertToString(e.NewSelection.Value);\r
+ if (e.NewSelection.PropertyDescriptor.CanResetValue(property_grid.SelectedObject))\r
+ grid_textbox.Font = new Font(this.Font, FontStyle.Bold);\r
+ else\r
+ grid_textbox.Font = this.Font;\r
+ }\r
\r
Invalidate(/*clip*/this.ClientRectangle);\r
Update();\r
private void HandlePropertyValueChanged(object s, PropertyValueChangedEventArgs e)\r
{\r
if (e.ChangedItem.PropertyDescriptor != null)\r
+ {\r
grid_textbox.Text = e.ChangedItem.PropertyDescriptor.Converter.ConvertToString(e.ChangedItem.Value);\r
+ if (e.ChangedItem.PropertyDescriptor.CanResetValue(property_grid.SelectedObject))\r
+ grid_textbox.Font = new Font(this.Font, FontStyle.Bold);\r
+ else\r
+ grid_textbox.Font = this.Font;\r
+ }\r
}\r
\r
#region IWindowsFormsEditorService Members\r
\r
public void CloseDropDown()\r
{\r
- // TODO: Add PropertyGrid.CloseDropDown implementation\r
+ dropdown_form_showing = false;\r
+ dropdown_form.Hide();\r
}\r
\r
public void DropDownControl(Control control)\r
{\r
- // TODO: Add PropertyGrid.DropDownControl implementation\r
+ //dropdown_form.FormBorderStyle = FormBorderStyle.None;\r
+ dropdown_form.Deactivate +=new EventHandler(dropdown_form_Deactivate);\r
+ dropdown_form.Size = control.Size;\r
+ control.Dock = DockStyle.Fill;\r
+ dropdown_form.Controls.Clear();\r
+ dropdown_form.Controls.Add(control);\r
+ dropdown_form.Location = PointToScreen(new Point(grid_textbox.Location.X,grid_textbox.Location.Y+ROW_HEIGHT));\r
+ dropdown_form.Width = grid_textbox.Width;\r
+\r
+ dropdown_form_showing = true;\r
+ dropdown_form.Show();\r
+ System.Windows.Forms.MSG msg = new MSG();\r
+ while (XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0) && dropdown_form_showing) \r
+ {\r
+ XplatUI.TranslateMessage(ref msg);\r
+ XplatUI.DispatchMessage(ref msg);\r
+ }\r
}\r
\r
public System.Windows.Forms.DialogResult ShowDialog(Form dialog)\r
#region DropDownForm Class\r
#endregion DropDownForm Class\r
\r
+ #region Internal Classes\r
+ internal class ITypeDescriptorContextImpl : System.ComponentModel.ITypeDescriptorContext\r
+ {\r
+ private PropertyGrid property_grid;\r
+ public ITypeDescriptorContextImpl(PropertyGrid propertyGrid)\r
+ {\r
+ property_grid = propertyGrid;\r
+ }\r
+ #region ITypeDescriptorContext Members\r
+\r
+ public void OnComponentChanged()\r
+ {\r
+ // TODO: Add SystemComp.OnComponentChanged implementation\r
+ }\r
+\r
+ public IContainer Container\r
+ {\r
+ get\r
+ {\r
+ return property_grid as IContainer;\r
+ }\r
+ }\r
+\r
+ public bool OnComponentChanging()\r
+ {\r
+ // TODO: Add SystemComp.OnComponentChanging implementation\r
+ return false;\r
+ }\r
+\r
+ public object Instance\r
+ {\r
+ get\r
+ {\r
+ // TODO: Add SystemComp.Instance getter implementation\r
+ return null;\r
+ }\r
+ }\r
+\r
+ public PropertyDescriptor PropertyDescriptor\r
+ {\r
+ get\r
+ {\r
+ // TODO: Add SystemComp.PropertyDescriptor getter implementation\r
+ return null;\r
+ }\r
+ }\r
+\r
+ #endregion\r
+\r
+ #region IServiceProvider Members\r
+\r
+ public object GetService(Type serviceType)\r
+ {\r
+ // TODO: Add SystemComp.GetService implementation\r
+ return null;\r
+ }\r
+\r
+ #endregion\r
+\r
+ }\r
+\r
+\r
+
+ /*
+ class ComboListBox
+ */
+ internal class PropertyGridDropDown : Form
+ {
+ protected override CreateParams CreateParams
+ {
+ get \r
+ {
+ CreateParams cp = base.CreateParams;
+ cp.Style = unchecked ((int)(WindowStyles.WS_POPUP | WindowStyles.WS_VISIBLE | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_CLIPCHILDREN));
+ cp.ExStyle |= (int)(WindowStyles.WS_EX_TOOLWINDOW | WindowStyles.WS_EX_TOPMOST);
+ return cp;
+ }
+ }
+
+ }\r
+ #endregion\r
\r
}\r
}