Пример #1
0
        /// <summary>
        /// Creates a new menu view model object
        /// </summary>
        public MenuViewModel()
        {
            this.AppIcon = SvgImageCache.GetImageSource("applogo.svg", noReplaceStringMap: true);

            try
            {
                this.VersionText = $"Version {AppInfo.VersionString} (Build {AppInfo.BuildString})";
            }
            catch (Exception)
            {
                this.VersionText = "Unknown version";
            }

            this.MenuItemList = new MenuItemViewModel[]
            {
                new MenuItemViewModel("Map", "icons/map.svg", PageKey.MapPage),
                new MenuItemViewModel("Layers", "icons/layers-outline.svg", PageKey.LayerListPage),
                new MenuItemViewModel("Locations", "icons/format-list-bulleted.svg", PageKey.LocationListPage),
                new MenuItemViewModel("Tracks", "icons/map-marker-distance.svg", PageKey.TrackListPage),
                new MenuItemViewModel("Current Position", "icons/compass.svg", PageKey.CurrentPositionDetailsPage),
                new MenuItemViewModel("Weather", "icons/weather-partlycloudy.svg", PageKey.WeatherDashboardPage),
                new MenuItemViewModel("Settings", "icons/settings.svg", PageKey.SettingsPage),
                new MenuItemViewModel("Info", "icons/information-outline.svg", PageKey.InfoPage),
            };

            this.MenuItemSelectedCommand = new Command(this.OnSelectedMenuItem);
        }
Пример #2
0
            /// <summary>
            /// Creates a new menu item view model object
            /// </summary>
            /// <param name="title">title of menu item</param>
            /// <param name="svgImageName">SVG image name of image to display</param>
            /// <param name="pageKey">page key of page to navigate to</param>
            public MenuItemViewModel(string title, string svgImageName, PageKey pageKey)
            {
                this.Title   = title;
                this.PageKey = pageKey;

                this.ImageSource = SvgImageCache.GetImageSource(svgImageName);
            }
Пример #3
0
        /// <summary>
        /// Creates a new view model object based on the given track object
        /// </summary>
        /// <param name="track">track object</param>
        public TrackDetailsViewModel(Track track)
        {
            this.track = track;

            this.TypeImageSource = SvgImageCache.GetImageSource(track, "#000000");

            this.SetupBindings();
        }
Пример #4
0
        /// <summary>
        /// Creates a new view model object based on the given layer object
        /// </summary>
        /// <param name="layer">layer object</param>
        public LayerDetailsViewModel(Layer layer)
        {
            this.layer = layer;

            this.TypeImageSource = SvgImageCache.GetImageSource(layer);

            this.SetupBindings();
        }
Пример #5
0
        /// <summary>
        /// Creates a new view model object based on the given track object
        /// </summary>
        /// <param name="parentViewModel">parent view model</param>
        /// <param name="track">track object</param>
        public TrackListEntryViewModel(TrackListViewModel parentViewModel, Track track)
        {
            this.parentViewModel = parentViewModel;
            this.track           = track;

            this.TypeImageSource = SvgImageCache.GetImageSource(track);

            this.SetupBindings();
        }
        /// <summary>
        /// Creates a new view model object based on the given layer object
        /// </summary>
        /// <param name="parentViewModel">parent view model</param>
        /// <param name="layer">layer object</param>
        public LayerListEntryViewModel(LayerListViewModel parentViewModel, Layer layer)
        {
            this.parentViewModel = parentViewModel;
            this.layer           = layer;

            this.TypeImageSource       = SvgImageCache.GetImageSource(layer, "#000000");
            this.VisibilityImageSource = SvgImageCache.GetLayerVisibilityImageSource(layer, "#000000");

            this.SetupBindings();
        }
Пример #7
0
        /// <summary>
        /// Converts svg image path to image source.
        /// </summary>
        /// <param name="value">value to use</param>
        /// <param name="targetType">target type to convert to</param>
        /// <param name="parameter">parameter to use, from ConverterParameter</param>
        /// <param name="culture">specific culture to use; unused</param>
        /// <returns>boolean true value when value greater-or-equal parameter, false else</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Debug.Assert(
                targetType == typeof(ImageSource),
                "convert target must be an ImageSource");

            string svgImageName = (string)value;

            return(SvgImageCache.GetImageSource(svgImageName));
        }
Пример #8
0
        /// <summary>
        /// Creates a new context menu view
        /// </summary>
        public ContextMenu()
        {
            this.BindingContext = this;

            this.ContextMenuImageSource =
                SvgImageCache.GetImageSource("icons/dots-vertical.svg");

            this.ContextMenuCommand = new AsyncCommand(this.ShowContextMenu);

            this.InitializeComponent();
        }
Пример #9
0
        /// <summary>
        /// Sets up bindings for this view model
        /// </summary>
        private void SetupBindings()
        {
            this.TypeImageSource       = SvgImageCache.GetImageSource(this.Layer);
            this.VisibilityImageSource = SvgImageCache.GetLayerVisibilityImageSource(this.Layer);

            this.ItemTappedCommand       = new AsyncCommand(this.OnTappedLayerItemAsync);
            this.VisibilityTappedCommand = new AsyncCommand(this.OnTappedLayerVisibilityAsync);
            this.ZoomToLayerCommand      = new AsyncCommand(this.OnZoomToLayerAsync, this.OnCanExecuteZoomToLayer);
            this.ExportLayerCommand      = new AsyncCommand(this.OnExportLayerAsync, this.OnCanExecuteExportLayer);
            this.DeleteLayerCommand      = new AsyncCommand(this.OnDeleteLayerAsync, this.OnCanExecuteDeleteLayer);
        }
Пример #10
0
        /// <summary>
        /// Shows the context menu
        /// </summary>
        /// <param name="point">map point where the long-tap occurred</param>
        /// <param name="appSettings">app settings</param>
        /// <returns>task to wait on</returns>
        public static async ValueTask <Result> ShowAsync(MapPoint point, AppSettings appSettings)
        {
            string latitudeText  = GeoDataFormatter.FormatLatLong(point.Latitude, appSettings.CoordinateDisplayFormat);
            string longitudeText = GeoDataFormatter.FormatLatLong(point.Longitude, appSettings.CoordinateDisplayFormat);

            string caption =
                $"Selected point at Latitude: {latitudeText}, Longitude: {longitudeText}, Altitude {point.Altitude.GetValueOrDefault(0.0)} m";

            var tcs = new TaskCompletionSource <Result>();

            var items = new List <MenuItem>
            {
                new MenuItem
                {
                    Text            = "Add new waypoint",
                    IconImageSource = SvgImageCache.GetImageSource("info/images/playlist-plus.svg"),
                    Command         = new Command(() => tcs.TrySetResult(Result.AddNewWaypoint)),
                },
                new MenuItem
                {
                    Text            = "Navigate here",
                    IconImageSource = SvgImageCache.GetImageSource("info/images/directions.svg"),
                    Command         = new Command(() => tcs.TrySetResult(Result.NavigateHere)),
                },
                new MenuItem
                {
                    Text            = "Show flying range",
                    IconImageSource = SvgImageCache.GetImageSource("info/images/arrow-expand-horizontal.svg"),
                    Command         = new Command(() => tcs.TrySetResult(Result.ShowFlyingRange)),
                },
            };

            ContextMenuPopupPage popupPage = null;

            EventHandler backgroundClicked =
                (sender, args) => tcs.TrySetResult(Result.Cancel);

            var viewModel = new ContextMenuPopupViewModel(
                caption,
                items,
                () =>
            {
                popupPage.Navigation.PopPopupAsync(true);
                popupPage.BackgroundClicked -= backgroundClicked;
            });

            popupPage = new ContextMenuPopupPage(viewModel);
            popupPage.BackgroundClicked += backgroundClicked;

            await popupPage.Navigation.PushPopupAsync(popupPage, true);

            return(await tcs.Task);
        }
Пример #11
0
        /// <summary>
        /// Creates a new view model object based on the given location object
        /// </summary>
        /// <param name="appSettings">app settings object</param>
        /// <param name="location">location object</param>
        public LocationDetailsViewModel(AppSettings appSettings, Location location)
        {
            this.appSettings = appSettings;
            this.location    = location;

            this.distance = 0.0;

            this.TypeImageSource =
                SvgImageCache.GetImageSource(location);

            this.SetupBindings();
        }
Пример #12
0
        /// <summary>
        /// Creates a new view model object based on the given location object
        /// </summary>
        /// <param name="parentViewModel">parent view model</param>
        /// <param name="location">location object</param>
        /// <param name="myCurrentPosition">the user's current position; may be null</param>
        public LocationListEntryViewModel(LocationListViewModel parentViewModel, Location location, MapPoint myCurrentPosition)
        {
            this.parentViewModel = parentViewModel;
            this.location        = location;

            this.Distance = myCurrentPosition != null?myCurrentPosition.DistanceTo(this.location.MapLocation) : 0.0;

            this.TypeImageSource =
                SvgImageCache.GetImageSource(this.location, "#000000");

            this.SetupBindings();
        }
Пример #13
0
        /// <summary>
        /// Called when the user tapped on the layer visibility icon
        /// </summary>
        /// <returns>task to wait on</returns>
        private async Task OnTappedLayerVisibilityAsync()
        {
            this.Layer.IsVisible = !this.Layer.IsVisible;

            IDataService dataService      = DependencyService.Get <IDataService>();
            var          layerDataService = dataService.GetLayerDataService();
            await layerDataService.Update(this.Layer);

            App.MapView.SetLayerVisibility(this.Layer);

            this.VisibilityImageSource = SvgImageCache.GetLayerVisibilityImageSource(this.Layer);
            this.OnPropertyChanged(nameof(this.VisibilityImageSource));
        }
            /// <summary>
            /// Creates a new view model for a list entry
            /// </summary>
            /// <param name="location">location object</param>
            /// <param name="parent">parent view model</param>
            public PlanTourListEntryViewModel(Location location, PlanTourPopupViewModel parent)
            {
                this.Id       = Guid.NewGuid().ToString("B");
                this.Location = location;
                this.parent   = parent;

                this.TypeImageSource =
                    SvgImageCache.GetImageSource(this.Location, "#000000");

                this.MoveUpCommand = new Command(
                    (obj) => this.parent.MoveUpLocation(this),
                    (obj) => !this.parent.IsFirstLocation(this));

                this.MoveDownCommand = new Command(
                    (obj) => this.parent.MoveDownLocation(this),
                    (obj) => !this.parent.IsLastLocation(this));

                this.RemoveCommand = new Command(
                    (obj) => this.parent.RemoveLocation(this));
            }