private static PropertyGrid GetParentPropertyGridOfCollectionEditor(CollectionEditor editor) { PropertyGrid result = null; try { PropertyInfo property = editor.GetType().GetProperty("Context", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property == null) { return(null); } object value = property.GetValue(editor, null); if (value == null) { return(null); } PropertyInfo property2 = value.GetType().GetProperty("OwnerGrid", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property2 == null) { return(null); } result = (property2.GetValue(value, null) as PropertyGrid); } catch { } return(result); }
public DataFieldCollectionForm(IServiceProvider serviceProvider, CollectionEditor editor) : base(editor) { this.fieldLabel = new Label(); this.fieldsList = new ListBoxWithEnter(); this.selectedFieldsLabel = new Label(); this.selectedFieldsList = new ListBoxWithEnter(); this.moveLeft = new Button(); this.moveRight = new Button(); this.moveUp = new Button(); this.moveDown = new Button(); this.okButton = new Button(); this.cancelButton = new Button(); this.layoutPanel = new TableLayoutPanel(); this.moveUpDownPanel = new Panel(); this.moveLeftRightPanel = new Panel(); this.editor = (DataFieldCollectionEditor)editor; this._serviceProvider = serviceProvider; if (!string.Equals(System.Design.SR.GetString("RTL"), "RTL_False", StringComparison.Ordinal)) { this.RightToLeft = RightToLeft.Yes; this.RightToLeftLayout = true; } this.InitializeComponent(); this._dataFields = this.GetControlDataFieldNames(); }
public ComponaCollectionForm(CollectionEditor e) : base(e) { this.Editor = e as ComponaCollectionEditor; GUI = this.Editor.CreateGUI(); GUI.Visible = true; GUI.Dock = DockStyle.Fill; this.Controls.Add(GUI); this.AcceptButton = GUI.btnOK; this.CancelButton = GUI.btnCancel; this.Size = new Size(630, 470); GUI.Editor = e as ComponaCollectionEditor; Type[] types = this.NewItemTypes; if (types.Length > 1) { GUI.btnDropdown.Visible = true; GUI.btnDropdown.ContextMenu = new ContextMenu(); for (int i = 0; (i < types.Length); i++) { GUI.btnDropdown.ContextMenu.MenuItems.Add(new TypeMenuItem(types[i], new EventHandler(this.btnDropDownMenuItem_Click))); } } GUI.btnRemove.Click += new EventHandler(this.btnRemove_Click); GUI.btnAdd.Click += new EventHandler(this.btnAdd_Click); GUI.btnCancel.Click += new EventHandler(this.btnCancel_Click); GUI.btnOK.Click += new EventHandler(this.btnOK_Click); GUI.btnUp.Click += new EventHandler(this.btnUp_Click); GUI.btnDown.Click += new EventHandler(this.btnDown_Click); GUI.btnDropdown.Click += new EventHandler(this.btnDropDown_Click); }
public FileDialogPlacesEditorForm(CollectionEditor editor) : base(editor) { InitializeComponent(); placesBar.Renderer = new FileFolderDialog.PlacesBarRenderer(); List <KeyValuePair <string, SpecialFolder> > specialFolders = new List <KeyValuePair <string, SpecialFolder> >(); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("Desktop", SpecialFolder.Desktop)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("My Computer", SpecialFolder.MyComputer)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("My Network Places", SpecialFolder.Network)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("My Documents", SpecialFolder.MyDocuments)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("My Pictures", SpecialFolder.MyPictures)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("My Music", SpecialFolder.MyMusic)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("My Video", SpecialFolder.MyVideo)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("Favorites", SpecialFolder.Favorites)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("My Recent Documents", SpecialFolder.Recent)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("Recycle Bin", SpecialFolder.RecycleBin)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("Windows", SpecialFolder.Windows)); specialFolders.Add(new KeyValuePair <string, SpecialFolder>("System", SpecialFolder.System)); specialFoldersComboBox.DataSource = specialFolders; specialFoldersComboBox.SelectedIndex = 0; placesListBox.DataSource = m_places; placesListBox.DisplayMember = "Text"; }
/// <summary> /// Constructs a StringCollectionForm. /// </summary> public StringCollectionForm(CollectionEditor editor) : base(editor) { _editor = (StringCollectionEditor)editor; InitializeComponent(); HookEvents(); }
public DialogResult ShowDialog(T lst) { CollectionEditor c = new CollectionEditor(typeof(T)); RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(); c.EditValue(serviceProvider, serviceProvider, lst); return(serviceProvider.windowsFormsEditorService.DialogResult); }
private void EditBlocks_OnClick(object sender, RoutedEventArgs e) { var editor = new CollectionEditor() { Owner = Window.GetWindow(this) }; editor.Edit <string>(Plugin.Config.IgnoreBlockList, "Ignored Blocks - Use ONLY subtypeId"); }
/// <summary> /// Initializes a new instance of the <see cref="PolygonPointCollectionForm"/> class. /// </summary> /// <param name="editor">The <see cref="T:System.ComponentModel.Design.CollectionEditor"/> to use for editing the collection.</param> public PolygonPointCollectionForm(CollectionEditor editor) : base(editor) { lblInstruction = new Label(); txtEntry = new TextBox(); btnOk = new Button(); btnCancel = new Button(); Editor = (PolygonPointCollectionEditor)editor; InitializeComponent(); }
internal ToolStripItemEditorForm(CollectionEditor parent) : base(parent) { this.customItemIndex = -1; this.editor = (ToolStripCollectionEditor)parent; this.InitializeComponent(); base.ActiveControl = this.listBoxItems; this._originalText = this.Text; base.SetStyle(ControlStyles.ResizeRedraw, true); }
private void EditRemovedBlocks_OnClick(object sender, RoutedEventArgs e) { var editor = new CollectionEditor() { Owner = Window.GetWindow(this) }; editor.Edit <string>(Plugin.Config.RemoveBlocks, "Removed Blocks - Use pairnames,typeId and/or subtypeId"); }
public TreeNodeCollectionForm(CollectionEditor editor) : base(editor) { this.editor = (TreeNodeCollectionEditor)editor; this.InitializeComponent(); this.HookEvents(); this.intialNextNode = this.NextNode; this.SetButtonsState(); DesignerUtils.ApplyTreeViewThemeStyles(this.treeView1); }
private void EditExclusion_OnClick(object sender, RoutedEventArgs e) { var editor = new CollectionEditor() { Owner = Window.GetWindow(this) }; editor.Edit(Plugin.Settings.Data.ExcludedSubtypes, "Excluded Subtypes"); }
public void MoveDownTest() { var editor = new CollectionEditor <string>(); var npcQueue = new Queue <PropertyChangedEventArgs>(); var cmdInvQueue = new Queue <EventArgs>(); editor.PropertyChanged += (s, p) => npcQueue.Enqueue(p); editor.MoveDownCommand.CanExecuteChanged += (s, e) => cmdInvQueue.Enqueue(e); editor.MoveDownCommand.Name.Is("Move Down"); editor.MoveDownCommand.CheckCanExecute(false); editor.Items = new ObservableCollection <string> { "Item1", "Item2", "Item3" }; editor.MoveDownCommand.CheckCanExecute(false); npcQueue.CheckNext(Properties.ItemsPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.SelectedIndex = 1; editor.MoveDownCommand.CheckCanExecute(true); npcQueue.CheckNext(Properties.SelectedIndexPropertyChanged).CheckNext(Properties.SelectedItemPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.SelectedIndex = 2; editor.MoveDownCommand.CheckCanExecute(false); npcQueue.CheckNext(Properties.SelectedIndexPropertyChanged).CheckNext(Properties.SelectedItemPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.SelectedIndex = 1; editor.MoveDownCommand.CheckCanExecute(true); npcQueue.CheckNext(Properties.SelectedIndexPropertyChanged).CheckNext(Properties.SelectedItemPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.AllowMove = false; editor.MoveDownCommand.CheckCanExecute(false); npcQueue.CheckNext(Properties.AllowMovePropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.AllowMove = true; editor.MoveDownCommand.CheckCanExecute(true); npcQueue.CheckNext(Properties.AllowMovePropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.MoveDownCommand.Execute(null); editor.Items.Count.Is(3, "Items count"); editor.Items[0].Is("Item1"); editor.Items[1].Is("Item3"); editor.Items[2].Is("Item2"); editor.SelectedIndex.Is(2); editor.SelectedItem.Is("Item2"); npcQueue.CheckNext(Properties.SelectedIndexPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).CheckNext(Assert.IsNotNull).IsEmpty(); editor.MoveDownCommand.CheckCanExecute(false); }
/// <summary> /// Initializes a new instance of the <see cref="PolygonPointCollectionForm"/> class. /// </summary> /// <param name="editor">The <see cref="T:System.ComponentModel.Design.CollectionEditor"/> to use for editing the collection.</param> public PolygonPointCollectionForm(CollectionEditor editor) : base(editor) { this.uxInstruction = new Label(); this.uxTextEntry = new TextBox(); this.uxOK = new Button(); this.uxCancel = new Button(); this.Editor = (PolygonPointCollectionEditor)editor; this.InitializeComponent(); }
public IntegerCollectionForm(CollectionEditor editor) : base(editor) { this.instruction = new Label(); this.textEntry = new TextBox(); this.okButton = new Button(); this.cancelButton = new Button(); this.helpButton = new Button(); this.editor = (IntegerCollectionEditor)editor; this.InitializeComponent(); }
public StringCollectionForm(CollectionEditor editor) : base(editor) { this.instruction = new Label(); this.textEntry = new StiTextBox(); this.btOk = new StiButton(); this.btCancel = new StiButton(); this.editor = null; this.editor = ((StiStringCollectionEditor)editor); this.InitializeComponent(); this.textEntry.Focus(); }
public void CollectionForm_Ctor_CollectionEditor() { var editor = new CollectionEditor(typeof(List <int>)); var form = new SubCollectionForm(editor); Assert.Equal(typeof(int), form.CollectionItemType); Assert.Same(form.CollectionItemType, form.CollectionItemType); Assert.Equal(typeof(List <int>), form.CollectionType); Assert.Null(form.Context); Assert.Null(form.EditValue); Assert.Empty(form.Items); Assert.Equal(new Type[] { typeof(int) }, form.NewItemTypes); }
private void OnEditItems(object sender, EventArgs e) { object component = _targetProperty.GetValue(_designer.Component); if (component != null) { CollectionEditor editor = TypeDescriptor.GetEditor(component, typeof(System.Drawing.Design.UITypeEditor)) as CollectionEditor; if (editor != null) { editor.EditValue(this, this, component); } } }
public void AddCommandsValidityTest() { var editor = new CollectionEditor <string>(); Assert.IsFalse(editor.AddCommand.CanExecute(null)); Assert.IsFalse(editor.RemoveCommand.CanExecute(null)); Assert.IsFalse(editor.CloneCommand.CanExecute(null)); Assert.IsFalse(editor.MoveUpCommand.CanExecute(null)); Assert.IsFalse(editor.MoveDownCommand.CanExecute(null)); Assert.IsTrue(editor.ClearCommand.CanExecute(null)); editor.ItemFactory = () => "New Item"; editor.ItemCloner = p => "Cloned from " + p; editor.Items = new ObservableCollection <string> { "Item1", "Item2", "Item3" }; Assert.IsTrue(editor.AddCommand.CanExecute(null)); Assert.IsFalse(editor.RemoveCommand.CanExecute(null)); Assert.IsFalse(editor.CloneCommand.CanExecute(null)); Assert.IsFalse(editor.MoveUpCommand.CanExecute(null)); Assert.IsFalse(editor.MoveDownCommand.CanExecute(null)); Assert.IsTrue(editor.ClearCommand.CanExecute(null)); editor.SelectedIndex = 1; Assert.IsTrue(editor.AddCommand.CanExecute(null)); Assert.IsTrue(editor.RemoveCommand.CanExecute(null)); Assert.IsTrue(editor.CloneCommand.CanExecute(null)); Assert.IsTrue(editor.MoveUpCommand.CanExecute(null)); Assert.IsTrue(editor.MoveDownCommand.CanExecute(null)); Assert.IsTrue(editor.ClearCommand.CanExecute(null)); editor.SelectedIndex = 0; Assert.IsTrue(editor.AddCommand.CanExecute(null)); Assert.IsTrue(editor.RemoveCommand.CanExecute(null)); Assert.IsTrue(editor.CloneCommand.CanExecute(null)); Assert.IsFalse(editor.MoveUpCommand.CanExecute(null)); Assert.IsTrue(editor.MoveDownCommand.CanExecute(null)); Assert.IsTrue(editor.ClearCommand.CanExecute(null)); editor.SelectedIndex = 2; Assert.IsTrue(editor.AddCommand.CanExecute(null)); Assert.IsTrue(editor.RemoveCommand.CanExecute(null)); Assert.IsTrue(editor.CloneCommand.CanExecute(null)); Assert.IsTrue(editor.MoveUpCommand.CanExecute(null)); Assert.IsFalse(editor.MoveDownCommand.CanExecute(null)); Assert.IsTrue(editor.ClearCommand.CanExecute(null)); }
/// <summary> /// When the verb is invoked, use all the stuff above to show the dialog, etc. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnEditItems(object sender, EventArgs e) { object propertyValue = _targetProperty.GetValue(_designer.Component); if (propertyValue == null) { return; } CollectionEditor itemsEditor = TypeDescriptor.GetEditor(propertyValue, typeof(UITypeEditor)) as CollectionEditor; Debug.Assert(itemsEditor != null, "Didn't get a collection editor for type '" + _targetProperty.PropertyType.FullName + "'"); if (itemsEditor != null) { itemsEditor.EditValue(this, this, propertyValue); } }
public void CloneTest() { var editor = new CollectionEditor <string>(); var npcQueue = new Queue <PropertyChangedEventArgs>(); var cmdInvQueue = new Queue <EventArgs>(); editor.PropertyChanged += (s, p) => npcQueue.Enqueue(p); editor.CloneCommand.CanExecuteChanged += (s, e) => cmdInvQueue.Enqueue(e); editor.CloneCommand.Name.Is("Clone"); editor.CloneCommand.CheckCanExecute(false); editor.Items = new ObservableCollection <string> { "Item1", "Item2", "Item3" }; editor.CloneCommand.CheckCanExecute(false); npcQueue.CheckNext(Properties.ItemsPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.ItemCloner = p => "Clone of " + p; editor.CloneCommand.CheckCanExecute(false); npcQueue.CheckNext(Properties.ItemClonerPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.SelectedIndex = 0; editor.CloneCommand.CheckCanExecute(true); npcQueue.CheckNext(Properties.SelectedIndexPropertyChanged).CheckNext(Properties.SelectedItemPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.AllowClone = false; editor.CloneCommand.CheckCanExecute(false); npcQueue.CheckNext(Properties.AllowClonePropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.AllowClone = true; editor.CloneCommand.CheckCanExecute(true); npcQueue.CheckNext(Properties.AllowClonePropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.CloneCommand.Execute(null); editor.Items.Count.Is(4, "Items count"); editor.Items[1].Is("Clone of Item1"); editor.SelectedIndex.Is(1, "SelectedIndex"); editor.SelectedItem.Is("Clone of Item1", "SelectedItem"); npcQueue.CheckNext(Properties.SelectedIndexPropertyChanged).CheckNext(Properties.SelectedItemPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).CheckNext(Assert.IsNotNull).IsEmpty(); }
private void OnEditItems(object sender, EventArgs e) { object component = this._targetProperty.GetValue((object)this._designer.Component); if (component == null) { return; } CollectionEditor collectionEditor = TypeDescriptor.GetEditor(component, typeof(UITypeEditor)) as CollectionEditor; if (collectionEditor == null) { return; } collectionEditor.EditValue((ITypeDescriptorContext)this, (IServiceProvider)this, component); }
public void CollectionForm_EditValue_Set_GetReturnsExpected(object value) { var editor = new CollectionEditor(typeof(int[])); var form = new SubCollectionForm(editor) { EditValue = value }; Assert.Same(value, form.EditValue); Assert.Equal(1, form.OnEditValueChangedCallCount); // Set same. form.EditValue = value; Assert.Same(value, form.EditValue); Assert.Equal(2, form.OnEditValueChangedCallCount); }
public void CollectionForm_Items_SetWithoutContext_GetReturnsExpected(object[] value) { var editor = new CollectionEditor(typeof(int[])); var form = new SubCollectionForm(editor) { Items = value }; Assert.Null(form.EditValue); Assert.Empty(form.Items); Assert.Equal(0, form.OnEditValueChangedCallCount); // Set same. form.Items = value; Assert.Null(form.EditValue); Assert.Empty(form.Items); Assert.Equal(0, form.OnEditValueChangedCallCount); }
private void OnEditItems(object sender, EventArgs e) { object @value = this._targetProperty.GetValue(this._designer.Component); if (@value != null) { CollectionEditor editor = TypeDescriptor.GetEditor(@value, typeof(UITypeEditor)) as CollectionEditor; if (editor != null) { editor.EditValue(this, this, @value); } return; } else { return; } }
private void OnEditItems(object sender, EventArgs e) { DesignerActionUIService service = (DesignerActionUIService)((IServiceProvider)this).GetService(typeof(DesignerActionUIService)); if (service != null) { service.HideUI(this._designer.Component); } object component = this._targetProperty.GetValue(this._designer.Component); if (component != null) { CollectionEditor editor = TypeDescriptor.GetEditor(component, typeof(UITypeEditor)) as CollectionEditor; if (editor != null) { editor.EditValue(this, this, component); } } }
public void AddTest() { var editor = new CollectionEditor <string>(); var npcQueue = new Queue <PropertyChangedEventArgs>(); var cmdInvQueue = new Queue <EventArgs>(); editor.PropertyChanged += (s, p) => npcQueue.Enqueue(p); editor.AddCommand.CanExecuteChanged += (s, e) => cmdInvQueue.Enqueue(e); editor.AddCommand.Name.Is("Add"); editor.AddCommand.CheckCanExecute(false); editor.Items = new ObservableCollection <string> { "Item1", "Item2", "Item3" }; editor.AddCommand.CheckCanExecute(false); npcQueue.CheckNext(Properties.ItemsPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.ItemFactory = () => "New Item"; editor.AddCommand.CheckCanExecute(true); npcQueue.CheckNext(Properties.ItemFactoryPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.AllowAdd = false; editor.AddCommand.CheckCanExecute(false); npcQueue.CheckNext(Properties.AllowAddPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.AllowAdd = true; editor.AddCommand.CheckCanExecute(true); npcQueue.CheckNext(Properties.AllowAddPropertyChanged).IsEmpty(); cmdInvQueue.CheckNext(Assert.IsNotNull).IsEmpty(); editor.AddCommand.Execute(null); editor.Items.Count.Is(4, "Items count"); editor.Items[3].Is("New Item"); editor.SelectedIndex.Is(3, "SelectedIndex"); editor.SelectedItem.Is("New Item", "SelectedItem"); }
private void re_Click(object sender, RoutedEventArgs e) { ScadaDataPropertyChange ds = new ScadaDataPropertyChange(); ds.Items.Add(new Item() { Control = new Button(), PropertyName = "Name", VariableName = "P00" }); ds.Items.Add(new Item() { Control = new Button(), PropertyName = "Name", VariableName = "P00" }); ds.Items.Add(new Item() { Control = new Button(), PropertyName = "Name", VariableName = "P00" }); ddd.PropertyChange = ds; System.ComponentModel.Design.CollectionEditor df = new CollectionEditor(typeof(ScadaDataPropertyChange)); _asss.Instance = asaaa; }
/// <summary> /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"/> method. /// </summary> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; if (service == null || value == null) { return(value); } Control control; var form = new Form { StartPosition = FormStartPosition.CenterParent, Text = value.ToString(), Width = 600, Height = 400 }; if (value is string || value.GetType().IsValueType) { control = new TextBox { Multiline = true, ReadOnly = true, Text = value.ToString(), Dock = DockStyle.Fill }; form.Height = 200; form.Width = 300; } else if (value is IEnumerable) { var editor = new CollectionEditor(value.GetType()); return(editor.EditValue(context, provider, value)); } else { control = new PropertyGrid { SelectedObject = new CustomClass(string.Empty, value), Dock = DockStyle.Fill }; ((PropertyGrid)control).ExtendSearch(); } form.Controls.Add(control); service.ShowDialog(form); return(value); }
internal StyleEditorForm(CollectionEditor editor, bool isRowCollection) : base(editor) { this.editor = (StyleCollectionEditor)editor; this.isRowCollection = isRowCollection; this.InitializeComponent(); this.HookEvents(); DesignerUtils.ApplyListViewThemeStyles(this.columnsAndRowsListView); base.ActiveControl = this.columnsAndRowsListView; this.tlp = base.Context.Instance as TableLayoutPanel; this.tlp.SuspendLayout(); this.deleteList = new ArrayList(); IDesignerHost service = this.tlp.Site.GetService(typeof(IDesignerHost)) as IDesignerHost; if (service != null) { this.tlpDesigner = service.GetDesigner(this.tlp) as TableLayoutPanelDesigner; this.compSvc = service.GetService(typeof(IComponentChangeService)) as IComponentChangeService; } this.rowStyleProp = TypeDescriptor.GetProperties(this.tlp)["RowStyles"]; this.colStyleProp = TypeDescriptor.GetProperties(this.tlp)["ColumnStyles"]; this.tlpDesigner.SuspendEnsureAvailableStyles(); }