コード例 #1
0
ファイル: Vector3.cs プロジェクト: slagusev/Sharp.Engine
        public Vector3(Control.Base parent)
            : base(parent)
        {
            posZ       = new TextBoxNumeric(this);
            posZ.Dock  = Pos.Right;
            posZ.Width = 50;
            //posZ.MaximumSize=new System.Drawing.Point(70,17);
            posZ.TextChanged += OnValueChanged;
            var label = new Label(this);

            label.Text = "Z ";
            label.Dock = Pos.Right;

            posY       = new TextBoxNumeric(this);
            posY.Dock  = Pos.Right;
            posY.Width = 50;
            //posY.MaximumSize=new System.Drawing.Point(70,17);
            posY.TextChanged += OnValueChanged;
            label             = new Label(this);
            label.Text        = "Y ";
            label.Dock        = Pos.Right;

            posX       = new TextBoxNumeric(this);
            posX.Dock  = Pos.Right;
            posX.Width = 50;
            //posX.MaximumSize=new System.Drawing.Point(70,17);
            posX.TextChanged += OnValueChanged;
            label             = new Label(this);
            label.Text        = "X ";
            label.Font.Size   = 7;
            label.Dock        = Pos.Right;
        }
コード例 #2
0
ファイル: XmlComponentTest.cs プロジェクト: Geinome/Gwen.Net
            public void OnSubmitPressed(ControlBase sender, EventArgs args)
            {
                TextBoxNumeric value = GetControl("Value") as TextBoxNumeric;

                if (ValueChanged != null)
                {
                    ValueChanged(this.View, new ValueChangedEventArgs()
                    {
                        Value = (int)value.Value
                    });
                }
            }
コード例 #3
0
        void LoadContent1()
        {
            int     yExpanded = Y - Height;
            Vector2 labelSize;

            labelSize       = fontRegular.MeasureString(subExplanation2str);
            subExplanation2 = new Label(
                Game,
                units.X + units.Width + 15,
                yExpanded + 2 * (Height / 4),
                fontSubExplanation,
                subExplanation2str);
            subExplanation2.Visible = false;
            subExplanation2.Blocked = true;
            parent.SubComponents.Add(subExplanation2);

            numberBox2 = new TextBoxNumeric(
                Game,
                subExplanation2.X + subExplanation2.Width + 5,
                yExpanded + (2 * (Height / 4)) - Math.Abs(((subExplanation2.Height - (Height / 4)) / 2)),
                40,
                Height / 4,
                maxInt2,
                "5",
                fontTyping);
            numberBox2.Visible = false;
            numberBox2.Blocked = true;
            parent.SubComponents.Add(numberBox2);

            labelSize = fontRegular.MeasureString(units2str);
            units2    = new Label(
                Game,
                numberBox2.X + numberBox2.Width + 5,
                yExpanded + 2 * (Height / 4),
                fontSubExplanation,
                units2str);
            units2.Visible = false;
            units2.Blocked = true;
            parent.SubComponents.Add(units2);

            this.FinishedSlidingIn += new FinishedSlidingInHandler(YesNoPanel_FinishedSlidingIn2);
        }
コード例 #4
0
ファイル: XmlComponentTest.cs プロジェクト: Geinome/Gwen.Net
            public void OnButtonClicked(ControlBase sender, ClickedEventArgs args)
            {
                TextBoxNumeric value = GetControl("Value") as TextBoxNumeric;

                int buttonId = (int)sender.UserData;

                if (buttonId == 1)
                {
                    value.Value -= Step;
                }
                else if (buttonId == 2)
                {
                    value.Value += Step;
                }

                if (ValueChanged != null)
                {
                    ValueChanged(this.View, new ValueChangedEventArgs()
                    {
                        Value = (int)value.Value
                    });
                }
            }
コード例 #5
0
        public UnitTestHarnessControls(ControlBase parent) : base(parent)
        {
            Dock = Dock.Fill;

            DockBase dock = new DockBase(this);

            dock.Dock = Dock.Fill;

            m_List = new CollapsibleList(this);

            dock.LeftDock.TabControl.AddPage("Unit tests", m_List);
            dock.LeftDock.Width = 150;

            m_TextOutput = new ListBox(this);
            m_TextOutput.AlternateColor = false;

            dock.BottomDock.TabControl.AddPage("Output", m_TextOutput);
            dock.BottomDock.Height = 200;

            m_StatusBar      = new StatusBar(this);
            m_StatusBar.Dock = Dock.Bottom;

            m_DebugCheck               = new LabeledCheckBox(m_StatusBar);
            m_DebugCheck.Text          = "Debug outlines";
            m_DebugCheck.CheckChanged += DebugCheckChanged;

            m_IncScale = new Button(m_StatusBar);
            m_IncScale.HorizontalAlignment = HorizontalAlignment.Left;
            m_IncScale.VerticalAlignment   = VerticalAlignment.Stretch;
            m_IncScale.Width       = 30;
            m_IncScale.Margin      = new Margin(0, 0, 8, 0);
            m_IncScale.TextPadding = new Padding(5, 0, 5, 0);
            m_IncScale.Text        = "+";
            m_IncScale.Clicked    += (sender, arguments) => { m_UIScale.Value = Math.Min(m_UIScale.Value + 0.25f, 3.0f); };

            m_UIScale = new TextBoxNumeric(m_StatusBar);
            m_UIScale.VerticalAlignment = VerticalAlignment.Stretch;
            m_UIScale.Width             = 70;
            m_UIScale.Value             = GetCanvas().Scale;
            m_UIScale.TextChanged      += (sender, arguments) => { GetCanvas().Scale = m_UIScale.Value; };

            m_DecScale = new Button(m_StatusBar);
            m_DecScale.HorizontalAlignment = HorizontalAlignment.Left;
            m_DecScale.VerticalAlignment   = VerticalAlignment.Stretch;
            m_DecScale.Width       = 30;
            m_DecScale.Margin      = new Margin(4, 0, 0, 0);
            m_DecScale.TextPadding = new Padding(5, 0, 5, 0);
            m_DecScale.Text        = "-";
            m_DecScale.Clicked    += (sender, arguments) => { m_UIScale.Value = Math.Max(m_UIScale.Value - 0.25f, 1.0f); };

            m_UIScaleText = new Label(m_StatusBar);
            m_UIScaleText.VerticalAlignment = VerticalAlignment.Stretch;
            m_UIScaleText.Alignment         = Alignment.Left | Alignment.CenterV;
            m_UIScaleText.Text = "Scale:";

            m_Center      = new DockLayout(dock);
            m_Center.Dock = Dock.Fill;

            List <Type> tests = typeof(UnitTestHarnessControls).Assembly.GetTypes().Where(t => t.IsDefined(typeof(UnitTestAttribute), false)).ToList();

            tests.Sort((t1, t2) =>
            {
                object[] a1s = t1.GetCustomAttributes(typeof(UnitTestAttribute), false);
                object[] a2s = t2.GetCustomAttributes(typeof(UnitTestAttribute), false);
                if (a1s.Length > 0 && a2s.Length > 0)
                {
                    UnitTestAttribute a1 = a1s[0] as UnitTestAttribute;
                    UnitTestAttribute a2 = a2s[0] as UnitTestAttribute;
                    if (a1.Order == a2.Order)
                    {
                        if (a1.Category == a2.Category)
                        {
                            return(String.Compare(a1.Name != null ? a1.Name : t1.Name, a2.Name != null ? a2.Name : t2.Name, StringComparison.OrdinalIgnoreCase));
                        }
                        else
                        {
                            return(String.Compare(a1.Category, a2.Category, StringComparison.OrdinalIgnoreCase));
                        }
                    }
                    return(a1.Order - a2.Order);
                }

                return(0);
            });

            foreach (Type type in tests)
            {
                object[] attribs = type.GetCustomAttributes(typeof(UnitTestAttribute), false);
                if (attribs.Length > 0)
                {
                    UnitTestAttribute attrib = attribs[0] as UnitTestAttribute;
                    if (attrib != null)
                    {
                        CollapsibleCategory cat = m_List.FindChildByName(attrib.Category) as CollapsibleCategory;
                        if (cat == null)
                        {
                            cat = m_List.Add(attrib.Category, attrib.Category);
                        }
                        GUnit test = Activator.CreateInstance(type, m_Center) as GUnit;
                        RegisterUnitTest(attrib.Name != null ? attrib.Name : type.Name, cat, test);
                    }
                }
            }

            m_StatusBar.SendToBack();
            PrintText("Unit Test started!");
        }
コード例 #6
0
        public InputBox(
            string title,
            string prompt,
            bool modal,
            InputType inputtype,
            EventHandler okayYesSubmitClicked,
            EventHandler cancelClicked,
            object userData,
            int quantity = 0,
            Base parent  = null,
            GameContentManager.UI stage = GameContentManager.UI.InGame
            ) : base(parent)
        {
            if (parent == null)
            {
                parent = Interface.GameUi.GameCanvas;
            }

            OkayEventHandler   = okayYesSubmitClicked;
            CancelEventHandler = cancelClicked;
            this.UserData      = userData;
            mInputType         = inputtype;
            _uiStage           = stage;
            mPrompt            = prompt;

            mMyWindow             = new WindowControl(parent, title, modal, "InputBox");
            mMyWindow.BeforeDraw += _myWindow_BeforeDraw;
            mMyWindow.DisableResizing();

            mNumericTextboxBg              = new ImagePanel(mMyWindow, "Textbox");
            mNumericTextbox                = new TextBoxNumeric(mNumericTextboxBg, "TextboxText");
            mNumericTextbox.SubmitPressed += TextBox_SubmitPressed;
            mNumericTextbox.Text           = quantity.ToString();
            if (inputtype == InputType.NumericInput)
            {
                mNumericTextbox.Focus();
            }

            mTextboxBg              = new ImagePanel(mMyWindow, "Textbox");
            mTextbox                = new TextBox(mTextboxBg, "TextboxText");
            mTextbox.SubmitPressed += TextBox_SubmitPressed;
            if (inputtype == InputType.TextInput)
            {
                mTextbox.Focus();
            }

            if (inputtype != InputType.NumericInput)
            {
                mNumericTextboxBg.IsHidden = true;
            }

            if (inputtype != InputType.TextInput)
            {
                mTextboxBg.IsHidden = true;
            }

            mYesButton = new Button(mMyWindow, "YesButton");
            mYesButton.SetText(Strings.InputBox.okay);
            mYesButton.Clicked += okayBtn_Clicked;

            mNoButton = new Button(mMyWindow, "NoButton");
            mNoButton.SetText(Strings.InputBox.cancel);
            mNoButton.Clicked += cancelBtn_Clicked;

            mOkayButton = new Button(mMyWindow, "OkayButton");
            mOkayButton.SetText(Strings.InputBox.okay);
            mOkayButton.Clicked += okayBtn_Clicked;

            mPromptLabel = new Label(mMyWindow, "PromptLabel");
            Interface.InputBlockingElements.Add(this);
        }
コード例 #7
0
        protected override void LoadContent()
        {
            Mute(Color.White);


            fontBold            = Game.Content.Load <SpriteFont>("Fonts\\InfoFontLarge");
            fontBold.Spacing    = 4;
            fontRegular         = Game.Content.Load <SpriteFont>("Fonts\\InfoFont");
            fontRegular.Spacing = 2;
            fontExplanation     = Game.Content.Load <SpriteFont>("Fonts\\Typing");
            fontSubExplanation  = Game.Content.Load <SpriteFont>("Fonts\\TypingSmall");
            fontTyping          = Game.Content.Load <SpriteFont>("Fonts\\TypingSmall");
            int yExpanded = Y - Height;

            Vector2 labelSize = fontBold.MeasureString(msgStr);

            msg = new Label(Game,
                            Convert.ToInt32(X + (Width / 2) - (labelSize.X / 2)),
                            Convert.ToInt32(yExpanded + (Height / 8) - (labelSize.Y / 2)),
                            fontBold,
                            msgStr);
            msg.Visible = false;
            msg.Blocked = true;
            parent.SubComponents.Add(msg);

            labelSize   = fontRegular.MeasureString(explanationStr);
            explanation = new Label(
                Game,
                X + 4,
                yExpanded + (Height / 4),
                fontExplanation,
                explanationStr);
            explanation.Visible = false;
            explanation.Blocked = true;
            parent.SubComponents.Add(explanation);

            labelSize      = fontRegular.MeasureString(subExplanationStr);
            subExplanation = new Label(
                Game,
                X + 30,
                yExpanded + 2 * (Height / 4),
                fontSubExplanation,
                subExplanationStr);
            subExplanation.Visible = false;
            subExplanation.Blocked = true;
            parent.SubComponents.Add(subExplanation);

            numberBox = new TextBoxNumeric(
                Game,
                subExplanation.X + subExplanation.Width + 5,
                yExpanded + (2 * (Height / 4)) - Math.Abs(((subExplanation.Height - (Height / 4)) / 2)),
                40,
                Height / 4,
                maxInt,
                "10",
                fontTyping);
            numberBox.Visible = false;
            numberBox.Blocked = true;
            parent.SubComponents.Add(numberBox);

            labelSize = fontRegular.MeasureString(unitsStr);
            units     = new Label(
                Game,
                numberBox.X + numberBox.Width + 5,
                yExpanded + 2 * (Height / 4),
                fontSubExplanation,
                unitsStr);
            units.Visible = false;
            units.Blocked = true;
            parent.SubComponents.Add(units);

            savePanel = new Rect(
                Game,
                X,
                yExpanded + 3 * (Height / 4),
                Width / 2,
                Height / 4);
            savePanel.Visible = false;
            savePanel.Blocked = true;
            savePanel.HoveredBackgroundColor = Color.Green;
            parent.SubComponents.Add(savePanel);

            cancelPanel = new Rect(
                Game,
                X + (Width / 2),
                yExpanded + 3 * (Height / 4),
                Width / 2,
                Height / 4);
            cancelPanel.Visible = false;
            cancelPanel.Blocked = true;
            cancelPanel.HoveredBackgroundColor = Color.DarkRed;
            parent.SubComponents.Add(cancelPanel);

            labelSize = fontRegular.MeasureString("Save");
            save      = new Label(Game,
                                  Convert.ToInt32(savePanel.X + (savePanel.Width / 2) - (labelSize.X / 2)),
                                  Convert.ToInt32(savePanel.Y + (savePanel.Height / 2) - (labelSize.Y / 2)),
                                  fontRegular,
                                  "Save");
            save.Visible = false;
            save.Blocked = true;
            parent.SubComponents.Add(save);

            labelSize = fontRegular.MeasureString("Cancel");
            cancel    = new Label(Game,
                                  Convert.ToInt32(cancelPanel.X + (cancelPanel.Width / 2) - (labelSize.X / 2)),
                                  Convert.ToInt32(cancelPanel.Y + (cancelPanel.Height / 2) - (labelSize.Y / 2)),
                                  fontRegular,
                                  "Cancel");
            cancel.Visible = false;
            cancel.Blocked = true;
            parent.SubComponents.Add(cancel);

            this.FinishedSlidingIn += new FinishedSlidingInHandler(YesNoPanel_FinishedSlidingIn);

            base.LoadContent();
        }
コード例 #8
0
ファイル: TextBoxTest.cs プロジェクト: Geinome/Gwen.Net
        public TextBoxTest(ControlBase parent)
            : base(parent)
        {
            m_Font1          = Skin.DefaultFont.Copy();
            m_Font1.FaceName = "Courier New"; // fixed width font!

            m_Font2          = Skin.DefaultFont.Copy();
            m_Font2.FaceName = "Times New Roman";
            m_Font2.Size    *= 3;

            m_Font3       = Skin.DefaultFont.Copy();
            m_Font3.Size += 5;

            VerticalLayout vlayout = new VerticalLayout(this);
            {
                DockLayout dockLayout = new DockLayout(vlayout);
                {
                    VerticalLayout vlayout2 = new VerticalLayout(dockLayout);
                    vlayout2.Dock  = Dock.Left;
                    vlayout2.Width = 200;
                    {
                        /* Vanilla Textbox */
                        {
                            TextBox textbox = new TextBox(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("Type something here");
                            textbox.TextChanged   += OnEdit;
                            textbox.SubmitPressed += OnSubmit;
                        }

                        {
                            TextBoxPassword textbox = new TextBoxPassword(vlayout2);
                            textbox.Margin = Margin.Five;
                            //textbox.MaskCharacter = '@';
                            textbox.SetText("secret");
                            textbox.TextChanged += OnEdit;
                        }

                        {
                            TextBox textbox = new TextBox(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("Select All Text On Focus");
                            textbox.SelectAllOnFocus = true;
                        }

                        {
                            TextBox textbox = new TextBox(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("Different Coloured Text, for some reason");
                            textbox.TextColor = Color.Green;
                        }

                        {
                            TextBox textbox = new TextBoxNumeric(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("200456698");
                            textbox.TextColor = Color.Red;
                        }
                    }

                    /* Multiline Textbox */
                    {
                        MultilineTextBox textbox = new MultilineTextBox(dockLayout);
                        textbox.Dock       = Dock.Fill;
                        textbox.Margin     = Margin.Five;
                        textbox.Font       = m_Font1;
                        textbox.AcceptTabs = true;
                        textbox.SetText("In olden times when wishing still helped one, there lived a king whose daughters were all beautiful,\nbut the youngest was so beautiful that the sun itself, which has seen so much, \nwas astonished whenever it shone in her face. \nClose by the king's castle lay a great dark forest, \nand under an old lime-tree in the forest was a well, and when the day was very warm, \nthe king's child went out into the forest and sat down by the side of the cool fountain, \nand when she was bored she took a golden ball, and threw it up on high and caught it, \nand this ball was her favorite plaything.");
                    }
                    {
                        Button pad = new Button(dockLayout);
                        pad.Dock     = Dock.Right;
                        pad.Margin   = Margin.Five;
                        pad.Text     = "Pad";
                        pad.Clicked += (s, a) => new TextPad(this);
                    }
                }

                {
                    TextBox textbox = new TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.SetText("In olden times when wishing still helped one, there lived a king whose daughters were all beautiful, but the youngest was so beautiful that the sun itself, which has seen so much, was astonished whenever it shone in her face. Close by the king's castle lay a great dark forest, and under an old lime-tree in the forest was a well, and when the day was very warm, the king's child went out into the forest and sat down by the side of the cool fountain, and when she was bored she took a golden ball, and threw it up on high and caught it, and this ball was her favorite plaything.");
                    textbox.TextColor = Color.Black;
                    textbox.Font      = m_Font3;
                }

                {
                    TextBox textbox = new TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.Width  = 150;
                    textbox.HorizontalAlignment = HorizontalAlignment.Right;
                    textbox.SetText("あおい うみから やってきた");
                    textbox.TextColor = Color.Black;
                    textbox.Font      = m_Font3;
                }

                {
                    TextBox textbox = new TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.HorizontalAlignment = HorizontalAlignment.Left;
                    textbox.FitToText           = "Fit the text";
                    textbox.SetText("FitToText");
                    textbox.TextColor = Color.Black;
                    textbox.Font      = m_Font3;
                }

                {
                    TextBox textbox = new TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.HorizontalAlignment = HorizontalAlignment.Left;
                    textbox.Width = 200;
                    textbox.SetText("Width = 200");
                    textbox.TextColor = Color.Black;
                    textbox.Font      = m_Font3;
                }

                {
                    TextBox textbox = new TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.SetText("Different Font");
                    textbox.Font = m_Font2;
                }
            }
        }