예제 #1
0
        /// <summary>
        /// Initializes a new <see cref="TextObject" /> instance.
        /// </summary>
        /// <param name="text">The initial text to set for this text object.</param>
        /// <param name="font">The font to use for this text object.</param>
        /// <param name="position">The intitial position of this text object.</param>
        /// <param name="alignment">The intitial alignment of the text in this text object.</param>
        public TextObject(string text, Font font, Point<int> position = new Point<int>(),
                          QFontAlignment alignment = QFontAlignment.Centre)
        {
            if (font == null)
                throw new EngineException("Font supplied for TextObject is null!", new ArgumentNullException("font"));

            Text = text;
            Font = font;
            Position = position;
            Alignment = alignment;
        }
예제 #2
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));
        }
예제 #3
0
파일: Label.cs 프로젝트: TriDevs/TriEngine
 /// <summary>
 /// Sets the font that this label uses.
 /// </summary>
 /// <param name="font">The new font instance to use.</param>
 public virtual void SetFont(Font font)
 {
     _font = font;
     UpdateTextObject();
 }