Skip to content

Commit

Permalink
1.7.10
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
Codectory committed Dec 5, 2021
1 parent 71bcebb commit 3bfffe7
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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();
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -108,7 +81,6 @@ public static ApplicationProfileAssignment NewAssigment(ApplicationItem applicat
return assigment;
}


private static int GetNextPosition()
{
int position = 0;
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions Source/HDRProfile/AutoHDR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="ApplicationChangedEventArgs.cs" />
<Compile Include="ApplicationProfileAssignment.cs" />
<Compile Include="Applications\ApplicationChangedEventArgs.cs" />
<Compile Include="Applications\ApplicationProfileAssignment.cs" />
<Compile Include="Audio\AudioManager.cs" />
<Compile Include="Audio\AudioMasterChangedProvider.cs" />
<Compile Include="Audio\VolumeProvider.cs" />
Expand Down Expand Up @@ -251,7 +251,7 @@
<DependentUpon>UWPApplicationDialogView.xaml</DependentUpon>
</Compile>
<Compile Include="UWP\UWPApplicationDialog.cs" />
<Compile Include="ApplicationState.cs" />
<Compile Include="Applications\ApplicationState.cs" />
<Compile Include="Displays\HDRController.cs" />
<Compile Include="Displays\Display.cs" />
<Compile Include="Displays\DisplayManager.cs" />
Expand Down Expand Up @@ -350,11 +350,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Locale_Enums.resx</DependentUpon>
</Compile>
<Compile Include="ApplicationAdder.cs" />
<Compile Include="Applications\ApplicationAdder.cs" />
<Compile Include="Views\ApplicationAdderView.xaml.cs">
<DependentUpon>ApplicationAdderView.xaml</DependentUpon>
</Compile>
<Compile Include="ApplicationItem.cs" />
<Compile Include="Applications\ApplicationItem.cs" />
<Compile Include="ProcessWatcher.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
Expand Down
67 changes: 65 additions & 2 deletions Source/HDRProfile/AutoHDRDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationProfileAssignment> EditApplicationCommand { get; private set; }

public RelayCommand<ApplicationProfileAssignment> RemoveAssignmentCommand { get; private set; }

public RelayCommand<ApplicationProfileAssignment> MoveAssignmentUpCommand { get; private set; }
Expand Down Expand Up @@ -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<ApplicationProfileAssignment>(EditApplication);
RemoveAssignmentCommand = new RelayCommand<ApplicationProfileAssignment>(RemoveAssignment);

MoveAssignmentUpCommand = new RelayCommand<ApplicationProfileAssignment>(MoveAssignmentUp);
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -559,6 +585,7 @@ private void ProfileActions_CollectionChanged(object sender, NotifyCollectionCha

private void ApplicationProfileAssigments_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
SortableObservableCollection<ApplicationProfileAssignment> collection = (SortableObservableCollection<ApplicationProfileAssignment>)sender;
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/HDRProfile/Profiles/Actions/ProfileActionAdder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public List<ActionTypeDescription> ProfileActions
public ProfileActionAdder()
{
EditMode = false;
Title = Locale_Texts.AddProfileAction;
Title = Locale_Texts.Add;
CreateRelayCommands();
}

Expand All @@ -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();
}
Expand Down
26 changes: 4 additions & 22 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.

10 changes: 2 additions & 8 deletions Source/HDRProfile/ProjectResources/Locale_Texts.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,7 @@
<data name="ActivateHDR" xml:space="preserve">
<value>HDR aktivieren</value>
</data>
<data name="AddApplication" xml:space="preserve">
<value>Hinzufügen</value>
</data>
<data name="AddProfile" xml:space="preserve">
<value>Hinzufügen</value>
</data>
<data name="AddProfileAction" xml:space="preserve">
<data name="Add" xml:space="preserve">
<value>Hinzufügen</value>
</data>
<data name="AllDisplays" xml:space="preserve">
Expand Down Expand Up @@ -231,7 +225,7 @@
<data name="DownloadNewestVersion" xml:space="preserve">
<value>Download</value>
</data>
<data name="EditProfileAction" xml:space="preserve">
<data name="Edit" xml:space="preserve">
<value>Editieren</value>
</data>
<data name="Error" xml:space="preserve">
Expand Down
10 changes: 2 additions & 8 deletions Source/HDRProfile/ProjectResources/Locale_Texts.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,9 @@
<data name="ActivateHDR" xml:space="preserve">
<value>Activate HDR</value>
</data>
<data name="AddApplication" xml:space="preserve">
<data name="Add" xml:space="preserve">
<value>Add</value>
</data>
<data name="AddProfile" xml:space="preserve">
<value>Add</value>
</data>
<data name="AddProfileAction" xml:space="preserve">
<value>Add profile action</value>
</data>
<data name="AllDisplays" xml:space="preserve">
<value>All displays</value>
</data>
Expand Down Expand Up @@ -240,7 +234,7 @@
<data name="DownloadNewestVersion" xml:space="preserve">
<value>Download</value>
</data>
<data name="EditProfileAction" xml:space="preserve">
<data name="Edit" xml:space="preserve">
<value>Edit</value>
</data>
<data name="Error" xml:space="preserve">
Expand Down
4 changes: 2 additions & 2 deletions Source/HDRProfile/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 3 additions & 1 deletion Source/HDRProfile/SortedObservableCollection.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,9 +22,10 @@ public SortableObservableCollection(IEnumerable<T> collection)

public SortableObservableCollection() : base()
{

}



public void Sort<TKey>(Func<T, TKey> keySelector, System.ComponentModel.ListSortDirection direction)
{
switch (direction)
Expand Down
6 changes: 5 additions & 1 deletion Source/HDRProfile/Views/ApplicationAdderView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
Expand All @@ -23,10 +24,13 @@
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0" Content="{x:Static pres:Locale_Texts.DisplayName}" HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top" FontSize="15"/>
<Label Grid.Column="0" Grid.Row="1" Content="{x:Static pres:Locale_Texts.FilePath}" HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top" />
<Label Grid.Column="0" Grid.Row="2" Content="{x:Static pres:Locale_Texts.Icon}" HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top" />

<TextBox Grid.Column="1" Grid.Row="0" Height="Auto" Margin="5" TextWrapping="Wrap" Text="{Binding DisplayName, Mode=TwoWay }" VerticalAlignment="Top"/>
<Label Grid.Column="1" Grid.Row="1" Content="{Binding FilePath}" Margin="5" Height="Auto" VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
<Image Grid.Column="1" Grid.Row="2" Margin="5" Height="40" Width="40" Source="{Binding ApplicationItem.Icon, Converter={StaticResource BitmapToBitmapImageConverter}}" HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="Uniform"/>

<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" >
<Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width=" Auto"/>
Expand Down
Loading

0 comments on commit 3bfffe7

Please sign in to comment.