52 lines
2.1 KiB
C#
52 lines
2.1 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using UnitsNet.Units;
|
|||
|
|
using UnitsNet;
|
|||
|
|
using System.Security.AccessControl;
|
|||
|
|
using System.Runtime.Remoting.Contexts;
|
|||
|
|
|
|||
|
|
namespace CaeGlobals
|
|||
|
|
{
|
|||
|
|
public class EquationLengthDefaultConverter : StringLengthDefaultConverter
|
|||
|
|
{
|
|||
|
|
// Constructors
|
|||
|
|
public EquationLengthDefaultConverter()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// Methods
|
|||
|
|
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
|||
|
|
{
|
|||
|
|
// Initializes the standard values list with string defaults.
|
|||
|
|
string initialValueStr = (string)ConvertTo(context, null, _initialValue, typeof(string));
|
|||
|
|
values = new ArrayList(new EquationString[] { new EquationString(_default), new EquationString(initialValueStr) });
|
|||
|
|
// Passes the local integer array.
|
|||
|
|
StandardValuesCollection svc = new StandardValuesCollection(values);
|
|||
|
|
return svc;
|
|||
|
|
}
|
|||
|
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
|||
|
|
{
|
|||
|
|
// Convert from string to equation
|
|||
|
|
return EquationToString.ConvertFromStringToEquationString(context, culture, value, base.ConvertFrom);
|
|||
|
|
}
|
|||
|
|
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
|||
|
|
{
|
|||
|
|
// Convert from equation to string
|
|||
|
|
return EquationToString.ConvertToStringFromEquationString(context, culture, value, destinationType,
|
|||
|
|
base.ConvertFrom, base.ConvertTo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|