1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Redid the main enable-mechanism, should be more robust and user friendly.

This commit is contained in:
SpoinkyNL 2016-02-26 20:30:05 +01:00
parent 60d15a12e6
commit ad5c28ff6f
8 changed files with 61 additions and 11 deletions

View File

@ -38,9 +38,16 @@
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
<Popup PlacementTarget="{Binding ElementName=EffectEnabled}"
IsOpen="{Binding Path=ShowDisabledPopup, Mode=TwoWay}" Placement="Left" VerticalOffset="-10"
PopupAnimation="Fade" StaysOpen="False">
<Border Margin="1">
<TextBlock Background="{DynamicResource AccentColorBrush}" Foreground="{DynamicResource IdealForegroundColorBrush}"
Text="You can't enable an effect when Artemis is disabled" Padding="4" />
</Border>
</Popup>
</StackPanel>
</StackPanel>
<!-- Top color -->
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,8">

View File

@ -36,6 +36,14 @@
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
<Popup PlacementTarget="{Binding ElementName=EffectEnabled}"
IsOpen="{Binding Path=ShowDisabledPopup, Mode=TwoWay}" Placement="Left" VerticalOffset="-10"
PopupAnimation="Fade" StaysOpen="False">
<Border Margin="1">
<TextBlock Background="{DynamicResource AccentColorBrush}" Foreground="{DynamicResource IdealForegroundColorBrush}"
Text="You can't enable an effect when Artemis is disabled" Padding="4" />
</Border>
</Popup>
</StackPanel>
</StackPanel>

View File

@ -31,9 +31,16 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
IsChecked="{Binding Path=EffectEnabled, Mode=OneWay}"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
<Popup PlacementTarget="{Binding ElementName=EffectEnabled}"
IsOpen="{Binding Path=ShowDisabledPopup, Mode=TwoWay}" Placement="Left" VerticalOffset="-10"
PopupAnimation="Fade" StaysOpen="False">
<Border Margin="1">
<TextBlock Background="{DynamicResource AccentColorBrush}" Foreground="{DynamicResource IdealForegroundColorBrush}"
Text="You can't enable an effect when Artemis is disabled" Padding="4" />
</Border>
</Popup>
</StackPanel>
</StackPanel>
</Grid>

View File

@ -35,8 +35,16 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]"
Style="{DynamicResource MetroCircleToggleButtonStyle}" />
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
<Popup PlacementTarget="{Binding ElementName=EffectEnabled}"
IsOpen="{Binding Path=ShowDisabledPopup, Mode=TwoWay}" Placement="Left" VerticalOffset="-10"
PopupAnimation="Fade" StaysOpen="False">
<Border Margin="1">
<TextBlock Background="{DynamicResource AccentColorBrush}" Foreground="{DynamicResource IdealForegroundColorBrush}"
Text="You can't enable an effect when Artemis is disabled" Padding="4" />
</Border>
</Popup>
</StackPanel>
</StackPanel>

View File

@ -10,7 +10,7 @@ namespace Artemis.Utilities.Keyboard
public void Subscribe(KeyEventHandler handleKeypress)
{
if (Subscriptions < 1)
if (_mGlobalHook == null)
_mGlobalHook = Hook.GlobalEvents();
_mGlobalHook.KeyDown += handleKeypress;
@ -19,6 +19,9 @@ namespace Artemis.Utilities.Keyboard
public void Unsubscribe(KeyEventHandler handleKeypress)
{
if (_mGlobalHook == null)
return;
_mGlobalHook.KeyDown -= handleKeypress;
Subscriptions--;

View File

@ -7,6 +7,7 @@ namespace Artemis.ViewModels.Abstract
public abstract class EffectViewModel : Screen
{
private EffectSettings _effectSettings;
private bool _showDisabledPopup;
public EffectModel EffectModel { get; set; }
public MainManager MainManager { get; set; }
@ -24,8 +25,26 @@ namespace Artemis.ViewModels.Abstract
public bool EffectEnabled => MainManager.EffectManager.ActiveEffect == EffectModel;
public bool ShowDisabledPopup
{
get { return _showDisabledPopup; }
set
{
if (value == _showDisabledPopup) return;
_showDisabledPopup = value;
NotifyOfPropertyChange(() => ShowDisabledPopup);
}
}
public void ToggleEffect()
{
if (!MainManager.ProgramEnabled)
{
NotifyOfPropertyChange(() => EffectEnabled);
ShowDisabledPopup = true;
return;
}
if (EffectEnabled)
MainManager.EffectManager.ClearEffect();
else

View File

@ -76,11 +76,9 @@ namespace Artemis.ViewModels.Flyouts
public void ToggleEnabled()
{
if (Enabled)
MainManager.Stop();
else if (MainManager.EffectManager.ActiveEffect != null)
MainManager.Start();
MainManager.DisableProgram();
else
MainManager.Start(MainManager.EffectManager.GetLastEffect());
MainManager.EnableProgram();
}
public void ResetSettings()

View File

@ -65,9 +65,9 @@ namespace Artemis.ViewModels
public void ToggleEnabled()
{
if (Enabled)
_shellViewModel.MainManager.Stop();
_shellViewModel.MainManager.DisableProgram();
else
_shellViewModel.MainManager.Start();
_shellViewModel.MainManager.EnableProgram();
}
protected override void OnActivate()