private void ProfileButtonClicked(object parameters)
        {
            string str = parameters.ToString();

            switch (str)
            {
            case "SAVE":
                if (DownloadExtent == null || Levels == null || Levels.Length == 0)
                {
                    MessageBox.Show(App.Current.FindResource("msgDownloadProfileInvalid").ToString(), App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                Util.Envelope env    = new Util.Envelope(DownloadExtent.XMin, DownloadExtent.YMin, DownloadExtent.XMax, DownloadExtent.YMax);
                string        result = _configManager.SaveDownloadProfileWithOverwrite(new PBS.DownloadProfile(SelectedProfile, Levels, env, _downloadPolygon));
                if (result != string.Empty)
                {
                    MessageBox.Show(result, App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "LOAD":
                DownloadProfile profile = _configManager.LoadDownloadProfile(SelectedProfile);
                if (profile == null)
                {
                    MessageBox.Show(App.Current.FindResource("msgLoadFailed").ToString(), App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                _downloadPolygon = profile.Polygon;
                Levels           = profile.Levels;
                DownloadExtent   = new Envelope(profile.Envelope.XMin, profile.Envelope.YMin, profile.Envelope.XMax, profile.Envelope.YMax);
                _graphicsLayer.ClearGraphics();
                _graphicsLayer.Graphics.Add(new Graphic()
                {
                    Symbol = new SimpleFillSymbol()
                    {
                        BorderBrush = new SolidColorBrush(Colors.Red),
                        Fill        = new SolidColorBrush(Color.FromArgb(100, 255, 0, 0))
                    },
                    Geometry = profile.Polygon == null ? _webMercator.FromGeographic(DownloadExtent) : AppUtility.ConvertPBSPolygonToEsriPolygon(profile.Polygon)
                });
                (CMDClickStartButton as DelegateCommand).RaiseCanExecuteChanged();
                TilesCount = AppUtility.CalculateTileCount(Levels, (Envelope)_webMercator.FromGeographic(DownloadExtent));
                break;

            case "DELETE":
                _configManager.DeleteDownloadProfile(SelectedProfile);
                break;

            default:
                break;
            }
            Profiles = new ObservableCollection <string>(_configManager.GetAllDownloadProfileNames());
        }
 void MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (_isRightMouseButtonDown && IsIdle)
     {
         //draw download extent
         Graphic  g        = _graphicsLayer.Graphics[0];
         MapPoint endPoint = _map.ScreenToMap(e.GetPosition(_map));
         g.Geometry = new Envelope(_startPoint.X, endPoint.Y, endPoint.X, _startPoint.Y);
         //tiles count
         if (Levels != null && Levels.Length > 0)
         {
             TilesCount = AppUtility.CalculateTileCount(Levels, (Envelope)g.Geometry);
         }
         DownloadExtent = (Envelope)_webMercator.ToGeographic(g.Geometry);
         NotifyPropertyChanged(p => p.DownloadExtent);
         NotifyPropertyChanged(p => p.IsDrawExtentTipVisible);
     }
 }