Exemplo n.º 1
0
        /// <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()
        {
            base.LoadContent();

            this.ImageControl = new ImageControl("MyImageTest")
            {
                Config =
                {
                    PositionX = 0, PositionY = 0,
                    Width = 200, Height = 100,
                },
                ImagePath = "Textures\\acid"
            };

            this.AddControl(this.ImageControl);

            this.Config.Width = Theme.ControlLargeSpacing + this.ImageControl.Config.Width + Theme.ControlLargeSpacing;
            this.Config.Height = Theme.ControlLargeSpacing + this.ImageControl.Config.Height + Theme.ControlLargeSpacing;
        }
Exemplo n.º 2
0
        /// <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()
        {
            // load the base dialog - making it load the window
            base.LoadContent();

            // make the button
            this.OkButton = new Button(Name + "-YesButton")
            {
                ConfigText = "OK",
                Config =
                    {
                        Width = Theme.ControlWidth, Height = Theme.ControlHeight
                    }
            };
            this.OkButton.Config.PositionX = Config.Width - this.OkButton.Config.Width - Theme.ControlLargeSpacing;
            this.OkButton.Config.PositionY = Config.Height - this.OkButton.Config.Height - Theme.ControlLargeSpacing;
            this.AddControl(this.OkButton);

            // Make the error image
            const int Y = 2;
            const int X = 2;
            this.ErrorImageControl = new ImageControl(Name + "-image")
            {
                Config =
                {
                    PositionX = X,
                    PositionY = Y,
                    Width = Theme.ControlHeight - 4,
                    Height = Theme.ControlHeight - 4
                },
                ImagePath = "Textures\\error"
            };
            this.AddControl(this.ErrorImageControl);

            // make the text
            this.Text = new Label(Name + "-Text")
            {
                ConfigText = DialogText,
                Config =
                    {
                        Width = Config.Width - (Theme.ControlLargeSpacing * 2),
                        Height = Config.Height - (Theme.ControlLargeSpacing * 2),
                        PositionX = Theme.ControlLargeSpacing,
                    PositionY = Theme.ControlLargeSpacing
                }
            };
            this.AddControl(this.Text);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when a item is selected.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void OnItemSelect(object sender, EventArgs eventArgs)
        {
            this.dropDownButton.Toggle(this, new ButtonStateEventArgs(ButtonState.Off));
            this.DropDownList.Config.Visible = false;
            this.Manager.ForegroundSceneNodes.Children.Remove(this.DropDownList);

            if (this.dropDownListShown)
            {
                this.dropDownListShown = false;
            }

            if (this.OnShowHide != null)
            {
                this.OnShowHide(this, new BooleanEventArgs(false));
            }

            var index = this.DropDownList.SelectedIndex;
            if (index > -1 && index < this.DropDownList.ListBoxItems.Count)
            {
                this.textValue.ConfigText = this.DropDownList.ListBoxItems[index].Text;
                this.ImagePath = this.DropDownList.ListBoxItems[index].ImagePath;
                this.SetText(this.textValue.ConfigText);

                if (this.OnSelectedItemChanged != null)
                {
                    this.OnSelectedItemChanged(this, new StringEventArgs(this.textValue.ConfigText));
                }

                // Also set our image value if we can
                if (this.imageControlBoxForValue != null)
                {
                    this.Children.Remove(this.imageControlBoxForValue);
                }

                this.imageControlBoxForValue = new ImageControl(this.Name + "-ImageBoxForValue")
                                                {
                                                    Config =
                                                    {
                                                        PositionX = 3,
                                                        PositionY = 3,
                                                        Width = (int)(this.State.Width - 6),
                                                        Height = (int)(this.State.Height - 6)
                                                    },
                                                    ImagePath = this.ImagePath
                                                };
                this.Children.Add(this.imageControlBoxForValue);

                // Shift text over
                const float Tolerance = 0.001f;
                if (this.ImagePath != null && Math.Abs(this.textValue.State.DrawPosition.X - 5f) < Tolerance)
                {
                    this.textValue.State.DrawPosition = new DVector2(this.imageControlBoxForValue.State.DrawPosition.X + this.imageControlBoxForValue.State.Width + 5f, this.textValue.State.DrawPosition.Y);
                }
            }

            this.Manager.SetFocusedControl(this.dropDownButton);
        }
Exemplo n.º 4
0
        /// <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()
        {
            // float textXOffset = Padding;
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            // add a image-item if image name is set 
            if (this.ImagePath != null)
            {
                this.imageControlBoxForValue = new ImageControl(this.Name + "-" + this.ImagePath)
                {
                    Config =
                    {
                        PositionX = this.Theme.ControlSmallSpacing,
                        PositionY = this.Theme.ControlSmallSpacing,
                        Width = (int)(this.State.Width - (2 * this.Theme.ControlSmallSpacing)),
                        Height = (int)(this.State.Height - (2 * this.Theme.ControlSmallSpacing)),
                    },
                    ImagePath = this.ImagePath,
                    Manager = this.Manager
                };

                this.imageControlBoxForValue.Initialize();

                this.Children.Add(this.imageControlBoxForValue);

                // textXOffset += _imageBoxForValue.State.DrawPosition.X + _imageBoxForValue.State.Width;
            }

            // add a text-box
            this.textValue = new Label(this.Name + "-TextBox")
            {
                ConfigText = this.Text,
                ConfigHorizontalAlignment = HorizontalAlignment.Left,
                ConfigVerticalAlignment = VerticalAlignment.Center,
                Config =
                {
                    Width = this.Config.Width - this.Config.Height,
                    Height = this.Config.Height,
                },
                ConfigDebugLayout = false
            };
            this.textValue.Initialize();
            this.AddControl(this.textValue);

            // add the drop-down button
            this.dropDownButton = new ToggleButton(this.Name + "-DropDownButton")
            {
                ConfigText = string.Empty,
                Config =
                {
                    Width = this.Config.Height,
                    Height = this.Config.Height
                }
            };
            this.dropDownButton.Config.PositionX = this.Config.Width - this.dropDownButton.Config.Width;
            this.AddControl(this.dropDownButton);
            this.dropDownButton.OnToggle += this.OnToggleDropDown;

            // add the drop down list
            this.DropDownList = new ListBox(this.Name + "-FlapOut")
            {
                Config =
                {
                    Width = this.Config.Width,
                    Height = this.Config.Width,
                    Visible = false,
                    PositionY = this.Config.PositionY + this.Config.Height
                }
            };
            this.AddControl(this.DropDownList);
            this.DropDownList.OnItemSelect += this.OnItemSelect;

            this.CurrentTextureName = this.Manager.ImageCompositor.CreateRectangleTexture(this.Name + "-Background", (int)this.Config.Width, (int)this.Config.Height, this.Theme.BorderWidth, this.Theme.ContainerFillColor, this.Theme.BorderColor);

            this.dropDownListShown = false;

            base.LoadContent();
        }
Exemplo n.º 5
0
        /// <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()
        {
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSourceRectangleByConfig();

            this.imagePos = new DVector2(this.Theme.ControlSmallSpacing, this.Theme.ControlSmallSpacing);

            // create my image if i have one
            if (this.ImagePath != null)
            {
                this.imageControl = new ImageControl(this.Name + "-Image")
                {
                    Config =
                    {
                        PositionX = (int)this.imagePos.X,
                        PositionY = (int)this.imagePos.Y,
                        Width = (int)(this.State.Height - (2 * this.Theme.ControlSmallSpacing)),
                        Height = (int)(this.State.Height - (2 * this.Theme.ControlSmallSpacing))
                    },
                    ImagePath = this.ImagePath
                };
                this.AddControl(this.imageControl);
            }

            // Align text centered vertically
            if (this.imageControl != null)
            {
                //// _textPos = new DVector2(State.Height + Padding, State.Height/2);
            }

            // Create my label
            this.label = new Label(this.Name + "-Label")
                                {
                                    ConfigText = this.Text,
                                    ConfigHorizontalAlignment = HorizontalAlignment.Left,
                                    ConfigVerticalAlignment = VerticalAlignment.Center
                                };

            this.AddControl(this.label);

            this.mustRedraw = true;

            // create my textures
            this.selectedTextureName = this.Manager.ImageCompositor.CreateRectangleTexture(this.Name + "-selected", (int)this.Config.Width, (int)this.Config.Height, 0, this.Theme.HoverFillColor, this.Theme.BorderColor);
            this.unselectedTextureName = this.Manager.ImageCompositor.CreateRectangleTexture(this.Name + "-unselected", (int)this.Config.Width, (int)this.Config.Height, 0, this.Theme.FillColor, this.Theme.BorderColor);

            base.LoadContent();
        }