/// <summary> /// открытие специального редактора, указанного для свойства /// </summary> private void OpenSpecialEditor(Type editorType) { if (openPropertyEditor != null) { openPropertyEditor(editingRowIndex, editingColumn); return; } var fastGrid = tabControl.SelectedTab.Controls[0] as FastGrid.FastGrid; if (fastGrid == null) { return; } var rowObject = (FastPropertyGridRow)fastGrid.rows[editingRowIndex].ValueObject; if (editorType == typeof(MultilineStringEditor)) { editorType = typeof(TextUItypeWEditor); } if (editorType == null) { return; } var constructor = editorType.GetConstructor(new Type[0]); if (constructor == null) { return; } var editor = (UITypeEditor)constructor.Invoke(new object[0]); if (editor is CheckedListBoxSeriesUITypeEditor) { var popEditor = new PopupCheckedListBoxSeriesUITypeEditor(); var position = fastGrid.GetCellCoords(editingColumn, editingRowIndex); popEditor.ShowDialogAsynch(SelectedObject, o => { UpdateObject(editingColumn, editingRowIndex, o); }, new Rectangle(position.X, position.Y, editingColumn.ResultedWidth, 280), fastGrid); return; } // пока нет возможности вызова popup-редакторs if (editor.GetEditStyle() != UITypeEditorEditStyle.Modal) { // попробуем показать хотя бы базовый OpenBaseEditor(rowObject.Property, fastGrid, editingRowIndex, editingColumn); return; } try { var context = new DescriptorContext(SelectedObject ?? SelectedObjects); var newValue = editor.EditValue(context, null, rowObject.Value); // если старое значение равно новому, то, возможно, от редактирования отказались if (newValue != rowObject.Value) { UpdateObject(editingColumn, editingRowIndex, newValue); } } catch (Exception ex) { Logger.Error("FastpropertyGrid.OpenSpecialEditor: editor error", ex); } }
/// <summary> /// открытие специального редактора, указанного для свойства /// </summary> private void OpenSpecialEditor(Type editorType) { if (openPropertyEditor != null) { openPropertyEditor(editingRowIndex, editingColumn); return; } var fastGrid = tabControl.SelectedTab.Controls[0] as FastGrid.FastGrid; if (fastGrid == null) return; var rowObject = (FastPropertyGridRow) fastGrid.rows[editingRowIndex].ValueObject; if (editorType == typeof (MultilineStringEditor)) editorType = typeof (TextUItypeWEditor); if (editorType == null) return; var constructor = editorType.GetConstructor(new Type[0]); if (constructor == null) return; var editor = (UITypeEditor) constructor.Invoke(new object[0]); if (editor is CheckedListBoxSeriesUITypeEditor) { var popEditor = new PopupCheckedListBoxSeriesUITypeEditor(); var position = fastGrid.GetCellCoords(editingColumn, editingRowIndex); popEditor.ShowDialogAsynch(SelectedObject, o => { UpdateObject(editingColumn, editingRowIndex, o); }, new Rectangle(position.X, position.Y, editingColumn.ResultedWidth, 280), fastGrid); return; } // пока нет возможности вызова popup-редакторs if (editor.GetEditStyle() != UITypeEditorEditStyle.Modal) { // попробуем показать хотя бы базовый OpenBaseEditor(rowObject.Property, fastGrid, editingRowIndex, editingColumn); return; } try { var context = new DescriptorContext(SelectedObject ?? SelectedObjects); var newValue = editor.EditValue(context, null, rowObject.Value); // если старое значение равно новому, то, возможно, от редактирования отказались if (newValue != rowObject.Value) UpdateObject(editingColumn, editingRowIndex, newValue); } catch(Exception ex) { Logger.Error("FastpropertyGrid.OpenSpecialEditor: editor error", ex); } }