Пример #1
0
    public static TextShape Create()
    {
        //TextShape shape = ScriptableObject.CreateInstance<TextShape>();
        TextShape shape = new TextShape();

        return(shape);
    }
Пример #2
0
        public IEnumerator BuiltInFontAttachCorrectlyOnTextComponentUpdate()
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            TextShape textShape =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model());

            yield return(textShape.routine);

            DCLFont font =
                TestHelpers.SharedComponentCreate <DCLFont, DCLFont.Model>(scene, CLASS_ID.FONT, new DCLFont.Model()
            {
                src = TEST_BUILTIN_FONT_NAME
            });

            yield return(font.routine);

            scene.EntityComponentUpdate(entity, CLASS_ID_COMPONENT.TEXT_SHAPE,
                                        JsonUtility.ToJson(new TextShape.Model {
                font = font.id
            }));
            yield return(textShape.routine);

            Assert.IsTrue(font.loaded, "Built-in font didn't load");
            Assert.IsFalse(font.error, "Built-in font has error");

            TextMeshPro tmpro = textShape.GetComponentInChildren <TextMeshPro>();

            Assert.IsTrue(font.fontAsset == tmpro.font, "Built-in font didn't apply correctly");
        }
Пример #3
0
 /// <summary>
 /// Initialize new instance of <see cref="ToolTextSelection"/> class.
 /// </summary>
 /// <param name="layer">The selection shapes layer.</param>
 /// <param name="shape">The selected shape.</param>
 /// <param name="style">The selection shapes style.</param>
 /// <param name="point">The selection point shape.</param>
 public ToolTextSelection(LayerContainer layer, TextShape shape, ShapeStyle style, BaseShape point)
 {
     _layer = layer;
     _text  = shape;
     _style = style;
     _point = point;
 }
Пример #4
0
        /// <summary>
        /// Scan area stencil
        /// </summary>
        public CornerAnchorShape(PointF point, String label)
        {
            this.Tag         = this.m_point = point;
            this.Position    = new PointF(point.X - 15, point.Y - 15);
            this.Size        = new SizeF(30, 30);
            this.m_markerBox = new RectangleShape()
            {
                Size         = new SizeF(24, 24),
                Position     = new PointF(3, 3),
                FillBrush    = new SolidBrush(Color.FromArgb(127, 255, 255, 0)),
                OutlineColor = Color.Orange,
                OutlineWidth = 5,
                OutlineStyle = System.Drawing.Drawing2D.DashStyle.Solid
            };
            this.m_labelShape = new TextShape()
            {
                FillBrush = Brushes.Black,
                Font      = new Font(SystemFonts.CaptionFont, FontStyle.Bold),
                Position  = new PointF(5, 5),
                Text      = label
            };

            this.Add(this.m_markerBox);
            this.Add(this.m_labelShape);
        }
Пример #5
0
        public static FormattedTextCache FromTextShape(TextShape text, Rect rect)
        {
            var constraint = new Size(rect.Width, rect.Height);

            var formattedText = new FormattedText()
            {
                Text          = text.Text.Value,
                Constraint    = constraint,
                TextAlignment = TextAlignment.Center,
                Wrapping      = TextWrapping.NoWrap,
                Typeface      = new Typeface("Arial", 11)
            };

            var size = formattedText.Measure();

            // Vertical Alignment: Top
            //var top = new Point(
            //    rect.X,
            //    rect.Y);

            // Vertical Alignment: Center
            var center = new Point(
                rect.X,
                rect.Y + rect.Height / 2 - size.Height / 2);

            // Vertical Alignment: Bottom
            //var bottom = new Point(
            //    rect.X,
            //    rect.Y + rect.Height - size.Height);

            return(new FormattedTextCache(formattedText, center));
        }
Пример #6
0
        public CommonDecorator()
        {
            _strokeStyleId = "Decorator-Stroke";
            _fillStyleId   = "Decorator-Fill";

            _line = new LineShape(new PointShape(0, 0, null), new PointShape(0, 0, null))
            {
                Points = new ObservableCollection <IPointShape>()
            };
            _line.StartPoint.Owner = _line;
            _line.Point.Owner      = _line;

            _ellipse = new EllipseShape(new PointShape(0, 0, null), new PointShape(0, 0, null))
            {
                Points = new ObservableCollection <IPointShape>(),
            };
            _ellipse.StartPoint.Owner = _ellipse;
            _ellipse.Point.Owner      = _ellipse;

            _rectangle = new RectangleShape(new PointShape(0, 0, null), new PointShape(0, 0, null))
            {
                Points = new ObservableCollection <IPointShape>(),
            };
            _rectangle.StartPoint.Owner = _rectangle;
            _rectangle.Point.Owner      = _rectangle;

            _text = new TextShape(new Text(), new PointShape(0, 0, null), new PointShape(0, 0, null))
            {
                Points = new ObservableCollection <IPointShape>(),
            };
            _text.StartPoint.Owner = _text;
            _text.Point.Owner      = _text;
        }
 public Form1()
 {
     InitializeComponent();
     arcScale.ValueChanged += OnScaleValueChanged;
     txt = CreateCustomTextualMarker((ComplexShape)marker.Shape);
     UpdateGauge();
 }
Пример #8
0
        public IEnumerator TestCreate()
        {
            string entityId = "e1";

            TestHelpers.CreateSceneEntity(scene, entityId);

            yield return(null);

            var textShapeModel = new TextShape.Model()
            {
                value = "Hello world!",

                color      = Color.white,
                opacity    = 0.5f,
                fontSize   = 10,
                fontWeight = "",

                width         = 20,
                height        = 20,
                adaptHeight   = false,
                adaptWidth    = false,
                paddingTop    = 10,
                paddingRight  = 0,
                paddingBottom = 10,
                paddingLeft   = 0,

                shadowBlur    = 0,
                shadowOffsetX = 0,
                shadowOffsetY = 0,
                shadowColor   = Color.white
            };

            TextShape textShape =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, scene.entities[entityId],
                                                                               textShapeModel);

            yield return(textShape.routine);

            TextMeshPro tmpro = textShape.GetComponentInChildren <TextMeshPro>();

            Assert.IsTrue(textShape != null, "Component creation fail!");
            Assert.IsTrue(tmpro != null, "TextMeshPro doesn't exists for TextShape!");
            Assert.IsTrue(textShape.text != null, "Unity Text component doesn't exists for TextShape!");

            yield return(null);

            TMProConsistencyAsserts(tmpro, textShapeModel);

            textShapeModel.paddingLeft  = 5;
            textShapeModel.paddingRight = 15;
            textShapeModel.value        = "Hello world again!";

            TextShape textShape2 =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, scene.entities[entityId],
                                                                               textShapeModel);

            TMProConsistencyAsserts(tmpro, textShapeModel);

            yield return(null);
        }
        TextShape CreateCustomTextualMarker(ComplexShape markerShape)
        {
            RectangleF2D box = new RectangleF2D(-15, -15, 30, 30);

            EllipseShape eShape = new EllipseShape(box);
            TextShape    txt    = new TextShape();

            eShape.BeginUpdate();
            eShape.Name = "bg";
            eShape.Appearance.ContentBrush = new SolidBrushObject(Color.White);
            eShape.Appearance.BorderBrush  = new SolidBrushObject(Color.Black);
            eShape.Appearance.BorderWidth  = 2;
            eShape.EndUpdate();

            txt.BeginUpdate();
            txt.Name = "marketText";
            txt.Text = "Test";
            txt.Box  = box;
            txt.AppearanceText.TextBrush = new SolidBrushObject(Color.Black);
            txt.AppearanceText.Font      = new Font("Tahoma", 8f);
            txt.ShadingFlags             = ShadingFlags.NoShading;
            txt.EndUpdate();

            markerShape.AddRange(new BaseShape[] { eShape, txt });
            return(txt);
        }
Пример #10
0
        public IEnumerator BuiltInFontCreateAndLoadTest()
        {
            DCLFont font =
                TestHelpers.SharedComponentCreate <DCLFont, DCLFont.Model>(scene, CLASS_ID.FONT, new DCLFont.Model()
            {
                src = TEST_BUILTIN_FONT_NAME
            });

            yield return(font.routine);

            var entity = TestHelpers.CreateSceneEntity(scene);

            TextShape textShape =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model()
            {
                font = font.id
            });

            yield return(textShape.routine);

            Assert.IsTrue(font.loaded, "Built-in font didn't load");
            Assert.IsFalse(font.error, "Built-in font has error");

            TextMeshPro tmpro = textShape.GetComponentInChildren <TextMeshPro>();

            Assert.IsTrue(font.fontAsset == tmpro.font, "Built-in font didn't apply correctly");
        }
Пример #11
0
        public IEnumerator BuiltInFontHandleErrorProperly()
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            TextShape textShape =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model());

            yield return(textShape.routine);

            TMP_FontAsset defaultFont = textShape.GetComponentInChildren <TextMeshPro>().font;

            DCLFont font =
                TestHelpers.SharedComponentCreate <DCLFont, DCLFont.Model>(scene, CLASS_ID.FONT, new DCLFont.Model()
            {
                src = "no-valid-font"
            });

            yield return(font.routine);

            scene.EntityComponentUpdate(entity, CLASS_ID_COMPONENT.TEXT_SHAPE,
                                        JsonUtility.ToJson(new TextShape.Model {
                font = font.id
            }));
            yield return(textShape.routine);

            Assert.IsTrue(font.error, "Built-in font error has not araise properly");
            Assert.IsTrue(textShape.GetComponentInChildren <TextMeshPro>().font == defaultFont, "Built-in font didn't apply correctly");
        }
Пример #12
0
    /// <summary>
    /// New point from location.
    /// </summary>
    /// <param name="location">Position of point</param>
    /// <param name="content">Text to display</param>
    public static TextShape Create(Vector2 location, string content)
    {
        TextShape shape = Create();

        shape.position = location;
        shape.text     = content;

        return(shape);
    }
Пример #13
0
        internal static void AddText(IToolContext context, TextShape text, double dx, double dy, SKPath geometry)
        {
            var style = context?.StyleLibrary?.Get(text.StyleId);

            if (style != null)
            {
                AddText(context, text.Text, text.StartPoint, text.Point, style.TextStyle, dx, dy, geometry);
            }
        }
Пример #14
0
        public static Shape createShape(ScreenshotEditor editor, bool cropBoxActive, XPathNavigator element)
        {
            string type = element.GetAttribute("type", "");
            Shape  s    = null;

            switch (type)
            {
            case "Arrow":
                s = new Arrow(editor, element);
                break;

            case "CropBox":
                s = new CropBox(editor, element, cropBoxActive);
                break;

            case "Censor":
                s = new Censor(editor, element);
                break;

            case "Line":
                s = new Line(editor, element);
                break;

            case "Oval":
                s = new Oval(editor, element);
                break;

            case "MagnifyingGlass":
                s = new MagnifyingGlass(editor, element);
                break;

            case "Pencil":
                s = new Pencil(editor, element);
                break;

            case "Picture":
                s = new Picture(editor, element);
                break;

            case "PonyVille":
                s = new PonyVille(editor, element);
                break;

            case "RectangleShape":
                s = new RectangleShape(editor, element);
                break;

            case "TextShape":
                s = new TextShape(editor, element);
                break;

            default:
                break;
            }
            return(s);
        }
Пример #15
0
        public void DrawText(object dc, TextShape text, string styleId, double dx, double dy, double scale)
        {
            var geometry = new SKPath()
            {
                FillType = SKPathFillType.Winding
            };

            SkiaHelper.AddText(null, text, dx, dy, geometry);
            _rootNodes[_currentRootNode].Children.Add(new ChildNode(text, styleId, dx, dy, scale, geometry));
        }
Пример #16
0
        /// <inheritdoc/>
        public override void Draw(object dc, TextShape text, double dx, double dy, object db, object r)
        {
            var canvas = dc as SKCanvas;

            var properties = (ImmutableArray <Property>)db;
            var record     = (Record)r;
            var tbind      = text.BindText(properties, record);

            if (string.IsNullOrEmpty(tbind))
            {
                return;
            }

            SKTypefaceStyle style = SKTypefaceStyle.Normal;

            if (text.Style.TextStyle.FontStyle != null)
            {
                if (text.Style.TextStyle.FontStyle.Flags.HasFlag(FontStyleFlags.Bold))
                {
                    style |= SKTypefaceStyle.Bold;
                }

                if (text.Style.TextStyle.FontStyle.Flags.HasFlag(FontStyleFlags.Italic))
                {
                    style |= SKTypefaceStyle.Italic;
                }

                if (text.Style.TextStyle.FontStyle.Flags.HasFlag(FontStyleFlags.Underline))
                {
                    // TODO: Add support for FontStyleFlags.Underline
                }

                if (text.Style.TextStyle.FontStyle.Flags.HasFlag(FontStyleFlags.Strikeout))
                {
                    // TODO: Add support for FontStyleFlags.Strikeout
                }
            }

            using (var pen = ToSKPaintBrush(text.Style.Stroke))
                using (var tf = SKTypeface.FromFamilyName(text.Style.TextStyle.FontName, style))
                {
                    pen.TextEncoding = SKTextEncoding.Utf16;
                    pen.TextSize     = _scaleToPage(text.Style.TextStyle.FontSize * _targetDpi / _sourceDpi);

                    var   fm     = pen.FontMetrics;
                    float offset = -(fm.Top + fm.Bottom);

                    var    rect   = CreateRect(text.TopLeft, text.BottomRight, dx, dy, _scaleToPage);
                    SKRect bounds = new SKRect();
                    pen.MeasureText(tbind, ref bounds);
                    SKPoint origin = GetTextOrigin(text.Style, ref rect, ref bounds);

                    canvas.DrawText(tbind, origin.X, origin.Y + offset, pen);
                }
        }
        private void InitializeComponent()
        {
            var resources  = new ComponentResourceManager(typeof(ExampleContainerWithHeader));
            var textShape1 = new TextShape();

            this.reflectionHeader1 = new ReflectionHeader();
            this.SuspendLayout();
            //
            // reflectionHeader1
            //
            this.reflectionHeader1.BandDown.Color.Color1    = Color.Black;
            this.reflectionHeader1.BandDown.Color.Color2    = Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
            this.reflectionHeader1.BandDown.Color.Direction = GradientDirection.Horizontal;
            this.reflectionHeader1.BandDown.Height          = 18;
            this.reflectionHeader1.BandUp.Color.Color1      = Color.Black;
            this.reflectionHeader1.BandUp.Color.Color2      = Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
            this.reflectionHeader1.BandUp.Color.Direction   = GradientDirection.Horizontal;
            this.reflectionHeader1.BandUp.Height            = 0;
            this.reflectionHeader1.Dock = DockStyle.Top;
            this.reflectionHeader1.GradientBack.Color1      = Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(1)))), ((int)(((byte)(74)))));
            this.reflectionHeader1.GradientBack.Color2      = Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(0)))), ((int)(((byte)(107)))));
            this.reflectionHeader1.GradientBack.Direction   = GradientDirection.Vertical;
            this.reflectionHeader1.Header.Color.Color1      = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.reflectionHeader1.Header.Color.Color2      = Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
            this.reflectionHeader1.Header.Color.Direction   = GradientDirection.Vertical;
            this.reflectionHeader1.Header.Font              = new Font("Trebuchet MS", 27.75F, FontStyle.Bold);
            this.reflectionHeader1.Header.Position          = new Point(80, 17);
            this.reflectionHeader1.Header.ReflectionLevel   = ((byte)(100));
            this.reflectionHeader1.Header.ReflectionOpacity = ((byte)(200));
            this.reflectionHeader1.Header.Text              = "FileHelpers Examples";
            this.reflectionHeader1.Images.AddRange(new ImageShape[] {
                new ImageShape(((Bitmap)(resources.GetObject("reflectionHeader1.Images"))), true, ((byte)(255)), new Point(3, 1), ((byte)(0)), 0)
            });
            this.reflectionHeader1.Location = new Point(0, 0);
            this.reflectionHeader1.Name     = "reflectionHeader1";
            this.reflectionHeader1.Size     = new Size(753, 85);
            this.reflectionHeader1.Text     = "FileHelpers Examples";
            textShape1.Color.Color1         = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            textShape1.Color.Color2         = Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
            textShape1.Color.Direction      = GradientDirection.Vertical;
            textShape1.Font              = new Font("Trebuchet MS", 11.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
            textShape1.Position          = new Point(615, 67);
            textShape1.ReflectionLevel   = ((byte)(100));
            textShape1.ReflectionOpacity = ((byte)(0));
            textShape1.Text              = "All FileHelpers Demos in one place";
            this.reflectionHeader1.Texts.AddRange(new TextShape[] {
                textShape1
            });
            //
            // ExampleContainerWithHeader
            //
            this.AutoScaleDimensions = new SizeF(6F, 13F);
            this.Name = "ExampleContainerWithHeader";
            this.ResumeLayout(false);
        }
Пример #18
0
        /**
         * Checks if the shape is a placeholder.
         * (placeholders aren't normal shapes, they are visible only in the Edit Master mode)
         *
         *
         * @return true if the shape is a placeholder
         */
        public static bool IsPlaceholder(Shape shape)
        {
            if (!(shape is TextShape))
            {
                return(false);
            }

            TextShape tx = (TextShape)shape;

            return(tx.GetPlaceholderAtom() != null);
        }
 public void TestTextAlignment()
 {
     Assert.AreEqual(TextAlignmentOptions.BottomLeft, TextShape.GetAlignment("bottom", "left"));
     Assert.AreEqual(TextAlignmentOptions.BottomRight, TextShape.GetAlignment("Bottom", "RIght"));
     Assert.AreEqual(TextAlignmentOptions.Center, TextShape.GetAlignment("Center", "center"));
     Assert.AreEqual(TextAlignmentOptions.TopLeft, TextShape.GetAlignment("top", "Left"));
     Assert.AreEqual(TextAlignmentOptions.TopRight, TextShape.GetAlignment("top", "right"));
     Assert.AreEqual(TextAlignmentOptions.Top, TextShape.GetAlignment("top", "center"));
     Assert.AreEqual(TextAlignmentOptions.Right, TextShape.GetAlignment("center", "right"));
     Assert.AreEqual(TextAlignmentOptions.Bottom, TextShape.GetAlignment("Bottom", "cEnter"));
     Assert.AreEqual(TextAlignmentOptions.Left, TextShape.GetAlignment("center", "left"));
 }
Пример #20
0
        ///////////////////////// Upcasting Downcasting //////////////////////////////////

        static void UpcastingDowncastingMethod()
        {
            var   text  = new TextShape();
            Shape shape = text; // upcasting este conversia de la clasa derivata la clasa de baza.

            text.Height  = 100;
            shape.Height = 200;

            Console.WriteLine(text.Height);     // afiseaza 200 pt ca shape si text sunt referinte catre acelasi obiect

            TextShape text2 = (TextShape)shape; // Downcasting este conversia de la clasa de baza la clasa derivata.
        }
Пример #21
0
        public static TextShape InstantiateEntityWithTextShape(ParcelScene scene, Vector3 position, TextShape.Model model)
        {
            DecentralandEntity entity      = CreateSceneEntity(scene);
            string             componentId =
                GetComponentUniqueId(scene, "textShape", (int)CLASS_ID_COMPONENT.TEXT_SHAPE, entity.entityId);

            TextShape textShape = EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, model);

            SetEntityTransform(scene, entity);

            return(textShape);
        }
 private void InitializeComponent()
 {
     var resources = new ComponentResourceManager(typeof(ExampleContainerWithHeader));
     var textShape1 = new TextShape();
     this.reflectionHeader1 = new ReflectionHeader();
     this.SuspendLayout();
     //
     // reflectionHeader1
     //
     this.reflectionHeader1.BandDown.Color.Color1 = Color.Black;
     this.reflectionHeader1.BandDown.Color.Color2 = Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
     this.reflectionHeader1.BandDown.Color.Direction = GradientDirection.Horizontal;
     this.reflectionHeader1.BandDown.Height = 18;
     this.reflectionHeader1.BandUp.Color.Color1 = Color.Black;
     this.reflectionHeader1.BandUp.Color.Color2 = Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
     this.reflectionHeader1.BandUp.Color.Direction = GradientDirection.Horizontal;
     this.reflectionHeader1.BandUp.Height = 0;
     this.reflectionHeader1.Dock = DockStyle.Top;
     this.reflectionHeader1.GradientBack.Color1 = Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(1)))), ((int)(((byte)(74)))));
     this.reflectionHeader1.GradientBack.Color2 = Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(0)))), ((int)(((byte)(107)))));
     this.reflectionHeader1.GradientBack.Direction = GradientDirection.Vertical;
     this.reflectionHeader1.Header.Color.Color1 = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
     this.reflectionHeader1.Header.Color.Color2 = Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
     this.reflectionHeader1.Header.Color.Direction = GradientDirection.Vertical;
     this.reflectionHeader1.Header.Font = new Font("Trebuchet MS", 27.75F, FontStyle.Bold);
     this.reflectionHeader1.Header.Position = new Point(80, 17);
     this.reflectionHeader1.Header.ReflectionLevel = ((byte)(100));
     this.reflectionHeader1.Header.ReflectionOpacity = ((byte)(200));
     this.reflectionHeader1.Header.Text = "FileHelpers Examples";
     this.reflectionHeader1.Images.AddRange(new ImageShape[] {
     new ImageShape(((Bitmap)(resources.GetObject("reflectionHeader1.Images"))), true, ((byte)(255)), new Point(3, 1), ((byte)(0)), 0)});
     this.reflectionHeader1.Location = new Point(0, 0);
     this.reflectionHeader1.Name = "reflectionHeader1";
     this.reflectionHeader1.Size = new Size(753, 85);
     this.reflectionHeader1.Text = "FileHelpers Examples";
     textShape1.Color.Color1 = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
     textShape1.Color.Color2 = Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
     textShape1.Color.Direction = GradientDirection.Vertical;
     textShape1.Font = new Font("Trebuchet MS", 11.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
     textShape1.Position = new Point(615, 67);
     textShape1.ReflectionLevel = ((byte)(100));
     textShape1.ReflectionOpacity = ((byte)(0));
     textShape1.Text = "All FileHelpers Demos in one place";
     this.reflectionHeader1.Texts.AddRange(new TextShape[] {
     textShape1});
     //
     // ExampleContainerWithHeader
     //
     this.AutoScaleDimensions = new SizeF(6F, 13F);
     this.Name = "ExampleContainerWithHeader";
     this.ResumeLayout(false);
 }
Пример #23
0
        static void Main(string[] args)
        {
            TextShape text = new TextShape();

            text.AddLine(Line.InputLine());
            text.AddLine(Line.InputLine());
            text.AddLine(Line.InputLine());
            text.ShowText();
            Console.WriteLine(text.GetLettersNumber());
            Console.WriteLine(text.findLine(Line.InputLine()));

            text.ShowText();
        }
Пример #24
0
        private void CreateTextShape(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            TextShape shape = new TextShape();

            shape.Box  = new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10));
            shape.Text = "    > > > > > ";
            shape.AppearanceText.TextBrush = new SolidBrushObject(Color.Salmon);
            needleShape.Add(shape);
        }
Пример #25
0
        /// <inheritdoc/>
        TextShape IShapeFactory.Text(double x1, double y1, double x2, double y2, string text, bool isStroked)
        {
            var style = _editor.Project.CurrentStyleLibrary.Selected;
            var txt   = TextShape.Create(
                x1, y1,
                x2, y2,
                _editor.Project.Options.CloneStyle ? style.Clone() : style,
                _editor.Project.Options.PointShape,
                text,
                isStroked);

            _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, txt);
            return(txt);
        }
Пример #26
0
        /// <inheritdoc/>
        TextShape IShapeFactory.Text(PointShape topLeft, PointShape bottomRight, string text, bool isStroked)
        {
            var style = _editor.Project.CurrentStyleLibrary.Selected;
            var txt   = TextShape.Create(
                topLeft,
                bottomRight,
                _editor.Project.Options.CloneStyle ? style.Clone() : style,
                _editor.Project.Options.PointShape,
                text,
                isStroked);

            _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, txt);
            return(txt);
        }
Пример #27
0
        public IEnumerator OpacityIsProcessedCorrectly(float opacity)
        {
            IDCLEntity entity             = TestHelpers.CreateSceneEntity(scene);
            TextShape  textShapeComponent = TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model {
                value = "Hello test", opacity = opacity
            });

            yield return(textShapeComponent.routine);

            TextMeshPro tmpro = textShapeComponent.gameObject.GetComponentInChildren <TextMeshPro>();

            Assert.NotNull(tmpro);
            Assert.AreEqual(opacity, textShapeComponent.GetModel().opacity);
            Assert.AreEqual(tmpro.color.a, opacity);
        }
Пример #28
0
        public IEnumerator VisibleFalseIsProcessedCorrectly()
        {
            DecentralandEntity entity             = TestHelpers.CreateSceneEntity(scene);
            TextShape          textShapeComponent = TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model {
                value = "Hello test", opacity = 0.3f, visible = false
            });

            yield return(textShapeComponent.routine);

            TextMeshPro tmpro = textShapeComponent.gameObject.GetComponentInChildren <TextMeshPro>();

            Assert.NotNull(tmpro);
            Assert.AreEqual(0.3f, textShapeComponent.model.opacity);
            Assert.IsFalse(textShapeComponent.model.visible);
            Assert.AreEqual(tmpro.color.a, 0f);
        }
Пример #29
0
        private void CleanInternal(IToolContext context)
        {
            CurrentState = State.TopLeft;

            Filters?.ForEach(f => f.Clear(context));

            if (_text != null)
            {
                context.WorkingContainer.Shapes.Remove(_text);
                context.Renderer.Selected.Remove(_text.TopLeft);
                context.Renderer.Selected.Remove(_text.BottomRight);
                _text = null;
            }

            context.Release?.Invoke();
            context.Invalidate?.Invoke();
        }
Пример #30
0
        public void GetPoints_Returns_Shapes_And_Connector_Points()
        {
            var target = new GroupShape();

            var text = new TextShape();

            text.Data.Properties = text.Data.Properties.Add(new Property());
            target.Shapes        = target.Shapes.Add(text);

            var point = new PointShape();

            point.Data.Properties = point.Data.Properties.Add(new Property());
            target.Connectors     = target.Connectors.Add(point);

            var count = target.GetPoints().Count();

            Assert.Equal(3, count);
        }
Пример #31
0
        public IEnumerator TestMissingValuesGetDefaultedOnUpdate()
        {
            string entityId = "1";

            TestHelpers.CreateSceneEntity(scene, entityId);

            // 1. Create component with non-default configs
            TextShape.Model textShapeModel = new TextShape.Model
            {
                color        = Color.green,
                width        = 0.25f,
                lineCount    = 3,
                fontAutoSize = true,
                shadowColor  = Color.red
            };

            TextShape textShapeComponent =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, scene.entities[entityId],
                                                                               textShapeModel);

            yield return(textShapeComponent.routine);

            // 2. Check configured values
            Assert.AreEqual(Color.green, textShapeComponent.model.color);
            Assert.AreEqual(0.25f, textShapeComponent.model.width);
            Assert.AreEqual(3, textShapeComponent.model.lineCount);
            Assert.IsTrue(textShapeComponent.model.fontAutoSize);
            Assert.AreEqual(Color.red, textShapeComponent.model.shadowColor);

            // 3. Update component with missing values
            scene.EntityComponentUpdate(scene.entities[entityId], CLASS_ID_COMPONENT.TEXT_SHAPE,
                                        JsonUtility.ToJson(new TextShape.Model {
            }));

            yield return(textShapeComponent.routine);

            // 4. Check defaulted values
            Assert.AreEqual(Color.white, textShapeComponent.model.color);
            Assert.AreEqual(1f, textShapeComponent.model.width);
            Assert.AreEqual(0, textShapeComponent.model.lineCount);
            Assert.IsFalse(textShapeComponent.model.fontAutoSize);
            Assert.AreEqual(new Color(1, 1, 1), textShapeComponent.model.shadowColor);
        }
Пример #32
0
 public TextPainter(TextShape shape){
     _shape = shape;
 }
Пример #33
0
    /**
     * Subclasses should call this method and update the array of text Runs
     * when a text shape is Added
     *
     * @param shape
     */
    protected void onAddTextShape(TextShape shape) {

    }
Пример #34
0
    protected void onAddTextShape(TextShape shape) {
        TextRun run = shape.GetTextRun();

        if(_Runs == null) _Runs = new TextRun[]{Run};
        else {
            TextRun[] tmp = new TextRun[_Runs.Length + 1];
            Array.Copy(_Runs, 0, tmp, 0, _Runs.Length);
            tmp[tmp.Length-1] = Run;
            _Runs = tmp;
        }
    }