Ejemplo n.º 1
0
        private void CopyScriptParameter_Click(object sender, EventArgs e)
        {
            var selection = (SelectedObjectComboBoxItem)this.editorObjects.SelectedItem;
            var currentScriptParameter = selection.EditorObject as ScriptParameter;

            if (currentScriptParameter == null)
            {
                return;
            }

            var copiedScriptParameter = new ScriptParameter(currentScriptParameter);

            copiedScriptParameter.Name = GetScriptParameterName(currentScriptParameter);
            this.scriptParameters.Add(copiedScriptParameter);
            this.scriptParameters.Current = copiedScriptParameter;

            var comboBoxItem = new SelectedScriptParameterComboBoxItem(copiedScriptParameter);

            this.editorObjectComboItems.Add(comboBoxItem);
            this.editorObjects.SelectedItem  = comboBoxItem;
            this.propertyGrid.SelectedObject = copiedScriptParameter;
            this.HasScriptParameterChanged   = true;
            UpdateCurrentScriptParameterFlag();
            UpdateCommandState();
        }
Ejemplo n.º 2
0
		private static BindingList<SelectedObjectComboBoxItem> CreateComboItems( DbConnectionParameter dbConnectionParameter, ScriptParameterCollection scriptParameters )
		{
			var result = new BindingList<SelectedObjectComboBoxItem>();

			if ( dbConnectionParameter != null ) {
				var connectionItem = new DbConnectionComboBoxItem( dbConnectionParameter );
				result.Add( connectionItem );
			}
			if ( scriptParameters != null ) {
				foreach ( var scriptParameter in scriptParameters ) {
					var parameterItem = new SelectedScriptParameterComboBoxItem( scriptParameter );
					parameterItem.IsCurrent = scriptParameter.Equals( scriptParameters.Current );
					result.Add( parameterItem );
				}
			}

			return result;
		}
Ejemplo n.º 3
0
		private void UpdateCurrentScriptParameterFlag()
		{
			// Buffer the items to update in a new collection. If modified in the first loop you
			// would get a "collection changed" exception.
			var updateItems = new List<SelectedScriptParameterComboBoxItem>();
			foreach ( var item in this.editorObjects.Items ) {
				SelectedScriptParameterComboBoxItem parameterItem = item as SelectedScriptParameterComboBoxItem;
				if ( parameterItem != null ) {
					bool isCurrent = parameterItem.EditorObject.Equals( this.scriptParameters.Current );
					if ( isCurrent != parameterItem.IsCurrent ) {
						updateItems.Add( parameterItem );
					}
				}
			}
			foreach ( var parameterItem in updateItems ) {
				bool isCurrent = parameterItem.EditorObject.Equals( this.scriptParameters.Current );
				parameterItem.IsCurrent = isCurrent;
			}
		}