protected override CollectionForm CreateCollectionForm() { _CollectionForm = base.CreateCollectionForm(); _LayoutPanel = _CollectionForm.Controls["overArchingTableLayoutPanel"] as TableLayoutPanel; if (_LayoutPanel != null) { PropertyGrid propertyGrid = _LayoutPanel.Controls["propertyBrowser"] as PropertyGrid; if (propertyGrid != null) { propertyGrid.HelpVisible = true; propertyGrid.GotFocus += PropertyGridGotFocus; } } _CollectionForm.Load += CollectionFormLoad; _CollectionForm.Resize += CollectionFormResize; _CollectionForm.LocationChanged += CollectionFormLocationChanged; return (_CollectionForm); }
protected override CollectionForm CreateCollectionForm() { CollectionForm collectionForm = base.CreateCollectionForm(); collectionForm.Text = caption ?? DefaultCaption; return(collectionForm); }
public frmAddEditCollection(CollectionManager collMgr, User user) { _collectionManager = collMgr; _collection = null; _type = CollectionForm.Add; _user = user; InitializeComponent(); }
/// <summary> /// Creates a new form to show the current collection. /// </summary> /// <returns>The form.</returns> protected override CollectionForm CreateCollectionForm() { CollectionForm form = base.CreateCollectionForm(); InitializeForm(form); return(form); }
private static void ValidateEditValue(CollectionForm collectionForm) { if (okayButtons.ContainsKey(collectionForm)) { Button okayButton = okayButtons[collectionForm]; IList <MyClass> items = collectionForm.EditValue as IList <MyClass>; okayButton.Enabled = MyCollectionIsValid(items); } }
// == METHODS ===================================================================== /// <summary> /// OverWritten CreateCollectionForm method, to add needed callbacks /// </summary> /// <returns>the created Form</returns> protected override CollectionForm CreateCollectionForm() { CollectionForm collectionForm = base.CreateCollectionForm(); Button Ok = collectionForm.Controls[0].Controls[6].Controls[0] as Button; Ok.Click += new EventHandler(Ok_Click); collectionForm.FormClosed += new FormClosedEventHandler(collection_FormClosed); return(collectionForm); }
protected override CollectionForm CreateCollectionForm() { CollectionForm form = base.CreateCollectionForm(); Type type = form.GetType(); PropertyInfo propertyInfo = type.GetProperty("CollectionEditable", BindingFlags.Instance | BindingFlags.NonPublic); propertyInfo?.SetValue(form, true); return(form); }
/// <summary> /// Creates a new form to show the current collection. /// </summary> protected override CollectionForm CreateCollectionForm() { CollectionForm form = base.CreateCollectionForm(); // We want to switch the title to ImageCollection Editor instead of ImageListImage Editor. // The collection editor is actually using ImageListImages, while the collection we're actually editing is the Image collection. form.Text = SR.ImageCollectionEditorFormText; return(form); }
/// <summary> /// Takes the base collection form and apply some changes. /// </summary> /// <remarks> /// This method uses reflection to change the internal collection editor dialog on-thy-fly. /// </remarks> /// <returns>The changed form is beeing returned completely.</returns> protected override CollectionForm CreateCollectionForm() { CollectionForm form = base.CreateCollectionForm(); form.FormBorderStyle = FormBorderStyle.SizableToolWindow; form.Text = "<AREA> Editor"; Type t = form.GetType(); // Get the private variables via Reflection FieldInfo fieldInfo; fieldInfo = t.GetField("propertyBrowser", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { PropertyGrid propertyGrid = (PropertyGrid)fieldInfo.GetValue(form); if (propertyGrid != null) { propertyGrid.ToolbarVisible = false; propertyGrid.HelpVisible = true; } } fieldInfo = t.GetField("helpButton", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { Button removeButton = (Button)fieldInfo.GetValue(form); removeButton.Visible = false; } fieldInfo = t.GetField("addButton", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { Button addButton = (Button)fieldInfo.GetValue(form); addButton.Text = ResourceManager.GetString("AreaCollectionEditor.addButton.Text"); addButton.FlatStyle = FlatStyle.System; } fieldInfo = t.GetField("okButton", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { Button okButton = (Button)fieldInfo.GetValue(form); okButton.Left += okButton.Width + 3; okButton.FlatStyle = FlatStyle.System; } fieldInfo = t.GetField("cancelButton", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { Button cancelButton = (Button)fieldInfo.GetValue(form); cancelButton.Left += cancelButton.Width + 3; cancelButton.FlatStyle = FlatStyle.System; } Label memberLabel = new Label(); memberLabel.Text = ResourceManager.GetString("AreaCollectionEditor.memberLabel.Text"); memberLabel.Location = new Point(10, 8); memberLabel.Size = new Size(200, 15); form.Controls.Add(memberLabel); memberLabel.BringToFront(); return(form); }
// Override this method in order to access the containing user controls // from the default Collection Editor form or to add new ones... protected override CollectionForm CreateCollectionForm() { CollectionForm collectionForm = base.CreateCollectionForm(); collectionForm.FormClosing += new FormClosingEventHandler(collectionForm_FormClosing); // TODO: Look in collectionForm.Controls collection for other // controls, and hook up to their validation events return(collectionForm); }
void collectionForm_FormClosing(object sender, FormClosingEventArgs e) { CollectionForm collectionForm = (CollectionForm)sender; DialogResult result = collectionForm.DialogResult; if (result == DialogResult.OK) { // TODO: Perform validation, and set e.Cancel } }
private static void collectionForm_FormClosed(object sender, FormClosedEventArgs e) { CollectionForm collectionForm = (CollectionForm)sender; if (okayButtons.ContainsKey(collectionForm)) { okayButtons.Remove(collectionForm); } }
protected override CollectionForm CreateCollectionForm() { CollectionForm Form = base.CreateCollectionForm(); Form.Text = "DS4 Button Map Editor"; Form.HelpButton = false; Form.StartPosition = FormStartPosition.CenterParent; return(Form); }
protected override CollectionForm CreateCollectionForm() { CollectionForm form = base.CreateCollectionForm(); form.Shown += delegate { ShowDescription(form); }; return(form); }
protected override CollectionForm CreateCollectionForm() { CollectionForm cf = base.CreateCollectionForm(); cf.FormClosing += delegate(object sender, FormClosingEventArgs e) { ownerGrid.Refresh(); }; return(cf); }
/// <summary> /// Initialize the CollectionForm. Called from CreateCollectionForm(). /// </summary> /// <param name="form">The CollectionForm to initialize.</param> protected virtual void InitializeForm(CollectionForm form) { foreach (System.Windows.Forms.Control ctrl in form.Controls) { if (ctrl is PropertyGrid) { InitializePropertyGrid((PropertyGrid)ctrl); break; } } }
// Override this method in order to access the containing user controls // from the default Collection Editor form or to add new ones... protected override CollectionForm CreateCollectionForm() { CollectionForm collectionForm = base.CreateCollectionForm(); collectionForm.FormClosed += new FormClosedEventHandler(collectionForm_FormClosed); collectionForm.Load += new EventHandler(collectionForm_Load); if (collectionForm.Controls.Count > 0) { TableLayoutPanel mainPanel = collectionForm.Controls[0] as TableLayoutPanel; if ((mainPanel != null) && (mainPanel.Controls.Count > 7)) { // Get a reference to the inner PropertyGrid and hook // an event handler to it. PropertyGrid propertyGrid = mainPanel.Controls[5] as PropertyGrid; if (propertyGrid != null) { propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler( propertyGrid_PropertyValueChanged); } // Also hook to the Add/Remove TableLayoutPanel buttonPanel = mainPanel.Controls[1] as TableLayoutPanel; if ((buttonPanel != null) && (buttonPanel.Controls.Count > 1)) { Button addButton = buttonPanel.Controls[0] as Button; if (addButton != null) { addButton.Click += new EventHandler(addButton_Click); } Button removeButton = buttonPanel.Controls[1] as Button; if (removeButton != null) { removeButton.Click += new EventHandler(removeButton_Click); } } // Find the OK button, and hold onto it. buttonPanel = mainPanel.Controls[6] as TableLayoutPanel; if ((buttonPanel != null) && (buttonPanel.Controls.Count > 1)) { Button okayButton = buttonPanel.Controls[0] as Button; if (okayButton != null) { okayButtons[collectionForm] = okayButton; } } } } return(collectionForm); }
protected override CollectionForm CreateCollectionForm() { collectionForm = base.CreateCollectionForm(); string formText = Context.PropertyDescriptor.DisplayName; if (Context.PropertyDescriptor.Attributes[typeof (CollectionNameAttribute)] != null) { collectionName = ((CollectionNameAttribute) Context.PropertyDescriptor.Attributes[typeof (CollectionNameAttribute)]). Name; formText = collectionName; } if (Context.PropertyDescriptor.Attributes[typeof (CollectionFormNameAttribute)] != null) { formText = ((CollectionFormNameAttribute) Context.PropertyDescriptor.Attributes[typeof (CollectionFormNameAttribute)]).Name; ; } if (Context.PropertyDescriptor.Attributes[typeof (PropertiesNameAttribute)] != null) propertiesName = ((PropertiesNameAttribute) Context.PropertyDescriptor.Attributes[typeof (PropertiesNameAttribute)]). Name; collectionForm.Text = formText; listbox = (ListBox) collectionForm.Controls["overArchingTableLayoutPanel"].Controls["listbox"]; listbox.DrawItem += new DrawItemEventHandler(listbox_DrawItem); if (collectionForm.Controls.Find("propertyBrowser", true).Length > 0) { propertyGrid = (PropertyGrid) collectionForm.Controls.Find("propertyBrowser", true)[0]; propertyGrid.Validating += new CancelEventHandler(propertyGrid_Validating); } if (collectionForm.Controls.Find("addButton", true).Length > 0) { ((Button) collectionForm.Controls.Find("addButton", true)[0]).Click += new EventHandler(CorrectNameCollectionEditor_Click); } if (collectionForm.Controls.Find("okButton", true).Length > 0) { okButton = ((Button) collectionForm.Controls.Find("okButton", true)[0]); okButton.Visible = false; Button saveButton = new Button(); saveButton.Size = okButton.Size; saveButton.Location = okButton.Location; saveButton.Click += new EventHandler(saveButton_Click); saveButton.Text = "Сохранить"; okButton.Parent.Controls.Add(saveButton); } LocalizeEditorForm(collectionForm, collectionName, propertiesName); return collectionForm; }
protected override CollectionForm CreateCollectionForm() { handler = (Context.Instance as Model)?.Handler ?? (Context.Instance as ITabularObject)?.Model?.Handler; CollectionForm form = base.CreateCollectionForm(); form.Load += Form_Load; form.FormClosed += Form_FormClosed; return form; }
protected override CollectionForm CreateCollectionForm() { CollectionForm form = base.CreateCollectionForm(); var addButton = (ButtonBase)form.Controls.Find("addButton", true).First(); addButton.Click += (sender, e) => { MessageBox.Show("hello world"); }; return(form); }
/// <summary> /// Delegate for the custom Event MyFormClosed /// </summary> /// <param name="sender">The current collection Editor</param> /// <param name="e">The event arguments</param> void collection_FormClosed(object sender, FormClosedEventArgs e) { CollectionForm collectionForm = sender as CollectionForm; propertyLabel = Context.PropertyDescriptor.Name; Cancelled = collectionForm.DialogResult == DialogResult.Cancel; if (MyFormClosed != null) { MyFormClosed(this, e); } }
/// <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 CollectionForm CreateCollectionForm() { _mForm = base.CreateCollectionForm(); _mForm.Text = _mEditorAttribute.Title ?? _mForm.Text; Type formType = _mForm.GetType(); PropertyInfo pi = formType.GetProperty("CollectionEditable", BindingFlags.NonPublic | BindingFlags.Instance); pi.SetValue(_mForm, true, null); return(_mForm); }
// 开启属性描述 protected override CollectionForm CreateCollectionForm() { CollectionForm frm = base.CreateCollectionForm(); FieldInfo fileinfo = frm.GetType() .GetField("propertyBrowser", BindingFlags.NonPublic | BindingFlags.Instance); if (fileinfo != null) { (fileinfo.GetValue(frm) as System.Windows.Forms.PropertyGrid).HelpVisible = true; } return(frm); }
protected override CollectionForm CreateCollectionForm() { CollectionForm collectionForm = base.CreateCollectionForm(); Form frm = collectionForm as Form; if (frm != null) { Button button = frm.AcceptButton as Button; button.Click += new EventHandler(OnCollectionChanged); } return(collectionForm); }
protected override CollectionForm CreateCollectionForm() { object list = GetList(); //copy object's properties propertyCopies = new Dictionary <object, List <Tuple <PropertyInfo, object> > >(); int listCount = GetListCount(list); for (int n = 0; n < listCount; n++) { object listItem = GetListItem(list, n); List <Tuple <PropertyInfo, object> > pairList = new List <Tuple <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 Tuple <PropertyInfo, object>(property, value)); } propertyCopies.Add(listItem, pairList); } CollectionForm form = base.CreateCollectionForm(); form.FormClosed += FormClosed; return(form); }
/// <summary> /// Creates the CollectionForm and overrides some standard control text and behaviours. /// </summary> /// <returns>The CollectionForm.</returns> protected override CollectionForm CreateCollectionForm() { CollectionForm form = base.CreateCollectionForm(); form.Text = "Column Mapping Editor"; form.Width = 700; PropertyGrid propertyGrid = (PropertyGrid)form.Controls[0].Controls[5]; propertyGrid.HelpVisible = true; return(form); }
protected override CollectionForm CreateCollectionForm() { form = base.CreateCollectionForm(); var addButton = form.Controls.Find("addButton", true).First(); orgAddClickHandler = DisableEvents(addButton, "Click")[0]; addButton.Click += OverrideAddButtonClick; var removeButton = form.Controls.Find("removeButton", true).First(); orgRemoveClickHandler = DisableEvents(removeButton, "Click")[0]; removeButton.Click += OverrideRemoveButtonClick; return(form); }
protected override CollectionForm CreateCollectionForm() { CollectionForm cf = base.CreateCollectionForm(); cf.FormClosing += delegate(object sender, FormClosingEventArgs e) { ownerGrid.Refresh(); if (CollectionEditorClosed != null) { CollectionEditorClosed(this, value); } }; return(cf); }
protected override CollectionForm CreateCollectionForm() { CollectionForm collectionForm = base.CreateCollectionForm(); Form frm = collectionForm as Form; if (frm != null) { // Get OK button of the Collection Editor... Button button = frm.AcceptButton as Button; // Handle click event of the button button.Click += new EventHandler(OnCollectionChanged); } return(collectionForm); }
public void ShowDialog() { CollectionForm frm = CreateCollectionForm(); try { //MethodInfo methodInfo = frm.GetType().GetMethod("AddItems", BindingFlags.NonPublic | BindingFlags.Instance); //methodInfo.Invoke(frm, new object[] {Settings.Default.QuittData}); } catch (Exception) { } frm.ShowDialog(); }
protected override System.ComponentModel.Design.CollectionEditor.CollectionForm CreateCollectionForm() { CollectionForm cf = base.CreateCollectionForm(); foreach (Control c in cf.Controls) { if (c is PropertyGrid) { PropertyGrid pg = (PropertyGrid)c; pg.PropertyValueChanged += new PropertyValueChangedEventHandler(SkinCollectionEditor_PropertyValueChanged); pg.SelectedObjectsChanged += new EventHandler(pg_SelectedObjectsChanged); } } return(cf); }
protected override CollectionForm CreateCollectionForm() { Form = base.CreateCollectionForm(); if (Form.AcceptButton is Button button) { button.Click += (_, _) => OnOKClick(EventArgs.Empty); } button = Form.CancelButton as Button; if (button != null) { button.Click += (_, _) => OnCancelClick(EventArgs.Empty); } OnFormCreated(EventArgs.Empty); return(Form); }
/// <summary> /// Простая локализация формы редактирования свойств. /// </summary> /// <param name="collectionForm"></param> private void LocalizeEditorForm(CollectionForm collectionForm, string collectionName, string propertiesName) { #region Русификация и изменение надписей на форме Label BlaBlaProperties = new Label(); // перебираем все control-ы на форме и заменяем // неправильные надписи foreach (Control ctrl in collectionForm.Controls) { foreach (Control ctrl1 in ctrl.Controls) { if (ctrl1.GetType().ToString() == "System.Windows.Forms.Label" && (ctrl1.Text == "&Members:")) { ctrl1.Text = collectionName; } if (ctrl1.GetType().ToString() == "System.Windows.Forms.Label" && (ctrl1.Text.Contains("&Properties"))) { BlaBlaProperties = (Label) ctrl1; BlaBlaProperties.TextChanged += new EventHandler(BlaBlaProperties_TextChanged); ctrl1.Text = propertiesName; } if (ctrl1.GetType().ToString() == "System.Windows.Forms.Button" && (ctrl1.Text == "&Members:")) { ctrl1.Text = collectionName == null ? "&Члены:" : collectionName; } if (ctrl1.GetType().ToString() == "System.Windows.Forms.TableLayoutPanel") { foreach (Control ctrl2 in ctrl1.Controls) { if ((ctrl2.Text == "&Add")) { ctrl2.Text = "&Добавить"; } if (ctrl2.GetType().ToString() == "System.Windows.Forms.Button" && (ctrl2.Text == "&Remove")) { ctrl2.Text = "&Удалить"; } if (ctrl2.GetType().ToString() == "System.Windows.Forms.Button" && (ctrl2.Text == "Cancel")) { ctrl2.Text = "&Отменить"; } } } if (ctrl1.GetType().ToString() == "System.Windows.Forms.Design.VsPropertyGrid") { foreach (Control ctrl2 in ctrl1.Controls) { if (ctrl2.GetType().ToString() == "System.Windows.Forms.ToolStrip") { foreach (ToolStripItem item in ((ToolStrip) ctrl2).Items) { if (item.Text == "Categorized") { item.Text = "По категориям"; item.ToolTipText = "По категориям"; } if (item.Text == "Alphabetical") { item.Text = "По алфавиту"; item.ToolTipText = "По алфавиту"; } } } } } #region Заголовок списка свойств if (ctrl1.GetType().ToString() == "System.ComponentModel.Design.CollectionEditor+FilterListBox") { ((ListBox) ctrl1).SelectedIndexChanged += delegate(object sndr, EventArgs ea) { BlaBlaProperties.Text = propertiesName; }; } if (ctrl1.GetType().ToString() == "System.Windows.Forms.Design.VsPropertyGrid") { // и на редактирование в PropertyGrid ((PropertyGrid) ctrl1).SelectedGridItemChanged += delegate(Object sndr, SelectedGridItemChangedEventArgs segichd) { BlaBlaProperties.Text = propertiesName; }; // также сделать доступным окно с подсказками по параметрам // в нижней части ((PropertyGrid) ctrl1).HelpVisible = true; ((PropertyGrid) ctrl1).HelpBackColor = SystemColors.Info; } #endregion } } #endregion }
/// <summary> /// Creates a new form to display and edit the current collection. /// </summary> /// <returns> /// A <see cref="T:System.ComponentModel.Design.CollectionEditor.CollectionForm"></see> to provide as the user interface for editing the collection. /// </returns> protected override CollectionForm CreateCollectionForm() { EditorForm = base.CreateCollectionForm(); EditorForm.Text = CollectionItemType.GetCustomAttributeValue<DisplayNameAttribute, string>(x => x.DisplayName); return EditorForm; }
/// <summary> /// Creates a new form to display and edit the current collection. /// </summary> /// <returns> /// A <see cref="T:System.ComponentModel.Design.CollectionEditor.CollectionForm"></see> to provide as the user interface for editing the collection. /// </returns> protected override System.ComponentModel.Design.CollectionEditor.CollectionForm CreateCollectionForm( ) { this.EditorForm = base.CreateCollectionForm ( ); ; this.EditorForm.Text = this.CollectionItemType.GetCustomAttributeValue<DisplayNameAttribute, String> ( x => x.DisplayName ); return this.EditorForm; }
private void AddCopyButton(CollectionForm collectionForm) { _CopyButton = new Button(); _CopyButton.Size = new Size(23, 24); _CopyButton.Enabled = false; _CopyButton.Click += CopyButton_Click; ResourceManager rm = Resources.ResourceManager; _CopyButton.Image = (Image)rm.GetObject("Copy"); collectionForm.Controls.Add(_CopyButton); _CopyButton.Location = new Point(208, 85); _CopyButton.BringToFront(); _ToolTip = new ToolTip(); _ToolTip.SetToolTip(_CopyButton, "Clone the selected item"); }
/// <summary> /// Creates a new form to display and edit the current collection. /// </summary> /// <returns> A CollectionEditor.CollectionForm to provide as the user interface for editing the collection.</returns> protected override CollectionForm CreateCollectionForm() { this.m_collectionForm = base.CreateCollectionForm(); return this.m_collectionForm; }