Beispiel #1
0
        /// <summary>
        /// PropertyChangedCallback for ColorString
        /// </summary>
        private static void ColorStringChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            if (obj is ColorPickerPlugin)
            {
                ColorPickerPlugin owner = (ColorPickerPlugin)obj;
                Shazzam.Properties.Settings.Default.ColorPickerColors = args.NewValue as string;

                if (!owner.updateinternal)
                {
                    owner.updateinternal = true;

                    owner.Colors.Clear();
                    string[] colors = (args.NewValue as string).Split(owner.DELIMITER);

                    foreach (string s in colors)
                    {
                        try
                        {
                            if (s.Length > 3)
                            {
                                Color c = ColorPickerUtil.ColorFromString(s);
                                owner.Colors.Add(c);
                            }
                        }
                        catch { }
                    }

                    owner.updateinternal = false;
                }
            }
        }
        public static void DrawFrame(System.Drawing.Graphics dc, System.Drawing.RectangleF r, float cornerRadius, System.Drawing.Color color)
        {
            var pen = new System.Drawing.Pen(color);

            if (cornerRadius <= 0)
            {
                dc.DrawRectangle(pen, ColorPickerUtil.Rect(r));
                return;
            }
            cornerRadius = (float)System.Math.Min(cornerRadius, System.Math.Floor(r.Width) - 2);
            cornerRadius = (float)System.Math.Min(cornerRadius, System.Math.Floor(r.Height) - 2);

            var path = new System.Drawing.Drawing2D.GraphicsPath();

            path.AddArc(r.X, r.Y, cornerRadius, cornerRadius, 180, 90);
            path.AddArc(r.Right - cornerRadius, r.Y, cornerRadius, cornerRadius, 270, 90);
            path.AddArc(r.Right - cornerRadius, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 0, 90);
            path.AddArc(r.X, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 90, 90);
            path.CloseAllFigures();
            dc.DrawPath(pen, path);
        }