Ejemplo n.º 1
0
        private void bttnSaveProjectFile_Click(object sender, RoutedEventArgs e)
        {
            MercatorProjection projections = new MercatorProjection();

            List <TrailMap.Projection.Point> allTiles = projections.GetAreaTileList(new LocationRect(this.AreaData.StLocation, this.AreaData.EtLocation), (int)this.AreaData.ZoomLevel, 0);
            List <Url> allUrls = new List <Url>();

            foreach (TrailMap.Projection.Point item in allTiles)
            {
                Url url = new Url();
                url.Src    = m_mainPage.CurrentSource.GetUri(item.X, item.Y, (int)this.AreaData.ZoomLevel).AbsoluteUri;
                url.Target = string.Format("Img_{0}_{1}_{2}.{3}", item.X, item.Y, (int)this.AreaData.ZoomLevel, m_mainPage.CurrentSource.FileExtn);

                allUrls.Add(url);
            }

            SaveFileDialog dialog;

            dialog            = new SaveFileDialog();
            dialog.DefaultExt = ".mapprj";
            dialog.Filter     = "Map Project|*.mapprj";

            if (dialog.ShowDialog() == true)
            {
                using (Stream fs = (Stream)dialog.OpenFile())
                {
                    XmlSerializer ser = new XmlSerializer(typeof(Url[]));

                    ser.Serialize(fs, allUrls.ToArray());

                    //fs.Write(fileBytes, 0, fileBytes.Length);
                    fs.Close();
                    MessageBox.Show("Save Completed");
                }
            }
        }