Skip to content

Commit

Permalink
1.7.9-2
Browse files Browse the repository at this point in the history
[Changes]
- Allow editing of profile actions #55
- Add starter profiles #53
- Some ui changes
  • Loading branch information
Codectory committed Dec 4, 2021
1 parent 45bf50e commit 71bcebb
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 88 deletions.
123 changes: 122 additions & 1 deletion Source/HDRProfile/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
<SolidColorBrush x:Key="HighlightedBrush" Color="{StaticResource SelectedBackgroundColor}"/>
<SolidColorBrush x:Key="MouseOverBrush" Color="{StaticResource ControlMouseOverColor}"/>
<SolidColorBrush x:Key="InactiveAccentBrush">#ad7b7b</SolidColorBrush>
<SolidColorBrush x:Key="DragScrollBrush">#757575</SolidColorBrush>
<SolidColorBrush x:Key="ScrollBrush">#969696</SolidColorBrush>
<SolidColorBrush x:Key="MouseOverScrollBrush">#a1a1a1</SolidColorBrush>

<SolidColorBrush x:Key="DisabledAccentBrush">#949ea6</SolidColorBrush>
<SolidColorBrush x:Key="HighlightedInactiveAccentBrush" Color="#95bfdb"/>
<StaticResource x:Key="ButtonBackgroundBrush" ResourceKey="AccentBrush"/>
Expand Down Expand Up @@ -152,7 +156,7 @@
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Height="Auto" Width="Auto" BorderBrush="{TemplateBinding Background}" Background="{TemplateBinding Background}" BorderThickness="0" CornerRadius="{StaticResource CornerRadius}">
<TextBlock FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Background="Transparent" Margin="5" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Background="Transparent" Margin="5,2" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
Expand Down Expand Up @@ -710,6 +714,123 @@



<Style x:Key="ScrollThumbs" TargetType="{x:Type Thumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Grid x:Name="Grid">
<Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Fill="Transparent" />
<Border x:Name="Rectangle1" CornerRadius="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Background="{TemplateBinding Background}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Tag" Value="Vertical">
<Setter TargetName="Rectangle1" Property="Width" Value="6" />
<Setter TargetName="Rectangle1" Property="Height" Value="Auto" />
</Trigger>
<Trigger Property="Tag" Value="Horizontal">
<Setter TargetName="Rectangle1" Property="Width" Value="Auto" />
<Setter TargetName="Rectangle1" Property="Height" Value="6" />

</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!--ScrollBars-->
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
<Setter Property="Stylus.IsFlicksEnabled" Value="false" />
<Setter Property="Foreground" Value="LightGray" />
<Setter Property="Background" Value="{StaticResource ScrollBrush}" />
<Setter Property="Width" Value="10" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Grid x:Name="GridRoot" Width="19" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="0.00001*" />
</Grid.RowDefinitions>

<Track x:Name="PART_Track" Grid.Row="0" IsDirectionReversed="true" Focusable="false">
<Track.Thumb>
<Thumb x:Name="Thumb" Background="{TemplateBinding Foreground}" Style="{DynamicResource ScrollThumbs}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton x:Name="PageUp" Command="ScrollBar.PageDownCommand" Opacity="0" Focusable="false" />
</Track.IncreaseRepeatButton>
<Track.DecreaseRepeatButton>
<RepeatButton x:Name="PageDown" Command="ScrollBar.PageUpCommand" Opacity="0" Focusable="false" />
</Track.DecreaseRepeatButton>
</Track>
</Grid>

<ControlTemplate.Triggers>
<Trigger SourceName="Thumb" Property="IsMouseOver" Value="true">
<Setter Value="{DynamicResource MouseOverScrollBrush}" TargetName="Thumb" Property="Background" />
</Trigger>
<Trigger SourceName="Thumb" Property="IsDragging" Value="true">
<Setter Value="{DynamicResource DragScrollBrush }" TargetName="Thumb" Property="Background" />
</Trigger>

<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="Thumb" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="Orientation" Value="Horizontal">
<Setter TargetName="GridRoot" Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="-90" />
</Setter.Value>
</Setter>
<Setter TargetName="PART_Track" Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="-90" />
</Setter.Value>
</Setter>
<Setter Property="Width" Value="Auto" />
<Setter Property="Height" Value="10" />
<Setter TargetName="Thumb" Property="Tag" Value="Horizontal" />
<Setter TargetName="PageDown" Property="Command" Value="ScrollBar.PageLeftCommand" />
<Setter TargetName="PageUp" Property="Command" Value="ScrollBar.PageRightCommand" />
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<!--<Setter TargetName="GridRoot" Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="-90" />
</Setter.Value>
</Setter>
<Setter TargetName="PART_Track" Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="-90" />
</Setter.Value>
</Setter>-->
<Setter Property="Width" Value="10" />
<Setter Property="Height" Value="Auto" />
<Setter TargetName="Thumb" Property="Tag" Value="Vertical" />
<Setter TargetName="PageDown" Property="Command" Value="ScrollBar.PageLeftCommand" />
<Setter TargetName="PageUp" Property="Command" Value="ScrollBar.PageRightCommand" />
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>















<local:EnumLocaleConverter x:Key="EnumLocaleConverter"/>
<corewpf:DialogService x:Key="DialogService" />
Expand Down
9 changes: 5 additions & 4 deletions Source/HDRProfile/Globals.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CodectoryCore.Logging;
using AutoHDR.Profiles;
using CodectoryCore.Logging;
using CodectoryCore.UI.Wpf;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -71,10 +72,9 @@ public void LoadSettings()
{
Globals.Logs.Add("No settings found. Creating settings file...", false);
Settings = new UserAppSettings();
_settingsLoadedOnce = true;

Settings.ApplicationProfiles.Add(Profile.DefaultProfile());
_settingsLoadedOnce = true;
}

SaveSettings();

}
Expand All @@ -97,6 +97,7 @@ public void LoadSettings()
Globals.Logs.Add("Settings loaded", false);
}


[Obsolete]
private UserAppSettings LoadObsoleteHDRSettings()
{
Expand Down
1 change: 1 addition & 0 deletions Source/HDRProfile/Info/AutoHDRInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public AutoHDRInfo()
{
CreateRelayCommands();
Version = VersionExtension.ApplicationVersion(System.Reflection.Assembly.GetExecutingAssembly());
Title = ProjectResources.Locale_Texts.Info;
}

private void CreateRelayCommands()
Expand Down
4 changes: 4 additions & 0 deletions Source/HDRProfile/Info/AutoHDRLicense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ namespace AutoHDR.Info
{
public class AutoHDRLicense : DialogViewModelBase
{
public AutoHDRLicense()
{
Title = ProjectResources.Locale_Texts.License;
}
}
}
20 changes: 18 additions & 2 deletions Source/HDRProfile/Profiles/Actions/ProfileActionAdder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public class ProfileActionAdder : DialogViewModelBase
{


private bool _editMode = false;
private bool _canCreate = false;

public bool CanCreate { get => _canCreate; set { _canCreate = value; OnPropertyChanged(); } }
public bool EditMode { get => _editMode; set { _editMode = value; OnPropertyChanged(); } }


private ActionTypeDescription _actionType = null;

Expand Down Expand Up @@ -52,7 +56,7 @@ public BaseViewModel ContentControlViewModel

private IProfileAction _profileAction = null;

public IProfileAction ProfileAction { get => _profileAction; private set { _profileAction = value; OnPropertyChanged(); } }
public IProfileAction ProfileAction { get => _profileAction; set { _profileAction = value; OnPropertyChanged(); } }

public List<ActionTypeDescription> ProfileActions
{
Expand All @@ -69,10 +73,22 @@ public List<ActionTypeDescription> ProfileActions

public ProfileActionAdder()
{
EditMode = false;
Title = Locale_Texts.AddProfileAction;
CreateRelayCommands();
}

public ProfileActionAdder(IProfileAction action)
{
EditMode = true;
ActionType = ProfileActions.First(d => d.ActionType.Equals(action.GetType()));
ContentControlViewModel = (BaseViewModel)action;

Title = Locale_Texts.EditProfileAction;

CreateRelayCommands();
}

private void CreateRelayCommands()
{
OKClickCommand = new RelayCommand<object>(CreateBaseProfileAction);
Expand All @@ -85,7 +101,7 @@ private void UpdateCanCreate()
CanCreate = ActionType != null;
}

public bool CanCreate { get => _canCreate; set { _canCreate = value; OnPropertyChanged(); } }



public void CreateBaseProfileAction(object parameter)
Expand Down
75 changes: 65 additions & 10 deletions Source/HDRProfile/Profiles/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace AutoHDR.Profiles
{
public enum ProfileActionListType
{
None,
Started,
Closed,
GotFocus,
Expand All @@ -24,17 +25,32 @@ public enum ProfileActionListType
public class Profile : BaseViewModel, IEquatable<Profile>
{


public static Profile DefaultProfile()
{
Profiles.Profile defaultProfile = new Profiles.Profile();
defaultProfile.Name = "HDR";
Profiles.Actions.DisplayAction startAction = new Profiles.Actions.DisplayAction();
startAction.Display = Displays.Display.AllDisplays;
startAction.SetHDR = true;
startAction.EnableHDR = true;
Profiles.Actions.DisplayAction endAction = new Profiles.Actions.DisplayAction();
endAction.Display = Displays.Display.AllDisplays;
endAction.SetHDR = true;
endAction.EnableHDR = false;
defaultProfile.ApplicationStarted.Add(startAction);
defaultProfile.ApplicationClosed.Add(endAction);
return defaultProfile;
}


public RelayCommand AddStartedActionCommand { get; private set; }
public RelayCommand AddClosedActionCommand { get; private set; }
public RelayCommand AddGotFocusActionCommand { get; private set; }
public RelayCommand AddLostFocusActionCommand { get; private set; }

public RelayCommand<ProfileActionBase> EditProfileActionCommand { get; private set; }
public RelayCommand<ProfileActionBase> RemoveProfileActionCommand { get; private set; }
public RelayCommand<ProfileActionBase> RemoveStartedActionCommand { get; private set; }
public RelayCommand<ProfileActionBase> RemoveClosedActionCommand { get; private set; }
public RelayCommand<ProfileActionBase> RemoveGotFocusActionCommand { get; private set; }
public RelayCommand<ProfileActionBase> RemoveLostFocusActionCommand { get; private set; }



public Profile()
Expand All @@ -44,12 +60,8 @@ public Profile()
AddClosedActionCommand = new RelayCommand(() => AddProfileAction(ProfileActionListType.Closed));
AddGotFocusActionCommand = new RelayCommand(() => AddProfileAction(ProfileActionListType.GotFocus));
AddLostFocusActionCommand = new RelayCommand(() => AddProfileAction(ProfileActionListType.LostFocus));
EditProfileActionCommand = new RelayCommand<ProfileActionBase>((pa) => EditProfileAction(pa));
RemoveProfileActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(pa));

RemoveStartedActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(ProfileActionListType.Started, pa));
RemoveClosedActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(ProfileActionListType.Closed, pa));
RemoveGotFocusActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(ProfileActionListType.GotFocus, pa));
RemoveLostFocusActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(ProfileActionListType.LostFocus, pa));
}

private Guid _guid = Guid.Empty;
Expand Down Expand Up @@ -143,6 +155,49 @@ public void AddProfileAction(ProfileActionListType listType)
DialogService.ShowDialogModal(adder, new System.Drawing.Size(800, 600));
}

public void EditProfileAction(ProfileActionBase profileAction)
{
ProfileActionListType listType = GetProfileActionListType(profileAction);
ProfileActionAdder adder = new ProfileActionAdder(profileAction);

adder.DialogService = DialogService;
adder.OKClicked += (o, e) =>
{
RemoveProfileAction(listType, profileAction);
switch (listType)
{
case ProfileActionListType.Started:
ApplicationStarted.Add(adder.ProfileAction);
break;
case ProfileActionListType.Closed:
ApplicationClosed.Add(adder.ProfileAction);
break;
case ProfileActionListType.GotFocus:
ApplicationGotFocus.Add(adder.ProfileAction);
break;
case ProfileActionListType.LostFocus:
ApplicationLostFocus.Add(adder.ProfileAction);
break;

}
};
if (DialogService != null)
DialogService.ShowDialogModal(adder, new System.Drawing.Size(800, 600));
}

private ProfileActionListType GetProfileActionListType(ProfileActionBase profileAction)
{
if (ApplicationStarted.Contains(profileAction))
return ProfileActionListType.Started;
if (ApplicationClosed.Contains(profileAction))
return ProfileActionListType.Closed;
if (ApplicationGotFocus.Contains(profileAction))
return ProfileActionListType.GotFocus;
if (ApplicationLostFocus.Contains(profileAction))
return ProfileActionListType.LostFocus;
return ProfileActionListType.None;
}

public void RemoveProfileAction(ProfileActionBase profileAction)
{
if (ApplicationStarted.Contains(profileAction))
Expand Down
9 changes: 9 additions & 0 deletions Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Source/HDRProfile/ProjectResources/Locale_Texts.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@
<data name="DownloadNewestVersion" xml:space="preserve">
<value>Download</value>
</data>
<data name="EditProfileAction" xml:space="preserve">
<value>Editieren</value>
</data>
<data name="Error" xml:space="preserve">
<value>Fehler</value>
</data>
Expand Down Expand Up @@ -372,6 +375,9 @@
<data name="Status" xml:space="preserve">
<value>Status</value>
</data>
<data name="String1" xml:space="preserve">
<value />
</data>
<data name="Version" xml:space="preserve">
<value>Version</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions Source/HDRProfile/ProjectResources/Locale_Texts.resx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@
<data name="DownloadNewestVersion" xml:space="preserve">
<value>Download</value>
</data>
<data name="EditProfileAction" xml:space="preserve">
<value>Edit</value>
</data>
<data name="Error" xml:space="preserve">
<value>Error</value>
</data>
Expand Down
Loading

0 comments on commit 71bcebb

Please sign in to comment.