Ejemplo n.º 1
0
        /// <summary>
        /// Draws itself
        /// </summary>
        /// <param name="gr">Graphics to draw</param>
        public void Draw(object gr)
        {
            Graphics g  = gr as Graphics;
            int      x1 = 0;
            int      y1 = 0;
            int      x2 = 0;
            int      y2 = 0;
            int      x3 = 0;
            int      y3 = 0;
            Control  p  = null;

            if (Source is Panel | Source is UserControl)
            {
                p = Source as Control;
            }
            else
            {
                p = ContainerPerformer.GetPanel(Source) as Control;
            }
            x1 = p.Left + p.Width / 2;
            y1 = p.Top + p.Height / 2;
            x2 = Left + Width / 2;
            y2 = Top + Height / 2;
            if (Target is Panel | Target is UserControl)
            {
                p = Target as Control;
            }
            else
            {
                p = ContainerPerformer.GetPanel(Target) as Control;
            }
            x3 = p.Left + p.Width / 2;
            y3 = p.Top + p.Height / 2;
            g.DrawLine(linePen, x1, y1, x2, y2);
            g.DrawLine(linePen, x2, y2, x3, y3);
            for (int i = 0; i < 3; i++)
            {
                trianglePoints[i].X = triangle[2 * i];
                trianglePoints[i].Y = triangle[2 * i + 1];
            }
            matrix.Reset();
            float  dx = x3 - x2;
            float  dy = y3 - y2;
            double s  = Math.Sqrt(dx * dx + dy * dy);

            if (s == 0)
            {
                return;
            }
            double angle = 180 * Math.Atan2(dy / s, dx / s) / Math.PI;

            matrix.Translate(x2 + dx / 2, y2 + dy / 2);
            matrix.RotateAt((float)angle, trianglePoints[0]);
            matrix.TransformPoints(trianglePoints);
            g.FillPolygon(triangleBrush, trianglePoints);
        }
Ejemplo n.º 2
0
        private static void removeForm(INamedComponent component)
        {
            if (component is NamedComponent)
            {
                NamedComponent nc = component as NamedComponent;
                nc.RemoveForm();
                return;
            }
            if (component is IShowForm)
            {
                IShowForm sf = component as IShowForm;
                sf.RemoveForm();
                return;
            }
            IChildObjectLabel l = ContainerPerformer.GetPanel(component as IObjectLabel) as IChildObjectLabel;

            l.RemoveForm();
        }