Beispiel #1
0
        public Setting()
        {
            Rectangle menu = new Rectangle(0, 0, Console.WindowWidth, 1);
            menu.BgColor = ConsoleColor.DarkBlue;
            Controls.Add(menu);

            buttonExit.OnSelect += new EventHandler(exit_OnSelect);
            buttonExit.BgColor = ConsoleColor.DarkBlue;
            Controls.Add(buttonExit);

            buttonSetting.BgColor = ConsoleColor.Black;
            Controls.Add(buttonSetting);
        }
Beispiel #2
0
        public override void Show()
        {
            if (setting == null)
            {
                setting = new HubSetting();
                int width = 20;
                int height = 5;
                int px = (Console.WindowWidth / 2) - width;
                int py = (Console.WindowHeight / 2) - height;

                Rectangle popup = new Rectangle(px, py, width * 2, height * 2, ConsoleColor.Gray, ConsoleColor.DarkBlue);
                popup.Show();

                Label popupTitle = new Label(px, py, "Connection Setting", width * 2);
                popupTitle.BgColor = ConsoleColor.Blue;
                popupTitle.FgColor = ConsoleColor.DarkBlue;
                popupTitle.Show();

                TextField address = new TextField(px + 1, py + 2, "IP/DNS:", 31);
                address.BgColor = ConsoleColor.DarkBlue;
                address.FgColor = ConsoleColor.Gray;
                address.Show();

                TextField port = new TextField(px + 1, py + 4, "Port:", 33);
                port.BgColor = ConsoleColor.DarkBlue;
                port.FgColor = ConsoleColor.Gray;
                port.Show();

                TextField nick = new TextField(px + 1, py + 6, "DisplayName:", 26);
                nick.BgColor = ConsoleColor.DarkBlue;
                nick.FgColor = ConsoleColor.Gray;
                nick.Show();

                Button buttonConnect = new Button(px + 1, py + 8, "Connect");
                buttonConnect.OnSelect += new EventHandler(buttonConnect_OnSelect);
                buttonConnect.BgColor = ConsoleColor.DarkBlue;
                buttonConnect.FgColor = ConsoleColor.Gray;
                buttonConnect.Show();

                // Select one at a time
                System.Net.IPAddress ip = null;
                do
                {
                    address.Focus();
                    if (!string.IsNullOrEmpty(address.Input))
                    {
                        try
                        {
                            ip = System.Net.Dns.GetHostEntry(address.Input).AddressList[0];
                        }
                        catch (System.Exception)
                        {
                            // We are not going to try to catch this as developer that used this class made something wrong if this has to be thrown.
                            try
                            {
                                ip = System.Net.IPAddress.Parse(address.Input);
                            }
                            catch { }
                        }
                    }
                } while (ip == null);
                setting.Address = address.Input;
                int p = 0;
                // Port
                do
                {
                    port.Focus();
                    try
                    {
                        p = int.Parse(port.Input);
                    }
                    catch { }
                } while (p <= 0 && p > 65535);
                setting.Port = p;

                do
                {
                    nick.Focus();
                } while (string.IsNullOrEmpty(nick.Input));
                setting.DisplayName = nick.Input;

                buttonConnect.Focus();

                setting.Protocol = "Auto";
                setting.Port = -1;
            }

            base.Show();
        }
Beispiel #3
0
        void MakeGui()
        {
            Rectangle menu = new Rectangle(0, 0, Console.WindowWidth, 1);
            menu.BgColor = ConsoleColor.DarkBlue;
            Controls.Add(menu);

            buttonExit.OnSelect += new EventHandler(exit_OnSelect);
            buttonExit.BgColor = ConsoleColor.DarkBlue;
            Controls.Add(buttonExit);

            buttonSetting.OnSelect += new EventHandler(settings_OnSelect);
            buttonSetting.BgColor = ConsoleColor.DarkBlue;
            Controls.Add(buttonSetting);

            buttonHub.OnSelect += new EventHandler(buttonHub_OnSelect);
            buttonHub.BgColor = ConsoleColor.DarkBlue;
            Controls.Add(buttonHub);

            Console.WriteLine("WindowWith" + Console.WindowWidth);
            Console.WriteLine("WindowHeight" + Console.WindowHeight);

            Console.WriteLine("BufferWith" + Console.BufferWidth);
            Console.WriteLine("BufferHeight" + Console.BufferHeight);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Welcome to this example on how to use FlowLib.");
            sb.AppendLine("");
            sb.AppendLine("If you think this exampe is to advanced.");
            sb.AppendLine("Please look in the examples directory");
            sb.AppendLine("where single functionality is demonstrated.");
            txtWelcome.Text = sb.ToString();
            Controls.Add(txtWelcome);
        }