本文整理汇总了C#中IData.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IData.TryGetValue方法的具体用法?C# IData.TryGetValue怎么用?C# IData.TryGetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IData
的用法示例。
在下文中一共展示了IData.TryGetValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetFromIData
protected override void SetFromIData(ILogicalDevice logicalDevice, IData data)
{
base.SetFromIData(logicalDevice, data);
object value;
if (data.TryGetValue(DataElements.Pan, out value))
this.pan = ((double)value).Limit(0, 540);
if (data.TryGetValue(DataElements.Tilt, out value))
this.tilt = ((double)value).Limit(0, 270);
}
示例2: SetFromIData
protected override void SetFromIData(ILogicalDevice logicalDevice, IData data)
{
base.SetFromIData(logicalDevice, data);
object value;
if (data.TryGetValue(DataElements.StrobeSpeed, out value))
this.strobeSpeed = (double)value;
}
示例3: SetFromIData
protected override void SetFromIData(ILogicalDevice logicalDevice, IData data)
{
base.SetFromIData(logicalDevice, data);
if (data.ContainsKey(DataElements.ColorRGB) ||
data.ContainsKey(DataElements.ColorWhite))
{
object value;
componentMaster = (this.colorBrightness.Brightness * (1 - Executor.Current.Blackout.Value)).GetByteScale();
Color colorRGB;
if (data.TryGetValue(DataElements.ColorRGB, out value))
colorRGB = (Color)value;
else
colorRGB = this.colorBrightness.Color;
componentRed = colorRGB.R;
componentGreen = colorRGB.G;
componentBlue = colorRGB.B;
//TODO: WhiteOut
if (data.TryGetValue(DataElements.ColorWhite, out value))
componentWhite = ((double)value).GetByteScale();
}
else
{
var rgbw = RgbConverter.GetRGBW(this.colorBrightness.Color);
componentMaster = this.colorBrightness.Brightness.GetByteScale();
componentRed = rgbw.R;
componentGreen = rgbw.G;
componentBlue = rgbw.B;
componentWhite = rgbw.W;
}
}
示例4: PreprocessPushData
protected override IData PreprocessPushData(IData data)
{
object value;
if (data.TryGetValue(DataElements.Color, out value))
{
Color allColor = (Color)value;
if (allColor != Color.Transparent)
{
var bitmap = (Bitmap)data[DataElements.PixelBitmap];
using (var g = Graphics.FromImage(bitmap))
using (var allColorBrush = new SolidBrush(allColor))
{
g.FillRectangle(allColorBrush, 0, 0, bitmap.Width, bitmap.Height);
}
}
data.Remove(DataElements.Color);
}
return base.PreprocessPushData(data);
}
示例5: SetFromIData
protected override void SetFromIData(ILogicalDevice logicalDevice, IData data)
{
base.SetFromIData(logicalDevice, data);
object value;
if (data.TryGetValue(DataElements.Pan, out value))
this.pan = ((double)value).Limit(0, 540);
if (data.TryGetValue(DataElements.Tilt, out value))
this.tilt = ((double)value).Limit(0, 270);
#if TRACE_IDATA
int id = 0;
foreach (var kvp in data)
{
id++;
log.Trace("{3} {0}. {1} = {2}", id, kvp.Key, kvp.Value, this.Name);
}
#endif
}
示例6: SetFromIData
protected virtual void SetFromIData(ILogicalDevice logicalDevice, IData data)
{
object value;
bool masterPower = true;
var masterPowerDevice = logicalDevice as IHasMasterPower;
if (masterPowerDevice != null)
masterPower = masterPowerDevice.MasterPower;
if (data.TryGetValue(DataElements.Brightness, out value))
this.colorBrightness.Brightness = (double)value * (masterPower ? 1 : 0);
else
{
bool? power = data.GetValue<bool>(DataElements.Power);
if (power.HasValue)
this.colorBrightness.Brightness = (power.Value && masterPower) ? 1 : 0;
}
if (data.TryGetValue(DataElements.Color, out value))
this.colorBrightness.Color = (Color)value;
}