Пример #1
0
 public frmMainApp(ServerManager manager)
 {
     InitializeComponent();
     manager.ServerAdded += ServerAdded;
     this.manager = manager;
     this.tabs = new List<ServerTab>();
 }
Пример #2
0
        public ServerTab(ServerManager manager, PBUCONServer server)
        {
            this.manager = manager;
            this.server = server;

            // Create console box
            rtb = new RichTextBox();
            rtb.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
            rtb.BackColor = SystemColors.ControlLight;
            rtb.Font = new Font("Consolas", 9F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
            rtb.ForeColor = SystemColors.WindowText;
            rtb.Location = new Point(7, 7);
            rtb.ReadOnly = true;
            rtb.ScrollBars = RichTextBoxScrollBars.Vertical;
            rtb.Size = new Size(839, 354);
            rtb.TabIndex = 0;

            // Create send button
            sendButton = new Button();
            sendButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right)));
            sendButton.Font = new Font("Segoe UI", 9F);
            sendButton.Location = new Point(771, 367);
            sendButton.Size = new Size(75, 23);
            sendButton.TabIndex = 2;
            sendButton.Text = "Send";
            sendButton.UseVisualStyleBackColor = true;
            sendButton.Click += new EventHandler(sendButton_Click);

            // Create command bar
            commandBox = new TextBox();
            commandBox.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right)));
            commandBox.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            commandBox.Location = new Point(7, 367);
            commandBox.Size = new Size(758, 23);
            commandBox.TabIndex = 1;
            commandBox.KeyPress += new KeyPressEventHandler(commandBox_KeyPress);

            // Create tab page that holds everything
            tab = new TabPage();
            tab.ImageIndex = 0;
            tab.Location = new Point(4, 23);
            tab.Name = server.Name;
            tab.Padding = new Padding(3);
            tab.Size = new Size(852, 396);
            tab.TabIndex = 0;
            tab.Text = server.Name;
            tab.UseVisualStyleBackColor = true;

            tab.Controls.Add(rtb);
            tab.Controls.Add(commandBox);
            tab.Controls.Add(sendButton);

            // Add events to the server
            server.NewMessage += NewMessage;
            server.ServerChallengeChanged += ChallengeChange;

            // Show the client challenge
            rtb.AppendText("Client challenge: " + server.ClientChallenge.ToString("X8") + "\n");
        }
Пример #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ServerManager manager = new ServerManager();

            // Get external IP
            string ip;
            try
            {
                ip = getExternalIP();
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: Could not determine external IP. Either you're not connected to the internet or whatismyip.com is blocked.");
                Application.Exit();
                return;
            }

            // Decide on a port
            KeyValueConfigurationCollection appSettings = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings;

            int port;
            if (appSettings["ListenPort"] != null)
            {
                port = Convert.ToInt32(appSettings["ListenPort"].Value);
            }
            else
            {
                Random r = new Random();
                port = r.Next(49152, 65535);
            }

            manager.StartPBClient(ip, port);
            manager.MainApp.Text += " [IP: " + ip + " - Listen port: " + port + "]";

            // Add servers from config
            int numServers = Convert.ToInt32(appSettings["NumServers"].Value);
            for (int i = 1; i <= numServers; i++)
            {
                string setting = appSettings["Server" + i].Value;
                string[] settings = setting.Split(';');
                if (settings.Length == 5)
                {
                    manager.AddServer(settings[0], settings[1], Convert.ToInt32(settings[2]), settings[3], settings[4]);
                }
            }

            Application.Run(manager.MainApp);
        }
Пример #4
0
 public frmAddServer(ServerManager manager)
 {
     InitializeComponent();
     this.manager = manager;
 }
Пример #5
0
 public frmBroadcastCommand(ServerManager manager)
 {
     InitializeComponent();
     this.manager = manager;
 }