Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow closing short-break window #21 #27

Merged
merged 2 commits into from
Feb 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/EyesGuard.Data/Languages/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Translation:
You can disable this feature from TaskManager >> Startup Tab.
AlertBeforeLongBreak: Notify me 1 minute before long-break
AlertBeforeLongBreakToolTip: Eyes Guard notifies you one minute before a long-break.
ShortBreakAllowCloseWithRightCLick: Close Short-break window with a right click
ShortBreakAllowCloseWithRightCLickToolTip: Allow closing Short-break window with a right click.
SystemIdle: Pause Eyes Guard when system detected as idle
SystemIdleToolTip:
- Eyes Guard uses system idle detection to detect if you are away from your
Expand Down
2 changes: 2 additions & 0 deletions Source/EyesGuard.Data/Languages/ru-RU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ Translation:
StartupApplicationToolTip: Программа Eyes Guard запускается при загрузке системы по умолчанию. Вы можете отменить данную функцию в Диспетчере задач Windows 10 на вкладке Автозагрузка.
AlertBeforeLongBreak: Напоминание за 1 минуту до длинного перерыва
AlertBeforeLongBreakToolTip: Eyes Guard напомнит о длинном перерыве за 1 минуту до его начала.
ShortBreakAllowCloseWithRightCLick: Разрешить закрывать заставку короткого перерыва правым кликом
ShortBreakAllowCloseWithRightCLickToolTip: Вы сможете закрыть заставку короткого перерыва правым кликом мыши
SystemIdle: Включать режим ожидания, если пользователь не активен
SystemIdleToolTip:
- Eyes Guard приостанавливает работу, если вы отошли от компьютера.
Expand Down
1 change: 1 addition & 0 deletions Source/EyesGuard/Configurations/ConfigurationProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public string LongBreakDurationString
public bool RunMinimized { get; set; } = false;
public bool ForceUserToBreak { get; set; } = false;
public bool OnlyOneShortBreak { get; set; } = false;
public bool ShortBreakAllowCloseWithRightCLick { get; set; } = false;
public bool SaveStats { get; set; } = true;
public bool RunAtStartUp { get { return runAtStartup; } set { runAtStartup = value; } }
public long ShortBreaksCompleted { get; set; } = 0;
Expand Down
4 changes: 2 additions & 2 deletions Source/EyesGuard/Views/Animations/ShowAndFadeAnimations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void HideUsingLinearAnimation(
int milliSeconds = 500,
IEasingFunction easingFunction = null)
{
if (element == null) return;
if (element == null || !element.IsVisible) return;
var anim = new DoubleAnimation()
{
From = 1,
Expand All @@ -37,7 +37,7 @@ public static Task HideUsingLinearAnimationAsync(
{
return Task.Run(async () =>
{
if (element == null) return;
if (element == null || !element.IsVisible) return;
element.Dispatcher.Invoke(() => HideUsingLinearAnimation(element, milliSeconds, easingFunction));
await Task.Delay(milliSeconds);
});
Expand Down
16 changes: 15 additions & 1 deletion Source/EyesGuard/Views/Pages/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="10" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -394,7 +395,20 @@
</CheckBox>

</StackPanel>

<StackPanel
Grid.Row="6"
Grid.Column="1"
Margin="5"
Orientation="Horizontal">
<CheckBox
x:Name="shortBreakAllowCloseWithRightCLick"
VerticalAlignment="Center"
Content="{lang:LocalizedString 'EyesGuard.Settings.UserSettings.ShortBreakAllowCloseWithRightCLick'}"
Foreground="White"
ToolTip="{lang:LocalizedString 'EyesGuard.Settings.UserSettings.ShortBreakAllowCloseWithRightCLickToolTip'}"
Style="{DynamicResource WhiteCheckbox}">
</CheckBox>
</StackPanel>
</Grid>

<StackPanel Orientation="Horizontal">
Expand Down
2 changes: 2 additions & 0 deletions Source/EyesGuard/Views/Pages/Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
onlyOneShortbreakCheckbox.IsChecked = App.Configuration.OnlyOneShortBreak;
storeStatsCheckbox.IsChecked = App.Configuration.SaveStats;
alertBeforeLongbreak.IsChecked = App.Configuration.AlertBeforeLongBreak;
alertBeforeLongbreak.IsChecked = App.Configuration.ShortBreakAllowCloseWithRightCLick;

sytemIdleCheckbox.IsChecked = App.Configuration.SystemIdleDetectionEnabled;

Expand Down Expand Up @@ -211,6 +212,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
App.Configuration.SaveStats = storeStatsCheckbox.IsChecked.Value;
App.Configuration.OnlyOneShortBreak = onlyOneShortbreakCheckbox.IsChecked.Value;
App.Configuration.AlertBeforeLongBreak = alertBeforeLongbreak.IsChecked.Value;
App.Configuration.ShortBreakAllowCloseWithRightCLick = shortBreakAllowCloseWithRightCLick.IsChecked.Value;
App.Configuration.SystemIdleDetectionEnabled = sytemIdleCheckbox.IsChecked.Value;
App.Configuration.ApplicationLocale = (LanguagesCombo.SelectedItem as LanguageHolder)?.Name ?? FsLanguageLoader.DefaultLocale;
App.Configuration.UseLanguageProvedidShortMessages = UseLanguageAsSourceCheckbox.IsChecked.Value;
Expand Down
3 changes: 2 additions & 1 deletion Source/EyesGuard/Views/Windows/ShortBreakWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">
mc:Ignorable="d"
MouseRightButtonUp="ShortBreakWindow_OnMouseRightButtonUp">
<Grid>

<Grid.ColumnDefinitions>
Expand Down
8 changes: 7 additions & 1 deletion Source/EyesGuard/Views/Windows/ShortBreakWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using EyesGuard.ViewModels;

namespace EyesGuard.Views.Windows
{
Expand All @@ -29,8 +30,13 @@ public ShortBreakWindow()

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!LetItClose)
if (!LetItClose && !App.Configuration.ShortBreakAllowCloseWithRightCLick)
e.Cancel = true;
}

private void ShortBreakWindow_OnMouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
@this.Close();
}
}
}