Esempio n. 1
0
        private void ChangeUserData(object sender, RoutedEventArgs e)
        {
            ChangeUserDataDialog    addUserDialog           = new ChangeUserDataDialog();
            UserDialogPreviewButton userDialogPreviewButton = null;


            foreach (var item in PreviewsPanel.Children)
            {
                if ((item as UserDialogPreviewButton).ID == CurrentChatID)
                {
                    userDialogPreviewButton = item as UserDialogPreviewButton;
                }
            }

            addUserDialog.UserName          = userDialogPreviewButton.UserName;
            addUserDialog.UserPhone         = userDialogPreviewButton.PhoneNumber;
            addUserDialog.CurrentPathToPict = userDialogPreviewButton.PictureURL;

            addUserDialog.ShowDialog();

            if (addUserDialog.DoexExecuted)
            {
                userDialogPreviewButton.UserName    = addUserDialog.NameTextBox.Text;
                userDialogPreviewButton.PhoneNumber = addUserDialog.NumberTextBox.Text;
                userDialogPreviewButton.PictureURL  = addUserDialog.CurrentPathToPict;
            }
        }
Esempio n. 2
0
        private void AddUserButton_Click(object sender, RoutedEventArgs e)
        {
            AddUserDialog addUserDialog = new AddUserDialog();

            addUserDialog.ShowDialog();

            UserDialogPreviewButton userDialogPreviewButton = new UserDialogPreviewButton(addUserDialog.NameTextBox.Text)
            {
                PhoneNumber = addUserDialog.NumberTextBox.Text, ID = GetBiggestID() + 1
            };

            Directory.CreateDirectory(Properties.Resources.UserDataDirPath + "\\" + userDialogPreviewButton.ID);

            if ((!File.Exists(Properties.Resources.UserDataDirPath + "\\" + userDialogPreviewButton.ID + "\\" + System.IO.Path.GetFileName(addUserDialog.CurrentPathToPict)) && File.Exists(addUserDialog.CurrentPathToPict)))
            {
                string destionation = Properties.Resources.UserDataDirPath + "\\" + userDialogPreviewButton.ID + "\\" + System.IO.Path.GetFileName(addUserDialog.CurrentPathToPict);
                File.Copy(addUserDialog.CurrentPathToPict, destionation);
                userDialogPreviewButton.PictureURL = destionation;
            }

            if (addUserDialog.DoexExecuted == true)
            {
                PreviewsPanel.Children.Add(userDialogPreviewButton);
            }
        }
Esempio n. 3
0
        private UserPreviewSerializableList GetPreviewSerList(long ID = long.MaxValue, Message msg = null)
        {
            UserPreviewSerializableList userPreviewSerializableList = new UserPreviewSerializableList();

            try
            {
                foreach (var inneritem in this.PreviewsPanel.Children)
                {
                    if (inneritem is UserDialogPreviewButton)
                    {
                        UserDialogPreviewButton item = inneritem as UserDialogPreviewButton;
                        UserPreviewSerializable userPreviewSerializable = new UserPreviewSerializable()
                        {
                            ID          = item.ID,
                            PhoneNumber = item.PhoneNumber,
                            PictureURL  = item.PictureURL,
                            UserName    = item.UserName,
                            LastMSG     = new Message()
                            {
                                SendDateTime = item.DateTimePreviewer, MessageText = item.TextPreview, MessageContentUrl = item.PictureURL, SenderName = item.UserName, MyTurn = item.MyTurn
                            }
                        };
                        userPreviewSerializableList.userPreviewSerializables.Add(userPreviewSerializable);
                        if (ID != long.MaxValue)
                        {
                            userPreviewSerializable.LastMSG = msg;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(userPreviewSerializableList);
        }