Exemple #1
0
        public MainWindow()
        {
            Tools.Utils.Touch();// We need to do that before any plugin is loaded so we "own" Current.
            Tools.Utils.MainWindow = this;

            _model                      = new Models.MainWindowModel();
            this.DataContext            = _model;
            Tools.Utils.MainWindowModel = _model;

            this.InitializeComponent();

            PropertyChangedEventHandler mapPropertyChanged = delegate(object s2, PropertyChangedEventArgs e2)
            {
                if (e2.PropertyName == nameof(IMap.UseAntiAliasing))
                {
                    RenderOptions.SetEdgeMode(this, Current.Map.UseAntiAliasing ? EdgeMode.Unspecified : EdgeMode.Aliased);
                    this.SnapsToDevicePixels = Current.Map.UseAntiAliasing;
                }
            };

            Current.MapChanged += delegate(CurrentPropertyChangedEventArgs <IMap> e)
            {
                if (e.OldValue != null)
                {
                    e.NewValue.PropertyChanged -= mapPropertyChanged;
                }
                if (e.NewValue != null)
                {
                    e.NewValue.PropertyChanged += mapPropertyChanged;
                }
                mapPropertyChanged(null, new PropertyChangedEventArgs(nameof(MapModel.UseAntiAliasing)));
            };

            PluginManager.Instance.Reload();
            rebuild();

#if DEBUG
            var newMap = new NewMapModel()
            {
                Datum      = Datum.WGS84,
                Projection = PluginManager.Instance.ProjectionProviders.First(),
                Name       = "test"
            };
            var map = newMap.CreateMap();
            Tools.Utils.Current.SetMap(map);
            map.ActiveObject = map;
            map.Layers.Add(PluginManager.Instance.LayerProviders.First().Create(map));
#endif
        }
Exemple #2
0
        private static void onNewMap(object sender, EventArgs args)
        {
            if (!saveDirty())
            {
                return;
            }

            var model  = new NewMapModel();
            var dialog = new NewMap()
            {
                Owner       = Utils.MainWindow,
                DataContext = model
            };

            if (dialog.ShowDialog() == true)
            {
                Utils.Current.SetMap(model.CreateMap());
                Current.Map.ActiveObject = Current.Map;
            }
        }