当前位置: 首页>>代码示例>>C#>>正文


C# ColorMatrix.GetType方法代码示例

本文整理汇总了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();
        }
开发者ID:tmzu,项目名称:keymapper,代码行数:27,代码来源:UserColours.cs

示例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();
        }
开发者ID:stuartd,项目名称:keymapper,代码行数:28,代码来源:ColourEditor.cs

示例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;
        }
开发者ID:tmzu,项目名称:keymapper,代码行数:53,代码来源:UserColours.cs


注:本文中的System.Drawing.Imaging.ColorMatrix.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。