コード例 #1
0
        private void AddCustom(object param)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = Global.PdfFilter;
            openFileDialog.Multiselect = true;
            openFileDialog.ShowDialog(Global.Dialogs.GetWindow(this));
            foreach (var fileName in openFileDialog.FileNames)
            {
                if (string.IsNullOrWhiteSpace(fileName) || !File.Exists(fileName))
                {
                    continue;
                }

                bool          add  = true;
                PartViewModel part = null;

                if (openFileDialog.FileNames.Length == 1) // if there is only one pdf to add, open window to edit properties of it
                {
                    EditPartViewModel dialogViewModel = new EditPartViewModel(openFileDialog.FileName);
                    Global.Dialogs.ShowDialog(this, dialogViewModel);
                    if (dialogViewModel.Result != EditPartViewModel.EditPartResult.Ok)
                    {
                        add = false;
                    }
                    else
                    {
                        part = dialogViewModel.Part;
                    }
                }
                else // if more then just add it
                {
                    part = PartViewModel.MakeCustom(fileName);
                    File.Copy(fileName, part.CustomPath);
                }

                if (add)
                {
                    m_searchResults.Add(part);
                    m_savedParts.Add(part);
                    part.LastUseDate = DateTime.MinValue;

                    ActionDialogViewModel actionDialogViewModel = new ActionDialogViewModel(part.ComputePagesCount(), Global.GetStringResource("StringCountingPages"));
                    Global.Dialogs.ShowDialog(this, actionDialogViewModel);
                }
            }

            m_filteredResults.Refresh();
        }
コード例 #2
0
 public EditPartViewModel(string originalPath)
     : this(PartViewModel.MakeCustom(originalPath))
 {
     m_addingOriginalPath = originalPath;
 }