Beispiel #1
0
        public ColorSchemeController()
        {
            // force init color table
            byte unused = SystemColors.Window.R;

            var systemDrawingAssembly = typeof(Color).Assembly;

            _colorTableField = systemDrawingAssembly.GetType("System.Drawing.KnownColorTable")
                               .GetField("colorTable", BindingFlags.Static | BindingFlags.NonPublic);

            _colorTable = readColorTable();
            SystemEvents.UserPreferenceChanging += userPreferenceChanging;

            OriginalColors      = _colorTable.ToArray();
            KnownOriginalColors = KnownColors.Cast <int>()
                                  .ToDictionary(i => i, i => OriginalColors[i])
                                  .AsReadOnlyDictionary();

            _threadDataProperty = systemDrawingAssembly.GetType("System.Drawing.SafeNativeMethods")
                                  .GetNestedType("Gdip", BindingFlags.NonPublic)
                                  .GetProperty("ThreadData", BindingFlags.Static | BindingFlags.NonPublic);

            SystemBrushesKey = typeof(SystemBrushes)
                               .GetField("SystemBrushesKey", BindingFlags.Static | BindingFlags.NonPublic)
                               .GetValue(null);

            SystemPensKey = typeof(SystemPens)
                            .GetField("SystemPensKey", BindingFlags.Static | BindingFlags.NonPublic)
                            .GetValue(null);
        }
Beispiel #2
0
 public IReadOnlyDictionary <int, int> Save() =>
 KnownColors.Cast <int>()
 .ToDictionary(i => i, i => _colorTable[i])
 .AsReadOnlyDictionary();