예제 #1
0
        private void Set_Click(object sender, EventArgs e)
        {
            string sNewHost  = HostNameBox.Text;
            string sNewPort  = PortName.Text;
            Int32  sPort_num = 0;

            ConnectingLabel.Text = "Connecting...";
            Application.DoEvents();
            try {
                sPort_num = Convert.ToInt32(sNewPort);
            }
            catch (FormatException e1)
            {
                sNewPort  = "0";
                sPort_num = 0;
            }

            ZumConsole.Properties.Settings.Default.Hostname = HostNameBox.Text;
            ZumConsole.Properties.Settings.Default.Port     = sPort_num;
            ZumConsole.Properties.Settings.Default.Save();

            /******Raise the event when OK button is pressed**********/
            NetUpdateEventArgs args = new NetUpdateEventArgs(sNewHost, sNewPort);

            NetParametersUpdated(this, args);
            /****************************************************/

            /******Raise the event of Form disposal **********/
            ConnFormCloseEventArgs args1 = new ConnFormCloseEventArgs(0x01);

            ConnFormClosing(this, args1);
            /****************************************************/

            this.Dispose();
        }
예제 #2
0
 // handles the event from form2
 private void Net_Settings_ButtonClicked(object sender, NetUpdateEventArgs e)
 {
     // update the forms values from the event args
     Hostname      = e.HostName;
     port_str      = e.PortName;
     PortNumber    = Convert.ToInt32(port_str, 10);
     tcp_stream    = net_conn.MakeConnection(Hostname, (int)PortNumber, Form1NeworkConnectionOwner);
     tcp_connected = net_conn.GetTcpConnected();
     if (tcp_connected)
     {
         SetHostNameText(Hostname + ":" + PortNumber);
     }
     else
     {
         SetHostNameText("Failed to connect to TCP");
     }
 }
예제 #3
0
        private void Net_Settings_ButtonClicked(object sender, NetUpdateEventArgs e)
        {
/*          If connection belongs to the current form3 and another connection parameters
 *          are requested,  existing connection may be closed and newly requested one
 *          can be established. If connection belongs to the console form1, newly
 *          requested parametrs should be ignored
 */
            if (net_conn.IsMyConnection(Form3NeworkConnectionOwner))
            {
                int PortNum = Convert.ToInt32(e.PortName);
                if ((net_conn.GetHostName() != e.HostName) || (net_conn.GetPort() != PortNum))
                {
                    net_conn.CloseConnection(Form3NeworkConnectionOwner);   //close if hostname or port differ
                    ChartInitialize();                                      //from current ones
                }
            }


            if (!net_conn.GetTcpConnected())
            {
                Hostname = e.HostName;
                String port_str = e.PortName;
                PortNumber = Convert.ToInt32(port_str, 10);
                tcp_stream = net_conn.MakeConnection(Hostname, (int)PortNumber, Form3NeworkConnectionOwner);
                if (net_conn.GetTcpConnected())
                {
                    SetHostNameText(Hostname + ":" + PortNumber);
                }
                else
                {
                    SetHostNameText("Failed to connect to TCP");
                }
            }

            else
            {
                tcp_stream = net_conn.GetStream();
                Hostname   = net_conn.GetHostName();
                PortNumber = net_conn.GetPort();
                SetHostNameText(Hostname + ":" + PortNumber);
            }
            tcp_connected = net_conn.GetTcpConnected();
        }