public DocumentViewerVm(DocumentViewer documentView, ICommonService service) : base(service) { currentDocumentView = documentView; _service = service; InitVm(); }
private static void OnDocumentViewerContextMenuOpening(object sender, ContextMenuEventArgs e) { if (e.CursorLeft == KeyboardInvokedSentinel) { DocumentViewer dv = sender as DocumentViewer; if (dv != null && dv.ScrollViewer != null) { OnContextMenuOpening(dv.ScrollViewer.Content, e); } } }
/// <summary> /// 加载文件到文档 /// </summary> /// <param name="documentViewer1"></param> public static void LoadDocument(this DocumentViewer documentViewer1) { var dialog = new OpenFileDialog(); dialog.Filter = "XPS 文档(*.xps)|*.xps"; if (dialog.ShowDialog() == true) { XpsDocument doc = new XpsDocument(dialog.FileName, FileAccess.Read); documentViewer1.Document = doc.GetFixedDocumentSequence(); } }
public ViewContextMenu(DocumentViewer documentViewer, Action selectAllTextAction) { _commandsBinder = new CommandsBinder(documentViewer); _commandsBinder.Items.Add(new CommandBinderItem { CommandNames = new string[] { DocumentViewerCommands.TextCopy, DocumentViewerCommands.AnnotationsCopy }, ToolStripItem = this.Items.Add("Copy") }); _commandsBinder.Items.Add(new CommandBinderItem { CommandName = DocumentViewerCommands.AnnotationsPaste, ToolStripItem = this.Items.Add("Paste"), GetValue = (() => { // The paste position, in viewer coordinates var position = documentViewer.View.ImageViewer.PointToClient(_openingPosition); return(LeadPoint.Create(position.X, position.Y)); }) }); _commandsBinder.Items.Add(new CommandBinderItem { CommandName = DocumentViewerCommands.AnnotationsDelete, ToolStripItem = this.Items.Add("Delete") }); this.Items.Add(new ToolStripSeparator()); _commandsBinder.Items.Add(new CommandBinderItem { CommandName = DocumentViewerCommands.TextSelectAll, ToolStripItem = this.Items.Add("Select all", null, new EventHandler(delegate { selectAllTextAction(); })), AutoRun = false }); _commandsBinder.Items.Add(new CommandBinderItem { CommandName = DocumentViewerCommands.AnnotationsSelectAll, ToolStripItem = this.Items.Add("Select all annotations") }); _commandsBinder.Items.Add(new CommandBinderItem { CommandNames = new string[] { DocumentViewerCommands.TextClearSelection, DocumentViewerCommands.AnnotationsClearSelection }, ToolStripItem = this.Items.Add("Clear selection") }); _commandsBinder.BindActions(true); _commandsBinder.Run(); }
private void InitDocumentViewer() { // Create the document viewer using panels of a System.Windows.Forms.SplitterPanel var createOptions = new Leadtools.Documents.UI.DocumentViewerCreateOptions(); createOptions.ViewContainer = this.splitContainer1.Panel2; createOptions.ThumbnailsContainer = this.splitContainer1.Panel1; _documentViewer = DocumentViewerFactory.CreateDocumentViewer(createOptions); _documentViewer.View.PreferredItemType = DocumentViewerItemType.Svg; _documentViewer.Commands.Run(DocumentViewerCommands.InteractivePanZoom); _documentViewer.Text.AutoGetText = true; }
public IActionResult UsingLayout() { var documentViewer = new DocumentViewer { Width = 800, Height = 600, Resizable = true, Document = "~/App_Data/ExampleFiles/Default.pdf" }; return(View(documentViewer)); }
private void ReportViewer_Load(object sender, EventArgs e) { var viewer = new DocumentViewer(); //using DevExpress.XtraPrinting.Preview viewer.Dock = DockStyle.Fill; panel2.Controls.Add(viewer); var report = new XtraReport1(); viewer.DocumentSource = report; report.CreateDocument(); }
public static void Print(this GridViewDataControl source, bool showDialog) { var dialog = new PrintDialog(); var dialogResult = showDialog ? dialog.ShowDialog() : true; if (dialogResult == true) { var viewer = new DocumentViewer(); viewer.Document = ToFixedDocument(ToPrintFriendlyGrid(source), dialog); dialog.PrintDocument(viewer.Document.DocumentPaginator, ""); } }
private DocumentViewer GetDocumentViewerModel() { var documentViewer = new DocumentViewer { Width = 800, Height = 600, Resizable = true, Document = "~/App_Data/ExampleFiles/Default.pdf" }; return(documentViewer); }
public override void SetChargeUiControls(ChartControl chartControlChargeProportion, ChartControl Fe_CuPropotionCtl, ChartControl chargePropotionChart, GridControl gridControl1, GridControl gridControl2, GridControl gridControl3, GridControl gridControl4, DocumentViewer documentView) { ChargeProportion = chartControlChargeProportion; Fe_CuPropotion = Fe_CuPropotionCtl; ChargeChart = chargePropotionChart; gridCharge_1 = gridControl1; gridCharge_2 = gridControl2; gridCharge_3 = gridControl3; gridCharge_4 = gridControl4; documentViewer = documentView; }
public override void SetChargeUiControls(ChartControl chartControlChargeProportion, ChartControl feCuPropotionCtl, ChartControl chargePropotionChart, GridControl gridControl1, GridControl gridControl2, GridControl gridControl3, GridControl gridControl4, DocumentViewer documentView) { ChargeProportion = chartControlChargeProportion; Fe_CuPropotion = feCuPropotionCtl; ChargeChart = chargePropotionChart; gridCharge_1 = gridControl1; gridCharge_2 = gridControl2; gridCharge_3 = gridControl3; gridCharge_4 = gridControl4; documentViewer = documentView; }
public static void Print(FrameworkElement source, bool showDialog = true, PageOrientation orientation = PageOrientation.Landscape, ZoomType zoom = ZoomType.TwoWide) { PrintDialog dialog = new PrintDialog(); bool? dialogResult = showDialog ? dialog.ShowDialog() : true; if (dialogResult == true) { DocumentViewer viewer = new DocumentViewer(); viewer.Document = ToFixedDocument(source, dialog, orientation); Zoom(viewer, zoom); dialog.PrintDocument(viewer.Document.DocumentPaginator, ""); } }
/// <summary> /// Perform a Print on GridView source /// </summary> /// <param name="source">Input GridView</param> /// <param name="showDialog">True to show print dialog before printing</param> /// <param name="orientation">Page Orientation (i.e. Portrait vs. Landscape)</param> /// <param name="zoom">Zoom Enumeration to specify how pages are stretched in print and preview</param> public static void Print(GridViewDataControl source, bool showDialog = true, System.Printing.PageOrientation orientation = System.Printing.PageOrientation.Landscape, ZoomType zoom = ZoomType.TwoWide) { PrintDialog dialog = new PrintDialog(); bool? dialogResult = showDialog ? dialog.ShowDialog() : true; if (dialogResult == true) { DocumentViewer viewer = new DocumentViewer(); viewer.Document = ToFixedDocument(ToPrintFriendlyGrid(source), dialog, orientation); Zoom(viewer, zoom); dialog.PrintDocument(viewer.Document.DocumentPaginator, ""); } }
/// <summary> /// Scale viewer to size specified by zoom /// </summary> /// <param name="viewer">Document to zoom</param> /// <param name="zoom">Zoom Enumeration to specify how pages are stretched in print and preview</param> public static void Zoom(DocumentViewer viewer, ZoomType zoom) { switch (zoom) { case ZoomType.Height: viewer.FitToHeight(); break; case ZoomType.Width: viewer.FitToWidth(); break; case ZoomType.TwoWide: viewer.FitToMaxPagesAcross(2); break; case ZoomType.Full: break; } }
private void ZoomLevelBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { DocumentViewer fixedDocumentViewer = ((ComboBox)sender).DataContext as DocumentViewer; if (fixedDocumentViewer != null) { double zoomLevel = 0; if (double.TryParse((string)(e.AddedItems[0] as ComboBoxItem).Tag, out zoomLevel)) { fixedDocumentViewer.Zoom = zoomLevel; } } }
/* * 3.2插入Word */ public void insertWordToPage(DControl ctl) { StorageFile storageFile = storageFileBll.get(ctl.storageId); DocumentViewer docViewer = NewControlUtil.newWord(ctl, storageFile); System.Windows.Style myStyle = (System.Windows.Style)mainContainer.FindResource("DocumentViewerDefaultStyle"); docViewer.Style = myStyle; docViewer.SizeChanged += WordUtil.Word_SizeChanged; docViewer.ManipulationBoundaryFeedback += scrollViewerManipulationBoundaryFeedback; loadAllAnimation(docViewer, ctl); mainContainer.Children.Add(docViewer); }
// Create the document viewer private void InitDocumentViewer(string documentPath, DocumentScanType scanType) { var createOptions = new DocumentViewerCreateOptions(); // Set the UI part where the main view is displayed createOptions.ViewContainer = DocumentViewerContainer; createOptions.UseAnnotations = false; // Now create the viewer _documentViewer = DocumentViewerFactory.CreateDocumentViewer(createOptions); // Set the user name _documentViewer.UserName = Environment.UserName; // We prefer SVG viewing (if supported) _documentViewer.View.PreferredItemType = DocumentViewerItemType.Svg; var imageViewer = _documentViewer.View.ImageViewer; if (scanType == DocumentScanType.Document) { imageViewer.ScrollOffsetChanged += ImageViewer_ScrollOffsetChanged; } imageViewer.BackgroundColor = Color.FromHex("#F5F7FA"); imageViewer.IsFastScrollEnabled = true; imageViewer.Zoom(ControlSizeMode.FitWidth, 1, imageViewer.DefaultZoomOrigin); // Helps with debugging of there was a rendering error imageViewer.RenderError += (sender, e) => { var message = string.Format("Error during render item {0} part {1}: {2}", e.Item != null ? imageViewer.Items.IndexOf(e.Item) : -1, e.Part, e.Error.Message); System.Diagnostics.Debug.WriteLine(message); }; _documentViewer.Text.AutoGetText = true; _documentViewer.Commands.Run(DocumentViewerCommands.InteractiveAutoPan); // Enable the pan/zoom interactive mode only if the scan type is Document and not Text because // we want the suer to be able to select text in case of extracted text mode. if (scanType == DocumentScanType.Document) { _documentViewer.Commands.Run(DocumentViewerCommands.InteractivePanZoom); } // Enable inertia scroll ToggleInertiaScroll(true); SetDocument(documentPath, scanType); }
public static void LoadDocumentViewer(string xpsFileName, DocumentViewer viewer) { XpsDocument oldXpsPackage = xpsPackage; //保存原来的XPS包 xpsPackage = new XpsDocument(xpsFileName, FileAccess.Read, CompressionOption.Fast); //从文件中读取XPS文档 FixedDocumentSequence fixedDocumentSequence = xpsPackage.GetFixedDocumentSequence(); //从XPS文档对象得到FixedDocumentSequence viewer.Document = fixedDocumentSequence as IDocumentPaginatorSource; if (oldXpsPackage != null) { oldXpsPackage.Close(); } xpsPackage.Close(); }
internal PrintForm() { InitializeComponent(); lblWaiting.Anchor = AnchorStyles.Bottom & AnchorStyles.Left & AnchorStyles.Right & AnchorStyles.Top; _document = new DocumentViewer(); EH_DocumentViewer.Child = _document; Load += PrintForm_Load; FormClosed += PrintForm_FormClosed; }
public void RunCommand(DocumentViewer documentViewer) { if (this.CommandName != null) { documentViewer.Commands.Run(this.CommandName, GetValue != null ? GetValue() : null); } else if (this.CommandNames != null) { foreach (var commandName in this.CommandNames) { documentViewer.Commands.Run(commandName, GetValue != null ? GetValue() : null); } } }
private async Task LoadReadingProgress() { //we need not scroll to 0 because we are already there ;) if (Book.LastReadPosition > 0) { //the scroll function. //we reverse calculate the scroll offset; from percentage to actual value. string functionString = "var offset = ({0} / 100) * ((document.documentElement.scrollHeight||document.body.scrollHeight) - document.documentElement.clientHeight); scrollTo(document.body, offset, 500);"; //invoke script in browser to scroll to the last read position. This will take 500 milliseconds. //TODO: add an option here to specify how long should the scroll take. await DocumentViewer.InvokeScriptAsync("eval", new string[] { string.Format(functionString, Book.LastReadPosition) }); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { FixedDocument fd = new FixedDocument(); PageContent pc = new PageContent(); FixedPage fp = new FixedPage(); ((IAddChild)pc).AddChild(fp); fd.Pages.Add(pc); Canvas cv = new Canvas(); Canvas cv2 = new Canvas(); TextBlock tb = new TextBlock(); TextBlock tb2 = new TextBlock(); TextBlock tb3 = new TextBlock(); tb.Text = " \t\tTICKET DE VIAJE\n" + "\t\tEmpresa de transporte: " + vtnPasaje.empresa + ".\n" + "\t\tBalcarce 200\tCUIT: 30-12345678-6\n" + "\tS.S de Jujuy\tIIBB:999\n\n"; tb2.Text = "______________________________________________________________\n\n" + "Pasaje Número: " + vtnPasaje.id + "\t\tFecha Operacion: " + vtnPasaje.fechaHoraVenta + "\n" + "______________________________________________________________\n\n" + "Fecha y Hora de Partida: " + vtnPasaje.fechaHoraServicio + "\n\n" + "Origen: " + vtnPasaje.origen + "\n\n" + "Destino: " + vtnPasaje.destino + "\n\n" + "Tipo de Servicio: " + vtnPasaje.tipo + "\t\tButaca: " + vtnPasaje.butaca + "\n\n" + "Precio: $" + vtnPasaje.precio + "\n\n" + "Cliente: " + vtnPasaje.nombre + " " + vtnPasaje.apellido + "\n\n" + "______________________________________________________________\n" + "Usuario: " + LoginCU.oUsuario.Usu_ApellidoNombre; tb.TextAlignment = TextAlignment.Center; tb.FontSize = 16; tb2.FontSize = 16; Canvas.SetLeft(tb, 10); Canvas.SetTop(tb, 10); Canvas.SetLeft(tb2, 10); Canvas.SetTop(tb2, 100); cv.Children.Add(tb); cv.Children.Add(tb2); fp.Children.Add(cv); // lo muestra en la ventana DocumentViewer dv = new DocumentViewer(); dv.Document = fd; ((IAddChild)this).AddChild(dv); }
public ActionResult Highlight() { var documentViewer = new DocumentViewer { Width = 800, Height = 600, Resizable = true, Document = "~/App_Data/ExampleFiles/Default.doc", HighlightedKeywords = new [] { "ancient", "ship" } //You can also split your whole search term into keywords like this: //HighlightedKeywords = "ancient ship".Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries) }; return(View(documentViewer)); }
private void OnButtonClick(object sender, RoutedEventArgs e) { SurfaceButton b = sender as SurfaceButton; DocumentViewer docViewer = new DocumentViewer(); docViewer.Margin = new Thickness(20); docViewer.Language = Language; XpsDocument doc = new XpsDocument(@"D:\Flip Project 2.0\preparation\ProjectFlipXPSPrototype\SurfaceDarstellung\xpss\" + b.Content, FileAccess.Read); docViewer.Document = doc.GetFixedDocumentSequence(); docViewer.FitToWidth(); doc.Close(); docContainer.Items.Add(docViewer); docContainer.Items.Remove(b); }
public static void DoPreview(string title, System.Windows.Media.Visual visual) { string fileName = System.IO.Path.GetTempFileName(); try { // write the XPS document using (XpsDocument doc = new XpsDocument(fileName, FileAccess.ReadWrite)) { XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc); writer.Write(visual); } // Read the XPS document into a dynamically generated // preview Window using (XpsDocument doc = new XpsDocument(fileName, FileAccess.Read)) { FixedDocumentSequence fds = doc.GetFixedDocumentSequence(); string s = _previewWindowXaml; s = s.Replace("@@TITLE", title.Replace("'", "'")); using (var reader = new System.Xml.XmlTextReader(new StringReader(s))) { Window preview = System.Windows.Markup.XamlReader.Load(reader) as Window; DocumentViewer dv1 = LogicalTreeHelper.FindLogicalNode(preview, "dv1") as DocumentViewer; dv1.Document = fds as IDocumentPaginatorSource; preview.ShowDialog(); } } } finally { if (File.Exists(fileName)) { try { File.Delete(fileName); } catch//temporary file anyway so doesn't matter if can't delete { } } } }
public void Print_Document() { try { PrintDialog printDialog = new PrintDialog(); printDialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue(); printDialog.PrintTicket = printDialog.PrintQueue.DefaultPrintTicket; printDialog.PrintTicket.PageOrientation = _pageOrientation; printDialog.PrintTicket.PageScalingFactor = 100; printDialog.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4); printDialog.PrintTicket.PageBorderless = PageBorderless.None; printDialog.PageRangeSelection = PageRangeSelection.AllPages; printDialog.UserPageRangeEnabled = true; printDialog.CurrentPageEnabled = true; printDialog.PrintTicket.PageResolution = new PageResolution(PageQualitativeResolution.High); if (printDialog.ShowDialog() == true) { if (printDialog.PrintQueue.FullName == "Microsoft XPS Document Writer") { MessageWindow.Show("\"Microsoft XPS Document Writer\" not supported!!"); return; } DocumentViewer viewer = PrintView; DocumentPaginator paginator = _fixedDocument.DocumentPaginator; if (printDialog.PageRangeSelection == PageRangeSelection.UserPages) { paginator = new PageRangeDocumentPaginator( _fixedDocument.DocumentPaginator, printDialog.PageRange); } else if (printDialog.PageRangeSelection == PageRangeSelection.CurrentPage) { paginator = new CurrentPageDocumentPaginator( _fixedDocument.DocumentPaginator, PrintView.MasterPageNumber); } _fixedDocument.PrintTicket = printDialog.PrintTicket; _documentName = _documentName.Replace("/", "-"); printDialog.PrintDocument(paginator, _documentName); } } catch (Exception e) { MessageBox.Show(e.Message); } }
public FileWindow(FileInfo doc, System.Windows.Controls.RichTextBox text) { InitializeComponent(); document = null; settings = File.ReadAllLines(Environment.CurrentDirectory + "\\settings.dat"); this.WindowState = WindowState.Maximized; this.Closing += FileWindow_Closing; GetInfo(); OpenOutput.Text = "Open A File"; document = doc; this.text = text; pagecontrol = new PageControl(settings[0]); control = new RichTextBoxPrintCtrl(); Save(); DocumentViewer.Navigate(Environment.CurrentDirectory + "\\index.html"); }
public ActionResult Protection() { var documentViewer = new DocumentViewer { Width = 800, Height = 600, Resizable = true, Document = "~/App_Data/ExampleFiles/Default.pdf", DeniedPermissions = DocumentViewerPermissions.Download | DocumentViewerPermissions.DownloadAsPdf | DocumentViewerPermissions.Print | DocumentViewerPermissions.SelectText }; return(View(documentViewer)); }
private void print() { DocumentViewer documentViewer = new DocumentViewer(); documentViewer.DataContext = this; if (ShowAbsence) { documentViewer.LoadPage(new EmployeeAbsenceTimes()); } else { documentViewer.LoadPage(new EmployeeAttendanceTimesReport()); } documentViewer.Print(); }
public ActionResult Protection() { var documentViewer = new DocumentViewer { Width = 800, Height = 600, Resizable = true, Document = "~/App_Data/ExampleFiles/Default.pdf", DownloadEnabled = false, DownloadAsPdfEnabled = false, PrintEnabled = false, TextSelectionEnabled = false }; return(View(documentViewer)); }
private void OnPrint(object sender, RoutedEventArgs args) { args.Handled = true; // use 0.5" margins in both dimensions PointD margin = new PointD(48, 48); var host = new ContainerVisualHost(CreateVisual(margin)); // create a page for the grid drawing... FixedPage page = new FixedPage(); page.Children.Add(host); // ..and a page content holder for the page... PageContent content = new PageContent(); ((IAddChild)content).AddChild(page); // ...and a document for the page content holder... FixedDocument document = new FixedDocument(); document.Pages.Add(content); // ...and a document viewer for the document! DocumentViewer viewer = new DocumentViewer(); viewer.Document = document; try { Window dialog = new Window() { Owner = this }; dialog.Title = "Print Grid"; dialog.Content = viewer; dialog.ShowDialog(); } catch (Exception e) { string message = String.Format( "An error occurred while attempting\n" + "to print the generated bitmap.\n\n{0}", e.Message); MessageBox.Show(this, message, "Print Grid Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
/*ControlTemplate.TargetType”时引发了异常。”,行号为“8”,行位置为“18”。” * * 3.2插入Word */ public void insertWordToPage(DControl ctl) { StorageFile storageFile = storageFileBll.get(ctl.storageId); DocumentViewer docViewer = NewControlUtil.newWord(ctl, storageFile); System.Windows.Style myStyle = (System.Windows.Style)pageTemplate.container.FindResource("DocumentViewerDesignDefaultStyle"); docViewer.Style = myStyle; docViewer.PreviewMouseLeftButtonDown += control_MouseDown; docViewer.PreviewMouseMove += control_MouseMove; docViewer.PreviewMouseLeftButtonUp += control_MouseUp; //控件上右击显示菜单 docViewer.MouseRightButtonUp += control_MouseRightButtonUp; docViewer.SizeChanged += WordUtil.Word_SizeChanged; pageTemplate.container.Children.Add(docViewer); }
private void v_ListViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListViewItem item = sender as ListViewItem; object obj = item.Content; DocumentViewer dv = new DocumentViewer(obj as Document); dv.ShowDialog(); }
public virtual void SetChargeUiControls(ChartControl chartControlChargeProportion, ChartControl feCuPropotionCtl, ChartControl chargePropotionChart, GridControl gridControl1, GridControl gridControl2, GridControl gridControl3, GridControl gridControl4, DocumentViewer documentView) { }
void Start() { TheUIHolder = GameObject.FindGameObjectWithTag("MainCamera").gameObject.GetComponent<AdventurePointer>(); TheDocumentHolder = GameObject.Find("Document Viewer").GetComponent<DocumentViewer>(); CurrentSequence = "0000"; }