public static dynamic GetTSObject(PreferredPlacingTypes dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Ejemplo n.º 2
0
        public void Modify(PropertyValueChangedEventArgs e)
        {
            try
            {
                string  label   = e.ChangedItem.Label;
                Drawing drawing = drawingHandler.GetActiveDrawing();
                DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected();
                while (drawingObjectEnum.MoveNext())
                {
                    if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Text)
                    {
                        Tekla.Structures.Drawing.Text text = (Tekla.Structures.Drawing.Text)drawingObjectEnum.Current;

                        if (label == "PreferredPlacingType")
                        {
                            Text.TextAttributes textAttributes = text.Attributes;
                            if (preferredPlacingType == PreferredPlacingEnum.PointPlacingType)
                            {
                                textAttributes.PreferredPlacing = PreferredPlacingTypes.PointPlacingType();
                            }
                            else if (preferredPlacingType == PreferredPlacingEnum.LeaderLinePlacingType)
                            {
                                textAttributes.PreferredPlacing = PreferredPlacingTypes.LeaderLinePlacingType();
                            }
                        }

                        if (label == "TextString")
                        {
                            string   formattedText = "";
                            string[] split         = textString.Split(new char[] { '¬' });
                            foreach (string temp in split)
                            {
                                formattedText = formattedText + temp + Environment.NewLine;
                            }

                            formattedText   = formattedText.Trim();
                            text.TextString = formattedText;
                        }

                        if (label == "FontColour")
                        {
                            text.Attributes.Font.Color = fontColour;
                        }
                        if (label == "FontHeight")
                        {
                            text.Attributes.Font.Height = double.Parse(fontHeight);
                        }
                        if (label == "FontName")
                        {
                            text.Attributes.Font.Name = fontName;
                        }
                        if (label == "FontBold")
                        {
                            text.Attributes.Font.Bold = bool.Parse(fontBold.ToString());
                        }
                        if (label == "FontItalic")
                        {
                            text.Attributes.Font.Italic = bool.Parse(fontItalic.ToString());
                        }
                        if (label == "TextAngle")
                        {
                            text.Attributes.Angle = double.Parse(textAngle);
                        }
                        if (label == "TextAlignment")
                        {
                            if (textAlignment == TextAlignmentEnum.Center)
                            {
                                text.Attributes.Alignment = Tekla.Structures.Drawing.TextAlignment.Center;
                            }
                            else if (textAlignment == TextAlignmentEnum.Left)
                            {
                                text.Attributes.Alignment = Tekla.Structures.Drawing.TextAlignment.Left;
                            }
                            else if (textAlignment == TextAlignmentEnum.Right)
                            {
                                text.Attributes.Alignment = Tekla.Structures.Drawing.TextAlignment.Right;
                            }
                        }

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

                        if (label == "FrameColour")
                        {
                            text.Attributes.Frame.Color = frameColour;
                        }
                        if (label == "ArrowheadType")
                        {
                            if (arrowheadType == ArrowheadTypeEnum.CircleArrow)
                            {
                                text.Attributes.ArrowHead.Head = ArrowheadTypes.CircleArrow;
                            }
                            else if (arrowheadType == ArrowheadTypeEnum.FilledArrow)
                            {
                                text.Attributes.ArrowHead.Head = ArrowheadTypes.FilledArrow;
                            }
                            else if (arrowheadType == ArrowheadTypeEnum.FilledCircleArrow)
                            {
                                text.Attributes.ArrowHead.Head = ArrowheadTypes.FilledCircleArrow;
                            }
                            else if (arrowheadType == ArrowheadTypeEnum.LineArrow)
                            {
                                text.Attributes.ArrowHead.Head = ArrowheadTypes.LineArrow;
                            }
                        }

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

                        if (label == "ArrowheadWidth")
                        {
                            text.Attributes.ArrowHead.Width = double.Parse(arrowheadWidth);
                        }
                        if (label == "ArrowheadHeight")
                        {
                            text.Attributes.ArrowHead.Height = double.Parse(arrowheadHeight);
                        }
                        text.Modify();
                        drawing.CommitChanges();
                    }
                }
            }
            catch { }
        }