Ejemplo n.º 1
0
 private void AlignedCenterManager_BT1Click(object sender, EventArgs e)
 {
     if (posFlag == 2)//两点计算圆心
     {
         float  arc = arc2 - arc1;
         PointF p   = RotateMath.RotateCenterPoint(p1, p2, arc);
         posFlag = 0;
         Common.ReportCmdKeyProgress(CmdKey.P0304);
         repairSucessful = true;
     }
     else if (posFlag == 3)//三点计算圆心
     {
         float r = 0;
         centerPos       = RotateMath.RotateCenterPoint(p1, p2, p3, out r);
         posFlag         = 0;
         repairSucessful = true;
         Common.ReportCmdKeyProgress(CmdKey.P0309);
     }
     else
     {
         Common.ReportCmdKeyProgress(CmdKey.P0307);
     }
     cPosX.Value = centerPos.X;
     cPosY.Value = centerPos.Y;
 }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Random a = new Random();

            for (int i = 0; i < 3; i++)
            {
                p[i].X = a.Next(pictureBox1.Width);
                p[i].Y = a.Next(pictureBox1.Height);
            }
            double angle = a.Next(360);

            angle = 180 - angle;
            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.Clear(pictureBox1.BackColor);
                g.SmoothingMode    = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                drawPen.Color      = Color.Blue;
                drawPen.DashStyle  = DashStyle.Dash;
                drawPen1.DashStyle = DashStyle.Dash;
                float r = 0;
                g.DrawPolygon(drawPen, p);
                drawPen.Color = Color.Green;
                g.DrawLine(drawPen, new Point(0, (int)p[0].Y), new Point(pictureBox1.Width, (int)p[0].Y));
                g.DrawLine(drawPen, new Point((int)p[0].X, 0), new Point((int)p[0].X, pictureBox1.Height));
                drawPen.Color = Color.DarkViolet;
                PointF center = RotateMath.RotateCenterPoint(p[0], p[1], p[2], out r);
                g.DrawPie(drawPen, new RectangleF((float)(center.X - r), (float)(center.Y - r), (float)(2 * r), (float)(2 * r)), 0, 360);
                g.DrawString("A", this.Font, drawBrush, p[0]);
                g.DrawString("B", this.Font, drawBrush, p[1]);
                g.DrawString("C", this.Font, drawBrush, p[2]);
                g.DrawString("O", this.Font, drawBrush, center);
            }
            pictureBox1.Image = bmp;
        }