Пример #1
1
        public static void Print(RadGanttView ganttView)
        {
            var isFirstPass  = true;
            var exportImages = Enumerable.Empty <BitmapSource>();
            var enumerator   = exportImages.GetEnumerator();
            var pd           = new System.Windows.Printing.PrintDocument();

            pd.BeginPrint += pd_BeginPrint;
            pd.PrintPage  += (s, e) =>
            {
                if (isFirstPass)
                {
                    var printingSettings = new ImageExportSettings(e.PrintableArea, true, GanttArea.AllAreas);
                    using (var export = ganttView.ExportingService.BeginExporting(printingSettings))
                    {
                        exportImages = export.ImageInfos.ToList().Select(info => info.Export());
                        enumerator   = exportImages.GetEnumerator();
                        enumerator.MoveNext();
                    }
                    isFirstPass = false;
                }

                e.PageVisual = PrintPage(enumerator.Current);
                enumerator.MoveNext();
                e.HasMorePages = enumerator.Current != null;
            };
            pd.Print("Gantt");
        }
        /// <summary>
        /// Runs the actual exporter
        /// </summary>
        /// <param name="settings">Export settings</param>
        private void RunExport(ImageExportSettings settings)
        {
            ICollection <Sector> sectors = General.Map.Map.SelectedSectorsCount == 0 ? General.Map.Map.Sectors : General.Map.Map.GetSelectedSectors(true);

            ImageExporter exporter = new ImageExporter(sectors, settings, AddProgress, ShowPhase, CheckCancelExport);

            try
            {
                exporter.Export();
            }
            catch (ArgumentException)             // Happens if there's not enough consecutive memory to create the file
            {
                StopExport(ImageExportResult.OutOfMemory);
                return;
            }
            catch (ImageExportCanceledException)
            {
                StopExport(ImageExportResult.Canceled);
                return;
            }
            catch (ImageExportImageTooBigException)
            {
                StopExport(ImageExportResult.ImageTooBig);
                return;
            }

            StopExport(ImageExportResult.OK);
        }
Пример #3
0
        public static void Print(RadGanttView ganttView)
        {
            var isFirstPass = true;
            var exportImages = Enumerable.Empty<BitmapSource>();
            var enumerator = exportImages.GetEnumerator();
            var pd = new System.Windows.Printing.PrintDocument();
            pd.PrintPage += (s, e) =>
            {
                if (isFirstPass)
                {
                    var printingSettings = new ImageExportSettings(e.PrintableArea, true, GanttArea.AllAreas);
                    using (var export = ganttView.ExportingService.BeginExporting(printingSettings))
                    {
                        exportImages = export.ImageInfos.ToList().Select(info => info.Export());
                        enumerator = exportImages.GetEnumerator();
                        enumerator.MoveNext();
                    }
                    isFirstPass = false;
                }

                e.PageVisual = PrintPage(enumerator.Current);
                enumerator.MoveNext();
                e.HasMorePages = enumerator.Current != null;
            };
            pd.Print("Gantt");
        }
        /// <summary>
        /// Starts exporting the image(s). Disables all controls and starts the thread that does the actual exporting.
        /// </summary>
        private void StartExport()
        {
            ICollection <Sector> sectors = General.Map.Map.SelectedSectorsCount == 0 ? General.Map.Map.Sectors : General.Map.Map.GetSelectedSectors(true);

            exporting    = true;
            cancelexport = false;

            progress.Maximum = 100;             //sectors.Count * (Brightmap ? 2 : 1);
            progress.Value   = 0;
            progress.Visible = true;

            lbPhase.Text    = "";
            lbPhase.Visible = true;

            foreach (Control c in Controls)
            {
                if (!(c is ProgressBar || c is Label))
                {
                    c.Enabled = false;
                }
            }

            export.Enabled = true;
            export.Text    = "Cancel";

            ImageExportSettings settings = new ImageExportSettings(Path.GetDirectoryName(FilePath), Path.GetFileNameWithoutExtension(FilePath), Path.GetExtension(FilePath), Floor, Fullbright, Brightmap, Tiles, ImageScale, GetPixelFormat(), GetImageFormat());

            exportthread          = new Thread(() => RunExport(settings));
            exportthread.Name     = "Image export";
            exportthread.Priority = ThreadPriority.Normal;
            exportthread.Start();
        }
		private void ExportCommandExecute(object obj)
		{
			var settings = new ImageExportSettings(
				new Size(815, 1023), // or 408, 600
				this.showHeaders,
				this.selectedArea);
			this.export(settings);
		}
Пример #6
0
 private void BeginExporting(ImageExportSettings settings)
 {
     using (var export = this.gantt.ExportingService.BeginExporting(settings))
     {
         var printPreviewDialog = new CustomPrintDialog(export);
         printPreviewDialog.Show();
     }
 }
Пример #7
0
		private void BeginExporting(ImageExportSettings settings)
		{
			using (var export = this.gantt.ExportingService.BeginExporting(settings))
			{
				var printPreviewDialog = new CustomPrintDialog(export);
				printPreviewDialog.Show();
			}
		}
Пример #8
0
        private void ExportCommandExecute(object obj)
        {
            var settings = new ImageExportSettings(
                new Size(815, 1023),                 // or 408, 600
                this.showHeaders,
                this.selectedArea);

            this.export(settings);
        }
Пример #9
0
        public static void Print(RadGanttView ganttView)
        {
            var printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == true)
            {
                var exportImages = Enumerable.Empty<BitmapSource>();
                var printingSettings = new ImageExportSettings(new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight), true, GanttArea.AllAreas);
                using (var export = ganttView.ExportingService.BeginExporting(printingSettings))
                {
                    exportImages = export.ImageInfos.ToList().Select(info => info.Export());
                }

                var paginator = new GanttPaginator(exportImages);
                printDialog.PrintDocument(paginator, "Print demo");
            }
        }
Пример #10
0
        public static void Print(RadGanttView ganttView)
        {
            var printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                var exportImages     = Enumerable.Empty <BitmapSource>();
                var printingSettings = new ImageExportSettings(new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight), true, GanttArea.AllAreas);
                using (var export = ganttView.ExportingService.BeginExporting(printingSettings))
                {
                    exportImages = export.ImageInfos.ToList().Select(info => info.Export());
                }

                var paginator = new GanttPaginator(exportImages);
                printDialog.PrintDocument(paginator, "Print demo");
            }
        }
Пример #11
0
        private void ExportToImage()
        {
            // Convert geometry selection to sectors
            General.Map.Map.ConvertSelection(SelectionType.Sectors);

            // Get sectors
            ICollection <Sector> sectors = General.Map.Map.SelectedSectorsCount == 0 ? General.Map.Map.Sectors : General.Map.Map.GetSelectedSectors(true);

            if (sectors.Count == 0)
            {
                General.Interface.DisplayStatus(StatusType.Warning, "Image export failed. Map has no sectors!");
                return;
            }

            ImageExportSettingsForm form = new ImageExportSettingsForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                ImageExportSettings settings = new ImageExportSettings(Path.GetDirectoryName(form.FilePath), Path.GetFileNameWithoutExtension(form.FilePath), Path.GetExtension(form.FilePath), form.Floor, form.Fullbright, form.Brightmap, form.Tiles, form.GetPixelFormat(), form.GetImageFormat());
                ImageExporter       exporter = new ImageExporter(sectors, settings);

                string text = "The following images will be created:\n\n" + string.Join("\n", exporter.GetImageNames());

                DialogResult result = MessageBox.Show(text, "Export to image", MessageBoxButtons.OKCancel);

                if (result == DialogResult.OK)
                {
                    try
                    {
                        exporter.Export();

                        MessageBox.Show("Export successful.", "Export to image", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (ArgumentException e)                     // Happens if there's not enough consecutive memory to create the file
                    {
                        MessageBox.Show("Exporting failed. There's likely not enough consecutive free memory to create the image. Try a lower color depth or file format", "Export failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }