本文整理汇总了C#中VariableDef.GetValueType方法的典型用法代码示例。如果您正苦于以下问题:C# VariableDef.GetValueType方法的具体用法?C# VariableDef.GetValueType怎么用?C# VariableDef.GetValueType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableDef
的用法示例。
在下文中一共展示了VariableDef.GetValueType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetVariable
public override void SetVariable(VariableDef variable, object obj) {
base.SetVariable(variable, obj);
if (variable != null) {
Type valueType = variable.GetValueType();
if (valueType == typeof(bool))
{ checkBox.Checked = (bool)variable.Value; }
}
}
示例2: SetVariable
public override void SetVariable(VariableDef variable, object obj)
{
base.SetVariable(variable, obj);
_valueWasAssigned = false;
clear();
if (variable != null)
{
Type enumtype = variable.GetValueType();
if (enumtype.IsEnum)
{
Array list = Enum.GetValues(enumtype);
string enumName = DesignerEnum.GetDisplayName(variable.Value);
foreach (object enumVal in list)
{
_allValues.Add(enumVal);
if (DesignerEnum.GetDisplayName(enumVal) == enumName)
{
_values.Add(enumVal);
comboBox.Items.Add(enumName);
}
}
comboBox.Text = enumName;
}
}
_valueWasAssigned = true;
}
示例3: SetVariable
public override void SetVariable(VariableDef variable, object obj)
{
base.SetVariable(variable, obj);
if (variable != null)
{
string str = trimQuotes(variable.Value.ToString());
if (textBox.Text != str)
{
textBox.Text = str;
_modified = true;
valueChanged();
}
if (Plugin.IsCharType(variable.GetValueType()))
{
textBox.MaxLength = 1;
}
}
}
示例4: SetVariable
public override void SetVariable(VariableDef variable, object obj) {
base.SetVariable(variable, obj);
if (variable != null) {
// extract the value
decimal value = 0;
Type valueType = variable.GetValueType();
if (Plugin.IsFloatType(valueType)) {
const float maxValue = 1000000000000;
SetRange(2,
(decimal)(-maxValue),
(decimal)maxValue,
(decimal)0.01);
float val = Convert.ToSingle(variable.Value);
value = (decimal)val;
numericUpDown.DecimalPlaces = 2;
} else if (valueType == typeof(int)) {
SetRange(0,
(decimal)int.MinValue,
(decimal)int.MaxValue,
(decimal)1);
int val = (int)variable.Value;
value = (decimal)val;
} else if (valueType == typeof(uint)) {
SetRange(0,
(decimal)int.MinValue,
(decimal)int.MaxValue,
(decimal)1);
uint val = (uint)variable.Value;
value = (decimal)val;
} else if (valueType == typeof(short)) {
SetRange(0,
(decimal)short.MinValue,
(decimal)short.MaxValue,
(decimal)1);
short val = (short)variable.Value;
value = (decimal)val;
} else if (valueType == typeof(ushort)) {
SetRange(0,
(decimal)ushort.MinValue,
(decimal)ushort.MaxValue,
(decimal)1);
ushort val = (ushort)variable.Value;
value = (decimal)val;
} else if (valueType == typeof(sbyte)) {
SetRange(0,
(decimal)sbyte.MinValue,
(decimal)sbyte.MaxValue,
(decimal)1);
sbyte val = (sbyte)variable.Value;
value = (decimal)val;
} else if (valueType == typeof(byte)) {
SetRange(0,
(decimal)byte.MinValue,
(decimal)byte.MaxValue,
(decimal)1);
byte val = (byte)variable.Value;
value = (decimal)val;
} else if (valueType == typeof(long)) {
SetRange(0,
(decimal)int.MinValue,
(decimal)int.MaxValue,
(decimal)1);
long val = (long)variable.Value;
value = (decimal)val;
} else if (valueType == typeof(ulong)) {
SetRange(0,
(decimal)uint.MinValue,
(decimal)uint.MaxValue,
(decimal)1);
ulong val = (ulong)variable.Value;
value = (decimal)val;
}
// assign value within limits
numericUpDown.Value = Math.Max(numericUpDown.Minimum, Math.Min(numericUpDown.Maximum, value));
}
}