Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool check = ErrorControls.NotEmptyTextBox(tbName);

            if (check)
            {
                ReplyNewUser newUser = null;
                try
                {
                    // connect to the server ...
                    handler = new CallbackHandler();
                    site    = new InstanceContext(handler);
                    proxy   = new ConnectionClient(site);
                    // logging
                    newUser = proxy.Join(tbName.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                if (newUser != null)
                {
                    ClientWindow client = new ClientWindow(newUser);
                    client.Owner = this;
                    client.Show();
                    this.Hide();
                }
            }
        }
Ejemplo n.º 2
0
        public ClientWindow(ReplyNewUser newUser)
        {
            InitializeComponent();
            log         = Logging.GetInstance();
            this.Title  = newUser.User.Name;
            this.user   = newUser.User;
            listClients = newUser.Users.ToList();
            MyMessages(newUser.User.Name + " вошел в чат");
            PrivateDenied = new List <User>();
            // add smiles
            DirectoryInfo di = new DirectoryInfo("../../Smiles");

            DirectoryInfo[] resultDirectory = di.GetDirectories();
            DirectoryInfo[] dirs            = di.GetDirectories();
            FileInfo[]      files           = di.GetFiles();
            smiles = new Dictionary <string, string>();
            foreach (FileInfo file in files)
            {
                smiles.Add(additionalTeg + System.IO.Path.GetFileNameWithoutExtension(file.FullName) + additionalTeg, file.FullName);
            }
            foreach (var item in smiles)
            {
                DrawSmile(item);
            }
        }
Ejemplo n.º 3
0
 public ClientWindow(ReplyNewUser newUser)
 {
     InitializeComponent();
     this.Title  = newUser.User.Name;
     this.user   = newUser.User;
     listClients = newUser.Users.ToList();
     UpdateListClients();
     AddTextToResult(newUser.User.Name + " вошел в чат");
 }
Ejemplo n.º 4
0
        static private List <User> users = new List <User>(); // all connections to the server

        public ReplyNewUser Join(string userName)
        {
            User user = new User()
            {
                Id      = Guid.NewGuid().ToString(),
                Name    = userName,
                Context = OperationContext.Current
            };
            // send new client list of all users of the chat
            ReplyNewUser newUserReply = new ReplyNewUser();

            newUserReply.User  = user;
            newUserReply.Users = users.ToArray();
            // update new list of users
            AddNewUserToAll(user);
            // send message that the new user came
            SendMessageToAll(user.Name + " вошел в чат");
            // add the new user in the list
            users.Add(user);

            return(newUserReply);
        }