private void MenuItemAttachFolder_Click(object sender, RoutedEventArgs e)
 {
     FolderDialog dialog = new FolderDialog();
     dialog.Folder = Settings.Default.LastSendDirectory;
     if (dialog.ShowDialog(this) == true)
     {
         Settings.Default.LastSendDirectory = dialog.Folder;
         MessagerViewModel.Instance.AttachDirectory(MessageContext, dialog.Folder);
         AutoAdjustHeight();
     }
 }
        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            if (button == null)
                return;

            var attachments = ((button.Tag) as ListBox).ItemsSource as List<Checkable<Attachment>>;
            if (attachments == null)
                return;

            var message = button.DataContext as Message;
            if (message == null)
                return;
            var selected = (from Checkable<Attachment> file in attachments
                            where file.Checked
                            select file.Item)
                              .ToArray();

            if (selected.Length > 0)
            {
                FolderDialog dialog = new FolderDialog();
                dialog.Folder = Settings.Default.LastReceivedDirectory;
                if (dialog.ShowDialog(this) == true)
                {
                    Settings.Default.LastReceivedDirectory = dialog.Folder;
                    System.Threading.Thread thread = new System.Threading.Thread(delegate ()
                    {
                        Messager.ReceiveFiles(message, selected, dialog.Folder, startProgress, updateProgressBar, endProgress);
                        fileReceived = true;
                    });
                    thread.Start();
                }
            }
        }
 private async void AttachFolderExecute(object parameter)
 {
     var messager = parameter as MessagerModel;
     if (messager == null)
         return;
     FolderDialog dialog = new FolderDialog();
     dialog.Folder = Settings.Default.LastSendDirectory;
     if (dialog.ShowDialog(Application.Current.MainWindow) == true)
     {
         Settings.Default.LastSendDirectory = dialog.Folder;
         AttachDirectory(messager,dialog.Folder);
         //AutoAdjustHeight();
     }
 }