Exemplo n.º 1
0
        void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            switch (selectedTool)
            {
            case Tools.Tool.Hand:
            {
                var mousePos = e.GetPosition(scrollViewer);
                if (mousePos.X <= scrollViewer.ViewportWidth && mousePos.Y < scrollViewer.ViewportHeight)         //make sure we still can use the scrollbars
                {
                    scrollViewer.Cursor = Cursors.SizeAll;
                    lastDragPoint       = mousePos;
                    Mouse.Capture(scrollViewer);
                }
            }
            break;

            case Tools.Tool.FillBucket:
            {
                var   p             = (Point)pixelEditor.GetMousePosition(e);
                Color targetColor   = pixelEditor.GetPixelColor((int)p.X, (int)p.Y);
                var   magnification = pixelEditor.Magnification;
                pixelEditor.floodfill((int)(p.X / magnification), (int)(p.Y / magnification), targetColor, _brushColor_Primary);
            }
            break;

            case Tools.Tool.ColorPicker:
            {
                var   p           = (Point)pixelEditor.GetMousePosition(e);
                Color pickedColor = pixelEditor.GetPixelColor((int)p.X, (int)p.Y);
                if (primaryColor.IsChecked == true)
                {
                    _brushColor_Primary = pickedColor;
                    BrushColor_Primary  = new SolidColorBrush(_brushColor_Primary);;
                }
                else if (secondColor.IsChecked == true)
                {
                    _brushColor_Primary  = pickedColor;
                    BrushColor_Secondary = new SolidColorBrush(_brushColor_Secondary);
                }
            }
            break;

            case Tools.Tool.ZoomIn:
            {
                ZoomIn();
            }
            break;

            case Tools.Tool.ZoomOut:
            {
                ZoomOut();
            }
            break;

            default:
                break;
            }
        }