Skip to content

Commit f1cd1fa

Browse files
committed
Activating profiles
Implemented time with active profile switching
1 parent ce8a5a1 commit f1cd1fa

File tree

11 files changed

+215
-157
lines changed

11 files changed

+215
-157
lines changed

Source/Debug_Any/AutoHDR.exe

1.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.

Source/HDRProfile/AutoHDR.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
<Compile Include="ApplicationProfileAssignment.cs" />
179179
<Compile Include="Globals.cs" />
180180
<Compile Include="Profiles\Actions\ActionEndResult.cs" />
181-
<Compile Include="Profiles\Actions\BaseProfileAction.cs" />
182181
<Compile Include="Profiles\Actions\ApplicationAction.cs" />
183182
<Compile Include="Profiles\Actions\DisplayAction.cs" />
184183
<Compile Include="Info\AutoHDRInfo.cs" />
@@ -189,6 +188,7 @@
189188
<Compile Include="Profiles\Actions\IProfileAction.cs" />
190189
<Compile Include="Profiles\Actions\ListOfProfileActions.cs" />
191190
<Compile Include="Profiles\Actions\ProfileActionAdder.cs" />
191+
<Compile Include="Profiles\Actions\ProfileActionBase.cs" />
192192
<Compile Include="Profiles\Profile.cs" />
193193
<Compile Include="Profiles\ProfileMode.cs" />
194194
<Compile Include="SortedObservableCollection.cs" />

Source/HDRProfile/AutoHDRDaemon.cs

Lines changed: 173 additions & 107 deletions
Large diffs are not rendered by default.

Source/HDRProfile/Profiles/Actions/ApplicationAction.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AutoHDR.ProjectResources;
2+
using CodectoryCore.UI.Wpf;
23
using System;
34
using System.Collections.Generic;
45
using System.Diagnostics;
@@ -10,10 +11,8 @@
1011
namespace AutoHDR.Profiles.Actions
1112
{
1213

13-
public class ApplicationAction : BaseProfileAction
14+
public class ApplicationAction : ProfileActionBase
1415
{
15-
16-
public Displays.Display Display { get; private set; } = null;
1716
public override string ActionTypeName => ProjectResources.Locale_Texts.ApplicationAction;
1817

1918

Source/HDRProfile/Profiles/Actions/DisplayAction.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
using AutoHDR.ProjectResources;
2+
using CodectoryCore.UI.Wpf;
23
using System;
34
using System.Collections.Generic;
4-
using System.Collections.ObjectModel;
55
using System.Drawing;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
6+
using System.Xml;
7+
using System.Xml.Schema;
98

109
namespace AutoHDR.Profiles.Actions
1110
{
1211

13-
public class DisplayAction : BaseProfileAction
12+
public class DisplayAction : ProfileActionBase
1413
{
1514
public List<Displays.Display> AllDisplays => AutoHDR.Displays.DisplayManager.GetActiveMonitors();
1615

@@ -69,6 +68,5 @@ public override ActionEndResult RunAction(params object[] parameters)
6968
return new ActionEndResult(false, ex.Message, ex);
7069
}
7170
}
72-
7371
}
7472
}

Source/HDRProfile/Profiles/Actions/ListOfProfileActions.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@ public ListOfProfileActions() : base() { }
1919
public void ReadXml(XmlReader reader)
2020
{
2121

22-
try
23-
{
24-
object value = reader.GetAttribute("ProfileActions");
25-
if (string.IsNullOrEmpty((string)value))
26-
return;
27-
}
28-
catch (Exception)
29-
{
22+
reader.Read();
23+
if (!reader.IsStartElement("IProfileAction"))
3024
return;
31-
}
32-
reader.ReadStartElement("ProfileActions");
3325
while (reader.IsStartElement("IProfileAction"))
3426
{
35-
Type type = Type.GetType(reader.GetAttribute("AssemblyQualifiedName"));
27+
object value = reader.GetAttribute("AssemblyQualifiedName");
28+
if (string.IsNullOrEmpty((string)value))
29+
return;
30+
31+
Type type = Type.GetType((string)value);
3632
XmlSerializer serial = new XmlSerializer(type);
3733

3834
reader.ReadStartElement("IProfileAction");

Source/HDRProfile/Profiles/Actions/BaseProfileAction.cs renamed to Source/HDRProfile/Profiles/Actions/ProfileActionBase.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
using System.Linq;
55
using System.Text;
66
using System.Threading.Tasks;
7+
using System.Xml;
8+
using System.Xml.Schema;
9+
using System.Xml.Serialization;
710

811
namespace AutoHDR.Profiles.Actions
912
{
10-
public abstract class BaseProfileAction : BaseViewModel, IProfileAction
13+
public abstract class ProfileActionBase : BaseViewModel, IProfileAction
1114
{
1215
public abstract string ActionName { get; }
1316
public abstract string ActionTypeName { get; }
14-
1517
public abstract ActionEndResult RunAction(params object[] parameter);
18+
1619
}
1720
}

Source/HDRProfile/Profiles/Profile.cs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public enum ProfileActionListType
3030
[XmlIgnore]
3131
public RelayCommand AddLostFocusActionCommand { get; private set; }
3232
[XmlIgnore]
33-
public RelayCommand<IProfileAction> RemoveProfileActionCommand { get; private set; }
33+
public RelayCommand<ProfileActionBase> RemoveProfileActionCommand { get; private set; }
3434
[XmlIgnore]
35-
public RelayCommand<IProfileAction> RemoveStartedActionCommand { get; private set; }
35+
public RelayCommand<ProfileActionBase> RemoveStartedActionCommand { get; private set; }
3636
[XmlIgnore]
37-
public RelayCommand<IProfileAction> RemoveClosedActionCommand { get; private set; }
37+
public RelayCommand<ProfileActionBase> RemoveClosedActionCommand { get; private set; }
3838
[XmlIgnore]
39-
public RelayCommand<IProfileAction> RemoveGotFocusActionCommand { get; private set; }
39+
public RelayCommand<ProfileActionBase> RemoveGotFocusActionCommand { get; private set; }
4040
[XmlIgnore]
41-
public RelayCommand<IProfileAction> RemoveLostFocusActionCommand { get; private set; }
41+
public RelayCommand<ProfileActionBase> RemoveLostFocusActionCommand { get; private set; }
4242

4343

4444
public Profile()
@@ -47,12 +47,12 @@ public Profile()
4747
AddClosedActionCommand = new RelayCommand(() => AddProfileAction(ProfileActionListType.Closed));
4848
AddGotFocusActionCommand = new RelayCommand(() => AddProfileAction(ProfileActionListType.GotFocus));
4949
AddLostFocusActionCommand = new RelayCommand(() => AddProfileAction(ProfileActionListType.LostFocus));
50-
RemoveProfileActionCommand = new RelayCommand<IProfileAction>((pa) => RemoveProfileAction(pa));
50+
RemoveProfileActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(pa));
5151

52-
RemoveStartedActionCommand = new RelayCommand<IProfileAction>((pa) => RemoveProfileAction(ProfileActionListType.Started, pa));
53-
RemoveClosedActionCommand = new RelayCommand<IProfileAction>((pa) => RemoveProfileAction(ProfileActionListType.Closed, pa));
54-
RemoveGotFocusActionCommand = new RelayCommand<IProfileAction>((pa) => RemoveProfileAction(ProfileActionListType.GotFocus, pa));
55-
RemoveLostFocusActionCommand = new RelayCommand<IProfileAction>((pa) => RemoveProfileAction(ProfileActionListType.LostFocus, pa));
52+
RemoveStartedActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(ProfileActionListType.Started, pa));
53+
RemoveClosedActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(ProfileActionListType.Closed, pa));
54+
RemoveGotFocusActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(ProfileActionListType.GotFocus, pa));
55+
RemoveLostFocusActionCommand = new RelayCommand<ProfileActionBase>((pa) => RemoveProfileAction(ProfileActionListType.LostFocus, pa));
5656
PropertyChanged += Profile_PropertyChanged;
5757
}
5858

@@ -69,14 +69,6 @@ public string Name
6969
set { _name = value; OnPropertyChanged(); }
7070
}
7171

72-
private ProfileMode _mode = ProfileMode.OnRunning;
73-
74-
public ProfileMode Mode
75-
{
76-
get { return _mode; }
77-
set { _mode = value; OnPropertyChanged(); }
78-
}
79-
8072
private ListOfProfileActions _applicationStarted = new ListOfProfileActions();
8173
public ListOfProfileActions ApplicationStarted
8274
{
@@ -139,7 +131,7 @@ public void AddProfileAction(ProfileActionListType listType)
139131
DialogService.ShowDialogModal(adder, new System.Drawing.Size(640,450));
140132
}
141133

142-
public void RemoveProfileAction( IProfileAction profileAction)
134+
public void RemoveProfileAction(ProfileActionBase profileAction)
143135
{
144136
if (ApplicationStarted.Contains(profileAction))
145137
ApplicationStarted.Remove(profileAction);
@@ -152,7 +144,7 @@ public void RemoveProfileAction( IProfileAction profileAction)
152144
}
153145

154146

155-
public void RemoveProfileAction(ProfileActionListType listType, IProfileAction profileAction)
147+
public void RemoveProfileAction(ProfileActionListType listType, ProfileActionBase profileAction)
156148
{
157149
switch (listType)
158150
{

Source/HDRProfile/Views/AutoHDRMainView.xaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@
3838
<DataTemplate x:Key="AssignmentTemplate" DataType="ApplicationProfileAssignment">
3939
<Grid>
4040
<Grid.ColumnDefinitions>
41-
<ColumnDefinition Width="Auto"/>
42-
<ColumnDefinition Width="Auto"/>
41+
<ColumnDefinition Width="50"/>
42+
<ColumnDefinition Width="250"/>
4343
<ColumnDefinition Width="*" />
44-
<ColumnDefinition Width="Auto" />
4544
</Grid.ColumnDefinitions>
4645
<Image Grid.Column="0" Source="{Binding Application.Icon, Converter={StaticResource BitmapToBitmapImageConverter}}" Width="50" Height="50" Stretch="Fill"></Image>
4746
<TextBlock Grid.Column="1" Text="{Binding Application.DisplayName}" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" />
48-
<ComboBox Grid.Column="2" SelectedItem="{Binding Profile}" ItemsSource="{Binding Settings.ApplicationProfiles}"/>
47+
<ComboBox Grid.Column="2" SelectedItem="{Binding Profile}" ItemsSource="{Binding ElementName=MainWindow , Path=DataContext.Settings.ApplicationProfiles}" FontSize="18" FontWeight="Bold" VerticalAlignment="Center"/>
4948
</Grid>
5049
</DataTemplate>
5150

@@ -124,13 +123,18 @@
124123
<TabItem Header="{x:Static pres:Locale_Texts.Applications}" >
125124
<Grid >
126125
<Grid.ColumnDefinitions>
126+
<ColumnDefinition Width="300"/>
127127
<ColumnDefinition Width="*"/>
128128
</Grid.ColumnDefinitions>
129129
<Grid.RowDefinitions>
130+
<RowDefinition Height="Auto"/>
130131
<RowDefinition Height="*"/>
131132
<RowDefinition Height="Auto" />
132133
</Grid.RowDefinitions>
133-
<Border Style="{StaticResource RoundedBorder}" BorderBrush="{DynamicResource AccentBrush}" BorderThickness="1" Margin="10,10,10,10" Grid.Row="0">
134+
<TextBlock Text="{x:Static pres:Locale_Texts.Applications}" Grid.Row="0" Grid.Column="0" Margin="10,10,10,00" />
135+
<TextBlock Text="{x:Static pres:Locale_Texts.Profiles}" Grid.Row="0" Grid.Column="1" Margin="10,10,10,0" />
136+
137+
<Border Style="{StaticResource RoundedBorder}" BorderBrush="{DynamicResource AccentBrush}" BorderThickness="1" Margin="10,10,10,10" Grid.Row="1" Grid.ColumnSpan="2">
134138
<Grid>
135139
<Grid.RowDefinitions>
136140
<RowDefinition Height="Auto"/>
@@ -141,7 +145,7 @@
141145
</ScrollViewer>
142146
</Grid>
143147
</Border>
144-
<Grid Grid.Row="1" Height="Auto" VerticalAlignment="Bottom" ScrollViewer.HorizontalScrollBarVisibility="Auto">
148+
<Grid Grid.Row="2" Grid.ColumnSpan="2" Height="Auto" VerticalAlignment="Bottom" ScrollViewer.HorizontalScrollBarVisibility="Auto">
145149
<Grid.ColumnDefinitions>
146150
<ColumnDefinition Width="Auto"/>
147151
<ColumnDefinition Width="Auto"/>

0 commit comments

Comments
 (0)