forked from gibbed/SteamAchievementManager
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed library settings loading and saving, updated grid view, and more.
- Loading branch information
Showing
28 changed files
with
938 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ChildProcessDebuggingSettings IsEnabled="true" xmlns="http://schemas.microsoft.com/vstudio/ChildProcessDebuggingSettings/2014"> | ||
<DefaultRule EngineFilter="[inherit]" /> | ||
<Rule IsEnabled="true" ProcessName="SAM.exe" CommandLine="" EngineFilter="[inherit]" /> | ||
</ChildProcessDebuggingSettings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/SAM/Common/Behaviors/DataGridColumnHeaderRowBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Controls.Primitives; | ||
using System.Windows.Media; | ||
using DevExpress.Mvvm.UI.Interactivity; | ||
|
||
namespace SAM.Behaviors; | ||
|
||
public class DataGridColumnHeaderRowBehavior : Behavior<ContentControl> | ||
{ | ||
public static readonly DependencyProperty DataGridProperty = | ||
DependencyProperty.Register(nameof(DataGrid), typeof(DataGrid), typeof(DataGridColumnHeaderRowBehavior)); | ||
|
||
public static readonly DependencyProperty ColumnHeaderRowProperty = | ||
DependencyProperty.Register(nameof(ColumnHeaderRow), typeof(DataGridColumnHeadersPresenter), typeof(DataGridColumnHeaderRowBehavior), | ||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender)); | ||
|
||
public DataGrid DataGrid | ||
{ | ||
get => (DataGrid) GetValue(DataGridProperty); | ||
set => SetValue(DataGridProperty, value); | ||
} | ||
|
||
public DataGridColumnHeadersPresenter ColumnHeaderRow | ||
{ | ||
get => (DataGridColumnHeadersPresenter) GetValue(ColumnHeaderRowProperty); | ||
set => SetValue(ColumnHeaderRowProperty, value); | ||
} | ||
|
||
protected override void OnAttached() | ||
{ | ||
base.OnAttached(); | ||
|
||
Update(); | ||
} | ||
|
||
protected override void OnDetaching() | ||
{ | ||
base.OnDetaching(); | ||
} | ||
|
||
private void Update() | ||
{ | ||
var columnHeaderRow = FindChild<DataGridColumnHeadersPresenter>(DataGrid); // @"PART_ColumnHeadersPresenter" | ||
|
||
if (columnHeaderRow == null) return; | ||
|
||
// TODO: remove from parent | ||
var p = columnHeaderRow.Parent as Grid; | ||
p?.Children.Remove(columnHeaderRow); | ||
|
||
AssociatedObject.Content = columnHeaderRow; | ||
} | ||
|
||
private T FindChild<T>(DependencyObject parent, string childName = null) | ||
where T : DependencyObject | ||
{ | ||
// confirm parent and childName are valid. | ||
if (parent == null) | ||
{ | ||
return null; | ||
} | ||
|
||
T foundChild = null; | ||
|
||
var childrenCount = VisualTreeHelper.GetChildrenCount(parent); | ||
for (var i = 0; i < childrenCount; i++) | ||
{ | ||
var child = VisualTreeHelper.GetChild(parent, i); | ||
// If the child is not of the request child type child | ||
if (child is not T childType) | ||
{ | ||
// recursively drill down the tree | ||
foundChild = FindChild<T>(child, childName); | ||
|
||
// If the child is found, break so we do not overwrite the found child. | ||
if (foundChild != null) | ||
{ | ||
break; | ||
} | ||
} | ||
else if (!string.IsNullOrEmpty(childName)) | ||
{ | ||
// If the child's name is set for search | ||
if (childType is not FrameworkElement frameworkElement || frameworkElement.Name != childName) | ||
{ | ||
continue; | ||
} | ||
|
||
// if the child's name is of the request name | ||
foundChild = childType; | ||
break; | ||
} | ||
else | ||
{ | ||
// child element found. | ||
foundChild = childType; | ||
break; | ||
} | ||
} | ||
|
||
return foundChild; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
using System.Windows.Markup; | ||
using SAM.Core.Extensions; | ||
|
||
namespace SAM.Converters; | ||
|
||
[ValueConversion(typeof (Enum), typeof (Visibility))] | ||
public class EnumToVisibilityConverter : IValueConverter | ||
{ | ||
public bool Inverse { get; set; } | ||
public bool HiddenInsteadOfCollapsed { get; set; } | ||
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
var trueResult = Visibility.Visible; | ||
var falseResult = HiddenInsteadOfCollapsed ? Visibility.Hidden : Visibility.Collapsed; | ||
|
||
if (value == null) return null; | ||
if (value is not Enum valueEnum) | ||
{ | ||
return Inverse ? falseResult : trueResult; | ||
} | ||
|
||
if (parameter == null) return null; | ||
if (parameter is not Enum paramEnum) | ||
{ | ||
return Inverse ? falseResult : trueResult; | ||
} | ||
|
||
var equal = Equals(valueEnum, paramEnum); | ||
|
||
if (Inverse) | ||
{ | ||
return equal ? falseResult : trueResult; | ||
} | ||
|
||
return equal | ||
? trueResult | ||
: falseResult; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
|
||
public class EnumToVisibilityConverterExtension : MarkupExtension | ||
{ | ||
public bool Inverse { get; set; } | ||
public bool HiddenInsteadOfCollapsed { get; set; } | ||
public IValueConverter ItemConverter { get; set; } | ||
|
||
public EnumToVisibilityConverterExtension() { } | ||
public EnumToVisibilityConverterExtension(IValueConverter itemConverter) | ||
{ | ||
ItemConverter = itemConverter; | ||
} | ||
|
||
public override object ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
return new EnumToVisibilityConverter | ||
{ | ||
Inverse = Inverse, | ||
HiddenInsteadOfCollapsed = HiddenInsteadOfCollapsed | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.ComponentModel; | ||
|
||
namespace SAM; | ||
|
||
public interface ILibrarySettings : INotifyPropertyChanged | ||
{ | ||
bool EnableGrouping { get; set; } | ||
bool ShowFavoritesOnly { get; set; } | ||
bool ShowHidden { get; set; } | ||
|
||
void Save(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.