public SinglesTesthelper(UnitTest1 test, Func <string, bool> funcFilter) { this.test = test; testdir = Path.Combine(Environment.CurrentDirectory, "testdir"); singlesFolder = Path.Combine(testdir, "singles"); test.AddLogEntry($"Test dir {testdir}"); if (!Directory.Exists(testdir)) { Directory.CreateDirectory(testdir); } foreach (var file in Directory.EnumerateFiles(testdir)) { File.Delete(file); } if (Directory.Exists(singlesFolder)) { foreach (var file in Directory.EnumerateFiles(singlesFolder)) { File.Delete(file); } Directory.Delete(singlesFolder, recursive: true); } Directory.CreateDirectory(singlesFolder); sourceFiles = Directory.GetFiles(Path.Combine(test.root1, @"ragtime\singles"), "*.pdf").OrderBy(p => p); foreach (var file in sourceFiles.OrderBy(f => f).Where(f => funcFilter(f))) { var dest = Path.Combine(singlesFolder, Path.GetFileName(file)); File.Copy(file, dest); } pdfViewerWindow = new SheetMusicViewer.PdfViewerWindow { _RootMusicFolder = testdir }; }
public ChooseMusic(PdfViewerWindow pdfViewerWindow) { InitializeComponent(); this.ShowInTaskbar = false; //this.Topmost = true; this.Owner = Application.Current.MainWindow; this._pdfViewerWindow = pdfViewerWindow; this.Loaded += ChooseMusic_Loaded; this.Top = _pdfViewerWindow.Top; this.Left = _pdfViewerWindow.Left; this.WindowState = WindowState.Maximized; }
private void LvTOC_TouchDown(object sender, TouchEventArgs e) { if (this.lvTOC.SelectedIndex >= 0) { if (PdfViewerWindow.IsDoubleTap(this.lvTOC, e)) { if (lvTOC.SelectedItem is TOCEntry curItem) { this.PageNumberResult = curItem.PageNo; this.DialogResult = true; this.Close(); } } } }
private void ImageButton_Click(object sender, RoutedEventArgs e) { PdfViewerWindow pdfViewer = new PdfViewerWindow { Owner = this, Topmost = true, Height = 1080, Width = 1920, Top = 0, WindowStartupLocation = WindowStartupLocation.Manual, }; pdfViewer.OpenPDF(@"F:\项目管理\智慧抚州\Exception Handling, VSTO.pdf"); pdfViewer.Show(); }
public MetaDataForm(PdfViewerWindow pdfViewerWindow) { InitializeComponent(); this._pdfViewerWindow = pdfViewerWindow; this.ShowInTaskbar = false; // this.Topmost = true; this.Owner = Application.Current.MainWindow; this.Title = pdfViewerWindow.currentPdfMetaData.GetFullPathFileFromVolno(0); LstTOC = new ObservableCollection <TOCEntry>(); foreach (var itm in pdfViewerWindow.currentPdfMetaData.lstTocEntries.OrderBy(p => p.PageNo)) { LstTOC.Add((TOCEntry)itm.Clone()); } LstVolInfo = new List <string>(); int volno = 0; var pgno = pdfViewerWindow.currentPdfMetaData.PageNumberOffset; foreach (var vol in pdfViewerWindow.currentPdfMetaData.lstVolInfo) { LstVolInfo.Add($"Vol={volno++} Pg= {pgno,3} {vol}"); pgno += vol.NPagesInThisVolume; } LstFavDisp = new ObservableCollection <FavDisp>(); foreach (var fav in pdfViewerWindow.currentPdfMetaData.dictFav.Values) { LstFavDisp.Add(new FavDisp() { PageNo = fav.Pageno, Description = pdfViewerWindow.currentPdfMetaData.GetDescription(fav.Pageno) }); } this.PageNumberOffset = pdfViewerWindow.currentPdfMetaData.PageNumberOffset; this.DocNotes = pdfViewerWindow.currentPdfMetaData.Notes; this.DataContext = this; this.Left = Properties.Settings.Default.EditWindowPos.Width; this.Top = Properties.Settings.Default.EditWindowPos.Height; this.Width = Properties.Settings.Default.EditWindowSize.Width; this.Height = Properties.Settings.Default.EditWindowSize.Height; this.Closed += (o, e) => { Properties.Settings.Default.EditWindowPos = new System.Drawing.Size((int)this.Left, (int)this.Top); Properties.Settings.Default.EditWindowSize = new System.Drawing.Size((int)this.ActualWidth, (int)this.ActualHeight); Properties.Settings.Default.Save(); }; }
public PageCache(PdfViewerWindow pdfViewerWindow) { this.pdfViewerWindow = pdfViewerWindow; }
async Task FillBookItemsAsync() { var lstBooks = this.lbBooks.ItemsSource as ObservableCollection <UIElement>; var lstFoldrs = this.lbfolders.ItemsSource as ObservableCollection <UIElement>; lstBooks.Clear(); var nBooks = 0; var nSongs = 0; var nPages = 0; var nFavs = 0; foreach (var pdfMetaDataItem in _pdfViewerWindow. lstPdfMetaFileData. OrderBy(p => { if (this.rbtnByDate.IsChecked == true) { var date = p.dtLastWrite; // (new System.IO.FileInfo(p.PdfBmkMetadataFileName)).LastWriteTime; return((DateTime.Now - date).TotalSeconds.ToString("0000000000")); } else if (this.rbtnByFolder.IsChecked == true) { return(p.GetFullPathFileFromVolno(volNo: 0, MakeRelative: true)); } else { return((100000 - p.NumPagesInSet).ToString("00000")); } })) { var includeThisItem = false; if (lstFoldrs.Count == 0) { includeThisItem = true; } else { foreach (CheckBox chk in lstFoldrs) { if (chk.IsChecked == true) { var str = chk.Content as string + System.IO.Path.DirectorySeparatorChar.ToString(); if (pdfMetaDataItem.GetFullPathFileFromVolno(volNo: 0, MakeRelative: true).IndexOf(str) >= 0) { includeThisItem = true; break; } } } } if (!includeThisItem && !pdfMetaDataItem.IsSinglesFolder) { continue; } if (tbxFilter.Text.Trim().Length > 0) { if (pdfMetaDataItem.GetFullPathFileFromVolno(volNo: 0, MakeRelative: true).IndexOf(tbxFilter.Text.Trim(), StringComparison.OrdinalIgnoreCase) < 0) { continue; } } var contentControl = new MyContentControl(pdfMetaDataItem); // ContentControl has doubleclick event var sp = new StackPanel() { Orientation = Orientation.Vertical }; await pdfMetaDataItem.GetBitmapImageThumbnailAsync(); var img = new Image() { Source = pdfMetaDataItem?.bitmapImageCache }; img.ToolTip = $"{pdfMetaDataItem} + {pdfMetaDataItem.dtLastWrite}"; sp.Children.Add(img); sp.Children.Add(new TextBlock() { Text = pdfMetaDataItem.GetFullPathFileFromVolno(volNo: 0, MakeRelative: true), ToolTip = pdfMetaDataItem.GetFullPathFileFromVolno(volNo: 0) }); var data = $"#Sngs={pdfMetaDataItem.GetSongCount()} Pg={pdfMetaDataItem.GetTotalPageCount()} Fav={pdfMetaDataItem.dictFav.Count}"; sp.Children.Add(new TextBlock() { Text = $"#Sngs={pdfMetaDataItem.GetSongCount()} Pg={pdfMetaDataItem.GetTotalPageCount()} Fav={pdfMetaDataItem.dictFav.Count}", ToolTip = data }); await Task.Delay(0); contentControl.Content = sp; lstBooks.Add(contentControl); contentControl.MouseDoubleClick += (o, e) => { BtnOk_Click(this, e); }; contentControl.TouchDown += (o, e) => { if (PdfViewerWindow.IsDoubleTap(this.lbBooks, e)) { this.lbBooks.SelectedItem = o; BtnOk_Click(o, e); } }; nBooks++; nSongs += pdfMetaDataItem.lstTocEntries.Count; nPages += pdfMetaDataItem.NumPagesInSet; nFavs += pdfMetaDataItem.dictFav.Count; } this.tbxTotals.Text = $@"Total #Books = { nBooks} # Songs = { nSongs:n0} # Pages = { nPages:n0} #Fav={ nFavs:n0}"; if (lstBooks.Count > 0) { this.lbBooks.ScrollIntoView(lstBooks[0]); } }