Exemplo n.º 1
0
        private Window2DTest()
            : base(800, 600, "TriEngine2D Test")
        {
            Services.Provide(new InputManager(this), new AudioManager());
            _controlManager = new ControlManager();
            ResourceManager.LoadSong("unknown1", "menu1.ogg");
            ResourceManager.LoadSong("call", "menu2.ogg");
            ResourceManager.LoadSong("pirates", "menu3.ogg").IsLooped = true;
            ResourceManager.LoadSound("test", "test1.wav");
            ResourceManager.LoadSound("test2", "test2.wav");
            //Services.Audio.LoadSong("unknown2", "menu4.ogg");
            _font = ResourceManager.LoadFont("Anon", "Anonymous.ttf", 32);
            _control = new Label
            {
                Rectangle = new Rectangle(100, 100, 250, 250),
                Color = Color.Green,
                Alignment = QFontAlignment.Left,
                Text = "Test"
            };
            ((Label) _control).SetFont(_font);
            _control.Clicked += ControlClicked;
            _controlManager.AddControl(_control);
            _text = new TextObject("Hello, World!", _font, new Point<int>(100, 50), QFontAlignment.Left);
            _label = new Label();
            _label.SetFont(_font);
            _label.Position = new Point<int>(250, 300);
            _label.Text = "Foo Bar Baz";
            _label.Alignment = QFontAlignment.Right;
            _controlManager.AddControl(_label);
            _link = new LinkLabel();
            _link.SetFont(_font);
            _link.Position = new Point<int>(300, 500);

            _link.Text = "Go to google";
            _link.Alignment = QFontAlignment.Centre;
            _link.Url = "http://www.google.com/";
            _controlManager.AddControl(_link);

            _triangle = new Triangle(new Point<int>(100, 25), new Point<int>(50, 100), new Point<int>(150, 100));
            _rectangle = new Graphics.Rectangle(new Rectangle(200, 100, 100, 200));
        }
Exemplo n.º 2
0
        protected virtual void UpdateTextObject()
        {
            if (_font == null)
                return;

            if (_textObject == null)
            {
                _textObject = new TextObject(_text, _font, Position, Alignment);
            }
            else
            {
                _textObject.Text = Text;
                _textObject.Font = _font;
                _textObject.Position = Position;
                _textObject.Alignment = Alignment;
            }

            Size = new Point<int>(_textObject.Bounds.Width, _textObject.Bounds.Height);

            switch (Alignment)
            {
                case QFontAlignment.Centre:
                    _drawPosition = new Point<int>(Position.X - Size.X / 2, Position.Y);
                    break;
                case QFontAlignment.Right:
                    _drawPosition = new Point<int>(Position.X - Size.X, Position.Y);
                    break;
                default:
                    _drawPosition = Position;
                    break;
            }
        }