diff --git a/App/KingPing/.gitignore b/App/KingPing/.gitignore new file mode 100644 index 0000000..8afdcb6 --- /dev/null +++ b/App/KingPing/.gitignore @@ -0,0 +1,454 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json diff --git a/App/KingPing/App.axaml b/App/KingPing/App.axaml new file mode 100644 index 0000000..b8f2ae1 --- /dev/null +++ b/App/KingPing/App.axaml @@ -0,0 +1,9 @@ + + + + + + diff --git a/App/KingPing/App.axaml.cs b/App/KingPing/App.axaml.cs new file mode 100644 index 0000000..dc051c5 --- /dev/null +++ b/App/KingPing/App.axaml.cs @@ -0,0 +1,52 @@ +using Avalonia; +using Avalonia.Controls.Shapes; +using Avalonia.Markup.Xaml; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using PropertyChanged; +using System; +using System.IO; +using TheXamlGuy.Framework.Avalonia; +using TheXamlGuy.Framework.Core; +using Path = System.IO.Path; + +namespace KingPing; + +[DoNotNotify] +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override async void OnFrameworkInitializationCompleted() + { + IHost? host = new HostBuilder() + .UseContentRoot(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Builder"), true) + .ConfigureTemplates(configuration => + { + configuration.Add(); + configuration.Add("Main"); + configuration.Add("Shell"); + configuration.Add("DigitalOutputs"); + configuration.Add("DigitalInputs"); + configuration.Add("AnalogOutputs"); + configuration.Add(); + configuration.Add("Favourites"); + }) + .ConfigureServices(ConfigureServices) + .Build(); + + await host.RunAsync(); + base.OnFrameworkInitializationCompleted(); + } + + private void ConfigureServices(HostBuilderContext context, IServiceCollection services) + { + services.AddReqiredCore() + .AddRequiredAvalonia() + .AddHostedService() + .RegisterHandlers(); + } +} diff --git a/App/KingPing/FodyWeavers.xml b/App/KingPing/FodyWeavers.xml new file mode 100644 index 0000000..d5abfed --- /dev/null +++ b/App/KingPing/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/App/KingPing/KingPing.csproj b/App/KingPing/KingPing.csproj new file mode 100644 index 0000000..8e96918 --- /dev/null +++ b/App/KingPing/KingPing.csproj @@ -0,0 +1,36 @@ + + + WinExe + net6.0 + enable + copyused + true + + + + + + + + + + + + + + + + + + + + + + + + + + ShellView.axaml + + + diff --git a/App/KingPing/LifeCycles/StartedHandler.cs b/App/KingPing/LifeCycles/StartedHandler.cs new file mode 100644 index 0000000..b87e652 --- /dev/null +++ b/App/KingPing/LifeCycles/StartedHandler.cs @@ -0,0 +1,27 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class StartedHandler : IMediatorHandler +{ + private readonly MainWindow window; + private readonly MainWindowViewModel viewModel; + + public StartedHandler(MainWindow window, + MainWindowViewModel viewModel) + { + this.window = window; + this.viewModel = viewModel; + } + + public void Handle(Started request) + { + window.DataContext = viewModel; + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = window; + } + } +} diff --git a/App/KingPing/Program.cs b/App/KingPing/Program.cs new file mode 100644 index 0000000..78eaa65 --- /dev/null +++ b/App/KingPing/Program.cs @@ -0,0 +1,17 @@ +using Avalonia; +using System; + +namespace KingPing +{ + internal class Program + { + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .LogToTrace(); + } +} diff --git a/App/KingPing/Views/AnalogOutputCollectionView.axaml b/App/KingPing/Views/AnalogOutputCollectionView.axaml new file mode 100644 index 0000000..4732501 --- /dev/null +++ b/App/KingPing/Views/AnalogOutputCollectionView.axaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/App/KingPing/Views/AnalogOutputCollectionView.axaml.cs b/App/KingPing/Views/AnalogOutputCollectionView.axaml.cs new file mode 100644 index 0000000..6338f44 --- /dev/null +++ b/App/KingPing/Views/AnalogOutputCollectionView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; +using PropertyChanged; + +namespace KingPing; + +[DoNotNotify] +public partial class AnalogOutputCollectionView : UserControl +{ + public AnalogOutputCollectionView() + { + InitializeComponent(); + } +} diff --git a/App/KingPing/Views/AnalogOutputCollectionViewModel.cs b/App/KingPing/Views/AnalogOutputCollectionViewModel.cs new file mode 100644 index 0000000..8c0a563 --- /dev/null +++ b/App/KingPing/Views/AnalogOutputCollectionViewModel.cs @@ -0,0 +1,22 @@ +using System; +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class AnalogOutputCollectionViewModel : ObservableViewModelCollection +{ + public AnalogOutputCollectionViewModel(IPropertyBuilder propertyBuilder, + IEventAggregator eventAggregator, + IServiceFactory serviceFactory, + IDisposer disposer, + ITemplateSelector templateSelector) : base(propertyBuilder, eventAggregator, serviceFactory, disposer) + { + for(int i = 0; i < 1000; i++) + { + Add(Guid.NewGuid().ToString()); + } + TemplateSelector = templateSelector; + } + + public ITemplateSelector TemplateSelector { get; } +} diff --git a/App/KingPing/Views/AnalogOutputView.axaml b/App/KingPing/Views/AnalogOutputView.axaml new file mode 100644 index 0000000..26cc409 --- /dev/null +++ b/App/KingPing/Views/AnalogOutputView.axaml @@ -0,0 +1,9 @@ + + + + + + diff --git a/App/KingPing/Views/AnalogOutputView.axaml.cs b/App/KingPing/Views/AnalogOutputView.axaml.cs new file mode 100644 index 0000000..8cfa26f --- /dev/null +++ b/App/KingPing/Views/AnalogOutputView.axaml.cs @@ -0,0 +1,17 @@ +using Avalonia.Styling; +using PropertyChanged; +using System; +using TheXamlGuy.UI.Avalonia.Controls; + +namespace KingPing; + +[DoNotNotify] +public partial class AnalogOutputView : SettingsExpander, IStyleable +{ + public AnalogOutputView() + { + InitializeComponent(); + } + + Type IStyleable.StyleKey => typeof(FluentAvalonia.UI.Controls.SettingsExpander); +} diff --git a/App/KingPing/Views/AnalogOutputViewModel.cs b/App/KingPing/Views/AnalogOutputViewModel.cs new file mode 100644 index 0000000..2ae6170 --- /dev/null +++ b/App/KingPing/Views/AnalogOutputViewModel.cs @@ -0,0 +1,17 @@ +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class AnalogOutputViewModel : ObservableViewModel +{ + public AnalogOutputViewModel(IPropertyBuilder propertyBuilder, + IEventAggregator eventAggregator, + IServiceFactory serviceFactory, + IDisposer disposer, + string name) : base(propertyBuilder, eventAggregator, serviceFactory, disposer) + { + Name = name; + } + + public string Name { get; } +} diff --git a/App/KingPing/Views/DigitalInputCollectionView.axaml b/App/KingPing/Views/DigitalInputCollectionView.axaml new file mode 100644 index 0000000..b738ab1 --- /dev/null +++ b/App/KingPing/Views/DigitalInputCollectionView.axaml @@ -0,0 +1,6 @@ + + Digital Inputs + diff --git a/App/KingPing/Views/DigitalInputCollectionView.axaml.cs b/App/KingPing/Views/DigitalInputCollectionView.axaml.cs new file mode 100644 index 0000000..c1c3b01 --- /dev/null +++ b/App/KingPing/Views/DigitalInputCollectionView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; +using PropertyChanged; + +namespace KingPing; + +[DoNotNotify] +public partial class DigitalInputCollectionView : UserControl +{ + public DigitalInputCollectionView() + { + InitializeComponent(); + } +} diff --git a/App/KingPing/Views/DigitalInputCollectionViewModel.cs b/App/KingPing/Views/DigitalInputCollectionViewModel.cs new file mode 100644 index 0000000..ac37fe8 --- /dev/null +++ b/App/KingPing/Views/DigitalInputCollectionViewModel.cs @@ -0,0 +1,14 @@ +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class DigitalInputCollectionViewModel : ObservableViewModel +{ + public DigitalInputCollectionViewModel(IPropertyBuilder propertyBuilder, + IEventAggregator eventAggregator, + IServiceFactory serviceFactory, + IDisposer disposer) : base(propertyBuilder, eventAggregator, serviceFactory, disposer) + { + + } +} diff --git a/App/KingPing/Views/DigitalOutputCollectionView.axaml b/App/KingPing/Views/DigitalOutputCollectionView.axaml new file mode 100644 index 0000000..7bba359 --- /dev/null +++ b/App/KingPing/Views/DigitalOutputCollectionView.axaml @@ -0,0 +1,6 @@ + + Digital Outputs + diff --git a/App/KingPing/Views/DigitalOutputCollectionView.axaml.cs b/App/KingPing/Views/DigitalOutputCollectionView.axaml.cs new file mode 100644 index 0000000..e6c835f --- /dev/null +++ b/App/KingPing/Views/DigitalOutputCollectionView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; +using PropertyChanged; + +namespace KingPing; + +[DoNotNotify] +public partial class DigitalOutputCollectionView : UserControl +{ + public DigitalOutputCollectionView() + { + InitializeComponent(); + } +} diff --git a/App/KingPing/Views/DigitalOutputCollectionViewModel.cs b/App/KingPing/Views/DigitalOutputCollectionViewModel.cs new file mode 100644 index 0000000..e4452d2 --- /dev/null +++ b/App/KingPing/Views/DigitalOutputCollectionViewModel.cs @@ -0,0 +1,14 @@ +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class DigitalOutputCollectionViewModel : ObservableViewModel +{ + public DigitalOutputCollectionViewModel(IPropertyBuilder propertyBuilder, + IEventAggregator eventAggregator, + IServiceFactory serviceFactory, + IDisposer disposer) : base(propertyBuilder, eventAggregator, serviceFactory, disposer) + { + + } +} diff --git a/App/KingPing/Views/FavouriteCollectionView.axaml b/App/KingPing/Views/FavouriteCollectionView.axaml new file mode 100644 index 0000000..8b5b95a --- /dev/null +++ b/App/KingPing/Views/FavouriteCollectionView.axaml @@ -0,0 +1,6 @@ + + Favourites + diff --git a/App/KingPing/Views/FavouriteCollectionView.axaml.cs b/App/KingPing/Views/FavouriteCollectionView.axaml.cs new file mode 100644 index 0000000..9f6ce4b --- /dev/null +++ b/App/KingPing/Views/FavouriteCollectionView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; +using PropertyChanged; + +namespace KingPing; + +[DoNotNotify] +public partial class FavouriteCollectionView : UserControl +{ + public FavouriteCollectionView() + { + InitializeComponent(); + } +} diff --git a/App/KingPing/Views/FavouriteCollectionViewModel.cs b/App/KingPing/Views/FavouriteCollectionViewModel.cs new file mode 100644 index 0000000..7292b93 --- /dev/null +++ b/App/KingPing/Views/FavouriteCollectionViewModel.cs @@ -0,0 +1,14 @@ +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class FavouriteCollectionViewModel : ObservableViewModel +{ + public FavouriteCollectionViewModel(IPropertyBuilder propertyBuilder, + IEventAggregator eventAggregator, + IServiceFactory serviceFactory, + IDisposer disposer) : base(propertyBuilder, eventAggregator, serviceFactory, disposer) + { + + } +} \ No newline at end of file diff --git a/App/KingPing/Views/MainView.axaml b/App/KingPing/Views/MainView.axaml new file mode 100644 index 0000000..0a33a21 --- /dev/null +++ b/App/KingPing/Views/MainView.axaml @@ -0,0 +1,9 @@ + diff --git a/App/KingPing/Views/MainView.axaml.cs b/App/KingPing/Views/MainView.axaml.cs new file mode 100644 index 0000000..6ef36ce --- /dev/null +++ b/App/KingPing/Views/MainView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; +using PropertyChanged; + +namespace KingPing; + +[DoNotNotify] +public partial class MainView : UserControl +{ + public MainView() + { + InitializeComponent(); + } +} diff --git a/App/KingPing/Views/MainViewModel.cs b/App/KingPing/Views/MainViewModel.cs new file mode 100644 index 0000000..98c6488 --- /dev/null +++ b/App/KingPing/Views/MainViewModel.cs @@ -0,0 +1,18 @@ +using TheXamlGuy.Framework.Avalonia; +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class MainViewModel : ObservableViewModel +{ + public MainViewModel(IPropertyBuilder propertyBuilder, + IEventAggregator eventAggregator, + IServiceFactory serviceFactory, + IDisposer disposer, + IRouter route) : base(propertyBuilder, eventAggregator, serviceFactory, disposer) + { + Route = route; + } + + public IRouter Route { get; } +} diff --git a/App/KingPing/Views/MainWindow.axaml b/App/KingPing/Views/MainWindow.axaml new file mode 100644 index 0000000..676f0a5 --- /dev/null +++ b/App/KingPing/Views/MainWindow.axaml @@ -0,0 +1,9 @@ + diff --git a/App/KingPing/Views/MainWindow.axaml.cs b/App/KingPing/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..4c02783 --- /dev/null +++ b/App/KingPing/Views/MainWindow.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; +using PropertyChanged; + +namespace KingPing; + +[DoNotNotify] +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} diff --git a/App/KingPing/Views/MainWindowViewModel.cs b/App/KingPing/Views/MainWindowViewModel.cs new file mode 100644 index 0000000..0918112 --- /dev/null +++ b/App/KingPing/Views/MainWindowViewModel.cs @@ -0,0 +1,18 @@ +using TheXamlGuy.Framework.Avalonia; +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class MainWindowViewModel : ObservableViewModel +{ + public MainWindowViewModel(IPropertyBuilder propertyBuilder, + IEventAggregator eventAggregator, + IServiceFactory serviceFactory, + IDisposer disposer, + IRouter route) : base(propertyBuilder, eventAggregator, serviceFactory, disposer) + { + Route = route; + } + + public IRouter Route { get; } +} \ No newline at end of file diff --git a/App/KingPing/Views/ShellView.axaml b/App/KingPing/Views/ShellView.axaml new file mode 100644 index 0000000..1717bf8 --- /dev/null +++ b/App/KingPing/Views/ShellView.axaml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/App/KingPing/Views/ShellView.axaml.cs b/App/KingPing/Views/ShellView.axaml.cs new file mode 100644 index 0000000..c1bf518 --- /dev/null +++ b/App/KingPing/Views/ShellView.axaml.cs @@ -0,0 +1,13 @@ +using PropertyChanged; +using TheXamlGuy.UI.Avalonia.Controls; + +namespace KingPing; + +[DoNotNotify] +public partial class ShellView : NavigationView +{ + public ShellView() + { + InitializeComponent(); + } +} diff --git a/App/KingPing/Views/ShellViewModel.cs b/App/KingPing/Views/ShellViewModel.cs new file mode 100644 index 0000000..264d091 --- /dev/null +++ b/App/KingPing/Views/ShellViewModel.cs @@ -0,0 +1,18 @@ +using TheXamlGuy.Framework.Avalonia; +using TheXamlGuy.Framework.Core; + +namespace KingPing; + +public class ShellViewModel : ObservableViewModel +{ + public ShellViewModel(IPropertyBuilder propertyBuilder, + IEventAggregator eventAggregator, + IServiceFactory serviceFactory, + IDisposer disposer, + IRouter route) : base(propertyBuilder, eventAggregator, serviceFactory, disposer) + { + Route = route; + } + + public IRouter Route { get; } +} \ No newline at end of file diff --git a/Framework/Avalonia/Templates/TemplateSelector.cs b/Framework/Avalonia/Templates/TemplateSelector.cs index fe7b7fd..1a7e36d 100644 --- a/Framework/Avalonia/Templates/TemplateSelector.cs +++ b/Framework/Avalonia/Templates/TemplateSelector.cs @@ -7,41 +7,37 @@ using TheXamlGuy.UI.Avalonia.Controls; namespace TheXamlGuy.Framework.Avalonia; -public class TemplateSelector : DataTemplateSelector, ITemplateSelector +public class TemplateSelector : IDataTemplate, ITemplateSelector { - private readonly Dictionary dataTracking = new(); + private readonly Dictionary dataTracking = new(); - private readonly ITemplateFactory templateFactory; private readonly IEventAggregator eventAggregator; + private readonly ITemplateFactory templateFactory; - public TemplateSelector(ITemplateFactory templateFactory, + public TemplateSelector(ITemplateFactory templateFactory, IEventAggregator eventAggregator) { this.templateFactory = templateFactory; this.eventAggregator = eventAggregator; } - protected override IDataTemplate SelectTemplateCore(object item, IControl container) + public IControl? Build(object? item) { if (item is not null) { - if (dataTracking.TryGetValue(item, out DataTemplate? cachedDataTemplate)) + if (dataTracking.TryGetValue(item, out IControl? control)) { - return cachedDataTemplate; + return control; } - return new FuncDataTemplate(item.GetType(), (value, namescope) => - { - if (templateFactory.Create(item) is TemplatedControl template) - { - return template; - } - - return null; - }); - + return (IControl?)templateFactory.Create(item); } - return base.SelectTemplateCore(item, container); + return null; + } + + public bool Match(object? data) + { + return true; } } \ No newline at end of file diff --git a/TheXamlGuy.sln b/TheXamlGuy.sln index 5350c92..9b58def 100644 --- a/TheXamlGuy.sln +++ b/TheXamlGuy.sln @@ -37,7 +37,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia", "UI\Avalonia\Ava EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UI", "UI\UI\UI.csproj", "{3094D318-5B54-4367-8195-D47FB431FCB2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Controls", "UI\Avalonia.Controls\Avalonia.Controls.csproj", "{DD446126-ABF5-452B-AE93-89A6E6EEF5E5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls", "UI\Avalonia.Controls\Avalonia.Controls.csproj", "{DD446126-ABF5-452B-AE93-89A6E6EEF5E5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KingPing", "App\KingPing\KingPing.csproj", "{8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -159,6 +161,14 @@ Global {DD446126-ABF5-452B-AE93-89A6E6EEF5E5}.Release|Any CPU.Build.0 = Release|Any CPU {DD446126-ABF5-452B-AE93-89A6E6EEF5E5}.Release|x64.ActiveCfg = Release|Any CPU {DD446126-ABF5-452B-AE93-89A6E6EEF5E5}.Release|x64.Build.0 = Release|Any CPU + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}.Debug|x64.ActiveCfg = Debug|Any CPU + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}.Debug|x64.Build.0 = Debug|Any CPU + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}.Release|Any CPU.Build.0 = Release|Any CPU + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}.Release|x64.ActiveCfg = Release|Any CPU + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -178,6 +188,7 @@ Global {E81C81B3-3FF3-4E1C-B348-C7997D892020} = {793B9D90-DE72-4226-84E8-93FD63548874} {3094D318-5B54-4367-8195-D47FB431FCB2} = {793B9D90-DE72-4226-84E8-93FD63548874} {DD446126-ABF5-452B-AE93-89A6E6EEF5E5} = {793B9D90-DE72-4226-84E8-93FD63548874} + {8AE9C2EB-C36D-4122-BE61-A5EEC8BBE8E7} = {10A06ACB-8070-4108-9BF9-AD48D546B56D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3B239B2D-8C12-47AC-BA53-BB2A3E5BFDB6} diff --git a/UI/Avalonia.Controls/DataTemplateSelector/DataTemplateSelector.cs b/UI/Avalonia.Controls/DataTemplateSelector/DataTemplateSelector.cs deleted file mode 100644 index 6333719..0000000 --- a/UI/Avalonia.Controls/DataTemplateSelector/DataTemplateSelector.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TheXamlGuy.UI.Avalonia.Controls -{ - public class DataTemplateSelector : FluentAvalonia.UI.Controls.DataTemplateSelector - { - } -} diff --git a/UI/Avalonia.Controls/ProgressRing/ProgressRing.axaml b/UI/Avalonia.Controls/ProgressRing/ProgressRing.axaml new file mode 100644 index 0000000..21c1bb0 --- /dev/null +++ b/UI/Avalonia.Controls/ProgressRing/ProgressRing.axaml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + 4 + + + + + + + + + + + + + + + + + diff --git a/UI/Avalonia.Controls/ProgressRing/ProgressRing.cs b/UI/Avalonia.Controls/ProgressRing/ProgressRing.cs new file mode 100644 index 0000000..529a452 --- /dev/null +++ b/UI/Avalonia.Controls/ProgressRing/ProgressRing.cs @@ -0,0 +1,37 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; + +namespace TheXamlGuy.UI.Avalonia.Controls +{ + public class ProgressRing : RangeBase + { + public static readonly StyledProperty IsIndeterminateProperty = + AvaloniaProperty.Register(nameof(IsIndeterminate), true); + + public bool IsIndeterminate + { + get => GetValue(IsIndeterminateProperty); + set => SetValue(IsIndeterminateProperty, value); + } + + protected override void OnApplyTemplate(TemplateAppliedEventArgs args) + { + UpdateIsIndeterminate(); + } + + private void UpdateIsIndeterminate() + { + PseudoClasses.Set(":indeterminate", IsIndeterminate); + + } + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + if (change.Property == IsIndeterminateProperty) + { + UpdateIsIndeterminate(); + } + } + } +} diff --git a/UI/Avalonia/Themes/ControlResources.axaml b/UI/Avalonia/Themes/ControlResources.axaml new file mode 100644 index 0000000..2e63ff6 --- /dev/null +++ b/UI/Avalonia/Themes/ControlResources.axaml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/UI/Avalonia/XamlControlsResources.cs b/UI/Avalonia/XamlControlsResources.cs index e2c41e3..026bc03 100644 --- a/UI/Avalonia/XamlControlsResources.cs +++ b/UI/Avalonia/XamlControlsResources.cs @@ -1,14 +1,23 @@ -using FluentAvalonia.Styling; +using Avalonia.Markup.Xaml; +using Avalonia.Styling; +using FluentAvalonia.Styling; +using FluentAvalonia.UI.Controls.Primitives; namespace TheXamlGuy.UI.Avalonia; public class XamlControlsResources : FluentAvaloniaTheme { - public XamlControlsResources(Uri baseUri) : base(baseUri) - { - } - public XamlControlsResources(IServiceProvider serviceProvider) : base(serviceProvider) { } + + //private void XamlControlsResources_OwnerChanged(object? sender, EventArgs e) + //{ + // Styles styles = (Styles)AvaloniaXamlLoader.Load(new Uri($"avares://TheXamlGuy.UI.Avalonia/Themes/ControlResources.axaml")); + + // foreach (var style in styles) + // { + // style.add + // } + //} }