void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { DataGridView d = (DataGridView)sender; // Se si sta per modificare il valore del parametro... if (e.ColumnIndex == 2) { ParamBinding b = (ParamBinding)Enum.Parse(typeof(ParamBinding), d.Rows[e.RowIndex].Cells[1].Value.ToString()); // Se la riga corrente si riferisce ad un parametro variable-bound, fai in modo che si apra il popup della scelta delle variabili. if (b == ParamBinding.Variable) { // Mostra il dialog di scelta delle variabili VariableChooser vc = new VariableChooser(_vars); DialogResult dr = vc.ShowDialog(); if (dr == DialogResult.OK) { Microsoft.SqlServer.Dts.Runtime.Variable v = vc.GetResult(); d.Rows[e.RowIndex].Cells[2].Value = v.QualifiedName; e.Cancel = true; //d.EndEdit(); } } else if (b == ParamBinding.InputField) { if (_input_options == null || _input_options.Length < 1) { MessageBox.Show("There is no input attached to this lane. First attach an input, then you'll be able to select a vale from this box."); e.Cancel = true; } } } }
void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { // If the binding type has changed, change the column relative to its possible value. // If binding type is either variable or custom, just leave it as textbox, otherwise keep it as combobox if (e.ColumnIndex == 1) { DataGridView d = (DataGridView)sender; ParamBinding b = (ParamBinding)Enum.Parse(typeof(ParamBinding), d.Rows[e.RowIndex].Cells[1].Value.ToString()); if (b == ParamBinding.Variable || b == ParamBinding.CustomValue) { d.Rows[e.RowIndex].Cells[2].Value = null; d.Rows[e.RowIndex].Cells[2] = new DataGridViewTextBoxCell(); } else if (b == ParamBinding.InputField) { d.Rows[e.RowIndex].Cells[2].ValueType = typeof(ParamBinding); var cbox = new DataGridViewComboBoxCell(); cbox.DataSource = _input_options; d.Rows[e.RowIndex].Cells[2] = cbox; } else { MessageBox.Show("Invalid or inconsistent HTTP binding type"); return; } } }
void HandleBindProperty(Rect rect, ParamBinding binding) { if (binding == null) { return; } var objectRect = rect; objectRect.y += 2; objectRect.height = EditorGUIUtility.singleLineHeight; objectRect.width *= 0.5f; EditorGUI.ObjectField(objectRect, null, typeof(UnityEngine.Object), true); objectRect.x += objectRect.width; // Button to invoke menu // local // -- // Pick runtime... // Pick asset... objectRect.y += 2; EditorGUI.Popup(objectRect, 0, new[] { "Component >", "Some Var", "Some Prop", }, SpaceEditorStyles.LightObjectField); }
void HandleBindValue(Rect rect, ParamBinding binding) { if (binding == null) { return; } var fieldRect = rect; fieldRect.y += 2; fieldRect.height = EditorGUIUtility.singleLineHeight; VariantUtils.DrawParameter(fieldRect, binding.DefaultValue, false); }
/// <summary> /// Parses the specified command line in a standard way that maps /// the command line parameters to the public static properties of /// the specified class. /// </summary> /// <typeparam name="T"> /// The class that has properties that will be specified from the /// command line parameters. /// </typeparam> /// <param name="args"> /// The command line to parse. /// </param> public static void Parse <T>(string[] args) { // First scan for any "-help" or "-?" strings. foreach (string arg in args) { if (arg == "/?" || arg == "/help" || arg == "-?" || arg == "-help") { ThrowUsageException <T>(); } } try { Dictionary <string, ParamBinding> bindings = GetParamBindings <T>(); // process the command line foreach (string arg in args) { string[] split = arg.Split(new[] { '=' }, 2); string argName = split[0]; string argValue = split.Length == 2 ? split[1] : null; if (bindings.ContainsKey(argName)) { ParamBinding paramBinding = bindings[argName]; if (paramBinding.HasBeenSet) { throw new CommandLineParameterException( string.Format("Argument '{0}' has already been specified.", argName)); } if (argValue != null) { object value = paramBinding.ParserMethod.Invoke(null, new object[] { argValue }); paramBinding.PropertyInfo.GetSetMethod().Invoke(null, new[] { value }); paramBinding.HasBeenSet = true; } else { if (paramBinding.PropertyInfo.PropertyType == typeof(bool)) { // Set the boolean property to true. paramBinding.PropertyInfo.GetSetMethod().Invoke(null, new object[] { true }); paramBinding.HasBeenSet = true; } else { // Only boolean properties can be specified without a value. throw new CommandLineParameterException( string.Format("Argument '{0}' must provide a value.", argName)); } } } else { throw new CommandLineParameterException(string.Format("Argument '{0}' was not expected.", argName)); } } // Make sure all required parameters were provided. foreach (ParamBinding paramBinding in bindings.Values) { if (!paramBinding.HasBeenSet && paramBinding.Attribute.IsRequired) { throw new CommandLineParameterException(string.Format("Argument '{0}' is required.", paramBinding.Attribute.Name)); } } } catch (Exception e) { ThrowUsageException <T>(e); } }
void HandleBindDataSet(Rect rect, ParamBinding binding) { if (binding == null) { return; } var buttonRect = rect; buttonRect.y += 2; buttonRect.height = EditorGUIUtility.singleLineHeight; buttonRect.width *= 0.5f; if (Event.current.commandName == "ObjectSelectorUpdated") { if (EditorGUIUtility.GetObjectPickerControlID() == DATASET_RUNTIME_PICKER_WINDOW_ID) { GUI.changed = true; var go = EditorGUIUtility.GetObjectPickerObject() as GameObject; if (go != null) { binding.Context = go.GetComponent <DataSetInstance>(); } DATASET_RUNTIME_PICKER_WINDOW_ID = -1; } else if (EditorGUIUtility.GetObjectPickerControlID() == DATASET_ASSET_PICKER_WINDOW_ID) { GUI.changed = true; binding.Context = EditorGUIUtility.GetObjectPickerObject(); DATASET_ASSET_PICKER_WINDOW_ID = -1; } } // Button to invoke menu // local // -- // Pick runtime... // Pick asset... if (EditorGUI.DropdownButton(buttonRect, new GUIContent(binding?.ContextAsDataSet?.ToString()), FocusType.Passive, EditorStyles.objectField)) { GenericMenu pickDataset = new GenericMenu(); pickDataset.AddItem(new GUIContent("local (from parametrized object IProvider)"), false, () => { GUI.changed = true; }); pickDataset.AddSeparator(string.Empty); pickDataset.AddItem(new GUIContent("Pick runtime..."), false, () => { DATASET_RUNTIME_PICKER_WINDOW_ID = GUIUtility.GetControlID(FocusType.Passive) + 200; EditorGUIUtility.ShowObjectPicker <DataSetInstance> ( null, true, string.Empty, DATASET_RUNTIME_PICKER_WINDOW_ID ); }); pickDataset.AddItem(new GUIContent("Pick asset..."), false, () => { DATASET_ASSET_PICKER_WINDOW_ID = GUIUtility.GetControlID(FocusType.Passive) + 100; EditorGUIUtility.ShowObjectPicker <DataSet> ( null, false, string.Empty, DATASET_ASSET_PICKER_WINDOW_ID ); }); pickDataset.DropDown(buttonRect); } buttonRect.x += buttonRect.width; EditorGUI.BeginDisabledGroup(binding.ContextAsDataSet == null); { // Button to invoke menu // go to DataSet... // -- // list of vars of matching type EditorGUI.Popup(buttonRect, 0, new[] { "SomeVar", }, GUI.skin.button); } EditorGUI.EndDisabledGroup(); }
void OnChangeBindingType(ParamBinding binding, IParameterBinder binder, BindingType type) { binding.SetBindingType(type, Provider); }