Example #1
0
        protected TextAlignment GetTextAlignment(TextAlignmentEnum? textAlignmentEnum)
        {
            TextAlignment textAlignment;
            if (textAlignmentEnum != null && Enum.TryParse(textAlignmentEnum.ToString(), true, out textAlignment))
                return textAlignment;

            return TextAlignment.TopCenter;
        }
Example #2
0
        protected override IEnumerable <ITerminalProperty> CreateTerminalProperties()
        {
            return(base.CreateTerminalProperties().Concat(new ITerminalProperty[]
            {
                new MockTerminalProperty <IMyTextPanel, int>("alignment", b => (int)_alignment, (b, v) => _alignment = (TextAlignmentEnum)v, 1),
                new MockTerminalProperty <IMyTextPanel, float>("FontSize", b => b.FontSize, (b, v) => b.FontSize = v, 1),
                new MockTerminalProperty <IMyTextPanel, Color>("FontColor", b => b.FontColor, (b, v) => b.FontColor = v, Color.White),
                new MockTerminalProperty <IMyTextPanel, Color>("BackgroundColor", b => b.BackgroundColor, (b, v) => b.BackgroundColor = v, Color.Black),
                new MockTerminalProperty <IMyTextPanel, float>("ChangeIntervalSlider", b => b.ChangeInterval, (b, v) => b.ChangeInterval = v),

                new MockTerminalProperty <IMyTextPanel, long>("Font", b =>
                {
                    throw new NotImplementedException("Sorry, don't know how the ID is generated");
                }, (b, v) =>
                {
                    throw new NotImplementedException("Sorry, don't know how the ID is generated");
                }),

                // Ugh... >_<
                new MockTerminalProperty <IMyTerminalBlock, StringBuilder>("Title", b => _publicTitle, (b, v) =>
                {
                    _publicTitle.Clear();
                    _publicTitle.Append(v);
                }),
            }));
        }
Example #3
0
        public void GetProperties()
        {
            DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected();

            if (drawingObjectEnum.GetSize() == 1)
            {
                while (drawingObjectEnum.MoveNext())
                {
                    if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Text)
                    {
                        Tekla.Structures.Drawing.Text text = (Tekla.Structures.Drawing.Text)drawingObjectEnum.Current;

                        Text.TextAttributes textAttributes = text.Attributes;
                        if (textAttributes.PreferredPlacing.ToString() == "Tekla.Structures.Drawing.PointPlacingType")
                        {
                            preferredPlacingType = PreferredPlacingEnum.PointPlacingType;
                        }
                        else if (textAttributes.PreferredPlacing.ToString() == "Tekla.Structures.Drawing.LeaderLinePlacingType")
                        {
                            preferredPlacingType = PreferredPlacingEnum.LeaderLinePlacingType;
                        }

                        textString = text.TextString.Replace("\n", "¬");

                        fontColour = text.Attributes.Font.Color;
                        fontHeight = text.Attributes.Font.Height.ToString();
                        fontName   = text.Attributes.Font.Name;
                        if (text.Attributes.Font.Bold)
                        {
                            fontBold = Bool.True;
                        }
                        else
                        {
                            fontBold = Bool.False;
                        }
                        if (text.Attributes.Font.Italic)
                        {
                            fontItalic = Bool.True;
                        }
                        else
                        {
                            fontItalic = Bool.False;
                        }
                        textAngle = text.Attributes.Angle.ToString();

                        if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Center)
                        {
                            textAlignment = TextAlignmentEnum.Center;
                        }
                        else if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Left)
                        {
                            textAlignment = TextAlignmentEnum.Left;
                        }
                        else if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Right)
                        {
                            textAlignment = TextAlignmentEnum.Right;
                        }

                        if (text.Attributes.Frame.Type == FrameTypes.Circle)
                        {
                            frameType = FrameTypeEnum.Circle;
                        }
                        else if (text.Attributes.Frame.Type == FrameTypes.Diamond)
                        {
                            frameType = FrameTypeEnum.Diamond;
                        }
                        else if (text.Attributes.Frame.Type == FrameTypes.Hexagon)
                        {
                            frameType = FrameTypeEnum.Hexagon;
                        }
                        else if (text.Attributes.Frame.Type == FrameTypes.Line)
                        {
                            frameType = FrameTypeEnum.Line;
                        }
                        else if (text.Attributes.Frame.Type == FrameTypes.None)
                        {
                            frameType = FrameTypeEnum.None;
                        }
                        else if (text.Attributes.Frame.Type == FrameTypes.Rectangular)
                        {
                            frameType = FrameTypeEnum.Rectangular;
                        }
                        else if (text.Attributes.Frame.Type == FrameTypes.Round)
                        {
                            frameType = FrameTypeEnum.Round;
                        }
                        else if (text.Attributes.Frame.Type == FrameTypes.Sharpened)
                        {
                            frameType = FrameTypeEnum.Sharpened;
                        }
                        else if (text.Attributes.Frame.Type == FrameTypes.Triangle)
                        {
                            frameType = FrameTypeEnum.Triangle;
                        }

                        frameColour = text.Attributes.Frame.Color;

                        if (text.Attributes.ArrowHead.Head == ArrowheadTypes.CircleArrow)
                        {
                            arrowheadType = ArrowheadTypeEnum.CircleArrow;
                        }
                        else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.FilledArrow)
                        {
                            arrowheadType = ArrowheadTypeEnum.FilledArrow;
                        }
                        else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.FilledCircleArrow)
                        {
                            arrowheadType = ArrowheadTypeEnum.FilledCircleArrow;
                        }
                        else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.LineArrow)
                        {
                            arrowheadType = ArrowheadTypeEnum.LineArrow;
                        }

                        if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.Both)
                        {
                            arrowheadPosition = ArrowheadPositionEnum.Both;
                        }
                        else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.End)
                        {
                            arrowheadPosition = ArrowheadPositionEnum.End;
                        }
                        else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.None)
                        {
                            arrowheadPosition = ArrowheadPositionEnum.None;
                        }
                        else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.Start)
                        {
                            arrowheadPosition = ArrowheadPositionEnum.Start;
                        }

                        arrowheadWidth  = text.Attributes.ArrowHead.Width.ToString();
                        arrowheadHeight = text.Attributes.ArrowHead.Height.ToString();
                    }
                }
            }
            else if (drawingObjectEnum.GetSize() > 1)
            {
                preferredPlacingType = new PreferredPlacingEnum();
                textString           = "";
                FontColour           = new DrawingColors();
                fontHeight           = "";
                fontName             = "";
                fontBold             = new Bool();
                fontItalic           = new Bool();
                textAngle            = "";
                textAlignment        = new TextAlignmentEnum();
                frameType            = new FrameTypeEnum();
                FrameColour          = new DrawingColors();
                arrowheadType        = new ArrowheadTypeEnum();
                arrowheadPosition    = new ArrowheadPositionEnum();
                arrowheadWidth       = "";
                arrowheadHeight      = "";
            }
        }
        public void GetProperties()
        {
            DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected();
            if (drawingObjectEnum.GetSize() == 1)
            {
                while (drawingObjectEnum.MoveNext())
                {
                    if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Text)
                    {
                        Tekla.Structures.Drawing.Text text = (Tekla.Structures.Drawing.Text)drawingObjectEnum.Current;

                        Text.TextAttributes textAttributes = text.Attributes;
                        if (textAttributes.PreferredPlacing.ToString() == "Tekla.Structures.Drawing.PointPlacingType")
                            preferredPlacingType = PreferredPlacingEnum.PointPlacingType;
                        else if (textAttributes.PreferredPlacing.ToString() == "Tekla.Structures.Drawing.LeaderLinePlacingType")
                            preferredPlacingType = PreferredPlacingEnum.LeaderLinePlacingType;

                        textString = text.TextString.Replace("\n", "¬");

                        fontColour = text.Attributes.Font.Color;
                        fontHeight = text.Attributes.Font.Height.ToString();
                        fontName = text.Attributes.Font.Name;
                        if (text.Attributes.Font.Bold) fontBold = Bool.True; else fontBold = Bool.False;
                        if (text.Attributes.Font.Italic) fontItalic = Bool.True; else fontItalic = Bool.False;
                        textAngle = text.Attributes.Angle.ToString();

                        if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Center) textAlignment = TextAlignmentEnum.Center;
                        else if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Left) textAlignment = TextAlignmentEnum.Left;
                        else if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Right) textAlignment = TextAlignmentEnum.Right;

                        if (text.Attributes.Frame.Type == FrameTypes.Circle) frameType = FrameTypeEnum.Circle;
                        else if (text.Attributes.Frame.Type == FrameTypes.Diamond) frameType = FrameTypeEnum.Diamond;
                        else if (text.Attributes.Frame.Type == FrameTypes.Hexagon) frameType = FrameTypeEnum.Hexagon;
                        else if (text.Attributes.Frame.Type == FrameTypes.Line) frameType = FrameTypeEnum.Line;
                        else if (text.Attributes.Frame.Type == FrameTypes.None) frameType = FrameTypeEnum.None;
                        else if (text.Attributes.Frame.Type == FrameTypes.Rectangular) frameType = FrameTypeEnum.Rectangular;
                        else if (text.Attributes.Frame.Type == FrameTypes.Round) frameType = FrameTypeEnum.Round;
                        else if (text.Attributes.Frame.Type == FrameTypes.Sharpened) frameType = FrameTypeEnum.Sharpened;
                        else if (text.Attributes.Frame.Type == FrameTypes.Triangle) frameType = FrameTypeEnum.Triangle;

                        frameColour = text.Attributes.Frame.Color;

                        if (text.Attributes.ArrowHead.Head == ArrowheadTypes.CircleArrow) arrowheadType = ArrowheadTypeEnum.CircleArrow;
                        else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.FilledArrow) arrowheadType = ArrowheadTypeEnum.FilledArrow;
                        else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.FilledCircleArrow) arrowheadType = ArrowheadTypeEnum.FilledCircleArrow;
                        else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.LineArrow) arrowheadType = ArrowheadTypeEnum.LineArrow;

                        if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.Both) arrowheadPosition = ArrowheadPositionEnum.Both;
                        else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.End) arrowheadPosition = ArrowheadPositionEnum.End;
                        else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.None) arrowheadPosition = ArrowheadPositionEnum.None;
                        else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.Start) arrowheadPosition = ArrowheadPositionEnum.Start;

                        arrowheadWidth = text.Attributes.ArrowHead.Width.ToString();
                        arrowheadHeight = text.Attributes.ArrowHead.Height.ToString();
                    }
                }
            }
            else if (drawingObjectEnum.GetSize() > 1)
            {
                preferredPlacingType = new PreferredPlacingEnum();
                textString = "";
                FontColour = new DrawingColors();
                fontHeight = "";
                fontName = "";
                fontBold = new Bool();
                fontItalic = new Bool();
                textAngle = "";
                textAlignment = new TextAlignmentEnum();
                frameType = new FrameTypeEnum();
                FrameColour = new DrawingColors();
                arrowheadType = new ArrowheadTypeEnum();
                arrowheadPosition = new ArrowheadPositionEnum();
                arrowheadWidth = "";
                arrowheadHeight = "";
            }
        }