markus / ConvertService / ServiceController / Markus.Service.StationController / ViewModel / MainViewModel.cs @ 5c387707
이력 | 보기 | 이력해설 | 다운로드 (3.34 KB)
1 | 5c387707 | semi | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.ServiceModel; |
||
5 | using System.Text; |
||
6 | using System.Threading.Tasks; |
||
7 | using System.Windows; |
||
8 | using System.Windows.Controls.Primitives; |
||
9 | using System.Windows.Input; |
||
10 | using System.Windows.Media; |
||
11 | using Markus.Mvvm.ToolKit; |
||
12 | using Markus.Service.Helper; |
||
13 | using Markus.Service.StationController.Data; |
||
14 | using Markus.Service.WcfClient.StationServiceTask; |
||
15 | |||
16 | namespace Markus.Service.StationController.ViewModel |
||
17 | { |
||
18 | public class MainViewModel : ViewModelBase |
||
19 | { |
||
20 | #region 프로퍼티 |
||
21 | |||
22 | private string id; |
||
23 | |||
24 | public string Id |
||
25 | { |
||
26 | get => id; set |
||
27 | { |
||
28 | id = value; |
||
29 | OnPropertyChanged(() => Id); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | private bool isMenuOpen; |
||
34 | |||
35 | public bool IsMenuOpen |
||
36 | { |
||
37 | get => isMenuOpen; set |
||
38 | { |
||
39 | isMenuOpen = value; |
||
40 | OnPropertyChanged(() => IsMenuOpen); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | |||
45 | |||
46 | private List<MenuItem> navigationItems; |
||
47 | |||
48 | public List<MenuItem> NavigationItems |
||
49 | { |
||
50 | get => navigationItems; set |
||
51 | { |
||
52 | navigationItems = value; |
||
53 | OnPropertyChanged(() =>NavigationItems); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | private MenuItem selectNavigationItem; |
||
58 | |||
59 | public MenuItem SelectNavigationItem |
||
60 | { |
||
61 | get => selectNavigationItem; set |
||
62 | { |
||
63 | selectNavigationItem = value; |
||
64 | OnPropertyChanged(() => SelectNavigationItem); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | #endregion 프로퍼티 |
||
69 | |||
70 | public override void Loaded() |
||
71 | { |
||
72 | base.Loaded(); |
||
73 | |||
74 | Application.Current.MainWindow.Height = System.Windows.SystemParameters.WorkArea.Height * 0.8; |
||
75 | Application.Current.MainWindow.Width = System.Windows.SystemParameters.WorkArea.Width * 0.8; |
||
76 | |||
77 | |||
78 | NavigationItems = new List<MenuItem> |
||
79 | { |
||
80 | |||
81 | new MenuItem |
||
82 | { |
||
83 | Name = "DataBase Items", |
||
84 | Description = "DataBase Items", |
||
85 | Content = new Views.DataBaseView() |
||
86 | }, |
||
87 | |||
88 | new MenuItem |
||
89 | { |
||
90 | Name = "FinalPDF Items", |
||
91 | Description = "FinalPDF Items", |
||
92 | Content = new Views.FinalPDFView() |
||
93 | }, |
||
94 | |||
95 | new MenuItem |
||
96 | { |
||
97 | Name = "Dash Board", |
||
98 | Description = "Dash Board", |
||
99 | Content = new Views.DashBoard() |
||
100 | }, |
||
101 | |||
102 | }; |
||
103 | |||
104 | SelectNavigationItem = NavigationItems.First(); |
||
105 | } |
||
106 | |||
107 | private void ListboxItemMouseUp() |
||
108 | { |
||
109 | var dependencyObject = Mouse.Captured as DependencyObject; |
||
110 | while (dependencyObject != null) |
||
111 | { |
||
112 | if (dependencyObject is ScrollBar) return; |
||
113 | dependencyObject = VisualTreeHelper.GetParent(dependencyObject); |
||
114 | } |
||
115 | |||
116 | IsMenuOpen = false; |
||
117 | } |
||
118 | |||
119 | #region Command |
||
120 | |||
121 | private ICommand _ListboxItemMouseUpCommand; |
||
122 | public ICommand ListboxItemMouseUpCommand |
||
123 | { |
||
124 | get => _ListboxItemMouseUpCommand ?? (_ListboxItemMouseUpCommand = new RelayCommand(param => ListboxItemMouseUp())); |
||
125 | } |
||
126 | |||
127 | #endregion |
||
128 | |||
129 | } |
||
130 | } |