public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Reference retval = null; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var table = (Table)context.Instance; var root = (ModelRoot)table.Root; var referenceCollection = table.Columns; //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; newBox.Items.Add("(Not Set)"); foreach(Reference reference in referenceCollection) { var column = ((ModelRoot)reference.Root).Database.Columns.GetById(reference.Ref)[0]; newBox.Items.Add(column); } edSvc.DropDownControl(newBox); if((newBox.SelectedIndex > 0) && (newBox.SelectedItem != null)) retval = ((Column)newBox.SelectedItem).CreateRef(); } catch(Exception ex) { } return retval; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var retval = false; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var column = (ColumnBase)context.Instance; retval = column.AllowNull; //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var values = new List <string>(); values.Add(false.ToString()); values.Add(true.ToString()); newBox.Items.AddRange(values.ToArray()); newBox.SelectedIndex = (column.AllowNull ? 1 : 0); edSvc.DropDownControl(newBox); if ((column != null) && (newBox.SelectedIndex != -1)) { retval = (newBox.SelectedIndex == 0 ? false : true); } } catch (Exception ex) { } return(retval); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var retval = Guid.Empty; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var moduleRule = context.Instance as ModuleRule; var modulelist = moduleRule.Module.nHydrateModel.Modules.OrderBy(x => x.Name).Where(x => x.Id != moduleRule.Module.Id).ToList(); var selected = modulelist.FirstOrDefault(x=>x.Id == moduleRule.DependentModule); //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var values = new List<string>(); values.Add(false.ToString()); values.Add(true.ToString()); newBox.Items.AddRange(modulelist.Select(x => x.Name).ToArray()); if (selected != null) newBox.SelectedIndex = modulelist.IndexOf(selected); edSvc.DropDownControl(newBox); if ((moduleRule != null) && (newBox.SelectedIndex != -1)) retval = modulelist[newBox.SelectedIndex].Id; } catch (Exception ex) { } return retval; }
//------------------------------------------------------------------------------------------------------ public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (context.Instance != null) && (provider != null)) { // Получаем интерфейс сервиса service = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService( typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (service != null) { Channel4_20Control cntrl = new Channel4_20Control(); cntrl.ValueChanged += new MeasuringDeviceTech.Classes.MeasuringDevice.UITypeEditors.ValueChangedEventHandler(cntrl_ValueChanged); cntrl.Value = (UInt32)value; service.DropDownControl(cntrl); value = cntrl.Value; } } else { return base.EditValue(context, provider, value); } return value; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Reference retval = null; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var table = (Table)context.Instance; var root = (ModelRoot)table.Root; var referenceCollection = table.Columns; //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; newBox.Items.Add("(Not Set)"); foreach (Reference reference in referenceCollection) { var column = ((ModelRoot)reference.Root).Database.Columns.GetById(reference.Ref)[0]; newBox.Items.Add(column); } edSvc.DropDownControl(newBox); if ((newBox.SelectedIndex > 0) && (newBox.SelectedItem != null)) { retval = ((Column)newBox.SelectedItem).CreateRef(); } } catch (Exception ex) { } return(retval); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var retval = Guid.Empty; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var indexColumn = context.Instance as IndexColumn; var field = indexColumn.Index.Entity.Fields.FirstOrDefault(x => x.Id == indexColumn.FieldID); var fieldList = indexColumn.Index.Entity.Fields.OrderBy(x => x.Name).ToList(); //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; newBox.Items.AddRange(fieldList.Select(x => x.Name).ToArray()); if (field != null) newBox.SelectedIndex = fieldList.IndexOf(field); edSvc.DropDownControl(newBox); if ((indexColumn != null) && (newBox.SelectedIndex != -1)) retval = fieldList[newBox.SelectedIndex].Id; } catch (Exception ex) { } return retval; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var retval = System.Data.SqlDbType.VarChar; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var column = (ColumnBase)context.Instance; retval = column.DataType; //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var values = new List<string>(); foreach (var t in Enum.GetNames(typeof(System.Data.SqlDbType)).OrderBy(x => x)) { values.Add(t); } newBox.Items.AddRange(values.ToArray()); newBox.SelectedIndex = newBox.FindString(column.DataType.ToString()); edSvc.DropDownControl(newBox); if ((column != null) && (newBox.SelectedIndex != -1)) retval = (System.Data.SqlDbType)Enum.Parse(typeof(System.Data.SqlDbType), values[newBox.SelectedIndex]); } catch (Exception ex) { } return retval; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var retval = Guid.Empty; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var indexColumn = context.Instance as IndexColumn; var field = indexColumn.Index.Entity.Fields.FirstOrDefault(x => x.Id == indexColumn.FieldID); var fieldList = indexColumn.Index.Entity.Fields.OrderBy(x => x.Name).ToList(); //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; newBox.Items.AddRange(fieldList.Select(x => x.Name).ToArray()); if (field != null) { newBox.SelectedIndex = fieldList.IndexOf(field); } edSvc.DropDownControl(newBox); if ((indexColumn != null) && (newBox.SelectedIndex != -1)) { retval = fieldList[newBox.SelectedIndex].Id; } } catch (Exception ex) { } return(retval); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var retval = false; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var column = (ColumnBase)context.Instance; retval = column.AllowNull; //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var values = new List<string>(); values.Add(false.ToString()); values.Add(true.ToString()); newBox.Items.AddRange(values.ToArray()); newBox.SelectedIndex = (column.AllowNull ? 1 : 0); edSvc.DropDownControl(newBox); if ((column != null) && (newBox.SelectedIndex != -1)) retval = (newBox.SelectedIndex == 0 ? false : true); } catch (Exception ex) { } return retval; }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService) provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc != null) { lb = new System.Windows.Forms.ListBox(); lb.BorderStyle = System.Windows.Forms.BorderStyle.None; lb.SelectedIndexChanged += new EventHandler(lb_SelectedIndexChanged); lb.Items.Add("onclick"); lb.Items.Add("ondblclick"); lb.Items.Add("onmouseover"); lb.Items.Add("onfocus"); lb.Items.Add("oncontextmenu"); edSvc.DropDownControl(lb); if (lb.SelectedIndex == -1) { return(value); } return(lb.SelectedItem); } } return(value); }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService) provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc != null) { lb = new System.Windows.Forms.ListBox(); lb.BorderStyle = System.Windows.Forms.BorderStyle.None; lb.SelectedIndexChanged += new EventHandler(lb_SelectedIndexChanged); foreach (Control ctrl in ((Control)context.Instance).Page.Controls) { if (ctrl.GetType().IsSubclassOf(typeShow) || ctrl.GetType().FullName == typeShow.FullName) { lb.Items.Add(ctrl.ID); } } edSvc.DropDownControl(lb); if (lb.SelectedIndex == -1) { return(value); } return(lb.SelectedItem); } } return(value); }
//------------------------------------------------------------------------------------------------------ public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (context.Instance != null) && (provider != null)) { // Получаем интерфейс сервиса service = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService( typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (service != null) { Channel4_20Control cntrl = new Channel4_20Control(); cntrl.ValueChanged += new MeasuringDeviceTech.Classes.MeasuringDevice.UITypeEditors.ValueChangedEventHandler(cntrl_ValueChanged); cntrl.Value = (UInt32)value; service.DropDownControl(cntrl); value = cntrl.Value; } } else { return(base.EditValue(context, provider, value)); } return(value); }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null || context.Instance == null || provider == null) { return base.EditValue(context, provider, value); } if ((m_EdSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService))) == null) { return value; } // Create a CheckedListBox and populate it with all the propertylist values m_List = new System.Windows.Forms.ListBox(); m_List.BorderStyle = System.Windows.Forms.BorderStyle.None; foreach (GXCategory cat in (context.Instance as GXKeepalive).Parent.Categories) { foreach (GXProperty prop in cat.Properties) { m_List.Items.Add(prop); } } if (value != null) { m_List.SelectedIndex = m_List.Items.IndexOf(value); } m_List.SelectedIndexChanged += new System.EventHandler(this.OnSelectedIndexChanged); // Show Listbox as a DropDownControl. This methods returns only when the dropdowncontrol is closed m_EdSvc.DropDownControl(m_List); (context.Instance as GXKeepalive).Target = m_List.SelectedItem; return value; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var retval = System.Data.SqlDbType.VarChar; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var column = (ColumnBase)context.Instance; retval = column.DataType; //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var values = new List <string>(); foreach (var t in Enum.GetNames(typeof(System.Data.SqlDbType)).OrderBy(x => x)) { values.Add(t); } newBox.Items.AddRange(values.ToArray()); newBox.SelectedIndex = newBox.FindString(column.DataType.ToString()); edSvc.DropDownControl(newBox); if ((column != null) && (newBox.SelectedIndex != -1)) { retval = (System.Data.SqlDbType)Enum.Parse(typeof(System.Data.SqlDbType), values[newBox.SelectedIndex]); } } catch (Exception ex) { } return(retval); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Reference retval = null; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); ModelRoot root = null; if (context.Instance is Relation) { root = (ModelRoot)((Relation)context.Instance).Root; } else if (context.Instance is Table) { root = (ModelRoot)((Table)context.Instance).Root; } var tableCollection = root.Database.Tables; //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var sortedList = new SortedList(); foreach (Table table in tableCollection) { //Ensure key is unique to avoid error var text = table.Name.ToLower(); var key = text; var ii = 0; while (sortedList.ContainsKey(key)) { key = text + ii.ToString(); ii++; } sortedList.Add(key, table); } //Re-add them in order foreach (DictionaryEntry di in sortedList) { newBox.Items.Add((Table)di.Value); } edSvc.DropDownControl(newBox); if ((newBox.SelectedIndex > -1) && (newBox.SelectedItem != null)) { retval = ((Table)newBox.SelectedItem).CreateRef(); } } catch (Exception ex) { } return(retval); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { m_objService = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (m_objService != null) Configuration.ShowConfiguration((PLCConnectionConfiguration) value); } return value; }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { System.Windows.Forms.Design.IWindowsFormsEditorService edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc != null) { GenerePicker genereEdit = new GenerePicker((Book.BookGenere)value); edSvc.DropDownControl(genereEdit); return(genereEdit.Genere); } return(value); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { m_objService = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (m_objService != null) { value = NckTagEditor.ShowPLCTagEditor((PLCNckTag)value); } } return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { try { System.Windows.Forms.Design.IWindowsFormsEditorService edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); Widgetsphere.Generator.Forms.CustomViewColumnCollectionForm F = new Widgetsphere.Generator.Forms.CustomViewColumnCollectionForm(); if (edSvc.ShowDialog(F) == System.Windows.Forms.DialogResult.OK) { context.OnComponentChanged(); } } catch (Exception ex) { } return(value); }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null || context.Instance == null || provider == null) { return base.EditValue(context, provider, value); } if ((m_EdSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService))) == null) { return value; } // Create a CheckedListBox and populate it with all the propertylist values m_List = new System.Windows.Forms.ListBox(); m_List.DrawItem += new System.Windows.Forms.DrawItemEventHandler(OnDrawItem); m_List.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; m_List.BorderStyle = System.Windows.Forms.BorderStyle.None; if (context.PropertyDescriptor.PropertyType == typeof(Type)) { m_List.Items.Add(typeof(string)); m_List.Items.Add(typeof(DateTime)); m_List.Items.Add(typeof(byte)); m_List.Items.Add(typeof(UInt16)); m_List.Items.Add(typeof(UInt32)); m_List.Items.Add(typeof(UInt64)); m_List.Items.Add(typeof(sbyte)); m_List.Items.Add(typeof(Int16)); m_List.Items.Add(typeof(Int32)); m_List.Items.Add(typeof(Int64)); } else { foreach(object it in Enum.GetValues(context.PropertyDescriptor.PropertyType)) { m_List.Items.Add(it); } } if (value != null) { m_List.SelectedIndex = m_List.Items.IndexOf(value); } m_List.SelectedIndexChanged += new System.EventHandler(this.OnSelectedIndexChanged); // Show Listbox as a DropDownControl. This methods returns only when the dropdowncontrol is closed m_EdSvc.DropDownControl(m_List); m_List.SelectedIndexChanged -= new System.EventHandler(this.OnSelectedIndexChanged); if (m_List.SelectedItem != null) { return m_List.SelectedItem ; } return value; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (provider != null) { service = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); } if (provider != null) { MyColor c = (MyColor)value; System.Windows.Forms.ColorDialog cd = new System.Windows.Forms.ColorDialog(); cd.Color = Color.FromArgb(c.GetARGB()); cd.ShowDialog(); value = new MyColor(cd.Color.ToArgb()); } return(value); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { System.Windows.Forms.Design.IWindowsFormsEditorService edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc != null) { // 可以打开任何特定的对话框 OpenFileDialog dialog = new OpenFileDialog(); dialog.AddExtension = false; if (dialog.ShowDialog().Equals(DialogResult.OK)) { return(dialog.FileName); } } return(value); }
public override Object EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value) { if ((context != null) && (provider != null)) { System.Windows.Forms.Design.IWindowsFormsEditorService svc = (System.Windows.Forms.Design.IWindowsFormsEditorService) provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (svc != null) { VerticesEditorWindow ipfrm = new VerticesEditorWindow((List <Vector>)value); ipfrm.ShowDialog(); } } return(base.EditValue(context, provider, value)); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Reference retval = null; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); ModelRoot root = null; if (context.Instance is Relation) root = (ModelRoot)((Relation)context.Instance).Root; else if (context.Instance is Table) root = (ModelRoot)((Table)context.Instance).Root; var tableCollection = root.Database.Tables; //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var sortedList = new SortedList(); foreach (Table table in tableCollection) { //Ensure key is unique to avoid error var text = table.Name.ToLower(); var key = text; var ii = 0; while (sortedList.ContainsKey(key)) { key = text + ii.ToString(); ii++; } sortedList.Add(key, table); } //Re-add them in order foreach (DictionaryEntry di in sortedList) newBox.Items.Add((Table)di.Value); edSvc.DropDownControl(newBox); if ((newBox.SelectedIndex > -1) && (newBox.SelectedItem != null)) retval = ((Table)newBox.SelectedItem).CreateRef(); } catch (Exception ex) { } return retval; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { try { System.Windows.Forms.Design.IWindowsFormsEditorService edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); Table table = (Table)context.Instance; Widgetsphere.Generator.Forms.UnitTestDependencyForm F = new Widgetsphere.Generator.Forms.UnitTestDependencyForm(table); if (edSvc.ShowDialog(F) == System.Windows.Forms.DialogResult.OK) { table.UnitTestDependencies.Clear(); table.UnitTestDependencies.AddRange(F.GetSelectedList()); table.Name = table.Name; //Make Dirty context.OnComponentChanged(); } } catch (Exception ex) { } return(value); }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null || context.Instance == null || provider == null) { return(base.EditValue(context, provider, value)); } if ((m_EdSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService))) == null) { return(value); } Target = value; // Create a CheckedListBox and populate it with all the propertylist values button = new Button(); button.Text = "Disable All Tests"; button.Click += new System.EventHandler(OnDisable); m_EdSvc.DropDownControl(button); return(value); }
//------------------------------------------------------------------------------------------------------ public override object EditValue( System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (context.Instance != null) && (provider != null)) { service = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService( typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (service != null) { if (context.Instance is MeasuringDeviceMainPower) { MeasuringPeriodMainPowerControl cntr = new MeasuringPeriodMainPowerControl(TYPE_NGK_DEVICE.BI_MAIN_POWERED); cntr.ValueChanged += new ValueChangedEventHandler(cntr_ValueChanged); cntr.Value = (UInt32)value; service.DropDownControl(cntr); value = cntr.Value; } else if (context.Instance is MeasuringDeviceBatteryPower) { MeasuringPeriodMainPowerControl cntr = new MeasuringPeriodMainPowerControl(TYPE_NGK_DEVICE.BI_BATTERY_POWER); cntr.ValueChanged += new ValueChangedEventHandler(cntr_ValueChanged); cntr.Value = (UInt32)value; service.DropDownControl(cntr); value = cntr.Value; } else { throw new InvalidOperationException( "Объект для которого вызывается редактор не яввляется устройством БИ"); } } } else { return(base.EditValue(context, provider, value)); } return(value); }
//------------------------------------------------------------------------------------------------------ public override object EditValue( System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (context.Instance != null) && (provider != null)) { service = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService( typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (service != null) { if (context.Instance is MeasuringDeviceMainPower) { MeasuringPeriodMainPowerControl cntr = new MeasuringPeriodMainPowerControl(TYPE_NGK_DEVICE.BI_MAIN_POWERED); cntr.ValueChanged += new ValueChangedEventHandler(cntr_ValueChanged); cntr.Value = (UInt32)value; service.DropDownControl(cntr); value = cntr.Value; } else if (context.Instance is MeasuringDeviceBatteryPower) { MeasuringPeriodMainPowerControl cntr = new MeasuringPeriodMainPowerControl(TYPE_NGK_DEVICE.BI_BATTERY_POWER); cntr.ValueChanged += new ValueChangedEventHandler(cntr_ValueChanged); cntr.Value = (UInt32)value; service.DropDownControl(cntr); value = cntr.Value; } else { throw new InvalidOperationException( "Объект для которого вызывается редактор не яввляется устройством БИ"); } } } else { return base.EditValue(context, provider, value); } return value; }
//------------------------------------------------------------------------------- #endregion //------------------------------------------------------------------------------- #region Methods //------------------------------------------------------------------------------- public override object EditValue( System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (context.Instance != null) && (provider != null)) { service = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService( typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (service != null) { if (context.Instance is IDataLinkLayer) { System.IO.Ports.SerialPort port = (System.IO.Ports.SerialPort)value; SerialPortSettings cntr = new SerialPortSettings(port); cntr.EditingIsComplete += new EditingIsCompleteEventHandler(cntr_EditingIsComplete); if (port.IsOpen) { // Запрещаем редактирование cntr.Enabled = false; } service.DropDownControl(cntr); value = cntr.SerialPort; } else { throw new InvalidOperationException( "Объект для которого вызывается редактор не яввляется IDataLinkLayer"); } } } else { return(base.EditValue(context, provider, value)); } return(value); }
//------------------------------------------------------------------------------- #endregion //------------------------------------------------------------------------------- #region Methods //------------------------------------------------------------------------------- public override object EditValue( System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (context.Instance != null) && (provider != null)) { service = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService( typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (service != null) { if (context.Instance is IDataLinkLayer) { System.IO.Ports.SerialPort port = (System.IO.Ports.SerialPort)value; SerialPortSettings cntr = new SerialPortSettings(port); cntr.EditingIsComplete += new EditingIsCompleteEventHandler(cntr_EditingIsComplete); if (port.IsOpen) { // Запрещаем редактирование cntr.Enabled = false; } service.DropDownControl(cntr); value = cntr.SerialPort; } else { throw new InvalidOperationException( "Объект для которого вызывается редактор не яввляется IDataLinkLayer"); } } } else { return base.EditValue(context, provider, value); } return value; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context!=null && context.Instance!=null && provider!=null) { m_EditorService=(System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if(m_EditorService!=null) { if(context.Instance is Bar) { Bar bar=context.Instance as Bar; if(bar.Owner is DotNetBarManager && ((DotNetBarManager)bar.Owner).UseGlobalColorScheme) System.Windows.Forms.MessageBox.Show("Please note that your DotNetBarManager has its UseGlobalColorScheme set to true and any changes you make to ColorScheme object on the bar will not be used."); } else if(context.Instance is DotNetBarManager && !((DotNetBarManager)context.Instance).UseGlobalColorScheme) { System.Windows.Forms.MessageBox.Show("Please note that you need to set UseGlobalColorScheme=true in order for all bars to use ColorScheme you change on this dialog."); } if(value==null) value=new ColorScheme(); ColorSchemeEditor editor=new ColorSchemeEditor(); editor.CreateControl(); editor.ColorScheme=(ColorScheme)value; m_EditorService.ShowDialog(editor); if(editor.ColorSchemeChanged) { value=editor.ColorScheme; context.OnComponentChanged(); ((ColorScheme)value)._DesignTimeSchemeChanged=true; if(context.Instance is Bar) { ((Bar)context.Instance).Refresh(); } } editor.Close(); } } return value; }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (!(value is ValueColorCollection)) { return(value); } ValuesColorEditorForm editorform = new ValuesColorEditorForm(value); System.Windows.Forms.Design.IWindowsFormsEditorService edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc != null) { if (edSvc.ShowDialog(editorform) == DialogResult.OK) { return(editorform.valuesColor); } } return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (null != context && null != context.Instance && null != provider) { this._service = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (null != this._service) { FormShowObject frm = new FormShowObject(value); switch (this._service.ShowDialog(frm)) { case DialogResult.OK: value = frm.SelectedObject; break; case DialogResult.Cancel: break; } } } return(value); }
/// <summary> /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle" /> method. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that can be used to gain additional context information.</param> /// <param name="provider">An <see cref="T:System.IServiceProvider" /> that this editor can use to obtain services.</param> /// <param name="value">The object to edit.</param> /// <returns>The new value of the object. If the value of the object has not changed, this should return the same object it was passed.</returns> public override Object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, Object value) { if (context != null && context.Instance != null && provider != null) { this.edSvc = ((System.Windows.Forms.Design.IWindowsFormsEditorService)(provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)))); if (this.edSvc != null) { this.TextFormatNamesList.Items.Clear(); if (context.Instance is CustomText) { CustomText customtext = (CustomText)context.Instance; this.TextFormatNamesList.Items.AddRange(customtext.Data); if (value != null && value.ToString() != "") { this.TextFormatNamesList.SelectedItem = value; } this.edSvc.DropDownControl(this.TextFormatNamesList); value = this.TextFormatNamesList.SelectedItem; } } } return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var retval = Guid.Empty; try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var moduleRule = context.Instance as ModuleRule; var modulelist = moduleRule.Module.nHydrateModel.Modules.OrderBy(x => x.Name).Where(x => x.Id != moduleRule.Module.Id).ToList(); var selected = modulelist.FirstOrDefault(x => x.Id == moduleRule.DependentModule); //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var values = new List <string>(); values.Add(false.ToString()); values.Add(true.ToString()); newBox.Items.AddRange(modulelist.Select(x => x.Name).ToArray()); if (selected != null) { newBox.SelectedIndex = modulelist.IndexOf(selected); } edSvc.DropDownControl(newBox); if ((moduleRule != null) && (newBox.SelectedIndex != -1)) { retval = modulelist[newBox.SelectedIndex].Id; } } catch (Exception ex) { } return(retval); }
//-------------------------------------------------------------------------------- #region Feilds And Propeties //-------------------------------------------------------------------------------- #endregion //-------------------------------------------------------------------------------- #region Constructors //-------------------------------------------------------------------------------- #endregion //-------------------------------------------------------------------------------- #region Methods //-------------------------------------------------------------------------------- public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { // Получаем интерфейс сервиса System.Windows.Forms.Design.IWindowsFormsEditorService edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService( typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc != null) { ICanPortUITypeEditorDialogForm form = new ICanPortUITypeEditorDialogForm(); // Устанавливаем текущее значение для редактирования form.ICanPort = (ICanPort)value; // Вызываем окно редактора System.Windows.Forms.DialogResult result = edSvc.ShowDialog(form); // Получаем новое значение value = form.ICanPort; } } //return base.EditValue(context, provider, value); return(value); }
public void SetDropDownParams(Section lastSection, System.Windows.Forms.Design.IWindowsFormsEditorService wfes) { this.wfes = wfes; sectionsTree.Section = lastSection; }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc != null) { // Create a CheckedListBox and populate it with all the enum values clb = new System.Windows.Forms.CheckedListBox(); clb.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; clb.CheckOnClick = true; clb.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown); clb.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMoved); tooltipControl = new System.Windows.Forms.ToolTip(); tooltipControl.ShowAlways = true; foreach (string name in System.Enum.GetNames(context.PropertyDescriptor.PropertyType)) { // Get the enum value object enumVal = System.Enum.Parse(context.PropertyDescriptor.PropertyType, name); // Get the int value int intVal = (int)System.Convert.ChangeType(enumVal, typeof(int), System.Globalization.CultureInfo.CurrentCulture); // Get the description attribute for this field System.Reflection.FieldInfo fi = context.PropertyDescriptor.PropertyType.GetField(name); System.ComponentModel.DescriptionAttribute[] attrs = (System.ComponentModel.DescriptionAttribute[])fi.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); // Store the the description string tooltip = attrs.Length > 0 ? attrs[0].Description : string.Empty; // Get the int value of the current enum value (the one being edited) int intEdited = (int)System.Convert.ChangeType(value, typeof(int), System.Globalization.CultureInfo.CurrentCulture); // Creates a clbItem that stores the name, the int value and the tooltip EnumEditorItem item = new EnumEditorItem(enumVal.ToString(), intVal, tooltip); // Get the checkstate from the value being edited //bool checkedItem = (intEdited & intVal) > 0; bool checkedItem = (intEdited & intVal) == intVal; // Add the item with the right check state clb.Items.Add(item, checkedItem); } // Show our CheckedListbox as a DropDownControl. // This methods returns only when the dropdowncontrol is closed edSvc.DropDownControl(clb); // Get the sum of all checked flags int result = 0; foreach (EnumEditorItem obj in clb.CheckedItems) { //result += obj.Value; result |= obj.Value; } // return the right enum value corresponding to the result return System.Enum.ToObject(context.PropertyDescriptor.PropertyType, result); } } return value; }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null || context.Instance == null || provider == null) { return base.EditValue(context, provider, value); } if ((m_EdSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService))) == null) { return value; } // Create a CheckedListBox and populate it with all the propertylist values m_List = new System.Windows.Forms.ListBox(); m_List.BorderStyle = System.Windows.Forms.BorderStyle.None; GXDataIOSource source = (GXDataIOSource)context.Instance; GXDataIOSourceAttribute att = TypeDescriptor.GetAttributes(source.Parent)[typeof(GXDataIOSourceAttribute)] as GXDataIOSourceAttribute; List<Enum> tmp = new List<Enum>(); Array SourceTypes = Enum.GetValues(value.GetType()); Array TargetTypes = null; if (att.SupportedProperties != null) { long values = (long)att.SupportedProperties; foreach (object it in Enum.GetValues(att.SupportedProperties.GetType())) { long val = Convert.ToInt64(it); if ((val & values) == val && val != 0) { tmp.Add((Enum)it); } } TargetTypes = tmp.ToArray(); } foreach (object it in SourceTypes) { if (TargetTypes == null) { long val = Convert.ToInt64(it); if (val > 0) { m_List.Items.Add(Enum.GetName(value.GetType(), it)); } } else { foreach (Enum it2 in TargetTypes) { if (string.Compare(Enum.GetName(value.GetType(), it), it2.ToString()) == 0) { m_List.Items.Add(Enum.GetName(value.GetType(), it)); break; } } } } if (value != null) { m_List.SelectedIndex = m_List.Items.IndexOf(value.ToString()); } m_List.SelectedIndexChanged += new System.EventHandler(this.OnSelectedIndexChanged); // Show Listbox as a DropDownControl. This methods returns only when the dropdowncontrol is closed m_EdSvc.DropDownControl(m_List); if (m_List.SelectedItem != null) { return Enum.Parse(value.GetType(), m_List.SelectedItem.ToString()); } return value; }
public override object EditValue(ITypeDescriptorContext ctx, IServiceProvider provider, object value) { Index idx = ctx.Instance as Index; Trigger trig = ctx.Instance as Trigger; ViewTableBase parent = null; if (idx != null) parent = idx.Table; else if (trig != null) parent = trig.ViewTableBase; // initialize editor service _edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (_edSvc == null) return value; if (value == null) value = String.Empty; if (String.IsNullOrEmpty(value.ToString()) == true) value = String.Empty; string[] values = value.ToString().Split(','); // populate the list _list.Items.Clear(); if (parent is Table) { foreach (Column c in ((Table)parent).Columns) { CheckState check = CheckState.Unchecked; for (int n = 0; n < values.Length; n++) { if (values[n].Trim() == String.Format("[{0}]", c.ColumnName)) { check = CheckState.Checked; break; } } _list.Items.Add(c.ColumnName, check); } } else { try { using (DbCommand cmd = trig.GetConnection().CreateCommand()) { cmd.CommandText = ((View)parent).SqlText; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly)) using (DataTable tbl = reader.GetSchemaTable()) { foreach (DataRow row in tbl.Rows) { CheckState check = CheckState.Unchecked; for (int n = 0; n < values.Length; n++) { if (values[n].Trim() == String.Format("[{0}]", row[SchemaTableColumn.ColumnName])) { check = CheckState.Checked; break; } } _list.Items.Add(row[SchemaTableColumn.ColumnName].ToString(), check); } } } } catch { } } _list.Height = Math.Min(300, (_list.Items.Count + 1) * _list.Font.Height); // show the list _cancel = false; _edSvc.DropDownControl(_list); // build return value from checked items on the list if (!_cancel) { // build a comma-delimited string with the checked items StringBuilder sb = new StringBuilder(); foreach (object item in _list.CheckedItems) { if (sb.Length > 0) sb.Append(", "); sb.AppendFormat("[{0}]", item.ToString()); } return sb.ToString(); } // done return value; }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider,object value) { if (context!=null&&context.Instance!=null&&provider!=null) { edSvc=(System.Windows.Forms.Design.IWindowsFormsEditorService) provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc!=null) { lb=new System.Windows.Forms.ListBox(); lb.BorderStyle=System.Windows.Forms.BorderStyle.None; lb.SelectedIndexChanged+=new EventHandler(lb_SelectedIndexChanged); foreach(Control ctrl in ((Control)context.Instance).Page.Controls) { if (ctrl.GetType().IsSubclassOf(typeShow)|| ctrl.GetType().FullName==typeShow.FullName) lb.Items.Add(ctrl.ID); } edSvc.DropDownControl(lb); if (lb.SelectedIndex==-1) return value; return lb.SelectedItem; } } return value; }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider,object value) { if (context!=null&&context.Instance!=null&&provider!=null) { edSvc=(System.Windows.Forms.Design.IWindowsFormsEditorService) provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc!=null) { lb=new System.Windows.Forms.ListBox(); lb.BorderStyle=System.Windows.Forms.BorderStyle.None; lb.SelectedIndexChanged+=new EventHandler(lb_SelectedIndexChanged); lb.Items.Add("onclick"); lb.Items.Add("ondblclick"); lb.Items.Add("onmouseover"); lb.Items.Add("onfocus"); lb.Items.Add("oncontextmenu"); edSvc.DropDownControl(lb); if (lb.SelectedIndex==-1) return value; return lb.SelectedItem; } } return value; }
/// <summary> /// Overrides the method used to provide basic behaviour for selecting editor. /// Shows our custom control for editing the value. /// </summary> /// <param name="context">The context of the editing control</param> /// <param name="provider">A valid service provider</param> /// <param name="value">The current value of the object to edit</param> /// <returns>The new value of the object</returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (edSvc != null) { // Create a CheckedListBox and populate it with all the enum values clb = new System.Windows.Forms.CheckedListBox(); clb.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; clb.CheckOnClick = true; clb.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown); clb.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMoved); tooltipControl = new System.Windows.Forms.ToolTip(); tooltipControl.ShowAlways = true; foreach (string name in System.Enum.GetNames(context.PropertyDescriptor.PropertyType)) { // Get the enum value object enumVal = System.Enum.Parse(context.PropertyDescriptor.PropertyType, name); // Get the int value int intVal = (int)System.Convert.ChangeType(enumVal, typeof(int), System.Globalization.CultureInfo.CurrentCulture); // Get the description attribute for this field System.Reflection.FieldInfo fi = context.PropertyDescriptor.PropertyType.GetField(name); System.ComponentModel.DescriptionAttribute[] attrs = (System.ComponentModel.DescriptionAttribute[])fi.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); // Store the the description string tooltip = attrs.Length > 0 ? attrs[0].Description : string.Empty; // Get the int value of the current enum value (the one being edited) int intEdited = (int)System.Convert.ChangeType(value, typeof(int), System.Globalization.CultureInfo.CurrentCulture); // Creates a clbItem that stores the name, the int value and the tooltip EnumEditorItem item = new EnumEditorItem(enumVal.ToString(), intVal, tooltip); // Get the checkstate from the value being edited //bool checkedItem = (intEdited & intVal) > 0; bool checkedItem = (intEdited & intVal) == intVal; // Add the item with the right check state clb.Items.Add(item, checkedItem); } // Show our CheckedListbox as a DropDownControl. // This methods returns only when the dropdowncontrol is closed edSvc.DropDownControl(clb); // Get the sum of all checked flags int result = 0; foreach (EnumEditorItem obj in clb.CheckedItems) { //result += obj.Value; result |= obj.Value; } // return the right enum value corresponding to the result return(System.Enum.ToObject(context.PropertyDescriptor.PropertyType, result)); } } return(value); }
protected internal virtual System.Windows.Forms.DialogResult ShowEditorDialog(System.Windows.Forms.Design.IWindowsFormsEditorService edSvc) { throw null; }
protected override object OnEditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, System.Windows.Forms.Design.IWindowsFormsEditorService service, object value) { IWithProject mc = context.Instance as IWithProject; if (mc != null) { if (mc.Project == null) { MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType())); } else { GetterClass val = value as GetterClass; System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position; rc.X = curPoint.X; rc.Y = curPoint.Y; DlgMethod dlg = val.CreateMethodEditor(rc); try { dlg.SetNameReadOnly(); dlg.LoadMethod(val, EnumParameterEditType.ReadOnly); dlg.Text = val.ToString(); if (service.ShowDialog(dlg) == DialogResult.OK) { value = val; ILimnorDesignerLoader l = LimnorProject.ActiveDesignerLoader as ILimnorDesignerLoader; if (l != null) { //save the property and hence save the getter DesignUtil.SaveCustomProperty(LimnorProject.ActiveDesignerLoader.Node, l.Writer, val.Property); //save actions List <IAction> actions = val.GetActions(); if (actions != null) { foreach (IAction a in actions) { l.GetRootId().SaveAction(a, l.Writer); } } LimnorProject.ActiveDesignerLoader.NotifyChanges(); } } } catch (Exception err) { MathNode.Log(TraceLogClass.GetForm(provider), err); } finally { val.ExitEditor(); } } } return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var selectedItemKey = string.Empty; var root = (ModelRoot)((Table)context.Instance).Root; var sourceTable = (Table)context.Instance; var retval = sourceTable.ParentTable; selectedItemKey = sourceTable.ParentTableKey; var tableCollection = new List<Table>(); foreach (Table t in root.Database.Tables) { tableCollection.Add(t); } //Remove the current table tableCollection.Remove(sourceTable); //Remove all parent tables var tList = sourceTable.GetTableHierarchy(); foreach (var t in tList) { if (tableCollection.Contains(t)) tableCollection.Remove(t); } //Remove all child tables tList = sourceTable.GetTablesInheritedFromHierarchy(); foreach (var t in tList) { if (tableCollection.Contains(t)) tableCollection.Remove(t); } //Add the current parent if one exists if (sourceTable.ParentTable != null) tableCollection.Add(sourceTable.ParentTable); //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var sortedList = new SortedList(); foreach (var table in tableCollection) { //Ensure key is unique to avoid error var text = table.Name.ToLower(); var key = text; var ii = 0; while (sortedList.ContainsKey(key)) { key = text + ii.ToString(); ii++; } sortedList.Add(key, table); } //Re-add them in order newBox.Items.Add("(None)"); newBox.SelectedIndex = 0; foreach (DictionaryEntry di in sortedList) { var t = (Table)di.Value; newBox.Items.Add(t); if (t.Key == selectedItemKey) newBox.SelectedIndex = newBox.Items.Count - 1; } edSvc.DropDownControl(newBox); if ((newBox.SelectedIndex > 0) && (newBox.SelectedItem != null)) retval = ((Table)newBox.SelectedItem); else if (newBox.SelectedIndex == 0) retval = null; return retval; } catch (Exception ex) { } return null; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { try { edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); var selectedItemKey = string.Empty; var root = (ModelRoot)((Table)context.Instance).Root; var sourceTable = (Table)context.Instance; var retval = sourceTable.ParentTable; selectedItemKey = sourceTable.ParentTableKey; var tableCollection = new List <Table>(); foreach (Table t in root.Database.Tables) { tableCollection.Add(t); } //Remove the current table tableCollection.Remove(sourceTable); //Remove all parent tables var tList = sourceTable.GetTableHierarchy(); foreach (var t in tList) { if (tableCollection.Contains(t)) { tableCollection.Remove(t); } } //Remove all child tables tList = sourceTable.GetTablesInheritedFromHierarchy(); foreach (var t in tList) { if (tableCollection.Contains(t)) { tableCollection.Remove(t); } } //Add the current parent if one exists if (sourceTable.ParentTable != null) { tableCollection.Add(sourceTable.ParentTable); } //Create the list box var newBox = new System.Windows.Forms.ListBox(); newBox.Click += new EventHandler(newBox_Click); newBox.IntegralHeight = false; var sortedList = new SortedList(); foreach (var table in tableCollection) { //Ensure key is unique to avoid error var text = table.Name.ToLower(); var key = text; var ii = 0; while (sortedList.ContainsKey(key)) { key = text + ii.ToString(); ii++; } sortedList.Add(key, table); } //Re-add them in order newBox.Items.Add("(None)"); newBox.SelectedIndex = 0; foreach (DictionaryEntry di in sortedList) { var t = (Table)di.Value; newBox.Items.Add(t); if (t.Key == selectedItemKey) { newBox.SelectedIndex = newBox.Items.Count - 1; } } edSvc.DropDownControl(newBox); if ((newBox.SelectedIndex > 0) && (newBox.SelectedItem != null)) { retval = ((Table)newBox.SelectedItem); } else if (newBox.SelectedIndex == 0) { retval = null; } return(retval); } catch (Exception ex) { } return(null); }
override public object EditValue(ITypeDescriptorContext ctx, IServiceProvider provider, object value) { Index idx = ctx.Instance as Index; Trigger trig = ctx.Instance as Trigger; ViewTableBase parent = null; if (idx != null) { parent = idx.Table; } else if (trig != null) { parent = trig.ViewTableBase; } // initialize editor service _edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (_edSvc == null) { return(value); } if (value == null) { value = String.Empty; } if (String.IsNullOrEmpty(value.ToString()) == true) { value = String.Empty; } string[] values = value.ToString().Split(','); // populate the list _list.Items.Clear(); if (parent is Table) { foreach (Column c in ((Table)parent).Columns) { CheckState check = CheckState.Unchecked; for (int n = 0; n < values.Length; n++) { if (values[n].Trim() == String.Format(CultureInfo.InvariantCulture, "[{0}]", c.ColumnName)) { check = CheckState.Checked; break; } } _list.Items.Add(c.ColumnName, check); } } else { try { using (DbCommand cmd = trig.GetConnection().CreateCommand()) { cmd.CommandText = ((View)parent).SqlText; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly)) using (DataTable tbl = reader.GetSchemaTable()) { foreach (DataRow row in tbl.Rows) { CheckState check = CheckState.Unchecked; for (int n = 0; n < values.Length; n++) { if (values[n].Trim() == String.Format(CultureInfo.InvariantCulture, "[{0}]", row[SchemaTableColumn.ColumnName])) { check = CheckState.Checked; break; } } _list.Items.Add(row[SchemaTableColumn.ColumnName].ToString(), check); } } } } catch { } } _list.Height = Math.Min(300, (_list.Items.Count + 1) * _list.Font.Height); // show the list _cancel = false; _edSvc.DropDownControl(_list); // build return value from checked items on the list if (!_cancel) { // build a comma-delimited string with the checked items StringBuilder sb = new StringBuilder(); foreach (object item in _list.CheckedItems) { if (sb.Length > 0) { sb.Append(", "); } sb.AppendFormat("[{0}]", item.ToString()); } return(sb.ToString()); } // done return(value); }
public void Start(System.Windows.Forms.Design.IWindowsFormsEditorService edSvc, object value) { }