Пример #1
0
        public static Rectangle showDialog(decimal x, decimal y, decimal w, decimal h)
        {
            RegionSelector s = new RegionSelector();
            Rectangle      d = s.GetScreen();

            s.KeyPress += (sender, e) =>
            {
                if (e.KeyChar == 's')
                {
                    s.Close();
                }
                if (e.KeyChar == 'c')
                {
                    s.Location = new Point(d.Width / 2 - s.Width / 2, d.Height / 2 - s.Height / 2);
                }
            };
            s.Shown += (sender, e) =>
            {
                s.Location = new Point((int)((double)x / 100.0 * d.Width), (int)((double)y / 100.0 * d.Height));
                s.Width    = (int)((double)w / 100.0 * d.Width);
            };
            s.Height = (int)((double)h / 100.0 * d.Height);

            s.ShowDialog();

            Rectangle t   = s.ClientRectangle;
            Rectangle res = new Rectangle(s.Location.X * 100 / d.Width, s.Location.Y * 100 / d.Height, t.Width * 100 / d.Width, t.Height * 100 / d.Height);

            return(res);
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Rectangle r = RegionSelector.showDialog(sX.Value, sY.Value, sW.Value, sH.Value);

            sX.Value = r.X;
            sY.Value = r.Y;
            sW.Value = r.Width;
            sH.Value = r.Height;
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Rectangle r = RegionSelector.showDialog(tX.Value, tY.Value, tW.Value, tH.Value);

            tX.Value = r.X;
            tY.Value = r.Y;
            tW.Value = r.Width;
            tH.Value = r.Height;
        }