private void Sh_MouseDown(object sender, MouseButtonEventArgs e)
        {
            t_resizing = Resizing.IsResizing;

            t_handleMousePoint = new Point(e.GetPosition(t_container).X, e.GetPosition(t_container).Y);

            // the handle being pressed determines a virtual selection rectangle transformation so that all
            // handles can use same resizing code
            SelectionHandle sh = (SelectionHandle)sender;

            double left = SelectionLocationLeft;
            double top  = SelectionLocationTop;

            System.Windows.Point point0 = new Point(left, top);
            System.Windows.Point point1 = new Point(left + t_selection.Width, top);
            System.Windows.Point point2 = new Point(left + t_selection.Width, top + t_selection.Height);
            System.Windows.Point point3 = new Point(left, top + t_selection.Height);

            switch (sh.Order)
            {
            case 0:
                t_currentMatrix = 0;     // rotation 180 °

                t_transformedRectanglePoints[0] = Engine.Calc.Matrix.Dot(point2, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[1] = Engine.Calc.Matrix.Dot(point3, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[2] = Engine.Calc.Matrix.Dot(point0, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[3] = Engine.Calc.Matrix.Dot(point1, t_matrices[t_currentMatrix]);
                break;

            case 1:
                t_currentMatrix = 1;     // rotation 90 °

                t_transformedRectanglePoints[0] = Engine.Calc.Matrix.Dot(point3, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[1] = Engine.Calc.Matrix.Dot(point0, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[2] = Engine.Calc.Matrix.Dot(point1, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[3] = Engine.Calc.Matrix.Dot(point2, t_matrices[t_currentMatrix]);
                break;

            case 2:
                t_currentMatrix = 2;     // rotation 0 °

                t_transformedRectanglePoints[0] = Engine.Calc.Matrix.Dot(point0, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[1] = Engine.Calc.Matrix.Dot(point1, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[2] = Engine.Calc.Matrix.Dot(point2, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[3] = Engine.Calc.Matrix.Dot(point3, t_matrices[t_currentMatrix]);

                break;

            case 3:
                t_currentMatrix = 3;     // rotation 270 °

                t_transformedRectanglePoints[0] = Engine.Calc.Matrix.Dot(point1, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[1] = Engine.Calc.Matrix.Dot(point2, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[2] = Engine.Calc.Matrix.Dot(point3, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[3] = Engine.Calc.Matrix.Dot(point0, t_matrices[t_currentMatrix]);
                break;
            }

            t_container.MouseMove += Sh_MouseMove;
        }
 private PaintualUI.Controls.SelectionHandle CreateHandles(System.Windows.Point p)
 {
     PaintualUI.Controls.SelectionHandle h = new SelectionHandle(p.X - SelectionHandle.Offset, p.Y - SelectionHandle.Offset);
     return(h);
 }