/// <summary> /// This should launch an open file dialog instead of the usual thing. /// </summary> /// <param name="context">System.ComponentModel.ITypeDescriptorContext</param> /// <param name="provider">IServiceProvider</param> /// <param name="value">The object being displayed</param> /// <returns>A new version of the object if the dialog was ok.</returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { object _backup; ICloneable parent = value as ICloneable; if (parent != null) { _backup = parent.Clone(); } else { _backup = value; } IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); PropertyDialog frm = new PropertyDialog(dialogProvider); frm.PropertyGrid.SelectedObject = value; if (dialogProvider.ShowDialog(frm) == System.Windows.Forms.DialogResult.OK) { return value; } else { return _backup; } }
/// <summary> /// Shows a PropertyGrid Dialog and uses the specified object as the edit copy. /// </summary> /// <param name="editCopy"></param> public void ShowDialog(object editCopy) { _frmDialog = new PropertyDialog(); _frmDialog.PropertyGrid.SelectedObject = editCopy; _frmDialog.ChangesApplied += frmDialog_ChangesApplied; _frmDialog.ShowDialog(); }
private void btnShadedRelief_Click(object sender, EventArgs e) { PropertyDialog frm = new PropertyDialog(); IShadedRelief newCopy = _rasterSymbolizer.ShadedRelief.Copy(); frm.PropertyGrid.SelectedObject = newCopy; if (frm.ShowDialog(this) != DialogResult.OK) return; _rasterSymbolizer.ShadedRelief = newCopy; OnDataChanged(); }
private void Configure() { dgvCategories.CellFormatting += dgvCategories_CellFormatting; dgvCategories.CellDoubleClick += dgvCategories_CellDoubleClick; dgvCategories.SelectionChanged += new EventHandler(dgvCategories_SelectionChanged); dgvCategories.CellValidated += new DataGridViewCellEventHandler(dgvCategories_CellValidated); dgvCategories.MouseDown += new MouseEventHandler(dgvCategories_MouseDown); cmbInterval.SelectedItem = "EqualInterval"; breakSliderGraph1.SliderSelected += new EventHandler<BreakSliderEventArgs>(breakSliderGraph1_SliderSelected); _quickSchemes = new ContextMenu(); string[] names = Enum.GetNames(typeof(ColorSchemes)); foreach (string name in names) { MenuItem mi = new MenuItem(name, QuickSchemeClicked); _quickSchemes.MenuItems.Add(mi); } cmbIntervalSnapping.Items.Clear(); var result = Enum.GetValues(typeof (IntervalSnapMethods)); foreach (var item in result) { cmbIntervalSnapping.Items.Add(item); } cmbIntervalSnapping.SelectedItem = IntervalSnapMethods.Rounding; _cleanupTimer = new Timer(); _cleanupTimer.Interval = 10; _cleanupTimer.Tick += new EventHandler(_cleanupTimer_Tick); // Allows shaded Relief to be edited _shadedReliefDialog = new PropertyDialog(); _shadedReliefDialog.ChangesApplied += PropertyDialog_ChangesApplied; }