Пример #1
0
        private void RowButtonEncryptedCall_Click(object sender, RoutedEventArgs args)
        {
            if (!callingService.isCalling && !callingService.isBusy)
            {
                CscUserMainData data = ((FrameworkElement)sender).DataContext as CscUserMainData;
                var             text = string.Format("{0} - {1} - {2}", data.FriendName, data.Ip, data.Email);

                Trace.WriteLine(text);

                if (data.Status == 1)
                {
                    try
                    {
                        IPEndPoint iPEndPoint =
                            new IPEndPoint(IPAddress.Parse(data.Ip), callingService.localEndPoint.Port);

                        Task.Run(() =>
                        {
                            callingService.EncryptedCallSender = true;
                            callingService.MakeCall(iPEndPoint, client.UserProfile.Email, data.Email);
                        });
                    }
                    catch (Exception ex)
                    { MessageBox.Show(ex.Message); }
                }
                else
                {
                    MessageBox.Show("Użytkownik nie jest dostępny");
                }
            }
            else
            {
                MessageBox.Show("Jesteś w trakcie rozmowy");
            }
        }
        public void AddOnlineUser(CscUserMainData user)
        {
            if (!String.IsNullOrEmpty(user.FriendName))
            {
                user.CanBeRemoved = true;
            }
            else
            {
                user.IsNotFriend = true;
            }


            Dispatcher.Invoke(new Action(() => client.onlineUsers.Add(user)));

            //var friend = client.FriendsList.Where(u => u.Id == user.Id).FirstOrDefault();
            //if (friend != null)
            //{
            //    CscUserMainData newUser = new CscUserMainData() { Email = friend.Email, Id = friend.Id, Ip = friend.Ip, FriendName = friend.FriendName, Status = 1 };
            //    Dispatcher.Invoke(new Action(() =>
            //    {
            //        client.FriendsList.Remove(friend);
            //        client.FriendsList.Add(newUser);
            //    }
            //    ));
            //}
        }
Пример #3
0
 public Client()
 {
     client             = new TcpClient();
     UserProfile        = new CscUserMainData();//n
     LastConfirmMessage = string.Empty;
     LastErrorMessage   = string.Empty;
 }
Пример #4
0
        private void RowButtonEditNickname_Click(object sender, RoutedEventArgs args)
        {
            CscUserMainData data = ((FrameworkElement)sender).DataContext as CscUserMainData;

            if (client.FriendsList.FirstOrDefault(u => u.Id == data.Id) != null)
            {
                FriendsListEditWindow window = new FriendsListEditWindow(FriendsListDataGrid, client, data, true);
                window.ShowDialog();
            }
        }
        //public void UpdateProfileEmail(CscUserMainData profile)
        //{
        //    Dispatcher.Invoke(new Action(() =>
        //    {
        //        UserEmailLabel.Text = profile.Email;
        //    }));
        //}

        private void AddFriendToObsCollection(CscUserMainData friendData)
        {
            Dispatcher.Invoke(new Action(() =>
            {
                friendData.IsNotFriend  = false;
                friendData.CanBeRemoved = true;
                client.FriendsList.Add(friendData);
            }
                                         ));
        }
        public void AddSearchUser(CscUserMainData user)
        {
            if (!String.IsNullOrEmpty(user.FriendName))
            {
                user.CanBeRemoved = true;
            }
            else
            {
                user.IsNotFriend = true;
            }

            Dispatcher.Invoke(new Action(() => client.SearchedUsers.Add(user)));
        }
 private void RemoveFriendToObsCollection(CscUserMainData userToRemove)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         try
         {
             client.FriendsList.Remove(client.FriendsList.FirstOrDefault(u => u.Id == userToRemove.Id));
         }
         catch (Exception)
         { return; }
     }
                                  ));
 }
        public void RemoveOnlineUser(CscUserMainData user)
        {
            Dispatcher.Invoke(new Action(() => client.onlineUsers.Remove(user)));

            //var friend = client.FriendsList.Where(u => u.Id == user.Id).FirstOrDefault();
            //if (friend != null)
            //{
            //    CscUserMainData newUser = new CscUserMainData() { Email = friend.Email, Id = friend.Id, Ip = "", FriendName = friend.FriendName, Status = 0 };
            //    Dispatcher.Invoke(new Action(() =>
            //    {
            //        client.FriendsList.Remove(friend);
            //        client.FriendsList.Add(newUser);
            //    }
            //    ));
            //}
        }
Пример #9
0
        private void RowButtonRemoveFriend_Click(object sender, RoutedEventArgs args)
        {
            CscUserMainData data = ((FrameworkElement)sender).DataContext as CscUserMainData;

            if (!String.IsNullOrEmpty(data.FriendName))
            {
                client.SendRemoveUserFromFriendsListDataRequestEncrypted(new CscChangeFriendData {
                    Id = data.Id, FriendName = data.FriendName
                });
                client.SearchedUsers.Remove(data);
                data.FriendName   = String.Empty;
                data.CanBeRemoved = false;
                data.IsNotFriend  = true;
                client.SearchedUsers.Add(data);
            }
            else
            {
                FriendsListEditWindow window = new FriendsListEditWindow(FriendsListDataGrid, client, data, false);
                window.ShowDialog();
            }
        }
        public FriendsListEditWindow(DataGrid usersGrid, Client client, CscUserMainData userdata, bool changeName)
        {
            this.client     = client;
            parentUsersGrid = usersGrid;
            friendData      = userdata;
            InitializeComponent();
            if (userdata.Email.Length >= 20)
            {
                EmailTextBlock.FontSize = 20;
            }
            else
            {
                EmailTextBlock.FontSize = 25;
            }
            EmailTextBlock.Text = userdata.Email;
            this.changeName     = changeName;

            if (changeName)
            {
                UsernameTextBox.Text            = friendData.FriendName;
                EditFavouriteUserButton.Content = "Edytuj";
            }
        }