1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40:
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
Rectangle rec = new Rectangle(100, 100, 100, 100); private void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Pen p = new Pen(Brushes.Black);
g.DrawRectangle(p , rec); Region regInner = new Region(rec); regInner.IsVisible(rec); }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (rec.regInner.IsVisible(e.Location)) { Cursor.Current = Cursors.Cross; return; } } } } |