📄 parameters.cs
字号:
#region License
/*
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#endregion
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
namespace daReport
{
/// <summary>
/// Delegate for the ParametersModified event
/// </summary>
public delegate void ParametersModified_EventHandler(object sender, ParameterModifiedEventArgs EventArgs);
/// <summary>
/// Summary description for Parameter.
/// </summary>
public class Parameters : CollectionBase
{
#region Declarations
/// <summary>
/// Public event which notifies listeners when an item in the collection is modified
/// </summary>
public event ParametersModified_EventHandler CollectionModified;
#endregion
#region Public Properties
/// <summary>
/// Adds a Parameter to the end of the Parameters collection.
/// </summary>
/// <param name="NewParam">Parameter to add</param>
/// <returns>The added Parameter</returns>
public Parameter Add(Parameter NewParam)
{
List.Add(NewParam);
return NewParam;
}
/// <summary>
/// Gets or sets the parameter at the specified index.
/// </summary>
public Parameter this[ int index ]
{
get { return( (Parameter) List[index]); }
set { List[index] = value; }
}
/// <summary>
/// Determines whether the Parameters contains a specific parameter.
/// </summary>
/// <param name="Param">Parameter Name to check for</param>
/// <returns>True if the parameter name is found</returns>
public bool Contains(Parameter Param)
{
return (List.Contains(Param));
}
/// <summary>
/// Determines whether the Parameters contains a specific parameter name.
/// </summary>
/// <param name="Param">Parameter Name to check for</param>
/// <returns>True if the parameter name is found</returns>
public bool Contains(string Param)
{
bool ReturnValue = false;
foreach (Parameter CurrentParameter in List)
{
if (CurrentParameter.Name == Param)
ReturnValue = true;
}
return ReturnValue;
}
#endregion
#region Event Overrides
/// <summary>
/// Performs additional custom processes after inserting a new element into the CollectionBase instance.
/// </summary>
/// <param name="index">Index value the Parameter was inserted at</param>
/// <param name="value">New <see cref="daReport.Parameter">daReport.Parameter</see></param>
protected override void OnInsertComplete(int index, object value)
{
ParameterModifiedEventArgs evArgs = new ParameterModifiedEventArgs();
evArgs.Index = index;
evArgs.Parameter = (Parameter)value;
if (this.CollectionModified != null)
this.CollectionModified(this, evArgs);
base.OnInsertComplete (index, value);
}
/// <summary>
/// Performs additional custom processes after removing an element from the CollectionBase instance.
/// </summary>
/// <param name="index">Index value the Parameter was removed from</param>
/// <param name="value">Deleted <see cref="daReport.Parameter">daReport.Parameter</see></param>
protected override void OnRemoveComplete(int index, object value)
{
ParameterModifiedEventArgs evArgs = new ParameterModifiedEventArgs();
evArgs.Index = index;
evArgs.Parameter = (Parameter)value;
if (this.CollectionModified != null)
this.CollectionModified(this, evArgs);
base.OnRemoveComplete(index, value);
}
#endregion
#region Creator
/// <summary>
/// <see cref="daReport.Parameters">daReport.Parameters</see> colection of parameters for the current report
/// </summary>
public Parameters()
{
}
#endregion
}
#region ParameterModifiedEventArgs
/// <summary>
/// Custom EventArgs class to pass back index and parameter when Collectrion is modified
/// </summary>
public class ParameterModifiedEventArgs : EventArgs
{
/// <summary>Index of modified Parameter</summary>
public int Index;
/// <summary>Modified Parameter</summary>
public Parameter Parameter;
}
#endregion
/// <summary>
/// The Parameter class is used to pass values into the report
/// </summary>
public class Parameter
{
#region Declarations
private string mName = "";
#endregion
#region Public Properties
/// <summary>
/// Sets the name for the current parameter
/// </summary>
public string Name
{
get { return this.mName; }
set { this.mName=value; }
}
#endregion
#region Public Overrides
/// <summary>
/// Returns the name of the parameter.
/// </summary>
/// <returns>strign Name of the Parameter</returns>
public override string ToString()
{
return this.mName;
}
#endregion
#region Creator
/// <summary>
/// Instantiates a new Parameter object
/// </summary>
public Parameter() {}
/// <summary>
/// Name which identifies this parameter
/// </summary>
/// <param name="ParameterName">string for the ParameterName</param>
public Parameter(string ParameterName)
{
this.mName = ParameterName;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -