Esempio n. 1
0
 public void OnDeleteExecuted(object parameter)
 {
     if (parameter != null)
     {
         PDFData data = (PDFData)parameter;
         AllPDFData.Remove(data);
     }
 }
Esempio n. 2
0
        /*
         *
         * Public Constructor
         *
         */

        public ViewModel()
        {
            _pdfData = new PDFData();

            AddCommand             = new PDFCommand(OnAddExecuted, OnAddCanExecute);
            MergeCommand           = new PDFCommand(OnMergeExecuted, OnMergeCanExecute);
            MoveUpCommand          = new PDFCommand(OnMoveUpExecuted, OnMoveUpCanExecute);
            MoveDownCommand        = new PDFCommand(OnMoveDownExecuted, OnMoveDownCanExecute);
            LeftDoubleClickCommand = new PDFCommand(OnLeftDoubleClickExecuted, OnLeftDoubleClickCanExecute);
            DeleteCommand          = new PDFCommand(OnDeleteExecuted, OnDeleteCanExecute);
            ResetCommand           = new PDFCommand(OnResetExecuted, OnResetCanExecute);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        public void OnLeftDoubleClickExecuted(object parameter)
        {
            if (parameter != null)
            {
                PDFData data = (PDFData)parameter;

                try
                {
                    PDFViewer pdfViewer = new PDFViewer();
                    pdfViewer.SetPDFPath(data.Filename);
                    pdfViewer.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error message:\n\n" + ex.Message,
                                    "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }