Example #1
0
        public void Start()
        {
            #region Чтение IP-адреса сервера

            string SettingsFileName = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\serverip.txt";
            SettingsFileName = SettingsFileName.Replace("file:\\", string.Empty);

            if (!File.Exists(SettingsFileName))
            {
                MessageBox.Show(string.Format("Не найден файл настроек [{0}]\r\n\r\nПриложение будет закрыто!", SettingsFileName));
                Application.Exit();
                return;
            }

            StreamReader SettingsFile = File.OpenText(SettingsFileName);

            string ServerIP;

            while ((ServerIP = SettingsFile.ReadLine()) != null)
            {
                if (ServerIP.Trim() != string.Empty)
                {
                    break;
                }
            }
            SettingsFile.Close();

            #endregion
            //ConnectionAgent = new ServerAgent("192.168.100.254", 8609, this, MainForm.DrawConnectionStatus, MainForm.ShowPingResult);

            try
            {
                ConnectionAgent = new ServerAgent(ServerIP, 8609, this, MainForm.DrawConnectionStatus, MainForm.ShowPingResult);
            }
            catch (Exception exp)
            {
                MessageBox.Show(string.Format("Ошибка создания агента сервера. Server IP = {0}\r\nОписание ошибки:\r\n{1}\r\nПриложение будет закрыто!", ServerIP, exp.Message));
                Application.Exit();
            }
            MainForm.ServerIP = ServerIP;

            StartConnectionAgent();

            Welcome();
        }
Example #2
0
        public void Start()
        {
            string serverIP;

            if (!readServerIP(out serverIP))
            {
                return;
            }

            try
            {
                ConnectionAgent = new ServerAgent(serverIP, 8609, this, MainForm.DrawConnectionStatus, MainForm.ShowPingResult);
            }
            catch (Exception exp)
            {
                MessageBox.Show(string.Format("Ошибка создания агента сервера. Server IP = {0}\r\nОписание ошибки:\r\n{1}\r\nПриложение будет закрыто!", serverIP, exp.Message));
                Application.Exit();
            }
            MainForm.ServerIP = serverIP;

            StartConnectionAgent();

            Welcome();
        }
Example #3
0
        public void Start()
        {
            string serverIP;
            if (!readServerIP(out serverIP)) return;

            try
                {
                ConnectionAgent = new ServerAgent(serverIP, 8609, this, MainForm.DrawConnectionStatus, MainForm.ShowPingResult);
                }
            catch (Exception exp)
                {
                MessageBox.Show(string.Format("Ошибка создания агента сервера. Server IP = {0}\r\nОписание ошибки:\r\n{1}\r\nПриложение будет закрыто!", serverIP, exp.Message));
                Application.Exit();
                }
            MainForm.ServerIP = serverIP;

            StartConnectionAgent();

            Welcome();
        }
Example #4
0
        public void Start()
        {
            #region Чтение IP-адреса сервера

            string SettingsFileName = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\serverip.txt";
            SettingsFileName = SettingsFileName.Replace("file:\\", string.Empty);

            if (!File.Exists(SettingsFileName))
            {
                MessageBox.Show(string.Format("Не найден файл настроек [{0}]\r\n\r\nПриложение будет закрыто!", SettingsFileName));
                Application.Exit();
                return;
            }

            StreamReader SettingsFile = File.OpenText(SettingsFileName);

            string ServerIP;

            while ((ServerIP = SettingsFile.ReadLine()) != null)
            {
                if (ServerIP.Trim() != string.Empty)
                {
                    break;
                }
            }
            SettingsFile.Close();

            #endregion
            //ConnectionAgent = new ServerAgent("192.168.100.254", 8609, this, MainForm.DrawConnectionStatus, MainForm.ShowPingResult);

            try
            {
                ConnectionAgent = new ServerAgent(ServerIP, 8609, this, MainForm.DrawConnectionStatus, MainForm.ShowPingResult);
            }
            catch (Exception exp)
            {
                MessageBox.Show(string.Format("Ошибка создания агента сервера. Server IP = {0}\r\nОписание ошибки:\r\n{1}\r\nПриложение будет закрыто!", ServerIP, exp.Message));
                Application.Exit();
            }
            MainForm.ServerIP = ServerIP;

            StartConnectionAgent();

            Welcome();
        }