/// <summary>
        /// Добавить прямоугольник в подсвечиваемые элементы
        /// </summary>
        /// <param name="colour">Цвет</param>
        /// <param name="objectFunction">Функция объекта</param>
        /// <param name="points">Точки</param>
        private void AddBoxForHighlighting(short colour,
                                           Eplan.EplApi.DataModel.Function objectFunction,
                                           Eplan.EplApi.Base.PointD[] points)
        {
            var rc = new Eplan.EplApi.DataModel.Graphics.Rectangle();

            rc.Create(objectFunction.Page);
            rc.IsSurfaceFilled = true;
            rc.DrawingOrder    = -1;
            rc.SetArea(points[0], points[1]);
            rc.Pen = new Eplan.EplApi.DataModel.Graphics.Pen(colour, -16002,
                                                             -16002, -16002, 0);
            rc.Properties.set_PROPUSER_TEST(1, objectFunction
                                            .ToStringIdentifier());
            highlightedObjects.Add(rc);
        }
        /// <summary>
        /// Настроить как зелено-серый прямоугольник
        /// </summary>
        /// <param name="colour">Цвет</param>
        /// <param name="oF">Функция объекта</param>
        /// <param name="points">Точки</param>
        private void SetGrenRedBoxHiglight(ref short colour,
                                           Eplan.EplApi.DataModel.Function oF,
                                           Eplan.EplApi.Base.PointD[] points)
        {
            var rc2 = new Eplan.EplApi.DataModel.Graphics.Rectangle();

            rc2.Create(oF.Page);
            rc2.IsSurfaceFilled = true;
            rc2.DrawingOrder    = 1;
            rc2.SetArea(new Eplan.EplApi.Base.PointD(points[0].X,
                                                     points[0].Y + (points[1].Y - points[0].Y) / 2),
                        points[1]);

            rc2.Pen = new Eplan.EplApi.DataModel.Graphics.Pen(
                252 /*Red*/, -16002, -16002, -16002, 0);

            rc2.Properties.set_PROPUSER_TEST(1,
                                             oF.ToStringIdentifier());
            highlightedObjects.Add(rc2);

            points[1].Y -= (points[1].Y - points[0].Y) / 2;
            colour       = 3; //Green.
        }
Example #3
0
        public void SetHighLighting(List <DrawInfo> objectsToDraw)
        {
            if (objectsToDraw == null)
            {
                return;
            }
            foreach (DrawInfo drawObj in objectsToDraw)
            {
                DrawInfo.Style howToDraw = drawObj.style;

                if (howToDraw == DrawInfo.Style.NO_DRAW)
                {
                    continue;
                }

                Eplan.EplApi.DataModel.Function oF =
                    (drawObj.dev as IODevice).EplanObjectFunction;
                if (oF == null)
                {
                    continue;
                }

                Eplan.EplApi.Base.PointD[] points = oF.GetBoundingBox();
                int number = 0;

                Eplan.EplApi.DataModel.Graphics.Rectangle rc =
                    new Eplan.EplApi.DataModel.Graphics.Rectangle();
                rc.Create(oF.Page);
                rc.IsSurfaceFilled = true;
                rc.DrawingOrder    = -1;

                short colour = 0;
                switch (howToDraw)
                {
                case DrawInfo.Style.GREEN_BOX:
                    colour = 3;     //Green.

                    //Для сигналов подсвечиваем полностью всю линию.
                    if (oF.Name.Contains("DI") || oF.Name.Contains("DO"))
                    {
                        if (oF.Connections.Length > 0)
                        {
                            points[1].X =
                                oF.Connections[0].StartPin.ParentFunction.GetBoundingBox()[1].X;
                        }
                    }
                    break;

                case DrawInfo.Style.RED_BOX:
                    colour = 252;     //Red.
                    break;

                case DrawInfo.Style.GREEN_UPPER_BOX:
                    points[0].Y += (points[1].Y - points[0].Y) / 2;
                    colour       = 3; //Green.
                    break;

                case DrawInfo.Style.GREEN_LOWER_BOX:
                    points[1].Y -= (points[1].Y - points[0].Y) / 2;
                    colour       = 3; //Green.
                    break;

                case DrawInfo.Style.GREEN_RED_BOX:
                    Eplan.EplApi.DataModel.Graphics.Rectangle rc2 =
                        new Eplan.EplApi.DataModel.Graphics.Rectangle();
                    rc2.Create(oF.Page);
                    rc2.IsSurfaceFilled = true;
                    rc2.DrawingOrder    = 1;
                    rc2.SetArea(
                        new Eplan.EplApi.Base.PointD(
                            points[0].X, points[0].Y + (points[1].Y - points[0].Y) / 2),
                        points[1]);

                    rc2.Pen = new Eplan.EplApi.DataModel.Graphics.Pen(
                        252 /*Red*/, -16002, -16002, -16002, 0);

                    rc2.Properties.set_PROPUSER_TEST(1, oF.ToStringIdentifier());
                    highlightedObjects.Add(rc2);

                    points[1].Y -= (points[1].Y - points[0].Y) / 2;
                    colour       = 3; //Green.
                    break;
                }

                rc.SetArea(points[0], points[1]);
                rc.Pen = new Eplan.EplApi.DataModel.Graphics.Pen(
                    colour, -16002, -16002, -16002, 0);

                if (number != 0)
                {
                    Eplan.EplApi.DataModel.Graphics.Text txt =
                        new Eplan.EplApi.DataModel.Graphics.Text();
                    txt.Create(oF.Page, number.ToString(), 3);
                    txt.Location = new Eplan.EplApi.Base.PointD(
                        points[1].X, points[1].Y);
                    txt.Justification =
                        Eplan.EplApi.DataModel.Graphics.TextBase.JustificationType.BottomRight;
                    txt.TextColorId = 0;

                    highlightedObjects.Add(txt);
                }

                rc.Properties.set_PROPUSER_TEST(1, oF.ToStringIdentifier());
                highlightedObjects.Add(rc);
            }
        }