@@ -6,15 +6,20 @@ namespace ExtractorSharp.Draw.Paint {
66 public class Canvas : IPaint {
77 public string Name { set ; get ; }
88 public Bitmap Image { set ; get ; }
9- public Rectangle Rectangle {
9+ public Rectangle Rectangle => new Rectangle ( _Location , Size ) ;
10+
11+ private Point _Location {
1012 get {
1113 var location = Location ;
12- if ( Tag is Sprite sprite && RealPosition ) {
13- location = location . Add ( sprite . Location ) ;
14- }
15- return new Rectangle ( location , Size ) ;
14+ if ( RealPosition ) {
15+ if ( Tag is Sprite sprite ) {
16+ location = location . Add ( sprite . Location ) ;
17+ }
18+ }
19+ return location ;
1620 }
1721 }
22+
1823 public bool Contains ( Point point ) => Rectangle . Contains ( point ) ;
1924 public Point Offset { set ; get ; } = Point . Empty ;
2025 public Size CanvasSize { set ; get ; }
@@ -30,14 +35,22 @@ public void Draw(Graphics g) {
3035 public bool Visible { set ; get ; }
3136 public bool Locked { set ; get ; }
3237
33- public bool RealPosition { set ; get ; }
38+ public bool RealPosition {
39+ set {
40+ _realPostion = value ;
41+ if ( ! value ) {
42+ Location = Point . Empty ;
43+ }
44+ }
45+ get {
46+ return _realPostion ;
47+ }
48+ }
49+
50+ private bool _realPostion ;
3451
3552 public override string ToString ( ) {
36- var location = Location ;
37- if ( Tag is Sprite sprite && RealPosition ) {
38- location = location . Add ( sprite . Location ) ;
39- }
40- return $ "{ Language . Default [ Name ] } ,{ Language . Default [ "Position" ] } ({ location . X } ,{ location . Y } ),{ Language . Default [ "Size" ] } ({ Size . Width } ,{ Size . Height } )";
53+ return $ "{ Language . Default [ Name ] } ,{ Language . Default [ "Position" ] } ({ _Location . GetString ( ) } ),{ Language . Default [ "Size" ] } ({ Size . GetString ( ) } )";
4154 }
4255 }
4356}
0 commit comments