comparison FBGUI/FBGUI.cs @ 79:4e4c600031e2

Merge FBGUI updates
author Ivo Smits <Ivo@UCIS.nl>
date Sun, 16 Feb 2014 15:02:36 +0100
parents 1a10ca0f662e 8f31b164ce7e
children 3352f89cf6f5 0d389692be32
comparison
equal deleted inserted replaced
78:1a10ca0f662e 79:4e4c600031e2
579 public Point Hotspot { get; private set; } 579 public Point Hotspot { get; private set; }
580 public Size Size { get; private set; } 580 public Size Size { get; private set; }
581 public FBGCursor(Image image, Point hotspot) { 581 public FBGCursor(Image image, Point hotspot) {
582 this.Image = image; 582 this.Image = image;
583 this.Hotspot = hotspot; 583 this.Hotspot = hotspot;
584 this.Size = image.Size; 584 this.Size = image == null ? Size.Empty : image.Size;
585 } 585 }
586 public Rectangle Area { get { return new Rectangle(-Hotspot.X, -Hotspot.Y, Size.Width, Size.Height); } } 586 public Rectangle Area { get { return new Rectangle(-Hotspot.X, -Hotspot.Y, Size.Width, Size.Height); } }
587 public FBGCursor RotateFlip(RotateFlipType type) { 587 public FBGCursor RotateFlip(RotateFlipType type) {
588 if (Image == null) return this;
588 Image img = new Bitmap(Image); 589 Image img = new Bitmap(Image);
589 img.RotateFlip(type); 590 img.RotateFlip(type);
590 Point hs = Hotspot; 591 Point hs = Hotspot;
591 switch (type) { 592 switch (type) {
592 case RotateFlipType.RotateNoneFlipNone: break; 593 case RotateFlipType.RotateNoneFlipNone: break;
607 using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("UCIS.FBGUI." + name + ".png")) { 608 using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("UCIS.FBGUI." + name + ".png")) {
608 return new FBGCursor(Image.FromStream(s), new Point(hotX, hotY)); 609 return new FBGCursor(Image.FromStream(s), new Point(hotX, hotY));
609 } 610 }
610 } 611 }
611 612
613 public static readonly FBGCursor None = new FBGCursor(null, Point.Empty);
612 public static readonly FBGCursor Arrow = LoadFromResource("cursor_arrow", 0, 0); 614 public static readonly FBGCursor Arrow = LoadFromResource("cursor_arrow", 0, 0);
613 public static readonly FBGCursor Move = LoadFromResource("cursor_move", 8, 8); 615 public static readonly FBGCursor Move = LoadFromResource("cursor_move", 8, 8);
614 public static readonly FBGCursor SizeLeft = LoadFromResource("cursor_left", 1, 10); 616 public static readonly FBGCursor SizeLeft = LoadFromResource("cursor_left", 1, 10);
615 public static readonly FBGCursor SizeRight = SizeLeft.RotateFlip(RotateFlipType.RotateNoneFlipX); 617 public static readonly FBGCursor SizeRight = SizeLeft.RotateFlip(RotateFlipType.RotateNoneFlipX);
616 public static readonly FBGCursor SizeTop = SizeLeft.RotateFlip(RotateFlipType.Rotate90FlipNone); 618 public static readonly FBGCursor SizeTop = SizeLeft.RotateFlip(RotateFlipType.Rotate90FlipNone);
745 RaiseEvent(Painted, new InvalidateEventArgs(rect)); 747 RaiseEvent(Painted, new InvalidateEventArgs(rect));
746 } 748 }
747 } 749 }
748 public virtual new void Paint(Graphics g) { 750 public virtual new void Paint(Graphics g) {
749 HandleEvent(new FBGPaintEvent(g)); 751 HandleEvent(new FBGPaintEvent(g));
750 if (cursor != null) { 752 if (cursor != null && cursor.Image != null) {
751 Rectangle r = cursor.Area; 753 Rectangle r = cursor.Area;
752 r.Offset(cursorposition); 754 r.Offset(cursorposition);
753 g.DrawImage(cursor.Image, r); 755 g.DrawImage(cursor.Image, r);
754 } 756 }
755 } 757 }