예제 #1
0
파일: Log.cs 프로젝트: xxy1991/cozy
        /// <summary>
        /// Called when graphics resources need to be loaded. 
        /// 
        /// Use this for the usage of :
        /// - creation of the internal embedded controls.
        /// - setting of the variables and resources in this control
        /// - to load any game-specific graphics resources
        /// - take over the config width and height and use it into State
        /// - overriding how this item looks like , by settings its texture or theme
        /// 
        /// Call base.LoadContent before you do your override code, this will cause :
        /// - State.SourceRectangle to be reset to the Config.Size 
        /// </summary>
        public override void LoadContent()
        {
            // do the basic stuff 
            base.LoadContent();

            // update state by using config
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            // create the text to show
            this.textBox = new MultilineTextBox(this.Name + "-Text")
                               {
                                   Config =
                                       {
                                           Width = this.Config.Width,
                                           Height = this.Config.Height,
                                           PositionX = 0,
                                           PositionY = 0
                                       },
                                   ConfigFont = "Fonts\\LucidaConsole"
                               };
            this.AddControl(this.textBox);

            // create the background
            this.CurrentTextureName = this.Manager.ImageCompositor.CreateRectangleTexture(
                                                                                    this.Name + "-Background",
                                                                                    (int)this.Config.Width,
                                                                                    (int)this.Config.Height,
                                                                                    1,
                                                                                    Theme.ContainerFillColor,
                                                                                    Theme.BorderColor);
        }
예제 #2
0
        public override void LoadContent()
        {
            base.LoadContent();

            // label
            var y = (float)Theme.ControlLargeSpacing + Theme.ControlHeight;
            this.Label = new Label("MyLabel")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing, 
                    PositionY = y, 
                }, 
                ConfigText = "Test label ff", 
                ConfigHorizontalAlignment = HorizontalAlignment.Left, 
                ConfigVerticalAlignment = VerticalAlignment.Center
            };
            this.AddControl(this.Label);

            // text-box
            y = y + this.Label.Config.Height + Theme.ControlSmallSpacing;
            this.TextBox = new TextBox("MyTextBox")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing, 
                    PositionY = y, 
                }, 
                Text = "My text control", 
            };
            this.AddControl(this.TextBox);

            // multi-line text-box
            y = y + this.TextBox.Config.Height + Theme.ControlSmallSpacing;
            var multilineTextBox = new MultilineTextBox("MyMultiLineTextBox")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = y,
                },
                ConfigText = "This is test text.\nTo see if this is working.\nIf you see this.\nAll is working.\n"
            };
            this.AddControl(multilineTextBox);

            Config.Width = this.Label.Config.Width + (Theme.ControlLargeSpacing * 4);
            Config.Height = multilineTextBox.Config.PositionY + (multilineTextBox.Config.Height * 4) + Theme.ControlLargeSpacing;
        }