Exemplo n.º 1
0
    static void AddLabel(DisplayObjectContainer container, string label)
    {
        if (string.IsNullOrEmpty(label))
        {
            return;
        }
        var c = new Label();

        c.text = label;
        container.addChild(c);
    }
Exemplo n.º 2
0
        public static T AttachTo <T>(this T e, DisplayObjectContainer x) where T : DisplayObject
        {
            if (e == null)
            {
                return(e);
            }

            x.addChild(e);

            return(e);
        }
Exemplo n.º 3
0
    static void AddCheckBox(DisplayObjectContainer container, string label, bool defval, Action <bool> action)
    {
        var cb = new CheckBox();

        cb.selected = defval;
        cb.label    = label;
        cb.change  += e =>
        {
            action(cb.selected);
        };
        container.addChild(cb);
    }
Exemplo n.º 4
0
 private void rec(DisplayObjectContainer parent, SpaceObject so)
 {
     for (int i = 0; i < so.links.Count; i++)
     {
         SpaceObject child = (SpaceObject)RegistrySystem.Registry.getInstance().getElement(so.links[i]);
         if (child.spaceobject_type != SpaceObject.SpaceSystem)
         {
             PlanetView b = new PlanetView(child);
             b.load(child.src);
             b.setScaleXY(child.size);
             b.setRSPointToCenter();
             parent.addChild(b);
         }
         else
         {
             SpaceSystemView d = new SpaceSystemView(child);
             parent.addChild(d);
             rec(d, child);
         }
     }
 }
        public static T AttachToContainer <T>(this T e, DisplayObjectContainer c) where T : global::System.Windows.Controls.Panel
        {
            __Panel p = e;

            if (p.InternalSprite.parent != null)
            {
                p.InternalSprite.parent.removeChild(p.InternalSprite);
            }

            c.addChild(p.InternalSprite);

            return(e);
        }
Exemplo n.º 6
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="uri"></param>
    public void SetUri(string uri)
    {
        movieClip = null;
        meshFilter.mesh.Clear();
        stage.removeAllChildren();
        SwfURI furi = new SwfURI(uri);

        movieClip                = new MovieClip(furi);
        movieClip.looping        = loop;
        movieClip.colorTransform = colorTransform;
        movieClip.alpha          = colorTransform.a;
        movieClip.scaleX         = drawScale.x;
        if (flipY)
        {
            movieClip.scaleY = drawScale.y;
        }
        else
        {
            movieClip.scaleY = -drawScale.y;
        }
        stage.addChild(movieClip);
        RenderFrame();
    }
Exemplo n.º 7
0
    static void AddInput(DisplayObjectContainer container, double defval, Action <double> action)
    {
        var input = new TextInput();

        input.text     = defval.ToString();
        input.width    = 50;
        input.keyDown += e =>
        {
            if (e.keyCode == Keyboard.ENTER)
            {
                var v = double.Parse(input.text);
                action(v);
            }
        };
        container.addChild(input);
    }
Exemplo n.º 8
0
    static void AddComboBox(DisplayObjectContainer container, string label, int defval, Action <int> action, params string[] values)
    {
        AddLabel(container, label);

        var col = new ArrayCollection();

        for (int i = 0; i < values.Length; ++i)
        {
            var item = avm.NewObject("label", values[i], "data", i);
            col.addItem(item);
        }

        var cb = new ComboBox();

        cb.dataProvider  = col;
        cb.selectedIndex = defval;
        cb.OnClose      += e =>
        {
            action(cb.selectedIndex);
        };
        container.addChild(cb);
    }
Exemplo n.º 9
0
        public static T AttachTo <T>(this T e, DisplayObjectContainer c) where T : DisplayObject
        {
            c.addChild(e);

            return(e);
        }
Exemplo n.º 10
0
        bool AddTextLine(TextLine line)
        {
            //++_ln;
            //Console.WriteLine("{0}. x: {1}, y: {2}", _ln, line.x, line.y);

            double lh = line.height;

            if (!IsFirst(line))
            {
                lh += GetLeading(line);
            }
            _ph += lh;

            #region research for case 128779
            //if (_firstLine)
            //{
            //    _firstLine = false;
            //    ElementFormat ef = line.textBlock.content.elementFormat;
            //    var em = ef.getFontMetrics().emBox;
            //    var fd = ef.fontDescription;

            //    var tf = new TextField
            //                 {
            //                     defaultTextFormat = new TextFormat
            //                                             {
            //                                                 font = fd.fontName,
            //                                                 italic = fd.fontPosture == FontPosture.ITALIC,
            //                                                 bold = fd.fontWeight == FontWeight.BOLD,
            //                                                 size = ef.fontSize,
            //                                             },
            //                     text = "Hello, World!"
            //                 };

            //    double leading = line.textHeight * 0.2;
            //    Console.WriteLine("---");
            //    Console.WriteLine(
            //        "FTE> FontSize: {0}, LH: {1}, TH: {2}, A: {3}, D: {4}, Leading: {5}, A+D: {6}, em: {7}, {8}, {9}, {10}",
            //        ef.fontSize, line.height, line.textHeight,
            //        line.ascent, line.descent, leading, line.ascent + line.descent,
            //        em.x, em.y, em.width, em.height);

            //    var tlm = tf.getLineMetrics(0);
            //    Console.WriteLine(
            //        "TF> A: {0}, D: {1}, Leading: {2}, Height: {3}",
            //        tlm.ascent, tlm.descent, tlm.leading, tlm.height);
            //}
            #endregion

            #region Positioning
            if (_vertical)
            {
                line.y = _y;
                if (_rtl)
                {
                    lh     = -lh;
                    line.x = _x + lh;
                }
                else
                {
                    if (IsFirst(line))
                    {
                        _x += line.descent;
                    }
                    line.x = _x;
                }
                _x += lh;
            }
            else
            {
                _y    += lh;
                line.x = _x;
                line.y = _y;
            }
            #endregion

            bool dobreak = IsBreak(line);

            var align = _format.Alignment;

            //Trimming
            if (_nowrap || dobreak || _availWidth <= 1)
            {
                if (!IsLast(line))
                {
                    var trimmedLine = Trim(line);
                    if (trimmedLine != line)
                    {
                        //TODO: Align of trimmed line. Investigate GDI+ behaviour and do the same
                        if (_format.Trimming == StringTrimming.EllipsisCharacter)
                        {
                            switch (align)
                            {
                            case StringAlignment.Center:
                                align = StringAlignment.Far;
                                break;
                            }
                        }
                    }
                    line = trimmedLine;
                }
            }

            Align(line, align);
            Decorate(line);

            _container.addChild(line);

            return(dobreak);
        }