Exemple #1
0
        // Conversion functions
        private static string BrushToString(object obj)
        {
            var solidBrush = obj as SolidBrush;
            var color      = solidBrush == null ? new Pen((Brush)obj).Color : solidBrush.Color;

            return(RgbHexColor.GetHex(color));
        }
Exemple #2
0
        public void DoPaste()
        {
            var clipboardText = ClipboardHelper.GetClipboardText(this);

            if (clipboardText == null)
            {
                return;
            }
            using (var reader = new StringReader(clipboardText))
            {
                string line;
                while (null != (line = reader.ReadLine()))
                {
                    line = line.Trim();
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }
                    var color = RgbHexColor.ParseHtmlColor(line) ?? RgbHexColor.ParseRgb(line);
                    if (color == null)
                    {
                        MessageDlg.Show(this, string.Format(Resources.EditCustomThemeDlg_DoPaste_Unable_to_parse_the_color___0____Use_HEX_or_RGB_format_, line));
                        return;
                    }
                    var colorRow = new T {
                        Color = color.Value
                    };
                    BindingSource.Insert(BindingSource.Position, colorRow);
                }
            }
        }