Пример #1
0
        private void ConnectButtonClick(object sender, RoutedEventArgs e)
        {
            if(string.IsNullOrEmpty(ServerBox.Text) || string.IsNullOrEmpty(PasswordBox.Password))
            {
                System.Windows.MessageBox.Show("You didn't fill in the required fields.", "Error!",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                return;
            }

            try
            {
                _server = ServerBox.Text;
                _password = PasswordBox.Password;
                _rmc = new RemoteClient("BasicHttpBinding_IRemote",
                                           new EndpointAddress(_server));

                _rmc.Open();

                if(!_rmc.Authorize(Utility.MD5String(_password)))
                {
                    System.Windows.MessageBox.Show("Invalid password entered!", "Error!", MessageBoxButton.OK,
                                    MessageBoxImage.Error);

                    _rmc.Close();

                    return;
                }

            }
            catch(Exception x)
            {
                System.Windows.MessageBox.Show(string.Format("Something unexpexted happened! Please report this to devs!{0}{1}---------------------------------------------------------------------------{2}{3}",
                    Environment.NewLine,
                    Environment.NewLine,
                    Environment.NewLine,
                    x), "Error!",   MessageBoxButton.OK,
                                    MessageBoxImage.Error);

                _rmc.Close();

                return;
            }

            MessageTab.IsEnabled = true;

            System.Windows.MessageBox.Show("Connection successful!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
            _connected = true;
        }