Changeset 1462 for trunk/sources/HeuristicLab.Visualization/TextShape.cs
- Timestamp:
- 03/27/09 20:23:17 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/TextShape.cs
r1337 r1462 1 1 using System; 2 2 using System.Drawing; 3 using System.Drawing.Drawing2D; 3 4 4 5 namespace HeuristicLab.Visualization { … … 19 20 private double x; 20 21 private double y; 22 private float rotation = 0; 21 23 22 24 private AnchorPositionX anchorPositionX = AnchorPositionX.Left; … … 59 61 } 60 62 63 public float Rotation { 64 get { return rotation; } 65 set { rotation = value; } 66 } 67 61 68 public Color Color { 62 69 get { return color; } … … 87 94 int screenX = Transform.ToScreenX(x, Parent.Viewport, Parent.ClippingArea); 88 95 int screenY = Transform.ToScreenY(y, Parent.Viewport, Parent.ClippingArea); 96 int offsetX, offsetY; 89 97 90 98 SizeF size = graphics.MeasureString(text, font); … … 92 100 switch (AnchorPositionX) { 93 101 case AnchorPositionX.Left: 102 offsetX = 0; 94 103 break; 95 104 case AnchorPositionX.Middle: 96 screenX -=(int)(size.Width/2);105 offsetX = -(int)(size.Width/2); 97 106 break; 98 107 case AnchorPositionX.Right: 99 screenX -=(int)size.Width;108 offsetX = -(int)size.Width; 100 109 break; 101 110 default: … … 105 114 switch (AnchorPositionY) { 106 115 case AnchorPositionY.Top: 116 offsetY = 0; 107 117 break; 108 118 case AnchorPositionY.Middle: 109 screenY -=(int)(size.Height/2);119 offsetY = -(int)(size.Height/2); 110 120 break; 111 121 case AnchorPositionY.Bottom: 112 screenY -=(int)size.Height;122 offsetY = -(int)size.Height; 113 123 break; 114 124 default: … … 116 126 } 117 127 118 graphics.DrawString(text, font, brush, screenX, screenY); 128 GraphicsState gstate = graphics.Save(); 129 graphics.TranslateTransform(screenX, screenY, MatrixOrder.Append); 130 graphics.RotateTransform(rotation, MatrixOrder.Prepend); 131 graphics.DrawString(text, font, brush, offsetX, offsetY); 132 graphics.Restore(gstate); 119 133 } 120 134
Note: See TracChangeset
for help on using the changeset viewer.