Fixed rotating elements which are just rectangles, like the enum-label.

This commit is contained in:
RKrom 2014-05-31 23:38:12 +02:00
commit c19564b6e3
3 changed files with 15 additions and 5 deletions

View file

@ -707,6 +707,18 @@ namespace Greenshot.Drawing {
} }
} }
public virtual void Transform(Matrix matrix) {
if (matrix == null) {
return;
}
Point center = new Point(Left + (Width/2), Top + (Height/2));
Point[] points = { center };
matrix.TransformPoints(points);
Left = points[0].X - (Width / 2);
Top = points[0].Y - (Height / 2);
}
public virtual void Rotate(RotateFlipType rotateFlipType) { public virtual void Rotate(RotateFlipType rotateFlipType) {
// somehow the rotation is the wrong way? // somehow the rotation is the wrong way?
int angle = 90; int angle = 90;

View file

@ -135,11 +135,7 @@ namespace Greenshot.Drawing {
bool modified = false; bool modified = false;
Invalidate(); Invalidate();
foreach (var dc in this) { foreach (var dc in this) {
Point[] location = { dc.Location }; dc.Transform(matrix);
matrix.TransformPoints(location);
dc.Left = location[0].X;
dc.Top = location[0].Y;
modified = true; modified = true;
} }
// Invalidate after // Invalidate after

View file

@ -20,6 +20,7 @@
*/ */
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Windows.Forms; using System.Windows.Forms;
using System.ComponentModel; using System.ComponentModel;
@ -87,6 +88,7 @@ namespace Greenshot.Plugin.Drawing {
void HideGrippers(); void HideGrippers();
void ShowGrippers(); void ShowGrippers();
void MoveBy(int x, int y); void MoveBy(int x, int y);
void Transform(Matrix matrix);
bool HandleMouseDown(int x, int y); bool HandleMouseDown(int x, int y);
void HandleMouseUp(int x, int y); void HandleMouseUp(int x, int y);
bool HandleMouseMove(int x, int y); bool HandleMouseMove(int x, int y);