예제 #1
0
        // IO
        public void Load(string path)
        {
            var settings = new IniSettings();

            settings.Load(path);

            foreach (var prop in properties.Values)
            {
                try
                {
                    string value;
                    if (settings.TryGetString(prop.Name, out value))
                    {
                        if (prop.PropertyType == typeof(Color))
                        {
                            // #FFFFFF
                            if (value.Length == 7 && value[0] == '#')
                            {
                                prop.SetValue(this, rgb(Convert.ToInt32(value.Substring(1), 16)), null);
                            }
                        }
                        else if (prop.PropertyType == typeof(Brush))
                        {
                            // #FFFFFF
                            if (value.Length == 7 && value[0] == '#')
                            {
                                prop.SetValue(this, new SolidBrush(rgb(Convert.ToInt32(value.Substring(1), 16))), null);
                            }
                        }
                        else if (prop.PropertyType == typeof(Pen))
                        {
                            // #FFFFFF
                            if (value.Length == 7 && value[0] == '#')
                            {
                                prop.SetValue(this, new Pen(new SolidBrush(rgb(Convert.ToInt32(value.Substring(1), 16)))), null);
                            }
                        }
                    }
                }
                catch { }
            }

            var c = (ChatBackground as SolidBrush)?.Color ?? Color.White;

            IsLightTheme = HSLColor.FromRGB(c.R / 255f, c.G / 255f, c.B / 255f).Luminosity > 0.5f;
        }