Ejemplo n.º 1
0
        private void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var      point    = e.GetPosition(canvas);
            int      diameter = 64;// _Random.Next(Radius_Min, Radius_Max);
            var      brush    = ColorSetBrush[GetRandomBrushIndex(0, ColorSet.Count)];
            RectArea rect     = new RectArea()
            {
                CenterX = point.X, CenterY = point.Y, Width = diameter, Height = diameter
            };

            _BubbleQueue.Add(rect, brush);

            Ellipse ellipse = new Ellipse()
            {
                Fill = brush, Width = diameter, Height = diameter
            };

            canvas.Children.Add(ellipse);
            Canvas.SetLeft(ellipse, point.X - diameter * 0.5d);
            Canvas.SetTop(ellipse, point.Y - diameter * 0.5d);
            ellipse.Tag = rect;
            ellipse.MouseRightButtonDown += ellipse_MouseRightButtonDown;
            ellipse.MouseWheel           += ellipse_MouseWheel;
            ellipse.MouseEnter           += ellipse_MouseEnter;
            ellipse.MouseLeave           += ellipse_MouseLeave;
            UpdateBubbleCount();
        }
Ejemplo n.º 2
0
        void ellipse_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Ellipse  ellipse = sender as Ellipse;
            RectArea rect    = (RectArea)ellipse.Tag;
            var      brush   = ColorSetBrush[GetRandomBrushIndex(0, ColorSet.Count)];

            ellipse.Fill       = brush;
            _BubbleQueue[rect] = brush;
        }
Ejemplo n.º 3
0
        void ellipse_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            Ellipse  ellipse     = sender as Ellipse;
            RectArea rect        = (RectArea)ellipse.Tag;
            int      diameter    = (int)rect.Width;
            Point    centerPoint = new Point(rect.CenterX, rect.CenterY);

            int newDiameter = diameter + (int)(e.Delta * 0.1d);

            if (newDiameter > Radius_Min && newDiameter < Radius_Max)
            {
                diameter = newDiameter;
            }

            Canvas.SetLeft(ellipse, centerPoint.X - diameter * 0.5d);
            Canvas.SetTop(ellipse, centerPoint.Y - diameter * 0.5d);
            ellipse.Width  = diameter;
            ellipse.Height = diameter;

            rect.Width  = diameter;
            rect.Height = diameter;
        }