Skip to content

Commit 3bfffe7

Browse files
committed
1.7.10
[Changes] - Cannot edit an application's name or path #51 [Bug fixes] - Can't move an application down in the list as expected #56 - Applications last coulmn doesn't fill entire space
1 parent 71bcebb commit 3bfffe7

16 files changed

+163
-143
lines changed

Source/HDRProfile/ApplicationAdder.cs renamed to Source/HDRProfile/Applications/ApplicationAdder.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ namespace AutoHDR
1616
public class ApplicationAdder : DialogViewModelBase
1717
{
1818
private bool _canCreate = false;
19+
1920
private string _displayName = string.Empty;
2021
private string _filePath = string.Empty;
2122
private ApplicationItem applicationItem = null;
23+
private bool _editMode = false;
2224

25+
public bool EditMode { get => _editMode; set { _editMode = value; OnPropertyChanged(); } }
2326
public ApplicationItem ApplicationItem { get => applicationItem; private set { applicationItem = value; OnPropertyChanged(); } }
2427

2528
public RelayCommand GetFileCommand { get; private set; }
@@ -31,7 +34,20 @@ public class ApplicationAdder : DialogViewModelBase
3134

3235
public ApplicationAdder()
3336
{
34-
Title = Locale_Texts.AddApplication;
37+
EditMode = false;
38+
39+
Title = Locale_Texts.Add;
40+
CreateRelayCommands();
41+
}
42+
43+
public ApplicationAdder(ApplicationItem application)
44+
{
45+
EditMode = true;
46+
Title = Locale_Texts.Edit;
47+
DisplayName = application.DisplayName;
48+
FilePath = application.ApplicationFilePath;
49+
ApplicationItem = application;
50+
3551
CreateRelayCommands();
3652
}
3753

Source/HDRProfile/ApplicationProfileAssignment.cs renamed to Source/HDRProfile/Applications/ApplicationProfileAssignment.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,6 @@ private ApplicationProfileAssignment(ApplicationItem application)
7171
Application = application;
7272
}
7373

74-
public void RemoveAssignment()
75-
{
76-
int removedPosition = Position;
77-
foreach (ApplicationProfileAssignment a in Assignments)
78-
{
79-
if (a.Position >= removedPosition)
80-
a.Position = a.Position - 1;
81-
}
82-
Assignments.Remove(this);
83-
Assignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending); }
84-
85-
public void ChangePosition(bool up)
86-
{
87-
if (up && Position == 0)
88-
return;
89-
if (!up && Position == Assignments.Count - 1)
90-
return;
91-
int newPosition = up ? Position - 1 : Position + 1;
92-
if (Assignments.Any(x => x.Position == newPosition))
93-
{
94-
Assignments.First(x => x.Position == newPosition).Position = up ? newPosition + 1 : newPosition - 1;
95-
}
96-
Position = newPosition;
97-
Assignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
98-
}
99-
100-
10174

10275
public static ApplicationProfileAssignment NewAssigment(ApplicationItem application)
10376
{
@@ -108,7 +81,6 @@ public static ApplicationProfileAssignment NewAssigment(ApplicationItem applicat
10881
return assigment;
10982
}
11083

111-
11284
private static int GetNextPosition()
11385
{
11486
int position = 0;

Source/HDRProfile/AutoHDR.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@
187187
<Generator>MSBuild:Compile</Generator>
188188
<SubType>Designer</SubType>
189189
</Page>
190-
<Compile Include="ApplicationChangedEventArgs.cs" />
191-
<Compile Include="ApplicationProfileAssignment.cs" />
190+
<Compile Include="Applications\ApplicationChangedEventArgs.cs" />
191+
<Compile Include="Applications\ApplicationProfileAssignment.cs" />
192192
<Compile Include="Audio\AudioManager.cs" />
193193
<Compile Include="Audio\AudioMasterChangedProvider.cs" />
194194
<Compile Include="Audio\VolumeProvider.cs" />
@@ -251,7 +251,7 @@
251251
<DependentUpon>UWPApplicationDialogView.xaml</DependentUpon>
252252
</Compile>
253253
<Compile Include="UWP\UWPApplicationDialog.cs" />
254-
<Compile Include="ApplicationState.cs" />
254+
<Compile Include="Applications\ApplicationState.cs" />
255255
<Compile Include="Displays\HDRController.cs" />
256256
<Compile Include="Displays\Display.cs" />
257257
<Compile Include="Displays\DisplayManager.cs" />
@@ -350,11 +350,11 @@
350350
<DesignTime>True</DesignTime>
351351
<DependentUpon>Locale_Enums.resx</DependentUpon>
352352
</Compile>
353-
<Compile Include="ApplicationAdder.cs" />
353+
<Compile Include="Applications\ApplicationAdder.cs" />
354354
<Compile Include="Views\ApplicationAdderView.xaml.cs">
355355
<DependentUpon>ApplicationAdderView.xaml</DependentUpon>
356356
</Compile>
357-
<Compile Include="ApplicationItem.cs" />
357+
<Compile Include="Applications\ApplicationItem.cs" />
358358
<Compile Include="ProcessWatcher.cs" />
359359
<Compile Include="Properties\AssemblyInfo.cs">
360360
<SubType>Code</SubType>

Source/HDRProfile/AutoHDRDaemon.cs

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class AutoHDRDaemon : BaseViewModel
4747
public RelayCommand ActivateHDRCommand { get; private set; }
4848
public RelayCommand DeactivateHDRCommand { get; private set; }
4949
public RelayCommand AddAssignmentCommand { get; private set; }
50+
public RelayCommand<ApplicationProfileAssignment> EditApplicationCommand { get; private set; }
51+
5052
public RelayCommand<ApplicationProfileAssignment> RemoveAssignmentCommand { get; private set; }
5153

5254
public RelayCommand<ApplicationProfileAssignment> MoveAssignmentUpCommand { get; private set; }
@@ -260,6 +262,7 @@ private void CreateRelayCommands()
260262
ActivateHDRCommand = new RelayCommand(DisplayManager.Instance.ActivateHDR);
261263
DeactivateHDRCommand = new RelayCommand(DisplayManager.Instance.DeactivateHDR);
262264
AddAssignmentCommand = new RelayCommand(AddAssignment);
265+
EditApplicationCommand = new RelayCommand<ApplicationProfileAssignment>(EditApplication);
263266
RemoveAssignmentCommand = new RelayCommand<ApplicationProfileAssignment>(RemoveAssignment);
264267

265268
MoveAssignmentUpCommand = new RelayCommand<ApplicationProfileAssignment>(MoveAssignmentUp);
@@ -418,26 +421,49 @@ private void AddAssignment()
418421
{
419422
ApplicationProfileAssignment.NewAssigment(adder.ApplicationItem);
420423
}
424+
Settings.ApplicationProfileAssignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
425+
421426
};
422427
if (DialogService != null)
423428
DialogService.ShowDialogModal(adder, new System.Drawing.Size(800, 600));
424429
}
425430

426431

432+
private void EditApplication(ApplicationProfileAssignment assignment)
433+
{
434+
435+
436+
ApplicationAdder adder = new ApplicationAdder(assignment.Application);
437+
adder.DialogService = DialogService;
438+
adder.OKClicked += (o, e) =>
439+
{
440+
assignment.Application = adder.ApplicationItem;
441+
};
442+
if (DialogService != null)
443+
DialogService.ShowDialogModal(adder, new System.Drawing.Size(800, 600));
444+
}
445+
427446
private void RemoveAssignment(ApplicationProfileAssignment assignment)
428447
{
429448
Settings.ApplicationProfileAssignments.Remove(assignment);
449+
Settings.ApplicationProfileAssignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
430450

431451
}
432452

433453
private void MoveAssignmentDown(ApplicationProfileAssignment assignment)
434454
{
435-
assignment.ChangePosition(false);
455+
if (assignment.Position == Settings.ApplicationProfileAssignments.Count - 1)
456+
return;
457+
Settings.ApplicationProfileAssignments.Move(assignment.Position, assignment.Position + 1);
458+
436459
}
437460

438461
private void MoveAssignmentUp(ApplicationProfileAssignment assignment)
439462
{
440-
assignment.ChangePosition(true);
463+
if (assignment.Position == 0)
464+
return;
465+
Settings.ApplicationProfileAssignments.Move(assignment.Position, assignment.Position - 1);
466+
441467
}
442468

443469
private void AddProfile()
@@ -559,6 +585,7 @@ private void ProfileActions_CollectionChanged(object sender, NotifyCollectionCha
559585

560586
private void ApplicationProfileAssigments_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
561587
{
588+
SortableObservableCollection<ApplicationProfileAssignment> collection = (SortableObservableCollection<ApplicationProfileAssignment>)sender;
562589
switch (e.Action)
563590
{
564591
case NotifyCollectionChangedAction.Add:
@@ -580,12 +607,48 @@ private void ApplicationProfileAssigments_CollectionChanged(object sender, Notif
580607
Globals.Logs.Add($"Application removed: {assignment.Application.ApplicationName}", false);
581608
assignment.PropertyChanged -= SaveSettingsOnPropertyChanged;
582609

610+
611+
int removedPosition = assignment.Position;
612+
foreach (ApplicationProfileAssignment a in collection)
613+
{
614+
if (a.Position >= removedPosition)
615+
a.Position = a.Position - 1;
616+
}
583617
ApplicationWatcher.RemoveProcess(assignment.Application);
584618
assignment.Application.PropertyChanged -= SaveSettingsOnPropertyChanged;
585619
}
586620

587621
break;
622+
case NotifyCollectionChangedAction.Move:
623+
624+
int up, down, delta;
588625

626+
if (e.OldStartingIndex < e.NewStartingIndex)
627+
{
628+
up = e.OldStartingIndex + 1;
629+
down = e.NewStartingIndex;
630+
delta = -1;
631+
}
632+
else
633+
{
634+
up = e.NewStartingIndex;
635+
down = e.OldStartingIndex - 1;
636+
delta = 1;
637+
}
638+
639+
foreach (ApplicationProfileAssignment assingment in collection)
640+
{
641+
int position = assingment.Position;
642+
if (position == e.OldStartingIndex)
643+
{
644+
assingment.Position = e.NewStartingIndex;
645+
}
646+
else if (down <= position && position <= up)
647+
{
648+
assingment.Position = position + delta;
649+
}
650+
}
651+
break;
589652
}
590653
Globals.Instance.SaveSettings();
591654
}

Source/HDRProfile/Profiles/Actions/ProfileActionAdder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public List<ActionTypeDescription> ProfileActions
7474
public ProfileActionAdder()
7575
{
7676
EditMode = false;
77-
Title = Locale_Texts.AddProfileAction;
77+
Title = Locale_Texts.Add;
7878
CreateRelayCommands();
7979
}
8080

@@ -84,7 +84,7 @@ public ProfileActionAdder(IProfileAction action)
8484
ActionType = ProfileActions.First(d => d.ActionType.Equals(action.GetType()));
8585
ContentControlViewModel = (BaseViewModel)action;
8686

87-
Title = Locale_Texts.EditProfileAction;
87+
Title = Locale_Texts.Edit;
8888

8989
CreateRelayCommands();
9090
}

Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs

Lines changed: 4 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/HDRProfile/ProjectResources/Locale_Texts.de.resx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,7 @@
126126
<data name="ActivateHDR" xml:space="preserve">
127127
<value>HDR aktivieren</value>
128128
</data>
129-
<data name="AddApplication" xml:space="preserve">
130-
<value>Hinzufügen</value>
131-
</data>
132-
<data name="AddProfile" xml:space="preserve">
133-
<value>Hinzufügen</value>
134-
</data>
135-
<data name="AddProfileAction" xml:space="preserve">
129+
<data name="Add" xml:space="preserve">
136130
<value>Hinzufügen</value>
137131
</data>
138132
<data name="AllDisplays" xml:space="preserve">
@@ -231,7 +225,7 @@
231225
<data name="DownloadNewestVersion" xml:space="preserve">
232226
<value>Download</value>
233227
</data>
234-
<data name="EditProfileAction" xml:space="preserve">
228+
<data name="Edit" xml:space="preserve">
235229
<value>Editieren</value>
236230
</data>
237231
<data name="Error" xml:space="preserve">

0 commit comments

Comments
 (0)