示例#1
0
文件: Tooltip.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()
        {
            base.LoadContent();

            // make the background
            this.CurrentTextureName = Manager.ImageCompositor.CreateRectangleTexture(
                                                                                    this.Name + "-Tool-tip Background",
                                                                                    (int)Config.Width,
                                                                                    (int)Config.Height,
                                                                                    1,
                                                                                    new GUIColor(252, 252, 220),
                                                                                    Theme.BorderColor);

            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();

            this.Label = new Label(Name + "-Label")
                                                     {
                                                         ConfigText = this.GetParentTooltipText(),
                                                         Config =
                                                             {
                                                                 Height = Config.Height
                                                             }
                                                     };
            this.AddControl(this.Label);
        }
示例#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()
        {
            base.LoadContent();

            var posy = Theme.ControlLargeSpacing + Theme.ControlHeight;

            // ToggleButton
            this.ToggleButton = new ToggleButton("Toggle button test")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = posy,
                },
                ConfigText = "Toggle Button"
            };
            this.AddControl(this.ToggleButton);
            this.ToggleButton.OnToggle += this.OnTogglePress;

            // button
            posy = posy + Theme.ControlHeight + Theme.ControlLargeSpacing;
            this.Button = new Button("MyButton")
            {
                ConfigText = "Button",
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = posy,
                }
            };
            this.AddControl(this.Button);
            this.Button.Clicked += this.OnButtonPress;

            // label
            posy = posy + Theme.ControlHeight + Theme.ControlLargeSpacing;
            this.InfoLabel = new Label("My label")
            {
                ConfigText = "Press button",
                ConfigHorizontalAlignment = HorizontalAlignment.Left,
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = posy,
                }
            };
            this.AddControl(this.InfoLabel);
        }
示例#3
0
        /// <summary>
        /// Creates or removes labels , to become in sync with the number of found Lines that we need to show.
        /// </summary>
        private void CreateRemoveLabels()
        {
            // add lines if needed
            while (this.MyLines.Count < this.textLines.Count)
            {
                var labelName = this.uniqueNameCreator.GetUniqueName(Name + "-Line");
                var newLine = new Label(labelName);
                this.AddControl(newLine);
                this.MyLines.Add(newLine);
            }

            // remove lines if needed
            while (this.MyLines.Count > this.textLines.Count)
            {
                var count1 = this.MyLines.Count;
                var lastLine1 = this.MyLines[count1 - 1];

                this.RemoveControl(lastLine1);
                this.MyLines.Remove(lastLine1);
                lastLine1.UnloadContent();
            }
        }
示例#4
0
文件: Grid.cs 项目: xxy1991/cozy
        /// <summary>
        /// Populates the grid with controls.
        /// </summary>
        private void MakeGridControls()
        {
            for (var x = 0; x < this.ConfigColumnCount; x++)
            {
                for (var y = 0; y < this.ConfigRowCount; y++)
                {
                    // if no fill type , then continue
                    if (this.configFillType == GridFillType.None)
                    {
                        continue;
                    }

                    var gridPosition = this.GridPosition(x, y);

                    switch (this.configFillType)
                    {
                        case GridFillType.Button:
                            var buttonname = Name + string.Format(" {0}, {1}", x, y);

                            var button = new Button(buttonname)
                                             {
                                                 Config =
                                                     {
                                                         PositionX = gridPosition.X,
                                                         PositionY = gridPosition.Y,
                                                         Width = this.cellWidth,
                                                         Height = this.cellHeight,
                                                     },
                                                 ConfigText = string.Format("{0}, {1}", x, y),
                                                 Theme = this.Theme
                                             };
                            button.Initialize();

                            this.controlArray[x][y] = button;
                            this.AddControl(button);

                            break;

                        case GridFillType.Text:
                            var textname = Name + string.Format(" {0}, {1}", x, y);

                            var text = new Label(textname)
                                           {
                                               Config =
                                                   {
                                                       PositionX =
                                                           gridPosition.X + (this.cellWidth / 2f),
                                                       PositionY =
                                                           gridPosition.Y + (this.cellHeight / 2f),
                                                       Width = this.cellWidth,
                                                       Height = this.cellHeight,
                                                   },
                                               ConfigText = string.Format("{0}, {1}", x, y),
                                               ConfigHorizontalAlignment = HorizontalAlignment.Center,
                                               ConfigVerticalAlignment = VerticalAlignment.Center,
                                           };

                            text.Initialize();
                            this.controlArray[x][y] = text;
                            this.AddControl(text);

                            break;
                    }
                }
            }
        }
示例#5
0
文件: ComboBox.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()
        {
            // 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();
        }
示例#6
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();

            // ToggleButton
            var posy = Theme.ControlLargeSpacing + Theme.ControlHeight;
            this.CheckBox1 = new CheckBox("CheckBox1")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = posy,
                },
                ConfigText = "Check-box 1"
            };
            this.AddControl(this.CheckBox1);

            // button
            posy = posy + Theme.ControlHeight + Theme.ControlLargeSpacing;
            this.CheckBox2 = new CheckBox("CheckBox2")
            {
                ConfigText = "Check-box 2",
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = posy,
                }
            };
            this.AddControl(this.CheckBox2);

            // label
            posy = posy + Theme.ControlHeight + Theme.ControlLargeSpacing;
            this.InfoLabel = new Label("My label")
            {
                ConfigText = "Change in check",
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = posy,
                }
            };
            this.AddControl(this.InfoLabel);
        }
示例#7
0
文件: Label.cs 项目: xxy1991/cozy
        /// <summary>This will result that we show a extra character to the right side.</summary>
        /// <param name="internalTextData">The internal Text Data.</param>
        /// <param name="visualTextData">The visual Text Data.</param>
        /// <returns>true when succeeded , otherwise false</returns>
        public static bool ShiftLastCharShownRight(TextBox internalTextData, Label visualTextData)
        {
#if DEBUG
            if (internalTextData == null)
            {
                throw new ArgumentNullException("internalTextData");
            }

            if (visualTextData == null)
            {
                throw new ArgumentNullException("visualTextData");
            }
#endif

            if (visualTextData.StateLastCharacterIndexShown < internalTextData.Text.Length)
            {
                visualTextData.StateLastCharacterIndexShown++;
                return true;
            }

            return false;
        }
示例#8
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();

            // TreeView
            this.TreeView = new TreeView("TreeView test")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = Theme.ControlLargeSpacing + Theme.ControlHeight,
                },
                DebugLocation = true
            };
            this.AddControl(this.TreeView);

            // add some child nodes to RootNode
            var root = this.TreeView.RootNode;

            root.AddTreeNode("Child1"); // tree-node text/name
            root.AddTreeNode("Child2", "IconUrl"); // tree-node text/name and icon
            root.AddTreeNode("Child3", "IconUrl", true); // tree-node text/name and icon and collapsed

            // add some child nodes to Child2
            var node = this.TreeView.GetTreeNode("Child2");
            node.AddTreeNode("Child2.1", "IconUrl", true);
            node.AddTreeNode("Child2.2", "IconUrl", true);

            // InfoLabel
            this.InfoLabel = new Label("MyButton")
            {
                ConfigText = "Info text",
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = Theme.ControlLargeSpacing + this.TreeView.Config.Height + this.TreeView.Config.PositionY,
                }
            };
            this.AddControl(this.InfoLabel);

            Config.Height = this.InfoLabel.Config.PositionY + this.InfoLabel.Config.Height + Theme.ControlLargeSpacing;
            Config.Width = this.TreeView.Config.Width + (Theme.ControlLargeSpacing * 2);
        }
示例#9
0
文件: Label.cs 项目: xxy1991/cozy
        /// <summary>This will result that we show one less character to the left.</summary>
        /// <param name="visualTextData">The visual Text Data.</param>
        /// <returns>true when succeeded , otherwise false</returns>
        public static bool ShiftLastCharShownToLeft(Label visualTextData)
        {
#if DEBUG
            if (visualTextData == null)
            {
                throw new ArgumentNullException("visualTextData");
            }
#endif
            if (visualTextData.StateLastCharacterIndexShown > 0)
            {
                visualTextData.StateLastCharacterIndexShown--;
                return true;
            }

            return false;
        }
示例#10
0
文件: Label.cs 项目: xxy1991/cozy
        /// <summary>Shifts the shown text to the right.</summary>
        /// <param name="internalTextData">The internal text data.</param>
        /// <param name="visualTextData">The visual text data.</param>
        /// <returns>True when successful , otherworldly false.</returns>
        /// <exception cref="System.ArgumentNullException">InternalTextData or visualTextData</exception>
        public static bool ShiftShownTextToTheRight(TextBox internalTextData, Label visualTextData)
        {
#if DEBUG
            if (internalTextData == null)
            {
                throw new ArgumentNullException("internalTextData");
            }

            if (visualTextData == null)
            {
                throw new ArgumentNullException("visualTextData");
            }
#endif
            if (ShiftFirstCharShownToRight(internalTextData, visualTextData) == false)
            {
                return false;
            }

            if (ShiftLastCharShownRight(internalTextData, visualTextData) == false)
            {
                return false;
            }

            return true;
        }
示例#11
0
文件: Label.cs 项目: xxy1991/cozy
        /// <summary>
        /// Shifts the shown text to the left.
        /// </summary>
        /// <param name="visualTextData">The visual text data.</param>
        /// <returns>True when successful , otherworldly false.</returns>
        /// <exception cref="System.ArgumentNullException">VisualTextData was null.</exception>
        public static bool ShiftShownTextToTheLeft(Label visualTextData)
        {
#if DEBUG
            if (visualTextData == null)
            {
                throw new ArgumentNullException("visualTextData");
            }
#endif

            if (ShiftFirstCharShownToLeft(visualTextData) == false)
            {
                return false;
            }

            if (ShiftLastCharShownToLeft(visualTextData) == false)
            {
                return false;
            }

            return true;
        }
示例#12
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();
        }
示例#13
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();

            // create the combo-box
            var y = Theme.ControlHeight + Theme.ControlLargeSpacing;
            this.ComboBox = new ComboBox("myFirstComboBox")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = y
                }
            };
            this.AddControl(this.ComboBox);

            // create the ADD-button
            y = (int)(y + this.ComboBox.Config.Height + Theme.ControlLargeSpacing);
            this.ButtonAdd = new Button("AddButton")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = y
                }
            };
            this.AddControl(this.ButtonAdd);

            // create the REMOVE-button
            y = (int)(y + this.ButtonAdd.Config.Height + Theme.ControlLargeSpacing);
            this.ButtonRemove = new Button("RemoveButton")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = y
                }
            };
            this.AddControl(this.ButtonRemove);

            // create the info-label
            y = (int)(y + this.ButtonRemove.Config.Height + Theme.ControlLargeSpacing);
            this.InfoLabel = new Label("Info label")
            {
                Config =
                {
                    PositionX = Theme.ControlLargeSpacing,
                    PositionY = y
                },
                ConfigText = "Oscariotes"
            };
            this.AddControl(this.InfoLabel);

            // now add dynamic items
            this.ComboBox.AddItem("Test1", null);
            this.ComboBox.AddItem("Test2", null);
        }