public void UITypeEditor_GetEditStyle_Invoke_ReturnsNone() { var editor = new UITypeEditor(); Assert.Equal(UITypeEditorEditStyle.None, editor.GetEditStyle()); Assert.Equal(UITypeEditorEditStyle.None, editor.GetEditStyle(null)); }
public void DefaultValues() { Assert.AreSame(graphics, editor.EditValue(null, graphics), "EditValue(2)"); Assert.AreSame(graphics, editor.EditValue(null, null, graphics), "EditValue(3)"); Assert.AreEqual(UITypeEditorEditStyle.None, editor.GetEditStyle(), "GetEditStyle()"); Assert.AreEqual(UITypeEditorEditStyle.None, editor.GetEditStyle(null), "GetEditStyle(null)"); Assert.IsFalse(editor.GetPaintValueSupported(), "GetPaintValueSupported()"); Assert.IsFalse(editor.GetPaintValueSupported(null), "GetPaintValueSupported(null)"); Assert.IsFalse(editor.IsDropDownResizable, "IsDropDownResizable"); }
private InstanceCreationEditor GetInstanceCreationEditor(PropertyDescriptorGridEntry entry) { if (entry is null) { return(null); } InstanceCreationEditor editor = null; // check the property type itself. this is the default path. // PropertyDescriptor pd = entry.PropertyDescriptor; if (pd != null) { editor = pd.GetEditor(typeof(InstanceCreationEditor)) as InstanceCreationEditor; } // now check if there is a dropdown UI type editor. If so, use that. // if (editor is null) { UITypeEditor ute = entry.UITypeEditor; if (ute != null && ute.GetEditStyle() == UITypeEditorEditStyle.DropDown) { editor = (InstanceCreationEditor)TypeDescriptor.GetEditor(ute, typeof(InstanceCreationEditor)); } } return(editor); }
protected override void OnMouseClick(DataGridViewCellMouseEventArgs e) { Point cellLocation = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location; cellLocation.Offset(e.Location); if (buttonBounds.Contains(cellLocation)) { UITypeEditor editor = OwningDesignerColumn.GetBoundPropertyEditor(); if (editor != null && editor.GetEditStyle() == UITypeEditorEditStyle.Modal) { ITypeDescriptorContext context = new TypeDescriptorContext(DataGridView.Site, OwningDesignerColumn.GetBoundProperty(), this); object value = GetValue(e.RowIndex); value = editor.EditValue(context, DataGridView.Site, value); SetValue(e.RowIndex, value); } // Notify the grid the cell was modified DataGridView.NotifyCurrentCellDirty(true); DataGridView.NotifyCurrentCellDirty(false); } else { base.OnMouseClick(e); } }
protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) { _editor = (UITypeEditor)PropertyDescriptor.GetEditor(typeof(UITypeEditor)); base.OnPropertyTaskItemUpdated(toolTip, ref currentTabIndex); if (_editor != null) { _button.Ellipsis = (_editor.GetEditStyle(TypeDescriptorContext) == UITypeEditorEditStyle.Modal); _hasSwatch = _editor.GetPaintValueSupported(TypeDescriptorContext); } else { _button.Ellipsis = false; } if (_button.Ellipsis) { EditControl.AccessibleRole = (IsReadOnly() ? AccessibleRole.StaticText : AccessibleRole.Text); } else { EditControl.AccessibleRole = (IsReadOnly() ? AccessibleRole.DropList : AccessibleRole.ComboBox); } _button.TabStop = _button.Ellipsis; _button.TabIndex = currentTabIndex++; _button.AccessibleRole = (_button.Ellipsis ? AccessibleRole.PushButton : AccessibleRole.ButtonDropDown); _button.AccessibleDescription = EditControl.AccessibleDescription; _button.AccessibleName = EditControl.AccessibleName; }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { if (context != null) { return(_parentEditor.GetEditStyle(CreateContext(context))); } return(base.GetEditStyle(context)); }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { if (delegateEditor == null) { return(UITypeEditorEditStyle.None); } if (context == null) { return(delegateEditor.GetEditStyle(context)); } else { return (context.PropertyDescriptor.IsReadOnly ? UITypeEditorEditStyle.None : delegateEditor.GetEditStyle(context)); } }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { UITypeEditor editor = lookUpEditor(context); if (editor != null) { return(editor.GetEditStyle(context)); } else { return(base.GetEditStyle(context)); } }
public static void EditValue(IWin32Window owner, object component, string propertyName) { PropertyDescriptor prop = TypeDescriptor.GetProperties(component)[propertyName]; if (prop == null) throw new ArgumentException("propertyName"); UITypeEditor editor = (UITypeEditor)prop.GetEditor(typeof(UITypeEditor)); MyHelper ctx = new MyHelper(owner, component, prop); if (editor != null && editor.GetEditStyle(ctx) == UITypeEditorEditStyle.Modal) { object value = prop.GetValue(component); value = editor.EditValue(ctx, ctx, value); if (!prop.IsReadOnly) { prop.SetValue(component, value); } } }
/// <summary> /// Show the dialog /// </summary> public override void ShowDialog() { try { OnDialogOpen(EventArgs.Empty); if (uiTypeEditor != null) { UITypeEditorEditStyle l_Style = uiTypeEditor.GetEditStyle(); if (l_Style == UITypeEditorEditStyle.DropDown || l_Style == UITypeEditorEditStyle.Modal) { object l_EditObject; try { l_EditObject = Value; } catch { if (Validator != null) { l_EditObject = Validator.DefaultValue; } else { l_EditObject = null; } } object tmp = uiTypeEditor.EditValue(this, l_EditObject); Value = tmp; } } OnDialogClosed(EventArgs.Empty); } catch (Exception ex) { LoggerManager.Log(LogLevels.Error, "Unexpected exception: " + ex.ToString()); MessageBox.Show(ex.Message, Application.ProductName + " build " + Application.ProductVersion, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static bool EditValue(IWin32Window owner, object component, string propertyName) { PropertyDescriptor prop = TypeDescriptor.GetProperties(component)[propertyName]; if (prop == null) { throw new ArgumentException("PropertyName [" + propertyName + "] in object not found."); } UITypeEditor editor = (UITypeEditor)prop.GetEditor(typeof(UITypeEditor)); CollectionEditor ctx = new CollectionEditor(owner, component, prop); if (editor != null && editor.GetEditStyle(ctx) == UITypeEditorEditStyle.Modal) { object value = prop.GetValue(component); value = editor.EditValue(ctx, ctx, value); if (!prop.IsReadOnly) { prop.SetValue(component, value); return(true); } } return(false); }
public void UITypeEditor_GetEditStyle_Invoke_ReturnsNone(ITypeDescriptorContext context) { var editor = new UITypeEditor(); Assert.Equal(UITypeEditorEditStyle.None, editor.GetEditStyle(context)); }
public UITypeEditorEditStyle GetEditorStyle() { return(_editor.GetEditStyle()); }
/// <summary> /// Binds the control to a property and owner</summary> /// <param name="context">Context for property editing control</param> public void Bind(PropertyEditorControlContext context) { if (m_textBox.Focused) { Flush(); } m_context = context; m_descriptor = m_context.Descriptor; bool visible = m_context != null; base.Visible = visible; if (visible) { SetTextBoxFromProperty(); bool editButtonVisible = false; if (!m_context.IsReadOnly) { UITypeEditor editor = WinFormsPropertyUtils.GetUITypeEditor(m_descriptor, this); if (editor != null) { editButtonVisible = true; m_editButton.Modal = (editor.GetEditStyle(this) == UITypeEditorEditStyle.Modal); } } m_editButton.Visible = editButtonVisible; // a standard set of values that can be picked from a list, like enum (but only if we're not readonly) if (!m_context.IsReadOnly && (m_descriptor.Converter != null)) { TypeDescriptorContext tdcontext = new TypeDescriptorContext(m_context.LastSelectedObject, m_descriptor, null); if (m_descriptor.Converter.GetStandardValuesExclusive(tdcontext)) { // this will redraw the control before we get to the invalidate below m_textBox.AutoCompleteMode = AutoCompleteMode.None; m_textBox.AutoCompleteCustomSource.Clear(); AutoCompleteStringCollection standardVals = new AutoCompleteStringCollection(); ICollection values = m_descriptor.Converter.GetStandardValues(tdcontext); foreach (object item in values) { standardVals.Add(item.ToString()); } m_textBox.AutoCompleteCustomSource = standardVals; // this will redraw the control before we get to the invalidate below m_textBox.AutoCompleteSource = AutoCompleteSource.CustomSource; m_textBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; } else { // this will redraw the control before we get to the invalidate below m_textBox.AutoCompleteMode = AutoCompleteMode.None; m_textBox.AutoCompleteSource = AutoCompleteSource.None; m_textBox.AutoCompleteCustomSource.Clear(); } } else { // this will redraw the control before we get to the invalidate below m_textBox.AutoCompleteMode = AutoCompleteMode.None; m_textBox.AutoCompleteSource = AutoCompleteSource.None; m_textBox.AutoCompleteCustomSource.Clear(); } PerformLayout(); Invalidate(); } }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance); return(uiTypeEditor.GetEditStyle(wrappedContext)); }