Example #1
0
 public KmlExportDocument(Document document, ImageExporter imageExporter)
 {
     this.document = document;
       this.sessions = document.Sessions;
       this.imageExporter = imageExporter;
       this.type = KmlExportDocumentType.Document;
 }
        public void Export(Stream stream)
        {
            // crrete kml exporter object
            var imageExporter = new ImageExporter(Document)
            {
                Properties = new ImageExporterProperties()
            };

            var kmlExporter = new KmlExporter(Document, imageExporter, Sessions, stream)
            {
                KmlProperties = KmlProperties
            };

            // set individual colors for the sessions
            var count = 0;

            foreach (var s in Sessions)
            {
                // create custom route line style for this session
                kmlExporter.RouteLineStyleForSessions[s] = new KmlLineStyle()
                {
                    Color = MultipleFileExporterProperties.Colors[count % MultipleFileExporterProperties.Colors.Count],
                    Width = KmlProperties.RouteLineStyle.Width
                };
                if (MultipleFileExporterProperties.IncludeReplay)
                {
                    // create custom replay marker style for this session
                    kmlExporter.ReplayMarkerStyleForSessions[s] = new KmlMarkerStyle()
                    {
                        Color = MultipleFileExporterProperties.Colors[count % MultipleFileExporterProperties.Colors.Count],
                        Size  = KmlProperties.ReplayMarkerStyle.Size
                    };
                }
                count++;
            }

            // export
            kmlExporter.ExportKmz(CommonUtil.GetTempFileName() + @"\");
        }
Example #3
0
        private void CreateKmz(Document document, Stream stream, KmlProperties kmlProperties, WaypointAttribute colorCodingAttribute, WaypointAttribute? secondaryColorCodingAttribute, ColorRangeProperties colorRangeProperties)
        {
            var imageExporterProperties = new ImageExporterProperties()
              {
            ColorCodingAttribute = colorCodingAttribute,
            SecondaryColorCodingAttribute = secondaryColorCodingAttribute,
            ColorRangeProperties = colorRangeProperties
              };

              var imageExporter = new ImageExporter(document)
              {
            Properties = imageExporterProperties
              };

              var kmlExporter = new KmlExporter(document, imageExporter, stream)
              {
            KmlProperties = kmlProperties
              };
              kmlExporter.ExportKmz(CommonUtil.GetTempFileName() + @"\");
        }
Example #4
0
        private void ExportImage()
        {
            using (var sfd = new SaveFileDialog
                         {
                           Title = Strings.ExportImageTitle,
                           Filter = (Strings.FileFilter_JpegFiles + "|" +
                                     Strings.FileFilter_PngFiles + "|" +
                                     Strings.FileFilter_TiffFiles),
                           FileName =
                             (canvas.Document != null && canvas.Document.FileName != null
                                ? Path.GetFileNameWithoutExtension(canvas.Document.FileName)
                                : Path.GetFileNameWithoutExtension(untitledDocumentFileNameProposal)),
                           FilterIndex = 1,
                           AddExtension = true,
                           OverwritePrompt = true
                         })
              {
            if (ApplicationSettings.InitialFolders.ContainsKey(ApplicationSettings.FileDialogType.ExportFile))
            {
              sfd.InitialDirectory = ApplicationSettings.InitialFolders[ApplicationSettings.FileDialogType.ExportFile];
            }

            if (sfd.ShowDialog() == DialogResult.OK)
            {
              try
              {
            // TODO: change to saved PercentualImageSize and Quality when dialog is working
            IMapImageFileExporterDialog selector = null;
            switch (sfd.FilterIndex)
            {
              case 1: // jpeg
                selector = new JpegPropertySelector
                             {
                               SizeCalculator = canvas.Document.CalculateImageForExportSize,
                               PercentualImageSize = 1,
                               //ApplicationSettings.ExportImagePercentualImageSize,
                               Quality = 0.8 //ApplicationSettings.ExportImageQuality,
                             };
                break;

              case 2: // png
                selector = new PngPropertySelector
                             {
                               SizeCalculator = canvas.Document.CalculateImageForExportSize,
                               PercentualImageSize = 1,
                               //ApplicationSettings.ExportImagePercentualImageSize
                             };
                break;

              default: // tiff
                selector = new TiffPropertySelector
                             {
                               SizeCalculator = canvas.Document.CalculateImageForExportSize,
                               PercentualImageSize = 1,
                               //ApplicationSettings.ExportImagePercentualImageSize
                             };
                break;
            }
            if (selector.ShowPropertyDialog() == DialogResult.OK)
            {
              BeginWork();
              using (var fs = new FileStream(sfd.FileName, FileMode.Create))
              {
                var imageExporterProperties = new ImageExporterProperties()
                                                {
                                                  EncodingInfo = selector.EncodingInfo,
                                                  RouteDrawingMode = Document.RouteDrawingMode.Extended,
                                                  ColorCodingAttribute = SelectedColorCodingAttribute,
                                                  SecondaryColorCodingAttribute = SelectedSecondaryColorCodingAttribute,
                                                  PercentualSize = selector.PercentualImageSize,
                                                  ColorRangeProperties = GetCurrentColorRangeProperties()
                                                };
                var imageExporter = new ImageExporter(canvas.Document, canvas.SelectedSessions, fs)
                                      {
                                        Properties = imageExporterProperties
                                      };
                imageExporter.Export();
                fs.Close();
              }
              ApplicationSettings.ExportImagePercentualImageSize = selector.PercentualImageSize;
              if (selector is JpegPropertySelector)
                ApplicationSettings.ExportImageQuality = ((JpegPropertySelector)selector).Quality; // ugly!
              ApplicationSettings.InitialFolders[ApplicationSettings.FileDialogType.ExportImage] =
                Path.GetDirectoryName(sfd.FileName);
              EndWork();
            }
              }
              catch (Exception ex)
              {
            Util.ShowExceptionMessageBox(ex, Strings.Error_ExportImage);
              }
            }
              }
        }
Example #5
0
 /// <summary>
 /// Creates an exporter where the map data is taken from one single QuickRoute document and the sessions are specified in a custom SessionCollection object
 /// </summary>
 /// <param name="document">The QuickRoute document that contains the map to export</param>
 /// <param name="imageExporter">The image exporter used to create the map image</param>
 /// <param name="sessions">The sessions to export</param>
 /// <param name="outputStream">The stream to export to</param>
 public KmlExporter(Document document, ImageExporter imageExporter, SessionCollection sessions, Stream outputStream)
     : this()
 {
     kmlExportDocuments = new List<KmlExportDocument> { new KmlExportDocument(document, sessions, imageExporter) };
       this.outputStream = outputStream;
 }
Example #6
0
 private void InitImageExporter()
 {
     if (imageExporter == null)
       {
     InitDocumentAndSessions();
     imageExporter = new ImageExporter(Document, Sessions) { Properties = imageExporterProperties };
       }
 }
Example #7
0
 private KmlMarkerStyle GetMarkerStyleFromWaypoint(Waypoint waypoint, ImageExporter imageExporter, SessionSettings sessionSettings)
 {
     var attribute = imageExporter.Properties.ColorCodingAttribute;
       var rls = sessionSettings.RouteLineSettingsCollection[attribute];
       return new KmlMarkerStyle()
       {
     Color = rls.ColorRange.GetColor(waypoint.Attributes[attribute].GetValueOrDefault(0), NoOfColorCodedSteps),
     Size = replayMarkerSizeFactor * ((rls.MaskVisible ? 2 * rls.MaskWidth : 0) + rls.Width)
       };
 }
        private MapInfo CreateMapInfoFromControls()
        {
            MapInfo mapInfo = new MapInfo();
              var selectedMap = map.SelectedValue as MapInfo;
              if (selectedMap != null) mapInfo.ID = selectedMap.ID;
              mapInfo.Date = date.Value.ToUniversalTime();
              var selectedCategory = category.SelectedItem as Category;
              if (selectedCategory != null) mapInfo.CategoryID = selectedCategory.ID;
              mapInfo.Name = name.Text;
              mapInfo.MapName = mapName.Text;
              mapInfo.Organiser = organiser.Text;
              mapInfo.Country = country.Text;
              mapInfo.Discipline = type.Text;
              mapInfo.RelayLeg = relayLeg.Text;
              mapInfo.ResultListUrl = resultListUrl.Text;
              mapInfo.Comment = comment.Text;
              mapInfo.MapImageFileExtension = imageFormat.Text;

              IMapImageFileExporterDialog selector = null;
              switch (imageFormat.Text)
              {
            case "jpg":
              selector = new JpegPropertySelector
              {
            SizeCalculator = document.CalculateImageForExportSize
              };
              break;
            case "png":
            default:
              selector = new PngPropertySelector
              {
            SizeCalculator = document.CalculateImageForExportSize
              };
              break;
            //case "tiff":
            //  selector = new TiffPropertySelector
            //  {
            //    SizeCalculator = document.CalculateImageForExportSize
            //  };

            //  break;

              }

              if (selector.ShowPropertyDialog() == DialogResult.OK)
              {
            Application.DoEvents();

            // map image
            using (var ms = new MemoryStream())
            {
              var imageExporterProperties = new ImageExporterProperties()
              {
            EncodingInfo = selector.EncodingInfo,
            RouteDrawingMode = Document.RouteDrawingMode.Extended,
            ColorCodingAttribute = colorCodingAttribute,
            SecondaryColorCodingAttribute = secondaryColorCodingAttribute,
            PercentualSize = selector.PercentualImageSize,
            ColorRangeProperties = colorRangeProperties
              };
              var imageExporter = new ImageExporter(document, document.Sessions, ms)
              {
            Properties = imageExporterProperties
              };
              imageExporter.Export();
              mapInfo.MapImageData = ms.ToArray();
            }

            // blank map image
            using (var ms = new MemoryStream())
            {
              var imageExporterProperties = new ImageExporterProperties()
              {
            EncodingInfo = selector.EncodingInfo,
            RouteDrawingMode = Document.RouteDrawingMode.None,
            PercentualSize = selector.PercentualImageSize
              };
              var blankImageExporter = new ImageExporter(document, document.Sessions, ms)
              {
            Properties = imageExporterProperties
              };
              blankImageExporter.Export();
              mapInfo.BlankMapImageData = ms.ToArray();
            }
            return mapInfo;
              }
              return null;
        }
 public static QuickRouteJpegExtensionData FromImageExporter(ImageExporter exporter)
 {
     var data = new QuickRouteJpegExtensionData
            {
              Version = currentVersion,
              ImageCornerPositions =
                exporter.Document.GetImageCornersLongLat(exporter.ImageBounds, exporter.MapBounds,
                                                         exporter.Properties.PercentualSize),
              MapCornerPositions = exporter.Document.GetMapCornersLongLat(),
              MapLocationAndSizeInPixels = exporter.MapBounds,
              Sessions = exporter.Sessions,
              PercentualSize = exporter.Properties.PercentualSize
            };
       return data;
 }
        public void Export(Stream stream)
        {
            // crrete kml exporter object
              var imageExporter = new ImageExporter(Document)
                            {
                              Properties = new ImageExporterProperties()
                            };

              var kmlExporter = new KmlExporter(Document, imageExporter, Sessions, stream)
                          {
                            KmlProperties = KmlProperties
                          };

              // set individual colors for the sessions
              var count = 0;
              foreach (var s in Sessions)
              {
            // create custom route line style for this session
            kmlExporter.RouteLineStyleForSessions[s] = new KmlLineStyle()
                                                     {
                                                       Color = MultipleFileExporterProperties.Colors[count % MultipleFileExporterProperties.Colors.Count],
                                                       Width = KmlProperties.RouteLineStyle.Width
                                                     };
            if (MultipleFileExporterProperties.IncludeReplay)
            {
              // create custom replay marker style for this session
              kmlExporter.ReplayMarkerStyleForSessions[s] = new KmlMarkerStyle()
              {
            Color = MultipleFileExporterProperties.Colors[count % MultipleFileExporterProperties.Colors.Count],
            Size = KmlProperties.ReplayMarkerStyle.Size
              };
            }
            count++;
              }

              // export
              kmlExporter.ExportKmz(CommonUtil.GetTempFileName() + @"\");
        }