< Summary

Information
Class: OffRouteMap.MainWindow
Assembly: OffRouteMap
File(s): File 1: D:\a\OffRouteMap\OffRouteMap\MainWindow.xaml
File 2: D:\a\OffRouteMap\OffRouteMap\MainWindow.xaml.cs
Tag: 5_18712131505
Line coverage
0%
Covered lines: 0
Uncovered lines: 34
Coverable lines: 34
Total lines: 160
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 11
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

D:\a\OffRouteMap\OffRouteMap\MainWindow.xaml

#LineLine coverage
 01<mah:MetroWindow x:Class="OffRouteMap.MainWindow"
 2        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6        xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
 7        xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
 8        xmlns:gmap="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation"
 9        xmlns:local="clr-namespace:OffRouteMap"
 10        Title="{Binding WindowTitle, UpdateSourceTrigger=PropertyChanged}"
 011        Closing="Window_Closing"
 12        GlowBrush="{DynamicResource MahApps.Brushes.Accent}"
 13        Height="500" Width="600">
 14
 15    <mah:MetroWindow.LeftWindowCommands>
 16        <mah:WindowCommands>
 17            <Button Command="{Binding GuiZoomOutCommand}">
 18                <iconPacks:PackIconModern Width="22"
 19                                  Height="22"
 20                                  Kind="MagnifyMinus" />
 21            </Button>
 22            <Button Command="{Binding GuiZoomInCommand}">
 23                <iconPacks:PackIconModern Width="22"
 24                                  Height="22"
 25                                  Kind="MagnifyAdd" />
 26            </Button>
 27
 28        </mah:WindowCommands>
 29    </mah:MetroWindow.LeftWindowCommands>
 30
 31    <mah:MetroWindow.RightWindowCommands>
 32        <mah:WindowCommands>
 33            <Button Command="{Binding RemoveRouteCommand}" Name="btnDelete">
 34                <iconPacks:PackIconModern Width="22"
 35                                  Height="22"
 36                                  Kind="Delete" />
 37            </Button>
 38
 39            <Button Command="{Binding LoadRouteCommand}" Name="btnLoad">
 40                <iconPacks:PackIconModern Width="22"
 41                                  Height="22"
 42                                  Kind="DiskDownload" />
 43            </Button>
 44            <Button Command="{Binding SaveRouteCommand}" Name="btnSave">
 45                <iconPacks:PackIconModern Width="22"
 46                                  Height="22"
 47                                  Kind="Save" />
 48            </Button>
 49
 50            <Button Command="{Binding SetCacheRootCommand}" Name="btnCacheRoot">
 51                <iconPacks:PackIconModern Width="22"
 52                                  Height="22"
 53                                  Kind="Suitcase" />
 54            </Button>
 55        </mah:WindowCommands>
 56    </mah:MetroWindow.RightWindowCommands>
 57
 58    <Grid>
 59        <Grid.LayoutTransform>
 60            <ScaleTransform ScaleX="{Binding GuiZoomFactor}" ScaleY="{Binding GuiZoomFactor}" />
 61        </Grid.LayoutTransform>
 62
 63        <gmap:GMapControl Name="gmapControl" Margin="10,10,10,43" MinZoom="0" MaxZoom="18" />
 64
 65        <Label Content="{Binding StatusLine}" Margin="10,0,10,10" VerticalAlignment="Bottom" HorizontalAlignment="Left" 
 66        <ComboBox Width="120"  Margin="10,0,10,10" VerticalAlignment="Bottom" HorizontalAlignment="Right"
 67                  DisplayMemberPath="DisplayName"
 68                  SelectedValuePath="Key"
 69                  SelectedValue="{Binding SelectedMap, Mode=TwoWay}"
 70                  ItemsSource="{Binding Items}" />
 71    </Grid>
 72</mah:MetroWindow>

D:\a\OffRouteMap\OffRouteMap\MainWindow.xaml.cs

#LineLine coverage
 1using GMap.NET.WindowsPresentation;
 2using MahApps.Metro.Controls;
 3using OffRouteMap.Properties;
 4using System.Windows.Input;
 5
 6namespace OffRouteMap
 7{
 8
 9    public partial class MainWindow : MetroWindow
 10    {
 11        private readonly ThemeService _themeService;
 12        private readonly MainViewModel _viewModel;
 13
 014        public MainWindow ()
 15        {
 016            InitializeComponent();
 17
 18            // A primitve way for localisations.
 019            btnCacheRoot.ToolTip = Strings.FolderDialog_Title;
 020            btnDelete.ToolTip = Strings.DelCommand_Hint;
 021            btnLoad.ToolTip = Strings.LoadDialog_Title;
 022            btnSave.ToolTip = Strings.SaveDialog_Title;
 23
 24            // set the UI theme
 025            _themeService = new ThemeService(140, 220, 178);
 026            _themeService.ApplyTheme(this, Settings.Default.isDark);
 27
 028            gmapControl.MouseMove += GMapControl_MouseMove;
 029            gmapControl.MouseDoubleClick += GMapControl_MouseDoubleClick;
 030            gmapControl.MouseRightButtonDown += GMapControl_MouseRightButtonDown;
 31
 032            var gmapWrapper = new GMapControlWrapper(gmapControl);
 033            _viewModel = new MainViewModel(gmapWrapper);
 034            DataContext = _viewModel;
 035        }
 36
 37        private void Window_Closing (object sender, System.ComponentModel.CancelEventArgs e)
 38        {
 039            var viewModel = (MainViewModel)this.DataContext;
 40
 041            if (viewModel.BeforeClosingCommand.CanExecute(null))
 42            {
 043                viewModel.BeforeClosingCommand.Execute(null);
 44            }
 45
 46            // @todo some newbie trail and error here :-S
 047            e.Cancel = false;
 48            //Application.Current.Shutdown();
 049            Environment.Exit(0);
 50            //this.Close();
 051        }
 52
 53        /// <summary>
 54        /// The event of mouse movement on the map forward to the DataModel.
 55        /// </summary>
 56        /// <param name="sender">sending ui element</param>
 57        /// <param name="e">mouse event. we need its position here</param>
 58        private void GMapControl_MouseMove (object sender, MouseEventArgs e)
 59        {
 060            var point = e.GetPosition(gmapControl);
 061            _viewModel.UpdateMousePositionFrom(point);
 062        }
 63
 64        /// <summary>
 65        /// The event of mouse double click on the map forward to the DataModel.
 66        /// </summary>
 67        /// <param name="sender">sending ui element</param>
 68        /// <param name="e">mouse event. we need its position here</param>
 69        private void GMapControl_MouseDoubleClick (object sender, MouseButtonEventArgs e)
 70        {
 071            var point = e.GetPosition(gmapControl);
 072            _viewModel.UpdateMousePositionFrom(point);
 073            _viewModel.AddRoutePoint();
 074        }
 75
 76        /// <summary>
 77        /// The event of mouse click on the map forward to the DataModel.
 78        /// </summary>
 79        /// <param name="sender">sending ui element</param>
 80        /// <param name="e">mouse event. we need its position here</param>
 81        private void GMapControl_MouseRightButtonDown (object sender, MouseButtonEventArgs e)
 82        {
 083            var point = e.GetPosition(gmapControl);
 084            _viewModel.UpdateMousePositionFrom(point);
 085            _viewModel.RemoveLastRoutePoint();
 086        }
 87    }
 88}