1+ using MahApps . Metro . Controls ;
2+ using OATCommunications . CommunicationHandlers ;
3+ using OATCommunications . Model ;
4+ using OATCommunications . WPF ;
5+ using OATCommunications . WPF . CommunicationHandlers ;
6+ using OATControl . Properties ;
7+ using OATControl . ViewModels ;
8+ using System ;
9+ using System . Collections . Generic ;
10+ using System . Collections . ObjectModel ;
11+ using System . ComponentModel ;
12+ using System . Drawing ;
13+ using System . IO ;
14+ using System . Linq ;
15+ using System . Text ;
16+ using System . Threading ;
17+ using System . Threading . Tasks ;
18+ using System . Windows ;
19+ using System . Windows . Controls ;
20+ using System . Windows . Data ;
21+ using System . Windows . Documents ;
22+ using System . Windows . Input ;
23+ using System . Windows . Media ;
24+ using System . Windows . Media . Imaging ;
25+ using System . Windows . Shapes ;
26+
27+ namespace OATControl
28+ {
29+ /// <summary>
30+ /// Interaction logic for DlgNinaPoolarAlignment.xaml
31+ /// </summary>
32+ public partial class DlgNinaPolarAlignment : MetroWindow , INotifyPropertyChanged
33+ {
34+ public class ChecklistItem : INotifyPropertyChanged
35+ {
36+ public event PropertyChangedEventHandler PropertyChanged ;
37+ private string _text ;
38+ private bool _isComplete ;
39+ public string Text
40+ {
41+ get { return _text ; }
42+ set
43+ {
44+ if ( _text != value )
45+ {
46+ _text = value ;
47+ OnPropertyChanged ( nameof ( Text ) ) ;
48+ }
49+ }
50+ }
51+ public bool IsComplete
52+ {
53+ get { return _isComplete ; }
54+ set
55+ {
56+ if ( _isComplete != value )
57+ {
58+ _isComplete = value ;
59+ OnPropertyChanged ( nameof ( IsComplete ) ) ;
60+ }
61+ }
62+ }
63+ protected void OnPropertyChanged ( string propertyName )
64+ {
65+ if ( PropertyChanged != null )
66+ {
67+ PropertyChanged ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
68+ }
69+ }
70+ }
71+
72+ private DelegateCommand _closeCommand ;
73+ private string _errorMessage ;
74+
75+ public DlgNinaPolarAlignment ( Action closeCallback )
76+ {
77+ _closeCommand = new DelegateCommand ( ( ) =>
78+ {
79+ closeCallback ( ) ;
80+ } ) ;
81+
82+ this . DataContext = this ;
83+ InitializeComponent ( ) ;
84+ }
85+
86+ public ObservableCollection < ChecklistItem > ChecklistItems { get ; } = new ObservableCollection < ChecklistItem >
87+ {
88+ new ChecklistItem { Text = "Plate solved first point..." } ,
89+ new ChecklistItem { Text = "Plate solved second point..." } ,
90+ new ChecklistItem { Text = "Plate solved third point..." } ,
91+ new ChecklistItem { Text = "Calculating error... " } ,
92+ new ChecklistItem { Text = "Adjusting mount AZ/ALT..." } ,
93+ } ;
94+
95+
96+ public void SetStatus ( string state , string statusDetails )
97+ {
98+ switch ( state )
99+ {
100+ case "Measure" :
101+ if ( statusDetails . Contains ( "First" ) )
102+ {
103+ ChecklistItems [ 0 ] . IsComplete = true ;
104+ }
105+ else if ( statusDetails . Contains ( "Second" ) )
106+ {
107+ ChecklistItems [ 1 ] . IsComplete = true ;
108+ }
109+ else if ( statusDetails . Contains ( "Third" ) )
110+ {
111+ ChecklistItems [ 2 ] . IsComplete = true ;
112+ }
113+ break ;
114+ case "CalculateSettle" :
115+ ChecklistItems [ 3 ] . IsComplete = true ;
116+ ChecklistItems [ 3 ] . Text = statusDetails ;
117+ break ;
118+ case "Adjust" :
119+ ChecklistItems [ 4 ] . IsComplete = true ;
120+ break ;
121+ case "ResetLoop" :
122+ ChecklistItems [ 3 ] . IsComplete = false ;
123+ ChecklistItems [ 3 ] . Text = "" ;
124+ ChecklistItems [ 4 ] . IsComplete = false ;
125+ break ;
126+ case "Error" :
127+ ErrorMessage = statusDetails ;
128+ break ;
129+ default :
130+ break ;
131+ }
132+ }
133+
134+ public ICommand CloseCommand { get { return _closeCommand ; } }
135+
136+ public string ErrorMessage
137+ {
138+ get { return _errorMessage ; }
139+ set
140+ {
141+ if ( _errorMessage != value )
142+ {
143+ _errorMessage = value ;
144+ OnPropertyChanged ( nameof ( ErrorMessage ) ) ;
145+ }
146+ }
147+ }
148+
149+ public event PropertyChangedEventHandler PropertyChanged ;
150+ private void OnPropertyChanged ( string field )
151+ {
152+ if ( PropertyChanged != null )
153+ {
154+ PropertyChanged ( this , new PropertyChangedEventArgs ( field ) ) ;
155+ }
156+ }
157+ }
158+ }
0 commit comments