Esempio n. 1
0
        public FormMain()
        {
            InitializeComponent();
            Global.MainWindow = this; // This is just so I can call WriteLog from other classes.

#if DEBUG
            this.Text += " (DEBUG)";
#endif

            _server = new UdpCommunication();
            _server.PacketReceived += ChatTwo_Server_Protocol.MessageReceivedHandler;
            ChatTwo_Server_Protocol.MessageTransmission += _server.SendPacket;
            _server.EtherConnectionReply += EtherConnectReply;

            notifyIcon1.BalloonTipTitle = this.Text;
            notifyIcon1.Text            = this.Text;
            notifyIcon1.Icon            = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

            // Steal the system "informaion icon" and resize it.
            _infoTip = SystemIcons.Information.ToBitmap();
            _infoTip = (Image)(new Bitmap(_infoTip, new Size(12, 12)));

            tabSqlTest.Parent = null;
        }
Esempio n. 2
0
        private void btnIpTest_Click(object sender, EventArgs e)
        {
            tbxIp_ExternalIpValuesChanged(null, null);
            btnIpTest.Enabled = false;

            if (chxIpUdp.Checked)
            {
                // Basic user feedback.
                toolStripStatusLabel1.Text = "Testing UDP port-forward...";
                statusStrip1.Refresh(); // Has to be done or the statusStrip won't display the new toolStripStatusLabel text.

                string errorMessage;
                string errorTip;
                System.Net.IPAddress address;
                if (System.Net.IPAddress.TryParse(tbxIpExternalAddress.Text, out address))
                {
                    // Check the result of the port-forward test.
                    bool portforwardTestStartSuccessful = UdpCommunication.TestPortforward(new System.Net.IPEndPoint(address, (int)nudIpExternalPort.Value));
                    if (portforwardTestStartSuccessful)
                    {
                        lblIpConnection.Text = "Test: testing...";
                        toolTip1.SetToolTip(lblIpConnection, "");
                        timer1.Start();
                        return;
                    }
                    else
                    {
                        errorMessage = "The UDP port-forward test failed";
                        errorTip     = "." + Environment.NewLine + Environment.NewLine +
                                       "Could not start the test. Please ensure you have an internet connection.";
                        lblIpConnection.Text = "Test: failed";
                    }
                }
                else
                {
                    errorMessage = "The entered external IP address is invalid";
                    errorTip     = "." + Environment.NewLine + Environment.NewLine +
                                   "Please enter a valid IP address." + Environment.NewLine +
                                   "If you don't know your external IP address, you can get it by googling \"what is my IP?\".";
                    lblIpConnection.Text = "Test: invalid IP address";
                }

                MessageBox.Show(errorMessage + errorTip, "Port-Forward Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                toolStripStatusLabel1.Text = "UDP port-forward test: failed. " + errorMessage;
                lblIpConnection.Image      = _infoTip;
                toolTip1.SetToolTip(lblIpConnection, errorMessage + errorTip);
            }
            if (chxIpTcp.Checked)
            {
                // Basic user feedback.
                toolStripStatusLabel1.Text = "Testing TCP port-forward...";
                statusStrip1.Refresh(); // Has to be done or the statusStrip won't display the new toolStripStatusLabel text.

                throw new NotImplementedException("TCP is not implemented yet.");
            }

            btnIpTest.Enabled = true;
        }