本文整理汇总了C#中System.Drawing.Imaging.ColorMatrix.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ColorMatrix.GetType方法的具体用法?C# ColorMatrix.GetType怎么用?C# ColorMatrix.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Imaging.ColorMatrix
的用法示例。
在下文中一共展示了ColorMatrix.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveSetting
public static void SaveSetting(ButtonEffect effect, ColorMatrix cm, int FontColour)
{
string key = AppController.ApplicationRegistryKeyName;
string subkey = effect.ToString();
RegistryKey reg = Registry.CurrentUser.CreateSubKey(key + @"\UserColours\" + subkey);
if (reg == null)
return;
reg.SetValue("FontColour", FontColour);
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
string name = "Matrix"
+ i.ToString(System.Globalization.CultureInfo.InvariantCulture)
+ j.ToString(System.Globalization.CultureInfo.InvariantCulture);
object value = cm.GetType().GetProperty(name).GetValue(cm, null);
// Console.WriteLine("i: {0}, j: {1}, value: {2}", i, j, value);
reg.SetValue(name, (float)System.Decimal.Parse(value.ToString(), System.Globalization.CultureInfo.InvariantCulture));
}
}
RaiseColoursChangedEvent();
}
示例2: RandomizeButtonClick
private void RandomizeButtonClick(object sender, EventArgs e)
{
ColorMatrix cm = new ColorMatrix();
int numberOfChanges = 5;
Random r = new Random();
for (int i = 0; i < numberOfChanges; i++)
{
int x = r.Next(0, 5);
int y = r.Next(0, 3);
string name = "Matrix" + x.ToString(CultureInfo.InvariantCulture) + y.ToString(CultureInfo.InvariantCulture);
float val = (r.Next(-10, 11) / 10F);
// Update control...
// (this.Controls[name] as NumericUpDown).Value = val;
// Or update field.
cm.GetType().GetProperty(name).SetValue(cm, val, null);
}
_fontColour = Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256));
UpdateMatrix(cm);
SaveSetting();
}
示例3: GetColourSettingFromRegistry
private static UserColourSetting GetColourSettingFromRegistry(ButtonEffect effect)
{
// Need to be defensively minded as user could change,
// delete, or change type of registry settings.
string subkey = AppController.ApplicationRegistryKeyName + @"\UserColours\" + effect.ToString();
RegistryKey reg = Registry.CurrentUser.OpenSubKey(subkey);
if (reg == null) // No settings have been defined for this effect
return null;
UserColourSetting setting = new UserColourSetting();
// User may have changed type of FontColour
// Using nullable int as any possible integer value could be a valid
// ToARGB() result (well, I'm assuming it could anyway)
int? fontColourArgb;
object value = reg.GetValue("FontColour");
if (value == null || reg.GetValueKind("FontColour") != RegistryValueKind.DWord)
fontColourArgb = Color.Black.ToArgb();
else
fontColourArgb = (int?)value;
setting.FontColour = Color.FromArgb((int)fontColourArgb);
ColorMatrix cm = new ColorMatrix();
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
string name = "Matrix"
+ i.ToString(System.Globalization.CultureInfo.InvariantCulture)
+ j.ToString(System.Globalization.CultureInfo.InvariantCulture);
value = reg.GetValue(name);
if (value != null)
{
Single svalue;
if (System.Single.TryParse(value.ToString(), out svalue))
{
cm.GetType().GetProperty(name).SetValue(cm, svalue, null);
}
}
}
}
setting.Matrix = cm;
return setting;
}