예제 #1
0
 public void OnDeleteExecuted(object parameter)
 {
     if (parameter != null)
     {
         PDFData data = (PDFData)parameter;
         AllPDFData.Remove(data);
     }
 }
예제 #2
0
        public void OnAddExecuted(object parameter)
        {
            if (AllPDFData == null)
            {
                AllPDFData = new ObservableCollection <PDFData>();
            }

            try
            {
                var dialog1 = new OpenFileDialog()
                {
                    Multiselect      = true,
                    InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                    Filter           = "PDF (*.pdf;*.PDF)|*.pdf;*.PDF",
                    Title            = "Select single or multiple files for PDF merging"
                };

                var resultOfDialog = dialog1.ShowDialog();

                if (resultOfDialog == true)
                {
                    if (dialog1.FileNames.Length > 0)
                    {
                        foreach (string file in dialog1.FileNames)
                        {
                            PDFData data = new PDFData()
                            {
                                Filename = file
                            };
                            AllPDFData.Add(data);
                        }
                    }
                }
                else
                {
                    if (AllPDFData.Count == 0)
                    {
                        AllPDFData = null;
                    }

                    MessageBox.Show("No files selected.",
                                    "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error message:\n\n" + ex.Message,
                                "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }