コード例 #1
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);
        }
コード例 #2
0
 private void FormMain_Resize(object sender, EventArgs e)
 {
     TGrid.SetCenter(box.Width / 2, box.Height / 2);
     box.Invalidate();
 }