Пример #1
0
 /// <summary>
 /// Initialise a basic label
 /// </summary>
 /// <param name="parent">The Parent Window</param>
 public Label(Window parent)
     : base(parent)
 {
     this.SetPosition(0, 0);
     this.Text = "Label";
     this.Parent.AddControl(this);
 }
Пример #2
0
 /// <summary>
 /// Initialise a label with X and Y position, and a default text
 /// </summary>
 /// <param name="parent">The Parent Window</param>
 /// <param name="left">X position</param>
 /// <param name="top">Y position</param>
 /// <param name="text">Label text</param>
 public Label(Window parent, Int32 left, Int32 top, String text)
     : base(parent)
 {
     this.SetPosition(left, top);
     this.Text = text;
     this.Parent.AddControl(this);
 }
Пример #3
0
 public Button(Window parent, Int32 left, Int32 top, Int32 width, Int32 height, String text)
     : base(parent)
 {
     this.Text = text;
     this.SetPosition(left, top);
     this.SetSize(width, height);
     this.Parent.AddControl(this);
 }
Пример #4
0
 public Button(Window parent)
     : base(parent)
 {
     this.Text = "Button";
     this.SetPosition(0, 0);
     this.SetSize(140, 24);
     this.Parent.AddControl(this);
 }
Пример #5
0
 /// <summary>
 /// Initialise a CheckBox with X and Y position, text
 /// </summary>
 /// <param name="parent">The Parent Window</param>
 /// <param name="left">X position</param>
 /// <param name="top">Y position</param>
 /// <param name="text">CheckBox text</param>
 /// <param name="checkOnText">Determines if you can check the control by clicking on the text</param>
 public CheckBox(Window parent, Int32 left, Int32 top, String text, Boolean checkOnText)
     : base(parent)
 {
     this.SetPosition(left, top);
     this.Text = text;
     this.CheckOnText = checkOnText;
     this.Parent.AddControl(this);
 }
Пример #6
0
 /// <summary>
 /// Initialise a CheckBox with X and Y position
 /// </summary>
 /// <param name="parent">The Parent Window</param>
 /// <param name="left">X position</param>
 /// <param name="top">Y position</param>
 public CheckBox(Window parent, Int32 left, Int32 top)
     : base(parent)
 {
     this.SetPosition(left, top);
     this.Text = "CheckBox";
     this.CheckOnText = true;
     this.Parent.AddControl(this);
 }
Пример #7
0
 /// <summary>
 /// Initialise a basic CheckBox
 /// </summary>
 /// <param name="parent">The Parent Window</param>
 public CheckBox(Window parent)
     : base(parent)
 {
     this.SetPosition(0, 0);
     this.Text = "CheckBox";
     this.CheckOnText = true;
     this.Parent.AddControl(this);
 }
Пример #8
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.Engine = new GuiEngine(this.Content, this.GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            /* Window 1 */
            this.win = new Window(this.Engine);

            /* Button */
            this.button1 = new UI.Button(this.win, 30, 200, 200, 24, "Leave Program");
            this.button1.Enabled = false;
            this.button1.OnMouseClick += button1_OnMouseClick;

            /* Label */
            this.label1 = new UI.Label(this.win, 55, 10, "Welcome to MonoGame.UI");

            /* CheckBox */
            this.checkBox1 = new UI.CheckBox(this.win, 20, 75, "Active leave button", true);
            this.checkBox1.OnCheckChange += checkBox1_OnCheckChange;

            /* Window 2 */
            this.win2 = new Window(this.Engine, 350, 10, 250, 150, "Gui Stats");
            this.win2.ShowCloseButton = false;
            this.label2 = new UI.Label(this.win2, 25, 10, "GuiEngine Stats :");

            this.win3 = new Window(this.Engine, 350, 200, 300, 225, "RadioButton tests");

            /* RadioButton 1 */
            this.radioGroup1 = new RadioGroup(this.win3);
            this.radioGroup1.Placement = RadioButtonPlacement.Horizontal;
            this.radioGroup1.SetPosition(20, 20);
            UI.RadioButton _r1 = new UI.RadioButton(this.radioGroup1);
            _r1.Text = "Power --";
            UI.RadioButton _r2 = new UI.RadioButton(this.radioGroup1);
            _r2.Text = "Power ++";
            this.radioGroup1.AddRadioButton(_r1);
            this.radioGroup1.AddRadioButton(_r2);

            /* RadioButton 2 */
            this.radioGroup2 = new RadioGroup(this.win3);
            this.radioGroup2.SetPosition(20, 50);

            UI.RadioButton _r3 = new UI.RadioButton(this.radioGroup2);
            _r3.Text = "XNA";
            UI.RadioButton _r4 = new UI.RadioButton(this.radioGroup2);
            _r4.Text = "MonoGame";

            this.radioGroup2.AddRadioButton(_r3);
            this.radioGroup2.AddRadioButton(_r4);

            this.Engine.AddWindow(this.win);
            this.Engine.AddWindow(this.win2);
            this.Engine.AddWindow(this.win3);

            base.Initialize();
        }
Пример #9
0
 /// <summary>
 /// Add window to the GuiEngine window list
 /// </summary>
 /// <param name="window"></param>
 public void AddWindow(Window window)
 {
     if (window == null)
     {
         return;
     }
     if (this.lstWindows.Contains(window) == false)
     {
         foreach (Window _win in this.lstWindows)
         {
             _win.Focused = false; // Lost focus
         }
         window.Focused = true;
         this.lstWindows.Add(window);
         this.CurrentWindow = window;
     }
 }
Пример #10
0
 public Control(Window parent)
 {
     this.enabled = true;
     this.visible = true;
     this.parent = parent;
 }
Пример #11
0
 /// <summary>
 /// Initialise a RadioGroup with a RadioButton list and the placement
 /// </summary>
 /// <param name="parent">Parent Window</param>
 /// <param name="lstRadioButtons">RadioButton list</param>
 /// <param name="placement">RadioButton placement (Vertical or Horizontal)</param>
 public RadioGroup(Window parent, List<RadioButton> lstRadioButtons, RadioButtonPlacement placement)
     : base(parent)
 {
     this.Enabled = true;
     this.Visible = true;
     this.Placement = placement;
     this.RadioButtons = lstRadioButtons;
     this.Parent.AddControl(this);
 }
Пример #12
0
 /// <summary>
 /// Initialise RadioGroup with one RadioButton
 /// </summary>
 /// <param name="parent">Parent Window</param>
 /// <param name="_firstRadio">One RadioButton</param>
 public RadioGroup(Window parent, RadioButton _firstRadio)
     : base(parent)
 {
     this.Enabled = true;
     this.Visible = true;
     this.Placement = RadioButtonPlacement.Vertical;
     this.RadioButtons = new List<RadioButton>();
     this.AddRadioButton(_firstRadio);
     this.Parent.AddControl(this);
 }
Пример #13
0
 /// <summary>
 /// Dispose the GuiEngine
 /// </summary>
 public void Dispose()
 {
     foreach (Window _window in this.lstWindows)
     {
         _window.Dispose();
     }
     this.lstWindows.Clear();
     this.CurrentWindow = null;
     this.Loader.Dispose();
     this.Loader = null;
     this.DisposeEngine = true;
 }
Пример #14
0
        /// <summary>
        /// Process the mouse Input for the moving window
        /// </summary>
        /// <param name="mouseState"></param>
        private void ProcessMouseInput(MouseState mouseState)
        {
            if (this.CurrentWindowMoving != null)
            {
                if (MouseHelper.mouseDown && this.CurrentWindowMoving.Enabled)
                {
                    this.CurrentWindowMoving.Left -= MouseHelper.lastMouseState.X - mouseState.X;
                    this.CurrentWindowMoving.Top -= MouseHelper.lastMouseState.Y - mouseState.Y;

                    if (this.CurrentWindowMoving.Rectangle.X < 0)
                    {
                        this.CurrentWindowMoving.Left = 0;
                    }
                    else if (this.CurrentWindowMoving.Rectangle.X + this.CurrentWindowMoving.Rectangle.Width > this.ClientWidth)
                    {
                        this.CurrentWindowMoving.Left = this.ClientWidth - this.CurrentWindowMoving.Rectangle.Width;
                    }

                    if (this.CurrentWindowMoving.Rectangle.Y < 0)
                    {
                        this.CurrentWindowMoving.Top = 0;
                    }
                    else if (this.CurrentWindowMoving.Rectangle.Y + this.CurrentWindowMoving.Rectangle.Height > this.ClientHeight)
                    {
                        this.CurrentWindowMoving.Top = this.ClientHeight - this.CurrentWindowMoving.Rectangle.Height;
                    }
                }
                else
                {
                    this.CurrentWindowMoving = null;
                }
            }
        }
Пример #15
0
 /// <summary>
 /// Delete window from the GuiEngine list
 /// </summary>
 /// <param name="window"></param>
 /// <param name="dispose"></param>
 public void RemoveWindow(Window window, Boolean dispose)
 {
     if (window == null)
     {
         return;
     }
     if (this.lstWindows.Contains(window) == true)
     {
         this.lstWindows.Remove(window);
         if (dispose == true)
         {
             window.Dispose();
             window = null;
             if (this.lstWindows.Count >= 1)
             {
                 this.CurrentWindow = this.lstWindows.Last();
                 this.CurrentWindow.Focused = true;
             }
             else
             {
                 this.CurrentWindow = null;
             }
         }
     }
 }