コード例 #1
0
        private void BOX_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.Wheat);

            TGrid.Draw(e.Graphics, box.Width, box.Height, GRID_SIZE);

            foreach (TShape shape in _shapes)
            {
                shape.Draw(e.Graphics, TGrid.Origin);
            }

            if (_shape != null)
            {
                _shape.Draw(e.Graphics, TGrid.Origin);
            }

            _pointer.Draw(e.Graphics, TGrid.Origin);

            base.OnPaint(e);
        }
コード例 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var rect = Screen.GetBounds(this);

            this.Width                = (int)(rect.Width * 0.75);
            this.Height               = (int)(rect.Height * 0.75);
            this.StartPosition        = FormStartPosition.CenterScreen;
            this.splitContainer2.Dock = DockStyle.Fill;

            toolLine.Tag      = Tools.Line;
            toolCircle.Tag    = Tools.Circle;
            toolRectangle.Tag = Tools.Rectangle;

            toolLine.Click      += ToolButton_Click;
            toolCircle.Click    += ToolButton_Click;
            toolRectangle.Click += ToolButton_Click;

            Color formColor = this.BackColor;

            SetStyle(ControlStyles.AllPaintingInWmPaint
                     | ControlStyles.Opaque
                     | ControlStyles.OptimizedDoubleBuffer
                     | ControlStyles.ResizeRedraw
                     | ControlStyles.UserPaint,
                     true);

            this.BackColor = formColor;

            TCircle circle = new TCircle(new TPoint(60, 60), 80);

            _shapes.Add(circle);

            TLine line = new TLine(new TPoint(-20, -20), new TPoint(40, 40));

            _shapes.Add(line);

            TGrid.SetCenter(box.Width / 2, box.Height / 2);
        }
コード例 #3
0
 private void FormMain_Resize(object sender, EventArgs e)
 {
     TGrid.SetCenter(box.Width / 2, box.Height / 2);
     box.Invalidate();
 }