Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LivelyProperties performance rewrite
- Rewrote LivelyProperties to use templating, virtualization and JsonConverter. Instant startup time and can handle 100k+ controls (old version crashes.) - LivelyProperties disk file is only updated on dialog/window close. - x:Load workaround for microsoft/microsoft-ui-xaml#8412 - New FolderDropdown UserControl. - Removed broken ImageEx UserControl. - Refactoring.
- Loading branch information
1 parent
b935a52
commit c8e3a02
Showing
41 changed files
with
1,847 additions
and
1,259 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class ButtonModel : ControlModel | ||
{ | ||
[JsonProperty("value")] | ||
public string Value { get; set; } | ||
|
||
public ButtonModel() : base("button") { } | ||
} | ||
} |
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,17 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class CheckboxModel : ControlModel | ||
{ | ||
[JsonProperty("value")] | ||
public bool Value { get; set; } | ||
|
||
public CheckboxModel() : base("checkbox") { } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Lively/Lively.Models/LivelyControls/ColorPickerModel.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,17 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class ColorPickerModel : ControlModel | ||
{ | ||
[JsonProperty("value")] | ||
public string Value { get; set; } | ||
|
||
public ColorPickerModel() : base("color") { } | ||
} | ||
} |
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,30 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class ControlModel | ||
{ | ||
[JsonIgnore] | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonProperty("text")] | ||
public string Text { get; set; } | ||
|
||
[JsonProperty("type")] | ||
public string Type { get; } | ||
|
||
[JsonProperty("help")] | ||
public string Help { get; set; } | ||
|
||
protected ControlModel(string Type) | ||
{ | ||
this.Type = Type; | ||
} | ||
} | ||
} |
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,20 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class DropdownModel : ControlModel | ||
{ | ||
[JsonProperty("value")] | ||
public int Value { get; set; } | ||
|
||
[JsonProperty("items")] | ||
public string[] Items { get; set; } | ||
|
||
public DropdownModel() : base("dropdown") { } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Lively/Lively.Models/LivelyControls/FolderDropdownModel.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,23 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class FolderDropdownModel : ControlModel | ||
{ | ||
[JsonProperty("value")] | ||
public string Value { get; set; } | ||
|
||
[JsonProperty("folder")] | ||
public string Folder { get; set; } | ||
|
||
[JsonProperty("filter")] | ||
public string Filter { get; set; } | ||
|
||
public FolderDropdownModel() : base("folderDropdown") { } | ||
} | ||
} |
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,17 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class LabelModel : ControlModel | ||
{ | ||
[JsonProperty("value")] | ||
public string Value { get; set; } | ||
|
||
public LabelModel() : base("label") { } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Lively/Lively.Models/LivelyControls/ScalerDropdownModel.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,20 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class ScalerDropdownModel : ControlModel | ||
{ | ||
[JsonProperty("value")] | ||
public int Value { get; set; } | ||
|
||
[JsonProperty("items")] | ||
public string[] Items { get; set; } | ||
|
||
public ScalerDropdownModel() : base("scalerDropdown") { } | ||
} | ||
} |
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,31 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class SliderModel : ControlModel | ||
{ | ||
[JsonIgnore] | ||
[JsonProperty("tick")] | ||
public int Tick { get; set; } | ||
|
||
[JsonProperty("min")] | ||
public double Min { get; set; } | ||
|
||
[JsonProperty("max")] | ||
public double Max { get; set; } | ||
|
||
[JsonProperty("value")] | ||
public double Value { get; set; } | ||
|
||
// Default value 1, otherwise if missing it will be 0 and crash on moving slider. | ||
[JsonProperty("step")] | ||
public double Step { get; set; } = 1f; | ||
|
||
public SliderModel() : base("slider") { } | ||
} | ||
} |
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,17 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lively.Models.LivelyControls | ||
{ | ||
public class TextboxModel : ControlModel | ||
{ | ||
[JsonProperty("value")] | ||
public string Value { get; set; } | ||
|
||
public TextboxModel() : base("textbox") { } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Lively/Lively.Models/UserControls/FolderDropdownUserControlModel.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,19 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Lively.Models.UserControls | ||
{ | ||
public partial class FolderDropdownUserControlModel : ObservableObject | ||
{ | ||
[ObservableProperty] | ||
private string fileName; | ||
|
||
[ObservableProperty] | ||
private string filePath; | ||
|
||
[ObservableProperty] | ||
private string imagePath; | ||
} | ||
} |
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
62 changes: 62 additions & 0 deletions
62
src/Lively/Lively.UI.WinUI/Behaviors/CheckBoxCheckedChangedBehavior.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,62 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Input; | ||
|
||
namespace Lively.UI.WinUI.Behaviors | ||
{ | ||
public class CheckBoxCheckedChangedBehavior | ||
{ | ||
public static readonly DependencyProperty CommandProperty = | ||
DependencyProperty.RegisterAttached("Command", typeof(ICommand), typeof(CheckBoxCheckedChangedBehavior), new PropertyMetadata(null, OnCommandChanged)); | ||
|
||
public static readonly DependencyProperty CommandParameterProperty = | ||
DependencyProperty.RegisterAttached("CommandParameter", typeof(object), typeof(CheckBoxCheckedChangedBehavior), new PropertyMetadata(null)); | ||
|
||
public static ICommand GetCommand(CheckBox checkBox) | ||
{ | ||
return (ICommand)checkBox.GetValue(CommandProperty); | ||
} | ||
|
||
public static void SetCommand(CheckBox checkBox, ICommand value) | ||
{ | ||
checkBox.SetValue(CommandProperty, value); | ||
} | ||
|
||
public static object GetCommandParameter(CheckBox checkBox) | ||
{ | ||
return checkBox.GetValue(CommandParameterProperty); | ||
} | ||
|
||
public static void SetCommandParameter(CheckBox checkBox, object value) | ||
{ | ||
checkBox.SetValue(CommandParameterProperty, value); | ||
} | ||
|
||
private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (d is CheckBox checkBox) | ||
{ | ||
checkBox.Checked -= OnCheckBoxCheckedChanged; | ||
checkBox.Unchecked -= OnCheckBoxCheckedChanged; | ||
if (e.NewValue is ICommand command) | ||
{ | ||
checkBox.Checked += OnCheckBoxCheckedChanged; | ||
checkBox.Unchecked += OnCheckBoxCheckedChanged; | ||
} | ||
} | ||
} | ||
|
||
private static void OnCheckBoxCheckedChanged(object sender, RoutedEventArgs e) | ||
{ | ||
if (sender is CheckBox checkBox && GetCommand(checkBox) != null && GetCommand(checkBox).CanExecute(GetCommandParameter(checkBox))) | ||
{ | ||
GetCommand(checkBox).Execute(GetCommandParameter(checkBox)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.