コード例 #1
0
ファイル: TextBox.cs プロジェクト: slagusev/Gwen.CS
            public TextPad(ControlBase parent)
                : base(parent)
            {
                StartPosition = StartPosition.CenterParent;
                Size          = new Size(400, 300);
                Padding       = new Padding(1, 0, 1, 1);
                Title         = "TextPad";

                DockLayout layout = new DockLayout(this);

                layout.Dock = Dock.Fill;

                Control.MenuStrip menuStrip = new MenuStrip(layout);
                menuStrip.Dock = Dock.Top;
                Control.MenuItem fileMenu = menuStrip.AddItem("File");
                fileMenu.Menu.AddItem("Open...", String.Empty, "Ctrl+O").SetAction((s, a) => OnOpen(s, a));
                fileMenu.Menu.AddItem("Save", String.Empty, "Ctrl+S").SetAction((s, a) => OnSave(s, a));
                fileMenu.Menu.AddItem("Save As...").SetAction((s, a) => OnSaveAs(s, a));
                fileMenu.Menu.AddItem("Quit", String.Empty, "Ctrl+Q").SetAction((s, a) => Close());

                m_Font          = Skin.DefaultFont.Copy();
                m_Font.FaceName = "Courier New";

                Control.StatusBar statusBar = new Gwen.Control.StatusBar(layout);
                statusBar.Dock = Dock.Bottom;

                Control.Label length = new Control.Label(statusBar);
                length.Margin = new Margin(5, 0, 5, 0);

                Control.Label label = new Control.Label(statusBar);
                label.Margin = new Margin(5, 0, 5, 0);
                label.Text   = "Length:";

                Control.Label lines = new Control.Label(statusBar);
                lines.Margin = new Margin(5, 0, 5, 0);

                label        = new Control.Label(statusBar);
                label.Margin = new Margin(5, 0, 5, 0);
                label.Text   = "Lines:";

                m_TextBox      = new Control.MultilineTextBox(layout);
                m_TextBox.Dock = Dock.Fill;
                m_TextBox.ShouldDrawBackground = false;
                m_TextBox.Font         = m_Font;
                m_TextBox.TextChanged += (sender, arguments) => { lines.Text = m_TextBox.TotalLines.ToString(); length.Text = m_TextBox.Text.Length.ToString(); };
                m_TextBox.Text         = "";

                m_Path = null;
            }
コード例 #2
0
ファイル: TextBox.cs プロジェクト: gl-obsoleted/utouch
        public TextBox(Base parent)
            : base(parent)
        {
            int row = 0;

            m_Font1 = new Font(Skin.Renderer, "Consolas", 14);             // fixed width font!
            m_Font2 = new Font(Skin.Renderer, "Impact", 50);
            m_Font3 = new Font(Skin.Renderer, "Arial", 14);

            /* Vanilla Textbox */
            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Type something here");
                textbox.SetPosition(10, 10 + 25 * row);
                textbox.TextChanged   += OnEdit;
                textbox.SubmitPressed += OnSubmit;
                row++;
            }

            /* Multiline Textbox */
            {
                Control.MultilineTextBox textbox = new Control.MultilineTextBox(this);
                textbox.Font       = m_Font1;
                textbox.AcceptTabs = true;
                textbox.SetText("using System;\npublic class Test {\n\tpublic static void Main(){\n\t\tConsole.WriteLine(\"Hello World\");\n\t}\n}");
                textbox.SetPosition(220, 10);
                textbox.SetSize(500, 150);
            }

            {
                Control.TextBoxPassword textbox = new Control.TextBoxPassword(this);
                //textbox.MaskCharacter = '@';
                textbox.SetText("secret");
                textbox.TextChanged += OnEdit;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Select All Text On Focus");
                textbox.SetPosition(10, 10 + 25 * row);
                textbox.SelectAllOnFocus = true;
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Different Coloured Text, for some reason");
                textbox.TextColor = Color.ForestGreen;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBoxNumeric(this);
                textbox.SetText("200456698");
                textbox.TextColor = Color.LightCoral;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("..............................................................");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("public override void SetText(string str, bool doEvents = true)");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("あおい うみから やってきた");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("..............................................................");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("public override void SetText(string str, bool doEvents = true)");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("あおい うみから やってきた");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Different Font (autosized)");
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font2;
                textbox.SizeToContents();

                row += 2;
            }
        }
コード例 #3
0
ファイル: TextBox.cs プロジェクト: slagusev/Gwen.CS
        public TextBox(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 */
                        {
                            Control.TextBox textbox = new Control.TextBox(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("Type something here");
                            textbox.TextChanged   += OnEdit;
                            textbox.SubmitPressed += OnSubmit;
                        }

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

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

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

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

                    /* Multiline Textbox */
                    {
                        Control.MultilineTextBox textbox = new Control.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.");
                    }
                    {
                        Control.Button pad = new Control.Button(dockLayout);
                        pad.Dock     = Dock.Right;
                        pad.Margin   = Margin.Five;
                        pad.Text     = "Pad";
                        pad.Clicked += (s, a) => new TextPad(this);
                    }
                }

                {
                    Control.TextBox textbox = new Control.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;
                }

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

                {
                    Control.TextBox textbox = new Control.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;
                }

                {
                    Control.TextBox textbox = new Control.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;
                }

                {
                    Control.TextBox textbox = new Control.TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.SetText("Different Font");
                    textbox.Font = m_Font2;
                }
            }
        }
コード例 #4
0
ファイル: TextBox.cs プロジェクト: Sprunth/gwen-dotnet
        public TextBox(Base parent)
            : base(parent)
        {
            int row = 0;

            m_Font1 = new Font(Skin.Renderer, "Consolas", 14); // fixed width font!
            m_Font2 = new Font(Skin.Renderer, "Impact", 50);
            m_Font3 = new Font(Skin.Renderer, "Arial", 14);

            /* Vanilla Textbox */
            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Type something here");
                textbox.SetPosition(10, 10 + 25 * row);
                textbox.TextChanged += OnEdit;
                textbox.SubmitPressed += OnSubmit;
                row++;
            }

            /* Multiline Textbox */
            {
                Control.MultilineTextBox textbox = new Control.MultilineTextBox(this);
                textbox.Font = m_Font1;
                textbox.AcceptTabs = true;
                textbox.SetText(
                    "using System;\npublic class Test {\n\tpublic static void Main(){\n\t\tConsole.WriteLine(\"Hello World\");\n\t}\n}");
                textbox.SetPosition(220, 10);
                textbox.SetSize(500, 150);
            }

            {
                Control.TextBoxPassword textbox = new Control.TextBoxPassword(this);
                //textbox.MaskCharacter = '@';
                textbox.SetText("secret");
                textbox.TextChanged += OnEdit;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Select All Text On Focus");
                textbox.SetPosition(10, 10 + 25 * row);
                textbox.SelectAllOnFocus = true;
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Different Coloured Text, for some reason");
                textbox.TextColor = Color.ForestGreen;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBoxNumeric(this);
                textbox.SetText("200456698");
                textbox.TextColor = Color.LightCoral;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("..............................................................");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("public override void SetText(string str, bool doEvents = true)");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("あおい うみから やってきた");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("..............................................................");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("public override void SetText(string str, bool doEvents = true)");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("あおい うみから やってきた");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Different Font (autosized)");
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font2;
                textbox.SizeToContents();

                row += 2;
            }
        }