< Summary

Information
Class: RouteEditorCS.MainWindow
Assembly: RouteEditorCS
File(s): File 1: D:\a\RouteEditorCS\RouteEditorCS\MainWindow.xaml
File 2: D:\a\RouteEditorCS\RouteEditorCS\MainWindow.xaml.cs
Tag: 9_19405000996
Line coverage
0%
Covered lines: 0
Uncovered lines: 33
Coverable lines: 33
Total lines: 154
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

D:\a\RouteEditorCS\RouteEditorCS\MainWindow.xaml

#LineLine coverage
 01<mah:MetroWindow x:Class="RouteEditorCS.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:RouteEditorCS"
 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        </mah:WindowCommands>
 51    </mah:MetroWindow.RightWindowCommands>
 52
 53    <Grid>
 54        <Grid.LayoutTransform>
 55            <ScaleTransform ScaleX="{Binding GuiZoomFactor}" ScaleY="{Binding GuiZoomFactor}" />
 56        </Grid.LayoutTransform>
 57
 58        <gmap:GMapControl Name="gmapControl" Margin="10,10,10,43" MinZoom="0" MaxZoom="18" />
 59
 60        <Label Content="{Binding StatusLine}" Margin="10,0,10,10" VerticalAlignment="Bottom" HorizontalAlignment="Left" 
 61        <ComboBox Width="120"  Margin="10,0,10,10" VerticalAlignment="Bottom" HorizontalAlignment="Right"
 62                  DisplayMemberPath="DisplayName"
 63                  SelectedValuePath="Key"
 64                  SelectedValue="{Binding SelectedMap, Mode=TwoWay}"
 65                  ItemsSource="{Binding Items}" />
 66    </Grid>
 67</mah:MetroWindow>

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

#LineLine coverage
 1using GMap.NET.WindowsPresentation;
 2using MahApps.Metro.Controls;
 3using RouteEditorCS.Properties;
 4using System.Windows.Input;
 5
 6namespace RouteEditorCS
 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            btnDelete.ToolTip = Strings.DelCommand_Hint;
 020            btnLoad.ToolTip = Strings.LoadDialog_Title;
 021            btnSave.ToolTip = Strings.SaveDialog_Title;
 22
 23            // set the UI theme
 024            _themeService = new ThemeService(140, 220, 178);
 025            _themeService.ApplyTheme(this, Settings.Default.isDark);
 26
 027            gmapControl.MouseMove += GMapControl_MouseMove;
 028            gmapControl.MouseDoubleClick += GMapControl_MouseDoubleClick;
 029            gmapControl.MouseRightButtonDown += GMapControl_MouseRightButtonDown;
 30
 031            var gmapWrapper = new GMapControlWrapper(gmapControl);
 032            _viewModel = new MainViewModel(gmapWrapper);
 033            DataContext = _viewModel;
 034        }
 35
 36        private void Window_Closing (object sender, System.ComponentModel.CancelEventArgs e)
 37        {
 038            var viewModel = (MainViewModel)this.DataContext;
 39
 040            if (viewModel.BeforeClosingCommand.CanExecute(null))
 41            {
 042                viewModel.BeforeClosingCommand.Execute(null);
 43            }
 44
 45            // @todo some newbie trail and error here :-S
 046            e.Cancel = false;
 47            //Application.Current.Shutdown();
 048            Environment.Exit(0);
 49            //this.Close();
 050        }
 51
 52        /// <summary>
 53        /// The event of mouse movement on the map forward to the DataModel.
 54        /// </summary>
 55        /// <param name="sender">sending ui element</param>
 56        /// <param name="e">mouse event. we need its position here</param>
 57        private void GMapControl_MouseMove (object sender, MouseEventArgs e)
 58        {
 059            var point = e.GetPosition(gmapControl);
 060            _viewModel.UpdateMousePositionFrom(point);
 061        }
 62
 63        /// <summary>
 64        /// The event of mouse double click on the map forward to the DataModel.
 65        /// </summary>
 66        /// <param name="sender">sending ui element</param>
 67        /// <param name="e">mouse event. we need its position here</param>
 68        private void GMapControl_MouseDoubleClick (object sender, MouseButtonEventArgs e)
 69        {
 070            var point = e.GetPosition(gmapControl);
 071            _viewModel.UpdateMousePositionFrom(point);
 072            _viewModel.AddRoutePoint();
 073        }
 74
 75        /// <summary>
 76        /// The event of mouse click on the map forward to the DataModel.
 77        /// </summary>
 78        /// <param name="sender">sending ui element</param>
 79        /// <param name="e">mouse event. we need its position here</param>
 80        private void GMapControl_MouseRightButtonDown (object sender, MouseButtonEventArgs e)
 81        {
 082            var point = e.GetPosition(gmapControl);
 083            _viewModel.UpdateMousePositionFrom(point);
 084            _viewModel.RemoveLastRoutePoint();
 085        }
 86    }
 87}