protected virtual void OnMapCreated(ThumbnailMapCollectionEventArgs e)
 {
     if (MapCreated != null)
     {
         MapCreated(this, e);
     }
 }
Beispiel #2
0
        private void OnMapFilled(object sender, ThumbnailMapCollectionEventArgs e)
        {
            ThumbnailMapCollection mapCollection = sender as ThumbnailMapCollection;

            ZipEntry oZipEntry = new ZipEntry("ThumbnailMap" + mapCollection.Maps.Count + ".bmp");

            this.oZipStream.PutNextEntry(oZipEntry);

            int size = mapCollection.MapSizeInBytes;

            byte[]       buffer = new byte[size];
            MemoryStream ms     = new MemoryStream(buffer);

            e.Map.Save(ms, FREE_IMAGE_FORMAT.FIF_BMP);

            oZipStream.Write(buffer, 0, size);

            e.Map.Dispose();
            ms.Dispose();
        }
Beispiel #3
0
        private void OnMapFilled(object sender, ThumbnailMapCollectionEventArgs e)
        {
            ThumbnailMapCollection mapCollection = sender as ThumbnailMapCollection;

            ZipEntry oZipEntry = new ZipEntry("ThumbnailMap" + mapCollection.Maps.Count + ".bmp");
            this.oZipStream.PutNextEntry(oZipEntry);

            int size = mapCollection.MapSizeInBytes;

            byte[] buffer = new byte[size];
            MemoryStream ms = new MemoryStream(buffer);

            e.Map.Save(ms, FREE_IMAGE_FORMAT.FIF_BMP);

            oZipStream.Write(buffer, 0, size);

            e.Map.Dispose();
            ms.Dispose();
        }
Beispiel #4
0
        // Save mosaic data.
        internal void SaveMosaicCacheFile()
        {
            if (this.threadController != null)
                this.threadController.ReportThreadStarted(this, "Saving Tiles");

            string tempFilePath = Path.GetTempFileName();

            try
            {
                this.oZipStream = new ZipOutputStream(System.IO.File.Create(tempFilePath));
            }
            catch(Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }

            this.oZipStream.SetLevel(2); // 9 = maximum compression level

            ZipEntry oZipEntry = new ZipEntry("info.txt");
            this.oZipStream.PutNextEntry(oZipEntry);

            StreamWriter sw = new StreamWriter(oZipStream);
            TileSaver.SaveMosaicHeader(MosaicWindow.MosaicInfo, sw);

            ThumbnailMapCollection mapCollection = new ThumbnailMapCollection(MosaicWindow.MosaicInfo.Items[0].Thumbnail.Width,
                                                MosaicWindow.MosaicInfo.Items[0].Thumbnail.Height);

            mapCollection.MapFilled += new ThumbnailMapCollectionEventHandler(OnMapFilled);

            int count = 1;
            int requiredMaps = (MosaicWindow.MosaicInfo.Items.Count / ThumbnailMap.MaxSize) + 1;

            foreach (Tile tile in MosaicWindow.MosaicInfo.Items) // For each file, generate a zipentry
            {
                if (this.threadController.ThreadAborted)
                    return;

                mapCollection.AddThumbnail(tile);

                if (this.threadController != null)
                    threadController.ReportThreadPercentage(this, "Creating Tile Maps",
                        count++, MosaicWindow.MosaicInfo.Items.Count);
            }

            // Final map may not get completly filled
            // if not then save it here

            if(mapCollection.Maps.Count <= requiredMaps) {
                ThumbnailMapCollectionEventArgs thumbnailEventArgs
                    = new ThumbnailMapCollectionEventArgs(mapCollection.Last);

                OnMapFilled(mapCollection, thumbnailEventArgs);
            }

            mapCollection.Dispose();
            oZipStream.Finish();
            oZipStream.Dispose();
            oZipStream.Close();

            try
            {
                File.Delete(MosaicWindow.MosaicInfo.TileReader.GetCacheFilePath());
                File.Copy(tempFilePath, MosaicWindow.MosaicInfo.TileReader.GetCacheFilePath());
            }
            catch (Exception)
            {

            }

            //File.SetAttributes(this.filePath, FileAttributes.Hidden);

            if (this.threadController != null)
                this.threadController.ReportThreadCompleted(this, "Cache Saved", false);

            GC.Collect();
        }
Beispiel #5
0
 // Invoke the NewMapCreated event; called whenever list changes
 protected virtual void OnMapFilled(ThumbnailMapCollectionEventArgs e)
 {
     if (MapFilled != null)
         MapFilled(this, e);
 }
Beispiel #6
0
        // Save mosaic data.
        internal void SaveMosaicCacheFile()
        {
            if (this.threadController != null)
            {
                this.threadController.ReportThreadStarted(this, "Saving Tiles");
            }

            string tempFilePath = Path.GetTempFileName();

            try
            {
                this.oZipStream = new ZipOutputStream(System.IO.File.Create(tempFilePath));
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }

            this.oZipStream.SetLevel(2); // 9 = maximum compression level

            ZipEntry oZipEntry = new ZipEntry("info.txt");

            this.oZipStream.PutNextEntry(oZipEntry);

            StreamWriter sw = new StreamWriter(oZipStream);

            TileSaver.SaveMosaicHeader(MosaicWindow.MosaicInfo, sw);

            ThumbnailMapCollection mapCollection = new ThumbnailMapCollection(MosaicWindow.MosaicInfo.Items[0].Thumbnail.Width,
                                                                              MosaicWindow.MosaicInfo.Items[0].Thumbnail.Height);

            mapCollection.MapFilled += new ThumbnailMapCollectionEventHandler(OnMapFilled);

            int count        = 1;
            int requiredMaps = (MosaicWindow.MosaicInfo.Items.Count / ThumbnailMap.MaxSize) + 1;

            foreach (Tile tile in MosaicWindow.MosaicInfo.Items) // For each file, generate a zipentry
            {
                if (this.threadController.ThreadAborted)
                {
                    return;
                }

                mapCollection.AddThumbnail(tile);

                if (this.threadController != null)
                {
                    threadController.ReportThreadPercentage(this, "Creating Tile Maps",
                                                            count++, MosaicWindow.MosaicInfo.Items.Count);
                }
            }

            // Final map may not get completly filled
            // if not then save it here

            if (mapCollection.Maps.Count <= requiredMaps)
            {
                ThumbnailMapCollectionEventArgs thumbnailEventArgs
                    = new ThumbnailMapCollectionEventArgs(mapCollection.Last);

                OnMapFilled(mapCollection, thumbnailEventArgs);
            }

            mapCollection.Dispose();
            oZipStream.Finish();
            oZipStream.Dispose();
            oZipStream.Close();

            try
            {
                File.Delete(MosaicWindow.MosaicInfo.TileReader.GetCacheFilePath());
                File.Copy(tempFilePath, MosaicWindow.MosaicInfo.TileReader.GetCacheFilePath());
            }
            catch (Exception)
            {
            }

            //File.SetAttributes(this.filePath, FileAttributes.Hidden);

            if (this.threadController != null)
            {
                this.threadController.ReportThreadCompleted(this, "Cache Saved", false);
            }

            GC.Collect();
        }