diff --git a/Source/HDRProfile/ApplicationAdder.cs b/Source/HDRProfile/Applications/ApplicationAdder.cs
similarity index 86%
rename from Source/HDRProfile/ApplicationAdder.cs
rename to Source/HDRProfile/Applications/ApplicationAdder.cs
index cb1bdd9..f845156 100644
--- a/Source/HDRProfile/ApplicationAdder.cs
+++ b/Source/HDRProfile/Applications/ApplicationAdder.cs
@@ -16,10 +16,13 @@ namespace AutoHDR
public class ApplicationAdder : DialogViewModelBase
{
private bool _canCreate = false;
+
private string _displayName = string.Empty;
private string _filePath = string.Empty;
private ApplicationItem applicationItem = null;
+ private bool _editMode = false;
+ public bool EditMode { get => _editMode; set { _editMode = value; OnPropertyChanged(); } }
public ApplicationItem ApplicationItem { get => applicationItem; private set { applicationItem = value; OnPropertyChanged(); } }
public RelayCommand GetFileCommand { get; private set; }
@@ -31,7 +34,20 @@ public class ApplicationAdder : DialogViewModelBase
public ApplicationAdder()
{
- Title = Locale_Texts.AddApplication;
+ EditMode = false;
+
+ Title = Locale_Texts.Add;
+ CreateRelayCommands();
+ }
+
+ public ApplicationAdder(ApplicationItem application)
+ {
+ EditMode = true;
+ Title = Locale_Texts.Edit;
+ DisplayName = application.DisplayName;
+ FilePath = application.ApplicationFilePath;
+ ApplicationItem = application;
+
CreateRelayCommands();
}
diff --git a/Source/HDRProfile/ApplicationChangedEventArgs.cs b/Source/HDRProfile/Applications/ApplicationChangedEventArgs.cs
similarity index 100%
rename from Source/HDRProfile/ApplicationChangedEventArgs.cs
rename to Source/HDRProfile/Applications/ApplicationChangedEventArgs.cs
diff --git a/Source/HDRProfile/ApplicationItem.cs b/Source/HDRProfile/Applications/ApplicationItem.cs
similarity index 100%
rename from Source/HDRProfile/ApplicationItem.cs
rename to Source/HDRProfile/Applications/ApplicationItem.cs
diff --git a/Source/HDRProfile/ApplicationProfileAssignment.cs b/Source/HDRProfile/Applications/ApplicationProfileAssignment.cs
similarity index 72%
rename from Source/HDRProfile/ApplicationProfileAssignment.cs
rename to Source/HDRProfile/Applications/ApplicationProfileAssignment.cs
index aafc979..3b8bddd 100644
--- a/Source/HDRProfile/ApplicationProfileAssignment.cs
+++ b/Source/HDRProfile/Applications/ApplicationProfileAssignment.cs
@@ -71,33 +71,6 @@ private ApplicationProfileAssignment(ApplicationItem application)
Application = application;
}
- public void RemoveAssignment()
- {
- int removedPosition = Position;
- foreach (ApplicationProfileAssignment a in Assignments)
- {
- if (a.Position >= removedPosition)
- a.Position = a.Position - 1;
- }
- Assignments.Remove(this);
- Assignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending); }
-
- public void ChangePosition(bool up)
- {
- if (up && Position == 0)
- return;
- if (!up && Position == Assignments.Count - 1)
- return;
- int newPosition = up ? Position - 1 : Position + 1;
- if (Assignments.Any(x => x.Position == newPosition))
- {
- Assignments.First(x => x.Position == newPosition).Position = up ? newPosition + 1 : newPosition - 1;
- }
- Position = newPosition;
- Assignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
- }
-
-
public static ApplicationProfileAssignment NewAssigment(ApplicationItem application)
{
@@ -108,7 +81,6 @@ public static ApplicationProfileAssignment NewAssigment(ApplicationItem applicat
return assigment;
}
-
private static int GetNextPosition()
{
int position = 0;
diff --git a/Source/HDRProfile/ApplicationState.cs b/Source/HDRProfile/Applications/ApplicationState.cs
similarity index 100%
rename from Source/HDRProfile/ApplicationState.cs
rename to Source/HDRProfile/Applications/ApplicationState.cs
diff --git a/Source/HDRProfile/AutoHDR.csproj b/Source/HDRProfile/AutoHDR.csproj
index 26c607b..6a74e0c 100644
--- a/Source/HDRProfile/AutoHDR.csproj
+++ b/Source/HDRProfile/AutoHDR.csproj
@@ -187,8 +187,8 @@
MSBuild:Compile
Designer
-
-
+
+
@@ -251,7 +251,7 @@
UWPApplicationDialogView.xaml
-
+
@@ -350,11 +350,11 @@
True
Locale_Enums.resx
-
+
ApplicationAdderView.xaml
-
+
Code
diff --git a/Source/HDRProfile/AutoHDRDaemon.cs b/Source/HDRProfile/AutoHDRDaemon.cs
index ad4f7fa..fa3fcd3 100644
--- a/Source/HDRProfile/AutoHDRDaemon.cs
+++ b/Source/HDRProfile/AutoHDRDaemon.cs
@@ -47,6 +47,8 @@ public class AutoHDRDaemon : BaseViewModel
public RelayCommand ActivateHDRCommand { get; private set; }
public RelayCommand DeactivateHDRCommand { get; private set; }
public RelayCommand AddAssignmentCommand { get; private set; }
+ public RelayCommand EditApplicationCommand { get; private set; }
+
public RelayCommand RemoveAssignmentCommand { get; private set; }
public RelayCommand MoveAssignmentUpCommand { get; private set; }
@@ -260,6 +262,7 @@ private void CreateRelayCommands()
ActivateHDRCommand = new RelayCommand(DisplayManager.Instance.ActivateHDR);
DeactivateHDRCommand = new RelayCommand(DisplayManager.Instance.DeactivateHDR);
AddAssignmentCommand = new RelayCommand(AddAssignment);
+ EditApplicationCommand = new RelayCommand(EditApplication);
RemoveAssignmentCommand = new RelayCommand(RemoveAssignment);
MoveAssignmentUpCommand = new RelayCommand(MoveAssignmentUp);
@@ -418,26 +421,49 @@ private void AddAssignment()
{
ApplicationProfileAssignment.NewAssigment(adder.ApplicationItem);
}
+ Settings.ApplicationProfileAssignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
+
};
if (DialogService != null)
DialogService.ShowDialogModal(adder, new System.Drawing.Size(800, 600));
}
+ private void EditApplication(ApplicationProfileAssignment assignment)
+ {
+
+
+ ApplicationAdder adder = new ApplicationAdder(assignment.Application);
+ adder.DialogService = DialogService;
+ adder.OKClicked += (o, e) =>
+ {
+ assignment.Application = adder.ApplicationItem;
+ };
+ if (DialogService != null)
+ DialogService.ShowDialogModal(adder, new System.Drawing.Size(800, 600));
+ }
+
private void RemoveAssignment(ApplicationProfileAssignment assignment)
{
Settings.ApplicationProfileAssignments.Remove(assignment);
+ Settings.ApplicationProfileAssignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
}
private void MoveAssignmentDown(ApplicationProfileAssignment assignment)
{
- assignment.ChangePosition(false);
+ if (assignment.Position == Settings.ApplicationProfileAssignments.Count - 1)
+ return;
+ Settings.ApplicationProfileAssignments.Move(assignment.Position, assignment.Position + 1);
+
}
private void MoveAssignmentUp(ApplicationProfileAssignment assignment)
{
- assignment.ChangePosition(true);
+ if (assignment.Position == 0)
+ return;
+ Settings.ApplicationProfileAssignments.Move(assignment.Position, assignment.Position - 1);
+
}
private void AddProfile()
@@ -559,6 +585,7 @@ private void ProfileActions_CollectionChanged(object sender, NotifyCollectionCha
private void ApplicationProfileAssigments_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
+ SortableObservableCollection collection = (SortableObservableCollection)sender;
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
@@ -580,12 +607,48 @@ private void ApplicationProfileAssigments_CollectionChanged(object sender, Notif
Globals.Logs.Add($"Application removed: {assignment.Application.ApplicationName}", false);
assignment.PropertyChanged -= SaveSettingsOnPropertyChanged;
+
+ int removedPosition = assignment.Position;
+ foreach (ApplicationProfileAssignment a in collection)
+ {
+ if (a.Position >= removedPosition)
+ a.Position = a.Position - 1;
+ }
ApplicationWatcher.RemoveProcess(assignment.Application);
assignment.Application.PropertyChanged -= SaveSettingsOnPropertyChanged;
}
break;
+ case NotifyCollectionChangedAction.Move:
+
+ int up, down, delta;
+ if (e.OldStartingIndex < e.NewStartingIndex)
+ {
+ up = e.OldStartingIndex + 1;
+ down = e.NewStartingIndex;
+ delta = -1;
+ }
+ else
+ {
+ up = e.NewStartingIndex;
+ down = e.OldStartingIndex - 1;
+ delta = 1;
+ }
+
+ foreach (ApplicationProfileAssignment assingment in collection)
+ {
+ int position = assingment.Position;
+ if (position == e.OldStartingIndex)
+ {
+ assingment.Position = e.NewStartingIndex;
+ }
+ else if (down <= position && position <= up)
+ {
+ assingment.Position = position + delta;
+ }
+ }
+ break;
}
Globals.Instance.SaveSettings();
}
diff --git a/Source/HDRProfile/Profiles/Actions/ProfileActionAdder.cs b/Source/HDRProfile/Profiles/Actions/ProfileActionAdder.cs
index f3b7f94..d665c09 100644
--- a/Source/HDRProfile/Profiles/Actions/ProfileActionAdder.cs
+++ b/Source/HDRProfile/Profiles/Actions/ProfileActionAdder.cs
@@ -74,7 +74,7 @@ public List ProfileActions
public ProfileActionAdder()
{
EditMode = false;
- Title = Locale_Texts.AddProfileAction;
+ Title = Locale_Texts.Add;
CreateRelayCommands();
}
@@ -84,7 +84,7 @@ public ProfileActionAdder(IProfileAction action)
ActionType = ProfileActions.First(d => d.ActionType.Equals(action.GetType()));
ContentControlViewModel = (BaseViewModel)action;
- Title = Locale_Texts.EditProfileAction;
+ Title = Locale_Texts.Edit;
CreateRelayCommands();
}
diff --git a/Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs b/Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs
index e8aed92..3f0203e 100644
--- a/Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs
+++ b/Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs
@@ -108,27 +108,9 @@ public static string ActivateHDR {
///
/// Sucht eine lokalisierte Zeichenfolge, die Add ähnelt.
///
- public static string AddApplication {
+ public static string Add {
get {
- return ResourceManager.GetString("AddApplication", resourceCulture);
- }
- }
-
- ///
- /// Sucht eine lokalisierte Zeichenfolge, die Add ähnelt.
- ///
- public static string AddProfile {
- get {
- return ResourceManager.GetString("AddProfile", resourceCulture);
- }
- }
-
- ///
- /// Sucht eine lokalisierte Zeichenfolge, die Add profile action ähnelt.
- ///
- public static string AddProfileAction {
- get {
- return ResourceManager.GetString("AddProfileAction", resourceCulture);
+ return ResourceManager.GetString("Add", resourceCulture);
}
}
@@ -432,9 +414,9 @@ public static string DownloadNewestVersion {
///
/// Sucht eine lokalisierte Zeichenfolge, die Edit ähnelt.
///
- public static string EditProfileAction {
+ public static string Edit {
get {
- return ResourceManager.GetString("EditProfileAction", resourceCulture);
+ return ResourceManager.GetString("Edit", resourceCulture);
}
}
diff --git a/Source/HDRProfile/ProjectResources/Locale_Texts.de.resx b/Source/HDRProfile/ProjectResources/Locale_Texts.de.resx
index 050da51..6913c2c 100644
--- a/Source/HDRProfile/ProjectResources/Locale_Texts.de.resx
+++ b/Source/HDRProfile/ProjectResources/Locale_Texts.de.resx
@@ -126,13 +126,7 @@
HDR aktivieren
-
- Hinzufügen
-
-
- Hinzufügen
-
-
+
Hinzufügen
@@ -231,7 +225,7 @@
Download
-
+
Editieren
diff --git a/Source/HDRProfile/ProjectResources/Locale_Texts.resx b/Source/HDRProfile/ProjectResources/Locale_Texts.resx
index 984f5e0..0b2eab7 100644
--- a/Source/HDRProfile/ProjectResources/Locale_Texts.resx
+++ b/Source/HDRProfile/ProjectResources/Locale_Texts.resx
@@ -132,15 +132,9 @@
Activate HDR
-
+
Add
-
- Add
-
-
- Add profile action
-
All displays
@@ -240,7 +234,7 @@
Download
-
+
Edit
diff --git a/Source/HDRProfile/Properties/AssemblyInfo.cs b/Source/HDRProfile/Properties/AssemblyInfo.cs
index f9006eb..58f526a 100644
--- a/Source/HDRProfile/Properties/AssemblyInfo.cs
+++ b/Source/HDRProfile/Properties/AssemblyInfo.cs
@@ -52,5 +52,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.7.9.0")]
-[assembly: AssemblyFileVersion("1.7.9.0")]
+[assembly: AssemblyVersion("1.7.10.0")]
+[assembly: AssemblyFileVersion("1.7.10.0")]
diff --git a/Source/HDRProfile/SortedObservableCollection.cs b/Source/HDRProfile/SortedObservableCollection.cs
index 7e62524..28a3f3b 100644
--- a/Source/HDRProfile/SortedObservableCollection.cs
+++ b/Source/HDRProfile/SortedObservableCollection.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -21,9 +22,10 @@ public SortableObservableCollection(IEnumerable collection)
public SortableObservableCollection() : base()
{
-
}
+
+
public void Sort(Func keySelector, System.ComponentModel.ListSortDirection direction)
{
switch (direction)
diff --git a/Source/HDRProfile/Views/ApplicationAdderView.xaml b/Source/HDRProfile/Views/ApplicationAdderView.xaml
index 2f4fc21..bc9d807 100644
--- a/Source/HDRProfile/Views/ApplicationAdderView.xaml
+++ b/Source/HDRProfile/Views/ApplicationAdderView.xaml
@@ -12,6 +12,7 @@
+
@@ -23,10 +24,13 @@
+
+
+
-
+
diff --git a/Source/HDRProfile/Views/AutoHDRMainView.xaml b/Source/HDRProfile/Views/AutoHDRMainView.xaml
index e5b2a6b..2ecccc6 100644
--- a/Source/HDRProfile/Views/AutoHDRMainView.xaml
+++ b/Source/HDRProfile/Views/AutoHDRMainView.xaml
@@ -53,6 +53,7 @@
+
@@ -60,11 +61,16 @@
-
+
+
-
-
+
+
+
+
+
+
@@ -209,44 +215,45 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -255,15 +262,19 @@
+
-
-
-
+
+
+
+
+
+
diff --git a/Source/HDRProfile/Views/AutoHDRMainView.xaml.cs b/Source/HDRProfile/Views/AutoHDRMainView.xaml.cs
index 7659db5..30a057a 100644
--- a/Source/HDRProfile/Views/AutoHDRMainView.xaml.cs
+++ b/Source/HDRProfile/Views/AutoHDRMainView.xaml.cs
@@ -15,13 +15,11 @@ public partial class AutoHDRMainView : MainWindowBase
public AutoHDRMainView()
{
InitializeComponent();
- Globals.Instance.Settings.ApplicationProfileAssignments.CollectionChanged += ApplicationProfileAssignments_CollectionChanged;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
- Globals.Instance.Settings.ApplicationProfileAssignments.CollectionChanged -= ApplicationProfileAssignments_CollectionChanged;
Properties.Settings.Default.Width = Width;
Properties.Settings.Default.Height = Height;
Properties.Settings.Default.Save();
@@ -29,24 +27,8 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
this.Hide();
}
- private void ApplicationProfileAssignments_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
- {
- ResizeApplicationList();
- }
+
- private void ResizeApplicationList()
- {
- lock (_listResizeLock)
- {
-
- GridView gv = ApplicationList.View as GridView;
- foreach (var column in gv.Columns)
- {
- column.Width = column.ActualWidth;
- column.Width = double.NaN;
- }
- }
- }
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{