Example #1
0
            public WelcomeFormEx()
            {
                AutoSize      = true;
                AutoSizeMode  = AutoSizeMode.GrowAndShrink;
                StartPosition = FormStartPosition.CenterScreen;

                TableLayoutPanel table = new TableLayoutPanel {
                    Dock = DockStyle.Fill, AutoSize = true
                };

                table.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50));
                table.Controls.Add(new Label {
                    Text = "Client: ", TextAlign = ContentAlignment.MiddleCenter
                }, 0, 0);
                table.Controls.Add(new Label {
                    Text = "Server: ", TextAlign = ContentAlignment.MiddleCenter
                }, 0, 1);
                table.Controls.Add(new Label {
                    Text = "Port: ", TextAlign = ContentAlignment.MiddleCenter
                }, 0, 2);
                table.Controls.Add(boxClient, 1, 0);
                table.Controls.Add(buttonClient, 2, 0);
                table.Controls.Add(boxServer, 1, 1);
                table.SetColumnSpan(boxServer, 2);
                table.Controls.Add(boxPort, 1, 2);
                table.SetColumnSpan(boxPort, 2);
                table.Controls.Add(buttonOK, 0, 3);
                table.SetColumnSpan(buttonOK, 3);
                Controls.Add(table);

                boxClient.Text      = ConfigEx.GetElement(Ultima.Client.GetFilePath("client.exe") ?? string.Empty, "Client");
                boxServer.Text      = ConfigEx.GetElement("185.21.223.28", "Server");
                boxPort.Text        = ConfigEx.GetElement("2593", "Port");
                buttonClient.Click += buttonClient_Click;
            }
Example #2
0
        static StartInfo()
        {
            if (ConfigEx.GetElement(true, "ShowWelcome"))
            {
                WelcomeFormEx form = new WelcomeFormEx();
                if (form.ShowDialog() != DialogResult.OK)
                {
                    Environment.Exit(0);
                }

                ConfigEx.SetElement(form.Client, "Client");
                ConfigEx.SetElement(form.Server, "Server");
                ConfigEx.SetElement(form.Port, "Port");
            }

            ClientPath = ConfigEx.GetElement(string.Empty, "Client");
            if (!File.Exists(ClientPath) || Path.GetExtension(ClientPath) != ".exe")
            {
                throw new Exception("Selected client path not found!");
            }

            Port = ConfigEx.GetElement(-1, "Port");
            if (Port < 0 || Port > 0xFFFF)
            {
                throw new Exception("Invalid port!");
            }

            Server = Engine.Resolve(ConfigEx.GetElement(string.Empty, "Server"));
            if (Equals(Server, IPAddress.None))
            {
                throw new Exception("Invalid server address!");
            }
        }