Mercurial > hg > ucis.core
comparison FBGUI/FBGUI.cs @ 74:8f31b164ce7e
FBGUI: Added invisible cursor support
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Thu, 28 Nov 2013 13:19:41 +0100 |
parents | 82290dc1403c |
children | 4e4c600031e2 |
comparison
equal
deleted
inserted
replaced
73:6aca18ee4ec6 | 74:8f31b164ce7e |
---|---|
587 public Point Hotspot { get; private set; } | 587 public Point Hotspot { get; private set; } |
588 public Size Size { get; private set; } | 588 public Size Size { get; private set; } |
589 public FBGCursor(Image image, Point hotspot) { | 589 public FBGCursor(Image image, Point hotspot) { |
590 this.Image = image; | 590 this.Image = image; |
591 this.Hotspot = hotspot; | 591 this.Hotspot = hotspot; |
592 this.Size = image.Size; | 592 this.Size = image == null ? Size.Empty : image.Size; |
593 } | 593 } |
594 public Rectangle Area { get { return new Rectangle(-Hotspot.X, -Hotspot.Y, Size.Width, Size.Height); } } | 594 public Rectangle Area { get { return new Rectangle(-Hotspot.X, -Hotspot.Y, Size.Width, Size.Height); } } |
595 public FBGCursor RotateFlip(RotateFlipType type) { | 595 public FBGCursor RotateFlip(RotateFlipType type) { |
596 if (Image == null) return this; | |
596 Image img = new Bitmap(Image); | 597 Image img = new Bitmap(Image); |
597 img.RotateFlip(type); | 598 img.RotateFlip(type); |
598 Point hs = Hotspot; | 599 Point hs = Hotspot; |
599 switch (type) { | 600 switch (type) { |
600 case RotateFlipType.RotateNoneFlipNone: break; | 601 case RotateFlipType.RotateNoneFlipNone: break; |
615 using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("UCIS.FBGUI." + name + ".png")) { | 616 using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("UCIS.FBGUI." + name + ".png")) { |
616 return new FBGCursor(Image.FromStream(s), new Point(hotX, hotY)); | 617 return new FBGCursor(Image.FromStream(s), new Point(hotX, hotY)); |
617 } | 618 } |
618 } | 619 } |
619 | 620 |
621 public static readonly FBGCursor None = new FBGCursor(null, Point.Empty); | |
620 public static readonly FBGCursor Arrow = LoadFromResource("cursor_arrow", 0, 0); | 622 public static readonly FBGCursor Arrow = LoadFromResource("cursor_arrow", 0, 0); |
621 public static readonly FBGCursor Move = LoadFromResource("cursor_move", 8, 8); | 623 public static readonly FBGCursor Move = LoadFromResource("cursor_move", 8, 8); |
622 public static readonly FBGCursor SizeLeft = LoadFromResource("cursor_left", 1, 10); | 624 public static readonly FBGCursor SizeLeft = LoadFromResource("cursor_left", 1, 10); |
623 public static readonly FBGCursor SizeRight = SizeLeft.RotateFlip(RotateFlipType.RotateNoneFlipX); | 625 public static readonly FBGCursor SizeRight = SizeLeft.RotateFlip(RotateFlipType.RotateNoneFlipX); |
624 public static readonly FBGCursor SizeTop = SizeLeft.RotateFlip(RotateFlipType.Rotate90FlipNone); | 626 public static readonly FBGCursor SizeTop = SizeLeft.RotateFlip(RotateFlipType.Rotate90FlipNone); |
753 RaiseEvent(Painted, new InvalidateEventArgs(rect)); | 755 RaiseEvent(Painted, new InvalidateEventArgs(rect)); |
754 } | 756 } |
755 } | 757 } |
756 public virtual new void Paint(Graphics g) { | 758 public virtual new void Paint(Graphics g) { |
757 HandleEvent(new FBGPaintEvent(g)); | 759 HandleEvent(new FBGPaintEvent(g)); |
758 if (cursor != null) { | 760 if (cursor != null && cursor.Image != null) { |
759 Rectangle r = cursor.Area; | 761 Rectangle r = cursor.Area; |
760 r.Offset(cursorposition); | 762 r.Offset(cursorposition); |
761 g.DrawImage(cursor.Image, r); | 763 g.DrawImage(cursor.Image, r); |
762 } | 764 } |
763 } | 765 } |