private async Task OpenFilePDFViewer(IStorageFile file, FileAccessMode mode) { if (file == null) { return; } Windows.Storage.Streams.IRandomAccessStream stream; try { stream = await file.OpenAsync(mode); } catch (Exception e) { // NOTE: If file already opened it will cause an exception var msg = new MessageDialog(e.Message); _ = msg.ShowAsync(); return; } PDFDoc doc = new PDFDoc(stream); doc.InitSecurityHandler(); // Set loaded doc to PDFView Controler PDFViewCtrl.SetDoc(doc); ThumbnailViewer = new ThumbnailViewer(PDFViewCtrl, file.Path); }
/// <summary> /// Initializes a new instance of the <see cref="ThumbnailViewerSettingsForm"/> class. /// </summary> /// <param name="viewer">The thumbnail viewer.</param> public ThumbnailViewerSettingsForm(ThumbnailViewer viewer) : this() { _viewer = viewer; _normalThumbnailAppearance = new ThumbnailAppearance(viewer.ThumbnailAppearance); _focusedThumbnailAppearance = new ThumbnailAppearance(viewer.FocusedThumbnailAppearance); _hoveredThumbnailAppearance = new ThumbnailAppearance(viewer.HoveredThumbnailAppearance); _selectedThumbnailAppearance = new ThumbnailAppearance(viewer.SelectedThumbnailAppearance); _notReadyThumbnailAppearance = new ThumbnailAppearance(viewer.NotReadyThumbnailAppearance); thumbnailAppearanceComboBox.SelectedIndex = 0; ShowSettings(); }
double DEFAULT_ZOOM_REGION_STEP = 2.5; // Amount of zoom when zooming to a specific region by right mouse click #endregion public MainPageViewModel() { // Initialize commands CMDOpenFile = new RelayCommand(OpenFile); CMDConvertFile = new RelayCommand(ConvertFile); CMDPrintDoc = new RelayCommand(PrintDoc); CMDExitApplication = new RelayCommand(ExitApplication); CMDTextAnnotation = new RelayCommand(TextAnnotationSample); CMDPreviousPage = new RelayCommand(PreviousPage); CMDNextPage = new RelayCommand(NextPage); CMDZoomIn = new RelayCommand(ZoomIn); CMDZoomOut = new RelayCommand(ZoomOut); CMDSaveDocAs = new RelayCommand(SaveDocAs); // Set control background color to gray PDFViewCtrl.SetBackgroundColor(Windows.UI.Color.FromArgb(100, 49, 51, 53)); // Initialize PDFView with a PDF document to be displayed PDFDoc doc = new PDFDoc("Resources/GettingStarted.pdf"); PDFViewCtrl.SetDoc(doc); PDFViewCtrl.AllowDrop = true; PDFViewCtrl.Drop += PDFViewCtrl_Drop; PDFViewCtrl.DragOver += PDFViewCtrl_DragOver; // ToolManager is initialized with the PDFViewCtrl and it activates all available tools _toolManagerPDF = new ToolManager(PDFViewCtrl); // Set Undo and Redo Manager UndoRedoManager undoRedoManager = new UndoRedoManager(); _toolManagerPDF.SetUndoRedoManager(undoRedoManager); _toolManagerPDF.IsSignatureDialogFullScreen = false; // AnnotationCommandBar is initialized with the ToolManager so it can attach all events to it _AnnotationCommandBar = new AnnotationCommandBar(_toolManagerPDF); // ThumbnailViewer is initialized by passing the PDFViewerCtrl and a document tag/name ThumbnailViewer = new ThumbnailViewer(PDFViewCtrl, "GettingStarted"); // Set up resource path for conversion pdftron.PDFNet.AddResourceSearchPath(System.IO.Path.Combine(Package.Current.InstalledLocation.Path, "Resources")); // Set up Print Manager InitPrintManager(); }
/// <summary> /// Convert a document to PDF format /// </summary> async private void ConvertFile() { FileOpenPicker filePicker = new FileOpenPicker(); filePicker.ViewMode = PickerViewMode.List; filePicker.FileTypeFilter.Add(".doc"); filePicker.FileTypeFilter.Add(".docx"); StorageFile file = await filePicker.PickSingleFileAsync(); if (file == null) { return; } Windows.Storage.Streams.IRandomAccessStream stream; try { stream = await file.OpenAsync(FileAccessMode.ReadWrite); } catch (Exception e) { // NOTE: If file already opened it will cause an exception var msg = new MessageDialog(e.Message); _ = msg.ShowAsync(); return; } // Convert Logic IFilter filter = new RandomAccessStreamFilter(stream); WordToPDFOptions opts = new WordToPDFOptions(); DocumentConversion conversion = pdftron.PDF.Convert.UniversalConversion(filter, opts); var convRslt = conversion.TryConvert(); if (convRslt == DocumentConversionResult.e_document_conversion_success) { PDFDoc doc = conversion.GetDoc(); doc.InitSecurityHandler(); PDFViewCtrl.SetDoc(doc); ThumbnailViewer = new ThumbnailViewer(PDFViewCtrl, file.Path); } }
//Where shit happens private void frmMain_Load(object sender, EventArgs e) { frmSplash splash = new frmSplash(); splash.Show(); Application.DoEvents(); //Tray icon nico.Icon = this.Icon; nico.DoubleClick += delegate(object lol, EventArgs dongs) { this.Visible = !this.Visible; }; nico.Visible = true; //Size in title tFixTitle.Interval = 2000; tFixTitle.Tick += delegate(object lol, EventArgs dongs) { tFixTitle.Stop(); Main_Title.Text = Application. ProductName + " v0.0.1"; }; tFixTitle.Start(); //Slideshow timer tSlideshow.Tick += delegate(object lol, EventArgs dongs) { Footer_cmNext_Click(lol, dongs); }; tSlideshow.Interval = 5000; //Thumbnail viewer thViewer = new ThumbnailViewer(pnMain); pnaSide = new Panel[] { pnSide }; pnaMain = new Panel[] { pnMain, pnDisp }; //Main panel bg if (System.IO.Directory.Exists("skin\\tan") && System.IO.Directory.GetFiles("skin\\tan", "*.png").Length > 0) { pnMainBG = new PictureBox(); pnMainBG.Visible = true; pnMain.Controls.Add(pnMainBG); TanPick(); } //Assign graphics Resources.Prep(); Main_Minimize.Image = Resources.getr("min"); Main_Maximize.Image = Resources.getr("max"); Main_Close.Image = Resources.getr("close"); SidebarToggle.Image = Resources.getr("close"); SidebarUndock.Image = Resources.getr("max"); SidebarChange.Image = Resources.getr("min"); //Hotkeys bullshit tConKeys.Visible = true; tConKeys.Size = new Size(1, 1); tConKeys.Location = new Point(-8, -8); tConKeys.KeyDown += new KeyEventHandler(bConKeys_KeyDown); this.Controls.Add(tConKeys); //this.Size = new Size(800, 480); this.Opacity = 0; this.Show(); Application.DoEvents(); bLoaded = true; frmMain_Resize(new object(), new EventArgs()); System.Threading.Thread.Sleep(500); for (int a = 0; a <= 10; a++) { this.Opacity = (double)a / 10; Application.DoEvents(); System.Threading.Thread.Sleep(10); } System.Threading.Thread.Sleep(250); splash.Close(); splash.Dispose(); }
/// <summary> /// Starts printing the images. /// </summary> /// <param name="showPrintDialog">Defines if print dialog should be shown.</param> /// <param name="reverse">Defines if pages should be printed in reverse order.</param> public void Print(bool showPrintDialog, bool reverse) { if (_isPrintingStarted) { return; } _isPrintingStarted = true; try { if (_imageViewer.Images.Count == 0) { return; } if (_imagesToPrint != null) { DemosTools.ShowWarningMessage("Another print process is still working."); return; } if (showPrintDialog) { // show print dialog DialogResult dialogResult = _printDialog.ShowDialog(); // PrintDialog control has bug and sometimes does not show print dialog and returns // Cancel as a result of execution of the ShowDialog method. This problem can be solved // if you will set the UseEXDialog property to True. if (dialogResult == DialogResult.Cancel) { _printDialog.UseEXDialog = true; dialogResult = _printDialog.ShowDialog(); } // start print if dialog results is OK if (dialogResult != DialogResult.OK) { return; } } switch (_printDialog.PrinterSettings.PrintRange) { case PrintRange.AllPages: _imagesToPrint = new int[_imageViewer.Images.Count]; for (int i = 0; i < _imagesToPrint.Length; i++) { _imagesToPrint[i] = i; } break; case PrintRange.SomePages: _imagesToPrint = new int[_printDialog.PrinterSettings.ToPage - _printDialog.PrinterSettings.FromPage + 1]; for (int i = 0; i < _imagesToPrint.Length; i++) { _imagesToPrint[i] = _printDialog.PrinterSettings.FromPage + i - 1; } break; case PrintRange.Selection: ThumbnailViewer thumbnailViewer = _imageViewer as ThumbnailViewer; if (thumbnailViewer != null && thumbnailViewer.SelectedIndices.Count > 0) { _imagesToPrint = thumbnailViewer.SelectedIndices.ToArray(); } else { _imagesToPrint = new int[1] { _imageViewer.FocusedIndex } }; break; case PrintRange.CurrentPage: _imagesToPrint = new int[1] { _imageViewer.FocusedIndex }; break; } if (reverse && _imagesToPrint.Length > 1) { Array.Reverse(_imagesToPrint); } _printDocument.Print(); } finally { _isPrintingStarted = false; } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this._searchTermsBox = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this._searchButton = new System.Windows.Forms.Button(); this._okButton = new System.Windows.Forms.Button(); this._notFoundLabel = new System.Windows.Forms.Label(); this._thumbnailViewer = new Palaso.UI.WindowsForms.ImageGallery.ThumbnailViewer(); this._localizationHelper = new Palaso.UI.WindowsForms.i18n.LocalizationHelper(this.components); ((System.ComponentModel.ISupportInitialize)(this._localizationHelper)).BeginInit(); this.SuspendLayout(); // // _searchTermsBox // this._searchTermsBox.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this._searchTermsBox.Location = new System.Drawing.Point(109, 18); this._searchTermsBox.Name = "_searchTermsBox"; this._searchTermsBox.Size = new System.Drawing.Size(232, 24); this._searchTermsBox.TabIndex = 1; // // label1 // this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); this.label1.Location = new System.Drawing.Point(12, 21); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(91, 28); this.label1.TabIndex = 2; this.label1.Text = "~Search Words"; // // _searchButton // this._searchButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); this._searchButton.Location = new System.Drawing.Point(358, 15); this._searchButton.Name = "_searchButton"; this._searchButton.Size = new System.Drawing.Size(106, 35); this._searchButton.TabIndex = 3; this._searchButton.Text = "~&Search"; this._searchButton.UseVisualStyleBackColor = true; this._searchButton.Click += new System.EventHandler(this._searchButton_Click); // // _okButton // this._okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this._okButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); this._okButton.Location = new System.Drawing.Point(523, 15); this._okButton.Name = "_okButton"; this._okButton.Size = new System.Drawing.Size(104, 35); this._okButton.TabIndex = 4; this._okButton.Text = "~&OK"; this._okButton.UseVisualStyleBackColor = true; this._okButton.Click += new System.EventHandler(this._okButton_Click); // // _notFoundLabel // this._notFoundLabel.AutoSize = true; this._notFoundLabel.BackColor = System.Drawing.SystemColors.Window; this._notFoundLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); this._notFoundLabel.ForeColor = System.Drawing.Color.Gray; this._notFoundLabel.Location = new System.Drawing.Point(58, 92); this._notFoundLabel.Name = "_notFoundLabel"; this._notFoundLabel.Size = new System.Drawing.Size(196, 25); this._notFoundLabel.TabIndex = 5; this._notFoundLabel.Text = "~No matching images"; this._notFoundLabel.Visible = false; // // _thumbnailViewer // this._thumbnailViewer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this._thumbnailViewer.CanLoad = false; this._thumbnailViewer.CaptionMethod = null; this._thumbnailViewer.Location = new System.Drawing.Point(0, 66); this._thumbnailViewer.MultiSelect = false; this._thumbnailViewer.Name = "_thumbnailViewer"; this._thumbnailViewer.Size = new System.Drawing.Size(627, 534); this._thumbnailViewer.TabIndex = 0; this._thumbnailViewer.ThumbBorderColor = System.Drawing.Color.Wheat; this._thumbnailViewer.ThumbNailSize = 95; this._thumbnailViewer.UseCompatibleStateImageBehavior = false; this._thumbnailViewer.SelectedIndexChanged += new System.EventHandler(this._thumbnailViewer_SelectedIndexChanged); this._thumbnailViewer.DoubleClick += new System.EventHandler(this._thumbnailViewer_DoubleClick); // // _localizationHelper // this._localizationHelper.Parent = this; // // PictureChooser // this.AcceptButton = this._searchButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(639, 612); this.Controls.Add(this._notFoundLabel); this.Controls.Add(this._okButton); this.Controls.Add(this._searchButton); this.Controls.Add(this.label1); this.Controls.Add(this._searchTermsBox); this.Controls.Add(this._thumbnailViewer); this.MaximizeBox = false; this.Name = "PictureChooser"; this.ShowIcon = false; this.ShowInTaskbar = false; this.Text = "~Search Image Gallery"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.PictureChooser_Load); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PictureChooser_FormClosing); ((System.ComponentModel.ISupportInitialize)(this._localizationHelper)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); }