-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.xaml.cs
204 lines (183 loc) · 7.73 KB
/
Settings.xaml.cs
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Worksly
{
/// <summary>
/// Interaction logic for Settings.xaml
/// </summary>
public partial class Settings : Window
{
public static RoutedCommand saveSettings = new RoutedCommand();
public static RoutedCommand closeApp = new RoutedCommand();
private readonly TimeSpan scheduledTime = Settings1.Default.EODTime;
private readonly bool EODHardMode = Settings1.Default.EODHardMode;
private readonly DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
const string timerMessage = "Next scheduled end of day pop-up: ";
SolidColorBrush disabledText = new SolidColorBrush(Color.FromRgb(112, 112, 112));
public Settings()
{
InitializeComponent();
CommandBinding cb = new CommandBinding(saveSettings, SaveExecuted, SaveCanExecute);
this.CommandBindings.Add(cb);
CommandBinding cb1 = new CommandBinding(closeApp, CloseExecuted, CloseCanExecute);
this.CommandBindings.Add(cb1);
saveButton.Command = saveSettings;
CloseButton.Command = closeApp;
KeyGesture kg = new KeyGesture(Key.Enter);
InputBinding ib = new InputBinding(saveSettings, kg);
this.InputBindings.Add(ib);
KeyGesture kg1 = new KeyGesture(Key.Escape);
InputBinding ib1 = new InputBinding(closeApp, kg1);
this.InputBindings.Add(ib1);
LoadSettings();
}
private void LoadSettings()
{
string nextTimerText;
if ( App.timer.Enabled == true)
{
DateTime nextTimer = HelperTags.NextTimerEvent(App.timer);
nextTimerText = nextTimer.ToString("dd.MM.yyyy HH:mm");
}
else { nextTimerText = "N/A"; }
feedbackSavePathTB.Text = Settings1.Default.feedbackFolder;
TvFToggle.IsChecked = Settings1.Default.enableFBTasks;
fbToggleString.Text = Settings1.Default.feedbackTag;
fuToggleString.Text = Settings1.Default.followUpTag;
fbTABCheck.IsChecked = Settings1.Default.fbModeRequireTab;
taskSavePathTB.Text = Settings1.Default.tasksFolder;
followupSavePathTB.Text = Settings1.Default.fuFolder;
TvFToggleChecked();
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
private void CloseCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void CloseExecuted(object sender, ExecutedRoutedEventArgs e)
{
e.Handled = true;
this.Close();
}
private void SaveCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void SaveExecuted(object sender, ExecutedRoutedEventArgs e)
{
e.Handled = true;
Settings1.Default.enableFBTasks = (bool)TvFToggle.IsChecked;
if (fbToggleString.Text.Length > 0) { Settings1.Default.feedbackTag = fbToggleString.Text; }
if (fuToggleString.Text.Length > 0) { Settings1.Default.followUpTag = fuToggleString.Text; }
Settings1.Default.fbModeRequireTab = (bool)fbTABCheck.IsChecked;
Settings1.Default.Save();
HelperTags.StopTimer(App.timer);
HelperTags.Schedule_Timer(App.timer);
this.Close();
}
private void winsLocationChange_Click(object sender, RoutedEventArgs e)
{
ChangeWinsLocation();
LoadSettings();
saveButton.Focus();
}
private void feedbackLocationChange_Click(object sender, RoutedEventArgs e)
{
OutlookFolder window = new OutlookFolder(3); // 1=tasks, 2=follow up, 3=feedback
window.Closed += new EventHandler(window_Closed);
window.ShowDialog();
saveButton.Focus();
}
void window_Closed(object sender, EventArgs e)
{
LoadSettings();
}
public static void ChangeWinsLocation()
{
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
if (Settings1.Default.winsSavePath.Length > 0)
{
dlg.FileName = Settings1.Default.winsSaveFile;
dlg.InitialDirectory = Settings1.Default.winsSavePath;
}
else { dlg.FileName = "Personal Wins"; }
dlg.DefaultExt = ".txt";
dlg.Filter = "Text documents (.txt)|*.txt";
dlg.Title = "Daily Wins Save Location";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
string fileName = dlg.SafeFileName;
string fullName = dlg.FileName;
int fileNameLen = fileName.Length;
Settings1.Default.winsSaveFile = fileName;
Settings1.Default.winsSavePath = fullName.Remove(fullName.Length - fileNameLen, fileNameLen);
Settings1.Default.Save();
}
}
private void TvFToggle_Click(object sender, RoutedEventArgs e)
{
TvFToggleChecked();
}
private void TvFToggleChecked()
{
if (TvFToggle.IsChecked == true)
{
toggleSetText.Foreground = Brushes.White;
fbToggleString.IsEnabled = true;
fuToggleString.IsEnabled = true;
fbTABCheckLabel.Foreground = Brushes.White;
fbTABCheck.IsEnabled = true;
fbSaveLabel.Foreground = Brushes.White;
toggleFUSetText.Foreground = Brushes.White;
feedbackLocationChange.IsEnabled = true;
fuSaveLabel.Foreground = Brushes.White;
followupLocationChange.IsEnabled = true;
}
else
{
toggleSetText.Foreground = disabledText;
toggleFUSetText.Foreground = disabledText;
fbToggleString.IsEnabled = false;
fuToggleString.IsEnabled = false;
fbToggleString.Text = Settings1.Default.feedbackTag;
fuToggleString.Text = Settings1.Default.followUpTag;
fbTABCheckLabel.Foreground = disabledText;
fbTABCheck.IsEnabled = false;
fbTABCheck.IsChecked = Settings1.Default.fbModeRequireTab;
feedbackLocationChange.IsEnabled = false;
fbSaveLabel.Foreground = disabledText;
fuSaveLabel.Foreground = disabledText;
followupLocationChange.IsEnabled = false;
}
}
private void followupLocationChange_Click(object sender, RoutedEventArgs e)
{
OutlookFolder window = new OutlookFolder(2); // 1=tasks, 2=follow up, 3=feedback
window.Closed += new EventHandler(window_Closed);
window.ShowDialog();
saveButton.Focus();
}
private void taskLocationChange_Click(object sender, RoutedEventArgs e)
{
OutlookFolder window = new OutlookFolder(1); // 1=tasks, 2=follow up, 3=feedback
window.Closed += new EventHandler(window_Closed);
window.ShowDialog();
saveButton.Focus();
}
}
}