Exemple #1
0
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.ConnectToBbs != "connected")
            {
                // Connect
                Properties.Settings.Default.ConnectToBbs = "connecting";
                // display Settings form if the host or port info are missing
                if (Properties.Settings.Default.BbsHostOrIp == "" || Properties.Settings.Default.ChatPort == "")
                {
                    MainSettings frmSettings = new MainSettings();
                    frmSettings.ShowDialog();
                }
                // make sure user didn't cancel out of the settings
                if (Properties.Settings.Default.ConnectToBbs == "connecting")
                {
                    // display the Login form if login info is missing
                    if (Properties.Settings.Default.SysopUsername == "" || Properties.Settings.Default.SysopPassword == "" || Properties.Settings.Default.SystemPassword == "")
                    {
                        LoginForm frmLogin = new LoginForm();
                        frmLogin.ShowDialog();
                    }
                }
                // make sure user didn't cancel out of the login
                if (Properties.Settings.Default.ConnectToBbs == "connecting")
                {
                    client = new TcpClient();
                    IPHostEntry host;
                    host = Dns.GetHostEntry(Properties.Settings.Default.BbsHostOrIp);
                    IPEndPoint IpEnd = new IPEndPoint(host.AddressList[0], int.Parse(Properties.Settings.Default.ChatPort));
                    try
                    {
                        initnodedisplay("connect");
                        client.Connect(IpEnd);

                        if (client.Connected)
                        {
                            Properties.Settings.Default.ConnectToBbs = "connected";
                            toolStripButtonConnect.Image             = Properties.Resources.icons8_connected_nolan_50;
                            toolStripButtonConnect.Text          = "Disconnect";
                            connectToolStripMenuItem.Text        = "Disconnect";
                            enablePagerToolStripMenuItem.Enabled = true;
                            toolStripButtonEnablePager.Enabled   = true;
                            STW           = new StreamWriter(client.GetStream());
                            STR           = new StreamReader(client.GetStream());
                            STW.AutoFlush = true;
                            backgroundWorkerReceive.RunWorkerAsync();
                            backgroundWorkerSend.WorkerSupportsCancellation = true;
                            backgroundWorkerReceive.WorkerReportsProgress   = true;
                            string[] args = Environment.GetCommandLineArgs();
                            if (args.Length > 1)
                            {
                                // CHAT STATUS will be manual instead of timed when in debug mode
                                if (args[1] == "debugall")
                                {
                                }
                            }
                            else
                            {
                                timerGetStatus.Start();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("from Connect: " + ex.Message.ToString());
                    }
                }
            }
            else
            {
                // Disconnect
                timerGetStatus.Stop();
                TextToSend = "QUIT";
                backgroundWorkerSend.RunWorkerAsync();
                Properties.Settings.Default.ConnectToBbs = "disconnected";
                Properties.Settings.Default.PagerEnabled = false;
                clientauthenticated = false;

                // reset nodes back to the disconnected display
                initnodedisplay("disconnect");

                client.Close();
                resetnodestatuses();
            }
        }
Exemple #2
0
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MainSettings frmSettings = new MainSettings();

            frmSettings.ShowDialog();
        }