-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
87 lines (74 loc) · 3.12 KB
/
MainWindow.xaml.cs
File metadata and controls
87 lines (74 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using GMap.NET.WindowsPresentation;
using MahApps.Metro.Controls;
using RouteEditorCS.Properties;
using System.Windows.Input;
namespace RouteEditorCS
{
public partial class MainWindow : MetroWindow
{
private readonly ThemeService _themeService;
private readonly MainViewModel _viewModel;
public MainWindow ()
{
InitializeComponent();
// A primitve way for localisations.
btnDelete.ToolTip = Strings.DelCommand_Hint;
btnLoad.ToolTip = Strings.LoadDialog_Title;
btnSave.ToolTip = Strings.SaveDialog_Title;
// set the UI theme
_themeService = new ThemeService(140, 220, 178);
_themeService.ApplyTheme(this, Settings.Default.isDark);
gmapControl.MouseMove += GMapControl_MouseMove;
gmapControl.MouseDoubleClick += GMapControl_MouseDoubleClick;
gmapControl.MouseRightButtonDown += GMapControl_MouseRightButtonDown;
var gmapWrapper = new GMapControlWrapper(gmapControl);
_viewModel = new MainViewModel(gmapWrapper);
DataContext = _viewModel;
}
private void Window_Closing (object sender, System.ComponentModel.CancelEventArgs e)
{
var viewModel = (MainViewModel)this.DataContext;
if (viewModel.BeforeClosingCommand.CanExecute(null))
{
viewModel.BeforeClosingCommand.Execute(null);
}
// @todo some newbie trail and error here :-S
e.Cancel = false;
//Application.Current.Shutdown();
Environment.Exit(0);
//this.Close();
}
/// <summary>
/// The event of mouse movement on the map forward to the DataModel.
/// </summary>
/// <param name="sender">sending ui element</param>
/// <param name="e">mouse event. we need its position here</param>
private void GMapControl_MouseMove (object sender, MouseEventArgs e)
{
var point = e.GetPosition(gmapControl);
_viewModel.UpdateMousePositionFrom(point);
}
/// <summary>
/// The event of mouse double click on the map forward to the DataModel.
/// </summary>
/// <param name="sender">sending ui element</param>
/// <param name="e">mouse event. we need its position here</param>
private void GMapControl_MouseDoubleClick (object sender, MouseButtonEventArgs e)
{
var point = e.GetPosition(gmapControl);
_viewModel.UpdateMousePositionFrom(point);
_viewModel.AddRoutePoint();
}
/// <summary>
/// The event of mouse click on the map forward to the DataModel.
/// </summary>
/// <param name="sender">sending ui element</param>
/// <param name="e">mouse event. we need its position here</param>
private void GMapControl_MouseRightButtonDown (object sender, MouseButtonEventArgs e)
{
var point = e.GetPosition(gmapControl);
_viewModel.UpdateMousePositionFrom(point);
_viewModel.RemoveLastRoutePoint();
}
}
}