@@ -16,7 +16,8 @@ public partial class FormMain : Form
1616 private PointF _center ;
1717 private Rectangle _drawingArea ;
1818 private RectangleF _innerDrawingArea ;
19- private int _ledSize ;
19+ private int _ledSize , _rotation = 0 ;
20+ private double LedAngleBetweenColumns = 360 / LedColumns ;
2021
2122 public FormMain ( )
2223 {
@@ -46,12 +47,15 @@ private void pictureBoxEditor_Paint(object sender, PaintEventArgs e)
4647 for ( var i = 0 ; i < LedRows ; i ++ )
4748 {
4849 var p = new PointF ( _center . X , _drawingArea . Top + ( yspacing * ( 1 + i ) ) ) ;
50+ var r = _rotation ;
4951
5052 for ( var j = 0 ; j < LedColumns ; j ++ )
5153 {
54+ p = RotatePoint ( p , _center , r + LedAngleBetweenColumns ) ;
55+ r = 0 ;
56+
5257 e . Graphics . FillEllipse ( GetBit ( i + j * LedRows ) ? Brushes . Blue : Brushes . LightYellow ,
5358 p . X - _ledSize / 2 , p . Y - _ledSize / 2 , _ledSize , _ledSize ) ;
54- p = RotatePoint ( p , _center , 360 / LedColumns ) ;
5559 }
5660 }
5761 }
@@ -179,6 +183,18 @@ public static byte[] BitArrayToByteArray(BitArray bits)
179183 return output . ToArray ( ) ;
180184 }
181185
186+ private void counterclockwiseToolStripMenuItem_Click ( object sender , EventArgs e )
187+ {
188+ _rotation -= 5 ;
189+ pictureBoxEditor . Invalidate ( ) ;
190+ }
191+
192+ private void clockwiseToolStripMenuItem_Click ( object sender , EventArgs e )
193+ {
194+ _rotation += 5 ;
195+ pictureBoxEditor . Invalidate ( ) ;
196+ }
197+
182198 private int GetBitByPosition ( Point point )
183199 {
184200 if ( ! _drawingArea . IsEmpty && ! _innerDrawingArea . IsEmpty && ! _center . IsEmpty )
@@ -187,12 +203,15 @@ private int GetBitByPosition(Point point)
187203 for ( var i = 0 ; i < LedRows ; i ++ )
188204 {
189205 var p = new PointF ( _center . X , _drawingArea . Top + ( yspacing * ( 1 + i ) ) ) ;
206+ var r = _rotation ;
190207
191208 for ( var j = 0 ; j < LedColumns ; j ++ )
192209 {
210+ p = RotatePoint ( p , _center , r + LedAngleBetweenColumns ) ;
211+ r = 0 ;
212+
193213 if ( new RectangleF ( p . X - _ledSize / 2 , p . Y - _ledSize / 2 , _ledSize , _ledSize ) . Contains ( point ) )
194214 return i + j * LedRows ;
195- p = RotatePoint ( p , _center , 360 / LedColumns ) ;
196215 }
197216 }
198217 }
0 commit comments