public ParameterControlEventArgs(ParameterControlBase control) { if (control == null) { throw new ArgumentNullException("control"); } Control = control; }
/// <summary> /// Fires the control value changed event. /// </summary> private void FireControlValueChanged(ParameterControlBase control) { var handler = ControlValueChanged; if (handler != null) { ControlValueChanged(control, new ParameterControlEventArgs(control)); } }
/// <summary> /// Sets caption to the control, also removing trailing colon. /// </summary> public static void SetCaption(this ParameterControlBase ctrl, string caption) { ctrl.Caption = caption; if (ctrl is BooleanParameterControl) { // do nothing } else { if (!ctrl.Caption.Trim().EndsWith(":")) { ctrl.Caption += ":"; } } }
/// <summary> /// Adds control to the event manager. /// </summary> public void AddControl(ParameterControlBase control) { _controls.Add(control); control.ValueChanged += (s, e) => FireControlValueChanged(s as ParameterControlBase); }
/// <summary> /// Creates a control for the parameter. /// </summary> /// <exception cref="System.ArgumentNullException">parameter</exception> /// <exception cref="System.ApplicationException">Failed to created control for parameter: + parameter.DisplayName</exception> public ParameterControlBase CreateControl(BaseParameter parameter, bool batchMode = false) { if (parameter == null) { throw new ArgumentNullException("parameter"); } ParameterControlBase control = null; if (parameter is FieldOperationParameter) { control = new FieldOperationParameterControl(); } else if (parameter is OutputNameParameter) { control = new OutputNameParameterControl(batchMode); } else if (parameter is GeoProjectionParameter) { control = _context.Container.GetInstance <ProjectionParameterControl>(); } else if (parameter is MultiFilenameParameter) { var p = parameter as MultiFilenameParameter; control = CreateInputControl(true, p.DataType, true); var bfpc = control as BatchFilenameParameterControl; if (bfpc != null) { bfpc.MultiFile = true; } } else if (parameter is FilenameParameter) { var p = parameter as FilenameParameter; control = CreateInputControl(batchMode, p.DataType, true); } else if (parameter is FieldParameter) { control = new FieldParameterControl(); } else if (parameter is DistanceParameter) { control = new DistanceParameterControl(); } else if (parameter is DoubleParameter) { control = new DoubleParameterControl(); } else if (parameter is StringParameter) { bool multiLine = (parameter as StringParameter).MultiLine; control = new StringParameterControl(multiLine); } else if (parameter is BooleanParameter) { control = new BooleanParameterControl(); } else if (parameter is IntegerParameter) { control = new IntegerParameterControl(); } else if (parameter is OutputLayerParameter) { var op = parameter as OutputLayerParameter; control = CreateOutputControl(batchMode, op.LayerType, op.SupportInMemory); } else if (parameter is OptionsParameter) { control = new ComboParameterControl(); } else if (parameter is LayerParameterBase) { var lp = parameter as LayerParameterBase; control = CreateInputControl(batchMode, lp.DataSourceType, false); } if (control == null) { throw new ApplicationException("Failed to created control for parameter: " + parameter.DisplayName); } if (parameter.ControlHint != null && parameter.ControlHint.ControlHeight != 0) { control.Height = parameter.ControlHint.ControlHeight; } control.ParameterName = parameter.Name; return(control); }