You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,201 @@
|
||||
//-------------------------------------------------------------
|
||||
// <copyright company=<3D>Microsoft Corporation<6F>>
|
||||
// Copyright <20> Microsoft Corporation. All Rights Reserved.
|
||||
// </copyright>
|
||||
//-------------------------------------------------------------
|
||||
// @owner=alexgor, deliant
|
||||
//=================================================================
|
||||
// File: FormulaRegistry.cs
|
||||
//
|
||||
// Namespace: System.Web.UI.WebControls[Windows.Forms].Charting.Formulas
|
||||
//
|
||||
// Classes: FormulaRegistry
|
||||
//
|
||||
// Purpose: Keep track of all registered formula module types.
|
||||
//
|
||||
// Reviewed: GS - August 6, 2002
|
||||
// AG - August 7, 2002
|
||||
//
|
||||
//===================================================================
|
||||
|
||||
|
||||
#region Used namespace
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#if Microsoft_CONTROL
|
||||
namespace System.Windows.Forms.DataVisualization.Charting.Formulas
|
||||
#else
|
||||
namespace System.Web.UI.DataVisualization.Charting.Formulas
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// Keep track of all registered formula modules types.
|
||||
/// </summary>
|
||||
internal class FormulaRegistry : IServiceProvider
|
||||
{
|
||||
#region Fields
|
||||
|
||||
// Storage for all registered formula modules
|
||||
internal Hashtable registeredModules = new Hashtable(StringComparer.OrdinalIgnoreCase);
|
||||
private Hashtable _createdModules = new Hashtable(StringComparer.OrdinalIgnoreCase);
|
||||
private ArrayList _modulesNames = new ArrayList();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Formula Registry public constructor
|
||||
/// </summary>
|
||||
public FormulaRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds modules into the registry.
|
||||
/// </summary>
|
||||
/// <param name="name">Module name.</param>
|
||||
/// <param name="moduleType">Module class type.</param>
|
||||
public void Register(string name, Type moduleType)
|
||||
{
|
||||
// First check if module with specified name already registered
|
||||
if(registeredModules.Contains(name))
|
||||
{
|
||||
// If same type provided - ignore
|
||||
if(registeredModules[name].GetType() == moduleType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Error - throw exception
|
||||
throw( new ArgumentException( SR.ExceptionFormulaModuleNameIsNotUnique( name ) ) );
|
||||
}
|
||||
|
||||
// Add Module Name
|
||||
_modulesNames.Add(name);
|
||||
|
||||
// Make sure that specified class support IFormula interface
|
||||
bool found = false;
|
||||
Type[] interfaces = moduleType.GetInterfaces();
|
||||
foreach(Type type in interfaces)
|
||||
{
|
||||
if(type == typeof(IFormula))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
throw( new ArgumentException( SR.ExceptionFormulaModuleHasNoInterface));
|
||||
}
|
||||
|
||||
// Add formula module to the hash table
|
||||
registeredModules[name] = moduleType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns formula module registry service object.
|
||||
/// </summary>
|
||||
/// <param name="serviceType">Service AxisName.</param>
|
||||
/// <returns>Service object.</returns>
|
||||
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
|
||||
object IServiceProvider.GetService(Type serviceType)
|
||||
{
|
||||
if(serviceType == typeof(FormulaRegistry))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
throw (new ArgumentException( SR.ExceptionFormulaModuleRegistryUnsupportedType( serviceType.ToString())));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns formula module object by name.
|
||||
/// </summary>
|
||||
/// <param name="name">Formula Module name.</param>
|
||||
/// <returns>Formula module object derived from IFormula.</returns>
|
||||
public IFormula GetFormulaModule(string name)
|
||||
{
|
||||
// First check if formula module with specified name registered
|
||||
if(!registeredModules.Contains(name))
|
||||
{
|
||||
throw( new ArgumentException( SR.ExceptionFormulaModuleNameUnknown( name ) ) );
|
||||
}
|
||||
|
||||
// Check if the formula module object is already created
|
||||
if(!_createdModules.Contains(name))
|
||||
{
|
||||
// Create formula module object
|
||||
_createdModules[name] =
|
||||
((Type)registeredModules[name]).Assembly.
|
||||
CreateInstance(((Type)registeredModules[name]).ToString());
|
||||
}
|
||||
|
||||
return (IFormula)_createdModules[name];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the module.
|
||||
/// </summary>
|
||||
/// <param name="index">Module index.</param>
|
||||
/// <returns>Module Name.</returns>
|
||||
public string GetModuleName( int index )
|
||||
{
|
||||
return (string)_modulesNames[index];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Return the number of registered modules.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _modulesNames.Count;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface which defines the set of standard methods and
|
||||
/// properties for each formula module
|
||||
/// </summary>
|
||||
internal interface IFormula
|
||||
{
|
||||
#region IFormula Properties and Methods
|
||||
|
||||
/// <summary>
|
||||
/// Formula Module name
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The first method in the module, which converts a formula
|
||||
/// name to the corresponding private method.
|
||||
/// </summary>
|
||||
/// <param name="formulaName">String which represent a formula name</param>
|
||||
/// <param name="inputValues">Arrays of doubles - Input values</param>
|
||||
/// <param name="outputValues">Arrays of doubles - Output values</param>
|
||||
/// <param name="parameterList">Array of strings - Formula parameters</param>
|
||||
/// <param name="extraParameterList">Array of strings - Extra Formula parameters from DataManipulator object</param>
|
||||
/// <param name="outLabels">Array of strings - Used for Labels. Description for output results.</param>
|
||||
void Formula(string formulaName, double [][] inputValues, out double [][] outputValues, string [] parameterList, string [] extraParameterList, out string [][] outLabels );
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,193 @@
|
||||
//-------------------------------------------------------------
|
||||
// <copyright company=<3D>Microsoft Corporation<6F>>
|
||||
// Copyright <20> Microsoft Corporation. All Rights Reserved.
|
||||
// </copyright>
|
||||
//-------------------------------------------------------------
|
||||
// @owner=alexgor, deliant
|
||||
//=================================================================
|
||||
// File: GeneralFormulas.cs
|
||||
//
|
||||
// Namespace: System.Web.UI.WebControls[Windows.Forms].Charting.Formulas
|
||||
//
|
||||
// Classes: GeneralFormulas
|
||||
//
|
||||
// Purpose: This class calculates Running total and average.
|
||||
// Could be used for Pareto chart.
|
||||
//
|
||||
// Reviewed: GS - August 6, 2002
|
||||
// AG - August 7, 2002
|
||||
//
|
||||
//===================================================================
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
#if Microsoft_CONTROL
|
||||
namespace System.Windows.Forms.DataVisualization.Charting.Formulas
|
||||
#else
|
||||
namespace System.Web.UI.DataVisualization.Charting.Formulas
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// This class calculates Running total and average.
|
||||
/// Could be used for Pareto chart
|
||||
/// </summary>
|
||||
internal class GeneralFormulas : PriceIndicators
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Formula Module name
|
||||
/// </summary>
|
||||
override public string Name { get { return SR.FormulaNameGeneralFormulas; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Formulas
|
||||
|
||||
/// <summary>
|
||||
/// Formula which calculates cumulative total.
|
||||
/// ---------------------------------------------------------
|
||||
/// Input:
|
||||
/// - Y values.
|
||||
/// Output:
|
||||
/// - Running Total.
|
||||
/// </summary>
|
||||
/// <param name="inputValues">Arrays of doubles: 1. row - X values, 2. row - Y values</param>
|
||||
/// <param name="outputValues">Arrays of doubles: 1. row - X values, 2. row - Moving average</param>
|
||||
private void RuningTotal(double [][] inputValues, out double [][] outputValues)
|
||||
{
|
||||
// There is not enough series
|
||||
if( inputValues.Length != 2 )
|
||||
{
|
||||
throw new ArgumentException(SR.ExceptionPriceIndicatorsFormulaRequiresOneArray);
|
||||
}
|
||||
|
||||
// Different number of x and y values
|
||||
CheckNumOfValues( inputValues, 1 );
|
||||
|
||||
outputValues = new double [2][];
|
||||
|
||||
outputValues[0] = new double [inputValues[0].Length];
|
||||
outputValues[1] = new double [inputValues[1].Length];
|
||||
|
||||
// Cumulative total
|
||||
for( int index = 0; index < inputValues[0].Length; index++ )
|
||||
{
|
||||
outputValues[0][index] = inputValues[0][index];
|
||||
|
||||
if( index > 0 )
|
||||
{
|
||||
outputValues[1][index] = inputValues[1][index] + outputValues[1][index-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
outputValues[1][index] = inputValues[1][index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Running Average Formula
|
||||
/// ---------------------------------------------------------
|
||||
/// Input:
|
||||
/// - Y values.
|
||||
/// Output:
|
||||
/// - Running Average.
|
||||
/// </summary>
|
||||
/// <param name="inputValues">Arrays of doubles: 1. row - X values, 2. row - Y values</param>
|
||||
/// <param name="outputValues">Arrays of doubles: 1. row - X values, 2. row - Moving average</param>
|
||||
private void RunningAverage(double [][] inputValues, out double [][] outputValues)
|
||||
{
|
||||
// There is no enough series
|
||||
if( inputValues.Length != 2 )
|
||||
throw new ArgumentException(SR.ExceptionPriceIndicatorsFormulaRequiresOneArray);
|
||||
|
||||
// Different number of x and y values
|
||||
CheckNumOfValues( inputValues, 1 );
|
||||
|
||||
outputValues = new double [2][];
|
||||
|
||||
outputValues[0] = new double [inputValues[0].Length];
|
||||
outputValues[1] = new double [inputValues[1].Length];
|
||||
|
||||
// Total
|
||||
double total = 0;
|
||||
for( int index = 0; index < inputValues[0].Length; index++ )
|
||||
{
|
||||
total += inputValues[1][index];
|
||||
}
|
||||
|
||||
// Runing Average
|
||||
for( int index = 0; index < inputValues[0].Length; index++ )
|
||||
{
|
||||
outputValues[0][index] = inputValues[0][index];
|
||||
|
||||
if( index > 0 )
|
||||
outputValues[1][index] = inputValues[1][index] / total * 100 + outputValues[1][index-1];
|
||||
else
|
||||
outputValues[1][index] = inputValues[1][index] / total * 100;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public GeneralFormulas()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The first method in the module, which converts a formula
|
||||
/// name to the corresponding private method.
|
||||
/// </summary>
|
||||
/// <param name="formulaName">String which represent a formula name.</param>
|
||||
/// <param name="inputValues">Arrays of doubles - Input values.</param>
|
||||
/// <param name="outputValues">Arrays of doubles - Output values.</param>
|
||||
/// <param name="parameterList">Array of strings - Formula parameters.</param>
|
||||
/// <param name="extraParameterList">Array of strings - Extra Formula parameters from DataManipulator object.</param>
|
||||
/// <param name="outLabels">Array of strings - Used for Labels. Description for output results.</param>
|
||||
override public void Formula( string formulaName, double [][] inputValues, out double [][] outputValues, string [] parameterList, string [] extraParameterList, out string [][] outLabels )
|
||||
{
|
||||
string name;
|
||||
outputValues = null;
|
||||
|
||||
// Not used for these formulas.
|
||||
outLabels = null;
|
||||
|
||||
name = formulaName.ToUpper(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
try
|
||||
{
|
||||
switch( name )
|
||||
{
|
||||
case "RUNINGTOTAL":
|
||||
RuningTotal( inputValues, out outputValues );
|
||||
break;
|
||||
case "RUNINGAVERAGE":
|
||||
RunningAverage( inputValues, out outputValues );
|
||||
break;
|
||||
default:
|
||||
outputValues = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch( IndexOutOfRangeException )
|
||||
{
|
||||
throw new InvalidOperationException( SR.ExceptionFormulaInvalidPeriod(name) );
|
||||
}
|
||||
catch( OverflowException )
|
||||
{
|
||||
throw new InvalidOperationException( SR.ExceptionFormulaNotEnoughDataPoints(name) );
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user