Exemple #1
0
        public Control(MapControlFactory mcf)
        {
            MapControlFactoryToUse = mcf;
            _mapControlFactory     = mcf;

            if (_mapControlFactory != null)
            {
                _mapControlFactory.TileGenerator.DownloadCountChanged += this.OnDownloadCountChanged;
                _mapControlFactory.TileGenerator.DownloadError        += this.OnDownloadError;

                DataContext = this;

                this.InitializeComponent();
                CommandManager.AddPreviewExecutedHandler(this, this.PreviewExecuteCommand); // We're going to do some effects when zooming.
                if (_mapControlFactory != null && _mapControlFactory.ID == "GoogleCache")
                {
                    creditsinfo.Visibility = System.Windows.Visibility.Hidden;
                }
                Core.ApplicationData.Instance.PropertyChanged += Instance_PropertyChanged;

                tileCanvas.ZoomChanged += tileCanvas_ZoomChanged;

                Task.Run(() =>
                {
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                        this.tileCanvas.Zoom = 13;
                        TargetGeocaches = GeocachesOnMap.Active;
                        CurrentConnectedDatabase = Core.ApplicationData.Instance.ActiveDatabase;
                    }));
                });
            }
        }
Exemple #2
0
        public Control(MapControlFactory mcf)
        {
            MapControlFactoryToUse = mcf;
            _mapControlFactory     = mcf;

            if (_mapControlFactory != null)
            {
                _mapControlFactory.TileGenerator.DownloadCountChanged += this.OnDownloadCountChanged;
                _mapControlFactory.TileGenerator.DownloadError        += this.OnDownloadError;

                DataContext = this;

                this.InitializeComponent();
                CommandManager.AddPreviewExecutedHandler(this, this.PreviewExecuteCommand); // We're going to do some effects when zooming.
                if (_mapControlFactory != null && _mapControlFactory.ID == "GoogleCache")
                {
                    creditsinfo.Visibility = System.Windows.Visibility.Hidden;
                }

                tileCanvas.ZoomChanged += tileCanvas_ZoomChanged;

                Task.Run(() =>
                {
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                        this.tileCanvas.Zoom = _initialZoomLevel;
                    }));
                });
            }
        }
Exemple #3
0
 /// <summary>Initializes a new instance of the Tile class.</summary>
 /// <param name="zoom">The zoom level for the tile.</param>
 /// <param name="x">The tile index along the X axis.</param>
 /// <param name="y">The tile index along the Y axis.</param>
 public Tile(MapControlFactory mapControlFactory, int zoom, int x, int y)
 {
     _mapControlFactory = mapControlFactory;
     _tileX = x;
     _tileY = y;
     _zoom = zoom;
     this.LoadTile();
 }
 /// <summary>Initializes a new instance of the SearchControl class.</summary>
 public SearchControl()
 {
     this.InitializeComponent();
     _mapControlFactory = UIControls.Maps.Control.MapControlFactoryToUse;
     if (_mapControlFactory != null)
     {
         _provider = _mapControlFactory.SearchProvider;
         _provider.SearchCompleted += this.OnSearchCompleted;
         _provider.SearchError += this.OnSearchError;
     }
 }
 /// <summary>Initializes a new instance of the SearchControl class.</summary>
 public SearchControl()
 {
     this.InitializeComponent();
     _mapControlFactory = UIControls.Maps.Control.MapControlFactoryToUse;
     if (_mapControlFactory != null)
     {
         _provider = _mapControlFactory.SearchProvider;
         _provider.SearchCompleted += this.OnSearchCompleted;
         _provider.SearchError     += this.OnSearchError;
     }
 }
Exemple #6
0
 public void Dispose()
 {
     if (_mapControlFactory != null)
     {
         if (_mapControlFactory is IDisposable)
         {
             (_mapControlFactory as IDisposable).Dispose();
         }
         _mapControlFactory = null;
     }
 }
Exemple #7
0
        /// <summary>Initializes a new instance of the MapOffset class.</summary>
        /// <param name="property">The property this MapOffset represents.</param>
        /// <param name="offsetChanged">Called when the Offset changes.</param>
        public MapOffset(MapControlFactory mapControlFactory, PropertyInfo property, EventHandler offsetChanged)
        {
            System.Diagnostics.Debug.Assert(property != null, "property cannot be null");
            System.Diagnostics.Debug.Assert(offsetChanged != null, "offsetChanged cannot be null");

            _mapControlFactory = mapControlFactory;
            _mapSize = mapControlFactory.TileGenerator.TileSize;
            _offsetChanged = offsetChanged;
            this.Property = property;
            this.Frames = 24;
            CompositionTarget.Rendering += this.OnRendering; // Used for manual animation
        }
Exemple #8
0
        public void Dispose()
        {
            if (_mapControlFactory != null)
            {
                CurrentConnectedDatabase = null;
                Core.ApplicationData.Instance.PropertyChanged -= Instance_PropertyChanged;

                if (_mapControlFactory is IDisposable)
                {
                    (_mapControlFactory as IDisposable).Dispose();
                }
                _mapControlFactory = null;
            }
        }
Exemple #9
0
 public MapCanvas()
 {
     _mapControlFactory = UIControls.Maps.Control.MapControlFactoryToUse;
     if (_mapControlFactory != null)
     {
         _offsetX = _mapControlFactory.GetMapOffset(_translate.GetType().GetProperty("X"), this.OnOffsetChanged);
         _offsetY = _mapControlFactory.GetMapOffset(_translate.GetType().GetProperty("Y"), this.OnOffsetChanged);
         _tilePanel = _mapControlFactory.TilePanel;
         _tilePanel.RenderTransform = _translate;
     }
     this.Background = Brushes.Transparent; // Register all mouse clicks
     this.Children.Add(_cache);
     if (_mapControlFactory != null)
     {
         this.Children.Add(_tilePanel);
     }
     this.ClipToBounds = true;
     this.Focusable = true;
     this.FocusVisualStyle = null;
     this.SnapsToDevicePixels = true;
 }
Exemple #10
0
        public TileGenerator(MapControlFactory mapControlFactory)
        {
            _mapControlFactory = mapControlFactory;
            _maxZoom = 18;
            _tileSize = 256;

            try
            {
                string p = Core.Settings.Default.SettingsFolder;
                if (!System.IO.Directory.Exists(p))
                {
                    System.IO.Directory.CreateDirectory(p);
                }
                p = System.IO.Path.Combine(new string[] { p, "MapCache" });
                if (!System.IO.Directory.Exists(p))
                {
                    System.IO.Directory.CreateDirectory(p);
                }

                if (string.IsNullOrEmpty(_mapControlFactory.ID))
                {
                    p = System.IO.Path.Combine(new string[] { p, "MapCache" });
                }
                else
                {
                    p = System.IO.Path.Combine(new string[] { p, _mapControlFactory.ID });
                }
                if (!System.IO.Directory.Exists(p))
                {
                    System.IO.Directory.CreateDirectory(p);
                }
                CacheFolder = p;
            }
            catch
            {
            }

        }
Exemple #11
0
 public TileGeneratorOSM(MapControlFactory mapControlFactory)
     : base(mapControlFactory)
 {
     _maxZoom = 18;
     _tileSize = 256;
 }
Exemple #12
0
 /// <summary>Initializes a new instance of the TilePanel class.</summary>
 public TilePanel(MapControlFactory mapControlFactory)
 {
     _mapControlFactory = mapControlFactory;
     // This stops the Images from being blurry
     RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.NearestNeighbor);
 }