Beispiel #1
0
        /// <summary>
        ///     Potvrdí zadaná nastavení a vypne okno.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnPotvrdit_Click(object sender, EventArgs e)
        {
            try
            {
                UvodKlienta.Port = int.Parse(TxtPort.Text);

                if (RadioSv.Checked)
                {
                    UvodKlienta.Tema   = MaterialSkinManager.Themes.LIGHT;
                    UvodKlienta.Vzhled = new ColorScheme(Primary.LightBlue400, Primary.LightBlue900,
                                                         Primary.Cyan100, Accent.LightBlue400, TextShade.WHITE);
                }
                else if (RadioTm.Checked)
                {
                    UvodKlienta.Tema   = MaterialSkinManager.Themes.DARK;
                    UvodKlienta.Vzhled = new ColorScheme(Primary.LightBlue400, Primary.LightBlue900,
                                                         Primary.Cyan100, Accent.LightBlue400, TextShade.WHITE);
                }

                Close();
            }
            catch
            {
                MessageBox.Show("Byla zadána neplatná hodnota portu!", "Chyba!");
                TxtPort.Focus();
                TxtPort.SelectAll();
            }
        }
        private void Connect_Btn_Click(object sender, RoutedEventArgs e)
        {
            if (client_Socket.Connected)
            {
                MessageBox.Show("이미 연결되어 있습니다", "경고", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            int Client_Port;

            if (!int.TryParse(TxtPort.Text, out Client_Port))
            {
                MessageBox.Show("포트번호를 다시 입력해 주십시오", "경고", MessageBoxButton.OK, MessageBoxImage.Warning);
                TxtPort.Focus();
                TxtPort.SelectAll();
                return;
            }

            try
            {
                client_Socket.Connect(Txt_IPadRess.Text, Client_Port);
            }
            catch
            {
                MessageBox.Show("연결에 실패하였습니다", "에러", MessageBoxButton.OK, MessageBoxImage.Error);
                Txt_history.Text += string.Format("\n서버와 연결실패");
                return;
            }

            Txt_history.Text += string.Format("\n서버와 연결되었습니다");
            Client_AsyncObject obj = new Client_AsyncObject(4096);

            obj.Working_socket = client_Socket;
            client_Socket.BeginReceive(obj.Buffer, 0, obj.BufferSize, 0, DataReceived, obj);
        }