コード例 #1
0
 private void ClearRectangles()
 {
     foreach (var rectangle in ColorRectangles)
     {
         rectangle.MouseDown -= RectangleMouseDown;
     }
     ColorRectangles.Clear();
 }
コード例 #2
0
        private void SetUi()
        {
            var brushBorder = (Brush)Application.Current.Resources["BrushBorder"];

            if (RadioGradient == false)
            {
                ClearRectangles();
                foreach (var color in _postModel.TransformColors)
                {
                    var rectangle = new Rectangle
                    {
                        Width  = 30, Height = 28, Fill = new SolidColorBrush(color),
                        Stroke = brushBorder,
                        Margin = new Thickness(3)
                    };
                    rectangle.MouseDown += RectangleMouseDown;
                    ColorRectangles.Add(rectangle);
                }
            }
            else
            {
                ColorRectangles.Clear();
                GradientFill = new LinearGradientBrush(_postModel.GradientModel.GetGradientStopCollection());
                foreach (var gradientValue in _postModel.GradientValues)
                {
                    var color     = gradientValue;
                    var rectangle = new Rectangle
                    {
                        Width  = 30,
                        Height = 28,
                        Fill   = new SolidColorBrush(_postModel.GradientModel.GetFromPosition(color)),
                        Stroke = brushBorder,
                        Margin = new Thickness(3)
                    };
                    rectangle.MouseDown += RectangleMouseDown;
                    ColorRectangles.Add(rectangle);
                }
            }

            BackColor = new SolidColorBrush(_postModel.BackColor);
        }