Beispiel #1
0
        private void miPanel_Paint(object sender, PaintEventArgs e)
        {
            if (pintar)
            {
                Graphics graficos = miPanel.CreateGraphics();
                graficos.DrawLine(new Pen(Color.Red), new Point(Convert.ToInt32(miPlan1.GetIX()), Convert.ToInt32(miPlan1.GetIY())), new Point(Convert.ToInt32(miPlan1.GetFX()), Convert.ToInt32(miPlan1.GetFY())));
                graficos.DrawLine(new Pen(Color.Green), new Point(Convert.ToInt32(miPlan1.Getposix()), Convert.ToInt32(miPlan1.Getposiy())), new Point(Convert.ToInt32(miPlan1.GetIX()), Convert.ToInt32(miPlan1.GetIY())));

                graficos.DrawLine(new Pen(Color.Red), new Point(Convert.ToInt32(miPlan2.GetIX()), Convert.ToInt32(miPlan2.GetIY())), new Point(Convert.ToInt32(miPlan2.GetFX()), Convert.ToInt32(miPlan2.GetFY())));
                graficos.DrawLine(new Pen(Color.Green), new Point(Convert.ToInt32(miPlan2.Getposix()), Convert.ToInt32(miPlan2.Getposiy())), new Point(Convert.ToInt32(miPlan2.GetIX()), Convert.ToInt32(miPlan2.GetIY())));

                if (miPlan1.Distance(miPlan2) < distSeg)
                {
                    Point esquina11 = new Point(Convert.ToInt32(miPlan1.GetIX() - distSeg / 2), Convert.ToInt32(miPlan1.GetIY() - distSeg / 2));
                    Size  tamaño11  = new Size(Convert.ToInt32(distSeg), Convert.ToInt32(distSeg));
                    graficos.FillEllipse(new SolidBrush(Color.Red), new Rectangle(esquina11, tamaño11));

                    Point esquina22 = new Point(Convert.ToInt32(miPlan2.GetIX() - distSeg / 2), Convert.ToInt32(miPlan2.GetIY() - distSeg / 2));
                    Size  tamaño22  = new Size(Convert.ToInt32(distSeg), Convert.ToInt32(distSeg));
                    graficos.FillEllipse(new SolidBrush(Color.Red), new Rectangle(esquina22, tamaño22));
                }
                else
                {
                    Point esquina = new Point(Convert.ToInt32(miPlan1.GetIX() - distSeg / 2), Convert.ToInt32(miPlan1.GetIY() - distSeg / 2));
                    Size  tamaño  = new Size(Convert.ToInt32(distSeg), Convert.ToInt32(distSeg));
                    graficos.DrawEllipse(new Pen(Color.Red), new Rectangle(esquina, tamaño));

                    Point esquina2 = new Point(Convert.ToInt32(miPlan2.GetIX() - distSeg / 2), Convert.ToInt32(miPlan2.GetIY() - distSeg / 2));
                    Size  tamaño2  = new Size(Convert.ToInt32(distSeg), Convert.ToInt32(distSeg));
                    graficos.DrawEllipse(new Pen(Color.Red), new Rectangle(esquina2, tamaño2));
                }

                graficos.Dispose();
            }
        }