コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: linjus/bingshin
 public DownloaderArgument(string key, Repository.MapStyle style)
 {
     this.QuadKey = key;
     this.Style = style;
 }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: linjus/bingshin
 private Uri GetTileURL(string quadkey, Repository.MapStyle style)
 {
     // The following information is from http://gc-livepedia.de/wiki/Map_servers.
     var s = new StringBuilder();
     s.Append(@"http://ecn.t0.tiles.virtualearth.net/tiles/");
     switch (style) {
         case Repository.MapStyle.Road:
             s.Append('r');
             s.Append(quadkey);
             s.Append(@".png?g=471&mkt=en-us&shading=hill");
             break;
         case Repository.MapStyle.Hybrid:
             s.Append('h');
             s.Append(quadkey);
             s.Append(@".jpeg?g=471");
             break;
     }
     return new Uri(s.ToString());
 }
コード例 #3
0
ファイル: MainPage.xaml.cs プロジェクト: linjus/bingshin
        private void SaveTile(string quadkey, Repository.MapStyle style)
        {
            if (this.repository.Exist(quadkey, style)) {
                this.downloadercontext.FinishOne(true);
                return;
            }

            var uri = this.GetTileURL(quadkey, style);

            var arg = new DownloaderArgument(quadkey, style);

            var client = new WebClient();
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            client.OpenReadAsync(uri, arg);

            this.downloadcompleteevent.WaitOne();
        }
コード例 #4
0
ファイル: MainPage.xaml.cs プロジェクト: linjus/bingshin
        public MainPage()
        {
            InitializeComponent();

            var rootdir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "lindsay");
            this.repository = new Repository(rootdir);

            this.downloadworker = new BackgroundWorker();
            this.downloadworker.WorkerReportsProgress = true;
            this.downloadworker.WorkerSupportsCancellation = true;
            this.downloadworker.DoWork += new DoWorkEventHandler(downloadworker_DoWork);
            this.downloadworker.ProgressChanged += new ProgressChangedEventHandler(downloadworker_ProgressChanged);
            this.downloadworker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(downloadworker_RunWorkerCompleted);

            if (!Application.Current.HasElevatedPermissions)
                this.textLog.Text = "permission!";

            this.borderMouseOverTile.Width = this.TileSize;
            this.borderMouseOverTile.Height = this.TileSize;

            this.borderSelectingTiles.Visibility = System.Windows.Visibility.Collapsed;
            this.borderSelectedTiles.Visibility = System.Windows.Visibility.Collapsed;

            this.mapMain.Layer = this.tilelayer;
            this.mapMain.Loaded += new RoutedEventHandler(mapMain_Loaded);
            this.mapMain.ViewChangeStart += new EventHandler<MapEventArgs>(mapMain_ViewChangeStart);
            this.mapMain.ViewChangeEnd += new EventHandler<MapEventArgs>(mapMain_ViewChangeEnd);
            this.mapMain.MouseMove += new MouseEventHandler(mapMain_MouseMove);
            this.mapMain.SelectionDoneEvent += new MouseButtonEventHandler(mapMain_SelectionDoneEvent);
        }