Exemplo n.º 1
0
		private static ITexture GetTexture(string filename)
		{
			if (!AssetBundle.Initialized) {
				return null;
			}
			if (Directory.Exists(filename)) {
				return null;
			}
			var extension = Path.GetExtension(filename).ToLower();
			if (extension == ".tan") {
				return DocumentPreview.ReadAsTexture2D(filename);
			} else {
				var fi = new FileInfo(filename);
				if (fi.Length > 1024 * 1024 * 10) {
					return null;
				}
				try {
					if (extension == ".png" || extension == ".jpg") {
						try {
							var texture = new Texture2D();
							using (var stream = new FileStream(filename, FileMode.Open)) {
								texture.LoadImage(stream);
							}
							return texture;
						} catch {
							return LoadFileAsRawBitmap(filename);
						}
					} else {
						return LoadFileAsRawBitmap(filename);
					}
				} catch {
					return new Texture2D();
				}
			}
		}
Exemplo n.º 2
0
 public override void ExecuteTransaction()
 {
     if (Document.Current.Format == DocumentFormat.Tan)
     {
         DocumentPreview.Generate(CompressionFormat.Png);
     }
 }
Exemplo n.º 3
0
        public IActionResult UpdateDocument(DocumentPreview document)
        {
            var documentDTO = _mapper.Map <DocumentDTO>(document);

            if (documentDTO.Id == 0) //Save new document
            {
                _documentContext.Documents.Add(documentDTO);
            }
            else // Update existing
            {
                var existingDocument = _documentContext.Documents.Find(document.Id);

                // Переделать, вроде можно через маппер
                existingDocument.Name        = documentDTO.Name;
                existingDocument.ParentId    = documentDTO.ParentId;
                existingDocument.SubjectId   = documentDTO.SubjectId;
                existingDocument.AuthorId    = documentDTO.AuthorId;
                existingDocument.Description = documentDTO.Description;
                existingDocument.Text        = documentDTO.Text;

                _documentContext.Documents.Update(existingDocument);
            }

            _documentContext.SaveChanges();

            return(new OkResult());
        }
Exemplo n.º 4
0
        public bool Print(IntPtr parentWindowHandle,
                          string devSerial,
                          string devFilename,
                          bool previewOnly)
        {
            if (previewOnly == true)
            {
                return(Preview(parentWindowHandle, devSerial, devFilename));
            }

            DocumentPreview preview = createPreview(devSerial, devFilename);

            if (preview == null)
            {
                return(false);
            }

            int numPages = preview.Renderer.FormattedDocument.PageCount;

            PrinterSettings printerSettings = new PrinterSettings();

            printerSettings.FromPage = 1;
            printerSettings.ToPage   = numPages;

            using (PrintDialog dialog = new PrintDialog())
            {
                printerSettings.DefaultPageSettings.Landscape = false;

                dialog.PrinterSettings = printerSettings;
                dialog.AllowSelection  = false;
                dialog.AllowSomePages  = true;

                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return(false);
                }

                printerSettings = dialog.PrinterSettings;

                if (printerSettings.ToPage > numPages)
                {
                    printerSettings.ToPage = numPages;
                }

                if (printerSettings.FromPage > numPages)
                {
                    printerSettings.FromPage = 1;
                }

                var printDocument = new MigraDocPrintDocument();
                printDocument.PrinterSettings = dialog.PrinterSettings;
                printDocument.Renderer        = preview.Renderer;
                printDocument.Print();
            }


            return(true);
        }
 /// <summary>
 /// Pres the load.
 /// </summary>
 public static void PreLoad()
 {
     var a = new GridControl();
     var b = new CarouselPanel();
     var c = new ChartControl();
     var d = new FlowLayoutControl();
     var e = new NavBarControl();
     var f = new PivotGridControl();
     var g = new DocumentPreview();
     var h = new RibbonControl();
     var i = new MapControl();
 }
        public void Execute(object parameter)
        {
            DocumentPreview      preview = new DocumentPreview();
            PrintableControlLink link    = new PrintableControlLink(parameter as IPrintableControl)
            {
                Landscape = true
            };

            link.CreateDocument(false);
            link.PrintingSystem.Document.AutoFitToPagesWidth = 1;
            link.ExportToPdf("Pivot.pdf");

            //((PivotGridControl)parameter).ExportToPdf("test.pdf", new DevExpress.XtraPrinting.PdfExportOptions() { ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest });
            //Process.Start("test.pdf");
        }
Exemplo n.º 7
0
        public bool Preview(IntPtr parentWindowHandle,
                            string devSerial,
                            string devFilename)
        {
            DocumentPreview preview = createPreview(devSerial, devFilename);

            if (preview == null)
            {
                return(false);
            }

            var previewDialog = new PreviewDialog(preview);

            previewDialog.Owner = owner;
            previewDialog.ShowDialog(owner);

            return(true);
        }
Exemplo n.º 8
0
        private void ShowPrintPreview(GridControl grid)
        {
            DocumentPreview      preview = new DocumentPreview();
            PrintableControlLink link    = new PrintableControlLink(grid.View as IPrintableControl);

            link.ExportServiceUri = "../ExportService.svc";
            LinkPreviewModel model = new LinkPreviewModel(link);

            preview.Model = model;

            link.CreateDocument(true);
            DXDialog dlg = new DXDialog();

            dlg.Content = preview;
            dlg.Height  = 640;
            dlg.Left    = 150;
            dlg.Top     = 150;
            dlg.ShowDialog();
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //   TableView1.ShowPrintPreview(this);
            DocumentPreview      preview = new DocumentPreview();
            PrintableControlLink link    = new PrintableControlLink(grid.View as IPrintableControl);

            link.ExportServiceUri = "../ExportService.svc";
            LinkPreviewModel model = new LinkPreviewModel(link);

            preview.Model = model;

            link.CreateDocument(true);
            DXDialog dlg = new DXDialog();

            dlg.Content = preview;
            dlg.Height  = 640;
            dlg.Left    = 150;
            dlg.Top     = 150;
            dlg.ShowDialog();
        }
Exemplo n.º 10
0
        private DocumentPreview createPreview(string devSerial, string devFilename)
        {
            if (prepareData(devSerial, devFilename) == false)
            {
                return(null);
            }

            Protocol protocol = prepareProtocol();

            if (protocol == null)
            {
                return(null);
            }

            // This renders the document; takes a while for big documents
            DocumentPreview preview = new DocumentPreview();

            preview.Document = DdlReader.DocumentFromString(protocol.GetDocumentDDL());

            return(preview);
        }
Exemplo n.º 11
0
        private void ShowPrintPreviewButton_Click(object sender, RoutedEventArgs e)
        {
            DocumentPreview      preview = new DocumentPreview();
            PrintableControlLink link    = new PrintableControlLink(grid.View as IPrintableControl);

            link.PageFooterTemplate = (DataTemplate)this.Resources["pageFooterTemplate"];

#if SILVERLIGHT
            link.ExportServiceUri = "../ExportService.svc";
#endif
            LinkPreviewModel model = new LinkPreviewModel(link);
            preview.Model = model;

            link.CreateDocument(true);
            DXDialog dlg = new DXDialog();
            dlg.Content = preview;
            dlg.Height  = 640;
            dlg.Left    = 150;
            dlg.Top     = 150;
            dlg.ShowDialog();
        }
Exemplo n.º 12
0
        private void PreViewButton_Click(object sender, RoutedEventArgs e)
        {
            if (SchemaCreator.CurrentChoise == null)
            {
                MessageBox.Show("Ju lutem zgjidhni skemen !");
                return;
            }

            DocumentPreview doc    = new DocumentPreview();
            var             dialog = Microsoft.VisualBasic.Interaction.InputBox("Fusni Paramtrat[" + SchemaCreator.CurrentChoise.MAIN_KEY.Key + "]?", "Dialog", "");

            SchemaCreator.CurrentChoise.MAIN_KEY.Value = dialog;
            SchemaCreator.CurrentChoise.LoadData();


            foreach (ControlInterface item in EDITOR_SCREEN.Children)
            {
                doc.Document.Children.Add(item.getPreview());
            }
            doc.Document.Height = EDITOR_SCREEN.Height;
            doc.Document.Width  = EDITOR_SCREEN.Width;
            doc.ShowDialog();
        }
Exemplo n.º 13
0
        public bool PDF(string devSerial,
                        string devFilename,
                        string pdfFilename)
        {
            DocumentPreview preview = createPreview(devSerial, devFilename);

            if (preview == null)
            {
                return(false);
            }

            if (pdfFilename == null)
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.RestoreDirectory = true;
                dlg.OverwritePrompt  = true;
                dlg.Filter           = "PDF|*.pdf";
                DialogResult dlgres = dlg.ShowDialog();
                if (dlgres != DialogResult.OK)
                {
                    return(false);
                }

                pdfFilename = dlg.FileName;
            }

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer();

            pdfRenderer.DocumentRenderer = preview.Renderer;
            pdfRenderer.Document         = preview.Document;

            pdfRenderer.RenderDocument();
            pdfRenderer.Save(pdfFilename);

            return(true);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Pres the load printing.
 /// </summary>
 public static void PreLoadPrinting()
 {
     var g = new DocumentPreview();
 }