protected override CollectionEditor.CollectionForm CreateCollectionForm() { _form = base.CreateCollectionForm(); _form.Text = "Index Editor"; /* Doing this because I can't figure out how to get the Columns collection editor to notify this editor when a column of an index is updated. * This forces the collection editor form to be "dirty" which calls SetItems() when you hit OK or cancel. Otherwise, if you * change a column around and hit OK, then hit OK on this editor, it won't be dirty and won't update. */ try { _form.GetType().InvokeMember("dirty", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetField, null, _form, new object[] { true }); } catch { } foreach (Control c in _form.Controls[0].Controls) { PropertyGrid grid = c as PropertyGrid; if (grid != null) { grid.HelpVisible = true; break; } } _form.Width = (int)(_form.Width * 1.25); _form.Height = (int)(_form.Height * 1.25); return(_form); }
/// <summary> /// Creates a new form to display and edit the current collection. /// </summary> /// <returns>A <see cref="CollectionEditor.CollectionForm"/> to provide as the user interface for editing the collection.</returns> protected override CollectionEditor.CollectionForm CreateCollectionForm() { m_Form = base.CreateCollectionForm(); m_Form.Text = Title; // Die Eigenschaft "CollectionEditable" muss hier per Reflection gesetzt werden (ist protected) Type formType = m_Form.GetType(); PropertyInfo pi = formType.GetProperty("CollectionEditable", BindingFlags.NonPublic | BindingFlags.Instance); pi.SetValue(m_Form, true, null); return(m_Form); }
/// <summary> /// Creates a new form to display and edit the current collection. /// </summary> /// <returns>A <see cref="CollectionEditor.CollectionForm"/> to provide as the user interface for editing the collection.</returns> protected override CollectionEditor.CollectionForm CreateCollectionForm() { m_Form = base.CreateCollectionForm(); m_Form.Text = this.m_EditorAttribute.Title ?? Wexman.Design.Properties.Resource1.GenericDictionaryEditorTitle; // Die Eigenschaft "CollectionEditable" muss hier per Reflection gesetzt werden (ist protected) Type formType = m_Form.GetType(); PropertyInfo pi = formType.GetProperty("CollectionEditable", BindingFlags.NonPublic | BindingFlags.Instance); pi.SetValue(m_Form, true, null); return(m_Form); }
/// <summary> /// Creates a new CollectionForm to display the collection editor /// </summary> /// <remarks> /// This methods uses reflection to access non-public fields/properties within the collectionform. /// This method can also be used to alter other visual aspects of the form. /// </remarks> /// <returns>CollectionForm</returns> protected override CollectionForm CreateCollectionForm() { //Get a reference top new collection form CollectionEditor.CollectionForm form = base.CreateCollectionForm(); //Center the form form.StartPosition = FormStartPosition.CenterParent; //Get the forms type Type formType = form.GetType(); //Get a reference to the private fieldtype propertyBrowser //This is the propertgrid inside the collectionform FieldInfo fieldInfo = formType.GetField("propertyBrowser", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { //get a reference to the propertygrid instance located on the form PropertyGrid propertyGrid = (PropertyGrid)fieldInfo.GetValue(form); if (propertyGrid != null) { //Make the tool bar visible propertyGrid.ToolbarVisible = true; //Make the help/description visible propertyGrid.HelpVisible = true; //Get the property grid's type. //Note that this is a vsPropertyGrid located in System.Windows.Forms.Design Type propertyGridType = propertyGrid.GetType(); //Get a reference to the non-public property ToolStripRenderer PropertyInfo propertyInfo = propertyGridType.GetProperty("ToolStripRenderer", BindingFlags.NonPublic | BindingFlags.Instance); if (propertyInfo != null) { //Assign a ToolStripProfessionalRenderer with our custom color table propertyInfo.SetValue(propertyGrid, new ToolStripProfessionalRenderer(new CustomColorTable()), null); } } } //Return the form return(form); }
/// <summary> /// Overriden, so that we can change the properties of the PropertyGrid. This is done /// via Reflection. /// </summary> /// <returns>The form</returns> protected override CollectionForm CreateCollectionForm() { CollectionEditor.CollectionForm form = base.CreateCollectionForm(); Type t = form.GetType(); // Get the private variable PropertyGrid.propertyBrowser via Reflection FieldInfo fieldInfo = t.GetField("propertyBrowser", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { PropertyGrid propertyGrid = (PropertyGrid)fieldInfo.GetValue(form); if (propertyGrid != null) { propertyGrid.ToolbarVisible = true; propertyGrid.HelpVisible = true; propertyGrid.BackColor = SystemColors.Control; } } return(form); }
protected override CollectionForm CreateCollectionForm() { CollectionEditor.CollectionForm form = base.CreateCollectionForm(); form.StartPosition = FormStartPosition.CenterParent; Type formType = form.GetType(); FieldInfo fieldInfo = formType.GetField("propertyBrowser", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { PropertyGrid propertyGrid = (PropertyGrid)fieldInfo.GetValue(form); if (propertyGrid != null) { propertyGrid.ToolbarVisible = true; propertyGrid.HelpVisible = true; Type propertyGridType = propertyGrid.GetType(); PropertyInfo propertyInfo = propertyGridType.GetProperty("ToolStripRenderer", BindingFlags.NonPublic | BindingFlags.Instance); if (propertyInfo != null) { propertyInfo.SetValue(propertyGrid, new ToolStripSystemRenderer(), null); } } } return(form); }
protected override CollectionEditor.CollectionForm CreateCollectionForm() { object list = GetList(); //copy object's properties propertyCopies = new Dictionary <object, List <Pair <PropertyInfo, object> > >(); int listCount = GetListCount(list); for (int n = 0; n < listCount; n++) { object listItem = GetListItem(list, n); List <Pair <PropertyInfo, object> > pairList = new List <Pair <PropertyInfo, object> >(); foreach (PropertyInfo property in listItem.GetType().GetProperties()) { if (!property.CanWrite) { continue; } BrowsableAttribute[] browsableAttributes = (BrowsableAttribute[])property. GetCustomAttributes(typeof(BrowsableAttribute), true); if (browsableAttributes.Length != 0) { bool browsable = true; foreach (BrowsableAttribute browsableAttribute in browsableAttributes) { if (!browsableAttribute.Browsable) { browsable = false; break; } } if (!browsable) { continue; } } object value = property.GetValue(listItem, null); pairList.Add(new Pair <PropertyInfo, object>(property, value)); } propertyCopies.Add(listItem, pairList); } CollectionEditor.CollectionForm form = base.CreateCollectionForm(); form.FormClosed += FormClosed; //enable fields with Config attribute EngineApp.Instance.Config.RegisterClassParameters(typeof(ProjectEntitiesGeneralListCollectionEditor)); //restore saved window state if (lastWindowSize != Vec2I.Zero && IsVisibleOnAnyScreen(new Rectangle(lastWindowPosition.X, lastWindowPosition.Y, lastWindowSize.X, lastWindowSize.Y))) { form.Location = new Point(lastWindowPosition.X, lastWindowPosition.Y); form.Size = new Size(lastWindowSize.X, lastWindowSize.Y); form.StartPosition = FormStartPosition.Manual; } else { form.Size = new System.Drawing.Size(1100, 800); } //show descriptions try { FieldInfo field = form.GetType().GetField("propertyBrowser", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); PropertyGrid grid = field.GetValue(form) as PropertyGrid; grid.HelpVisible = true; } catch { } return(form); }