diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d076fd5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,247 @@ +# editorconfig.org + +# top-most EditorConfig file +root = true + +# Default settings: +# A newline ending every file +# Use 4 spaces as indentation +[*] +insert_final_newline = true +indent_style = space +indent_size = 4 + +# C# files +[*.cs] +# New line preferences +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true +# trim_trailing_whitespace = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = one_less_than_current + +# avoid this. unless absolutely necessary +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion + +# prefer var +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true +csharp_style_var_elsewhere = true:suggestion + +# use language keywords instead of BCL types +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion + +# name all constant fields using PascalCase +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style + +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.required_modifiers = const + +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +# private static fields should have s_ prefix +dotnet_naming_rule.private_static_fields_should_have_prefix.severity = suggestion +dotnet_naming_rule.private_static_fields_should_have_prefix.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_have_prefix.style = private_static_prefix_style + +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.required_modifiers = static +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private + +dotnet_naming_style.private_static_prefix_style.required_prefix = s_ +dotnet_naming_style.private_static_prefix_style.capitalization = camel_case + +# internal and private fields should be _camelCase +dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion +dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style + +dotnet_naming_symbols.private_internal_fields.applicable_kinds = field +dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal + +dotnet_naming_style.camel_case_underscore_style.required_prefix = _ +dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case + +# use accessibility modifiers +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +# Code style defaults +dotnet_sort_system_directives_first = true +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false + +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion + +# Expression-bodied members +csharp_style_expression_bodied_methods = false:none +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_operators = false:none +csharp_style_expression_bodied_properties = true:none +csharp_style_expression_bodied_indexers = true:none +csharp_style_expression_bodied_accessors = true:none + +# Pattern matching +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion + +# Null checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false +space_within_single_line_array_initializer_braces = true + +#Net Analyzer +dotnet_analyzer_diagnostic.category-Performance.severity = none #error - Uncomment when all violations are fixed. + +# CS0649: Field 'field' is never assigned to, and will always have its default value 'value' +dotnet_diagnostic.CS0649.severity = error + +# CS1591: Missing XML comment for publicly visible type or member +dotnet_diagnostic.CS1591.severity = suggestion + +# CS0162: Remove unreachable code +dotnet_diagnostic.CS0162.severity = error +# CA1018: Mark attributes with AttributeUsageAttribute +dotnet_diagnostic.CA1018.severity = error +# CA1304: Specify CultureInfo +dotnet_diagnostic.CA1304.severity = warning +# CA1802: Use literals where appropriate +dotnet_diagnostic.CA1802.severity = warning +# CA1813: Avoid unsealed attributes +dotnet_diagnostic.CA1813.severity = error +# CA1815: Override equals and operator equals on value types +dotnet_diagnostic.CA1815.severity = warning +# CA1820: Test for empty strings using string length +dotnet_diagnostic.CA1820.severity = warning +# CA1821: Remove empty finalizers +dotnet_diagnostic.CA1821.severity = error +# CA1822: Mark members as static +dotnet_diagnostic.CA1822.severity = suggestion +dotnet_code_quality.CA1822.api_surface = private, internal +# CA1823: Avoid unused private fields +dotnet_diagnostic.CA1823.severity = error +# CA1825: Avoid zero-length array allocations +dotnet_diagnostic.CA1825.severity = warning +# CA1826: Use property instead of Linq Enumerable method +dotnet_diagnostic.CA1826.severity = suggestion +# CA1827: Do not use Count/LongCount when Any can be used +dotnet_diagnostic.CA1827.severity = warning +# CA1828: Do not use CountAsync/LongCountAsync when AnyAsync can be used +dotnet_diagnostic.CA1828.severity = warning +# CA1829: Use Length/Count property instead of Enumerable.Count method +dotnet_diagnostic.CA1829.severity = warning +#CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters +dotnet_diagnostic.CA1847.severity = warning +#CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method +dotnet_diagnostic.CA1854.severity = warning +#CA2211:Non-constant fields should not be visible +dotnet_diagnostic.CA2211.severity = error + +# Wrapping preferences +csharp_wrap_before_ternary_opsigns = false + +# Avalonia DevAnalyzer preferences +dotnet_diagnostic.AVADEV2001.severity = error + +# Avalonia PublicAnalyzer preferences +dotnet_diagnostic.AVP1000.severity = error +dotnet_diagnostic.AVP1001.severity = error +dotnet_diagnostic.AVP1002.severity = error +dotnet_diagnostic.AVP1010.severity = error +dotnet_diagnostic.AVP1011.severity = error +dotnet_diagnostic.AVP1012.severity = warning +dotnet_diagnostic.AVP1013.severity = error +dotnet_diagnostic.AVP1020.severity = error +dotnet_diagnostic.AVP1021.severity = error +dotnet_diagnostic.AVP1022.severity = error +dotnet_diagnostic.AVP1030.severity = error +dotnet_diagnostic.AVP1031.severity = error +dotnet_diagnostic.AVP1032.severity = error +dotnet_diagnostic.AVP1040.severity = error +dotnet_diagnostic.AVA2001.severity = error + +# Xaml files +[*.{xaml,axaml}] +indent_size = 2 +# DuplicateSetterError +avalonia_xaml_diagnostic.AVLN2203.severity = error +# StyleInMergedDictionaries +avalonia_xaml_diagnostic.AVLN2204.severity = error +# RequiredTemplatePartMissing +avalonia_xaml_diagnostic.AVLN2205.severity = error +# OptionalTemplatePartMissing +avalonia_xaml_diagnostic.AVLN2206.severity = info +# TemplatePartWrongType +avalonia_xaml_diagnostic.AVLN2207.severity = error +# Obsolete +avalonia_xaml_diagnostic.AVLN5001.severity = error + +# Xml project files +[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] +indent_size = 2 + +# Xml build files +[*.builds] +indent_size = 2 + +# Xml files +[*.{xml,stylecop,resx,ruleset}] +indent_size = 2 + +# Xml config files +[*.{props,targets,config,nuspec}] +indent_size = 2 + +[*.json] +indent_size = 2 + +# Shell scripts +[*.sh] +end_of_line = lf +[*.{cmd,bat}] +end_of_line = crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7a6a542..104b544 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,484 @@ -Notification.Avalonia/bin -Notification.Avalonia/obj -.idea +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# 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 +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 +*.tlog +*.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 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# 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/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# 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 + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea + +## +## 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 + +# Vim temporary swap files +*.swp diff --git a/Avalonia.Notification.Samples/App.axaml.cs b/Avalonia.Notification.Samples/App.axaml.cs index 9794029..7877f20 100644 --- a/Avalonia.Notification.Samples/App.axaml.cs +++ b/Avalonia.Notification.Samples/App.axaml.cs @@ -1,29 +1,27 @@ -using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using Avalonia.Notification.Samples.ViewModels; using Avalonia.Notification.Samples.Views; -namespace Avalonia.Notification.Samples +namespace Avalonia.Notification.Samples; + +public partial class App : Application { - public partial class App : Application + public override void Initialize() { - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } + AvaloniaXamlLoader.Load(this); + } - public override void OnFrameworkInitializationCompleted() + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + desktop.MainWindow = new MainWindow { - desktop.MainWindow = new MainWindow - { - DataContext = new MainWindowViewModel(), - }; - } - - base.OnFrameworkInitializationCompleted(); + DataContext = new MainWindowViewModel(), + }; } + + base.OnFrameworkInitializationCompleted(); } -} \ No newline at end of file +} diff --git a/Avalonia.Notification.Samples/Avalonia.Notification.Samples.csproj b/Avalonia.Notification.Samples/Avalonia.Notification.Samples.csproj index d89ff43..2258cc2 100644 --- a/Avalonia.Notification.Samples/Avalonia.Notification.Samples.csproj +++ b/Avalonia.Notification.Samples/Avalonia.Notification.Samples.csproj @@ -1,32 +1,38 @@  - - WinExe - net8.0 - enable - - copyused - true - - - - - - - + copyused + true + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/Avalonia.Notification.Samples/Program.cs b/Avalonia.Notification.Samples/Program.cs index 3e533a9..9f610d5 100644 --- a/Avalonia.Notification.Samples/Program.cs +++ b/Avalonia.Notification.Samples/Program.cs @@ -1,24 +1,17 @@ -using System; -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.ReactiveUI; +namespace Avalonia.Notification.Samples; -namespace Avalonia.Notification.Samples +class Program { - class Program - { - // Initialization code. Don't use any Avalonia, third-party APIs or any - // SynchronizationContext-reliant code before AppMain is called: things aren't initialized - // yet and stuff might break. - [STAThread] - public static void Main(string[] args) => BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); - // Avalonia configuration, don't remove; also used by visual designer. - public static AppBuilder BuildAvaloniaApp() - => AppBuilder.Configure() - .UsePlatformDetect() - .LogToTrace() - .UseReactiveUI(); - } -} \ No newline at end of file + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .LogToTrace(); +} diff --git a/Avalonia.Notification.Samples/ViewLocator.cs b/Avalonia.Notification.Samples/ViewLocator.cs index 3aee177..a991b7b 100644 --- a/Avalonia.Notification.Samples/ViewLocator.cs +++ b/Avalonia.Notification.Samples/ViewLocator.cs @@ -1,30 +1,28 @@ -using System; using Avalonia.Controls; using Avalonia.Controls.Templates; using Avalonia.Notification.Samples.ViewModels; -namespace Avalonia.Notification.Samples +namespace Avalonia.Notification.Samples; + +public class ViewLocator : IDataTemplate { - public class ViewLocator : IDataTemplate + public Control Build(object data) { - public Control Build(object data) - { - var name = data.GetType().FullName!.Replace("ViewModel", "View"); - var type = Type.GetType(name); + var name = data.GetType().FullName!.Replace("ViewModel", "View"); + var type = Type.GetType(name); - if (type != null) - { - return (Control)Activator.CreateInstance(type)!; - } - else - { - return new TextBlock { Text = "Not Found: " + name }; - } + if (type != null) + { + return (Control)Activator.CreateInstance(type)!; } - - public bool Match(object data) + else { - return data is ViewModelBase; + return new TextBlock { Text = "Not Found: " + name }; } } -} \ No newline at end of file + + public bool Match(object data) + { + return data is ViewModelBase; + } +} diff --git a/Avalonia.Notification.Samples/ViewModels/MainWindowViewModel.cs b/Avalonia.Notification.Samples/ViewModels/MainWindowViewModel.cs index 60d3b23..7c7a883 100644 --- a/Avalonia.Notification.Samples/ViewModels/MainWindowViewModel.cs +++ b/Avalonia.Notification.Samples/ViewModels/MainWindowViewModel.cs @@ -1,89 +1,83 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Avalonia.Controls; -using Avalonia.Interactivity; +using Avalonia.Controls; using Avalonia.Layout; using Avalonia.Media; -namespace Avalonia.Notification.Samples.ViewModels +namespace Avalonia.Notification.Samples.ViewModels; + +public class MainWindowViewModel : ViewModelBase { - public class MainWindowViewModel : ViewModelBase + /// + /// Gets the notification message manager. + /// + /// + /// The notification message manager. + /// + public INotificationMessageManager Manager { get; } = new NotificationMessageManager(); + + public void ButtonBaseErrorOnClick() { - - /// - /// Gets the notification message manager. - /// - /// - /// The notification message manager. - /// - public INotificationMessageManager Manager { get; } = new NotificationMessageManager(); - - public void ButtonBaseErrorOnClick() - { - this.Manager - .CreateMessage() - .Accent("#F15B19") - .Background("#F15B19") - .HasHeader("Lost connection to server") - .HasMessage("Reconnecting...") - .WithOverlay(new ProgressBar - { - VerticalAlignment = VerticalAlignment.Bottom, - HorizontalAlignment = HorizontalAlignment.Stretch, - Height = 3, - BorderThickness = new Thickness(0), - Foreground = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)), - Background = Brushes.Transparent, - IsIndeterminate = true, - IsHitTestVisible = false - }) - .Queue(); - } + this.Manager + .CreateMessage() + .Accent("#F15B19") + .Background("#F15B19") + .HasHeader("Lost connection to server") + .HasMessage("Reconnecting...") + .WithOverlay(new ProgressBar + { + VerticalAlignment = VerticalAlignment.Bottom, + HorizontalAlignment = HorizontalAlignment.Stretch, + Height = 3, + BorderThickness = new Thickness(0), + Foreground = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)), + Background = Brushes.Transparent, + IsIndeterminate = true, + IsHitTestVisible = false + }) + .Queue(); + } - public void ButtonBaseWarningOnClick() - { - this.Manager - .CreateMessage() - .Accent("#E0A030") - .Background("#333") - .HasBadge("Warn") - .HasHeader("Error") - .HasMessage("Failed to retrieve data.") - .WithButton("Try again", async button => { }) - .Dismiss().WithButton("Ignore", button => { }) - .Queue(); - } + public void ButtonBaseWarningOnClick() + { + this.Manager + .CreateMessage() + .Accent("#E0A030") + .Background("#333") + .HasBadge("Warn") + .HasHeader("Error") + .HasMessage("Failed to retrieve data.") + .WithButton("Try again", async button => { }) + .Dismiss().WithButton("Ignore", button => { }) + .Queue(); + } - public void ButtonBaseInfoOnClick() - { - this.Manager - .CreateMessage() - .Accent("#1751C3") - .Background("#333") - .HasBadge("Info") - .HasMessage("Update will be installed on next application restart.") - .Dismiss().WithButton("Update now", button => { }) - .Dismiss().WithButton("Release notes", button => { }) - .Dismiss().WithButton("Later", button => { }) - .Queue(); - } + public void ButtonBaseInfoOnClick() + { + this.Manager + .CreateMessage() + .Accent("#1751C3") + .Background("#333") + .HasBadge("Info") + .HasMessage("Update will be installed on next application restart.") + .Dismiss().WithButton("Update now", button => { }) + .Dismiss().WithButton("Release notes", button => { }) + .Dismiss().WithButton("Later", button => { }) + .Queue(); + } - public void ButtonBaseInfoDelayOnClick() - { - this.Manager - .CreateMessage() - .Accent("#1751C3") - .Animates(true) - .Background("#333") - .HasBadge("Info") - .HasMessage( - "Update will be installed on next application restart. This message will be dismissed after 5 seconds.") - .Dismiss().WithButton("Update now", button => { }) - .Dismiss().WithButton("Release notes", button => { }) - .Dismiss().WithDelay(TimeSpan.FromSeconds(5)) - .Queue(); - } - public string Greeting => "Welcome to Avalonia!"; + public void ButtonBaseInfoDelayOnClick() + { + this.Manager + .CreateMessage() + .Accent("#1751C3") + .Animates(true) + .Background("#333") + .HasBadge("Info") + .HasMessage( + "Update will be installed on next application restart. This message will be dismissed after 5 seconds.") + .Dismiss().WithButton("Update now", button => { }) + .Dismiss().WithButton("Release notes", button => { }) + .Dismiss().WithDelay(TimeSpan.FromSeconds(5)) + .Queue(); } -} \ No newline at end of file + public string Greeting => "Welcome to Avalonia!"; +} diff --git a/Avalonia.Notification.Samples/ViewModels/ViewModelBase.cs b/Avalonia.Notification.Samples/ViewModels/ViewModelBase.cs index 765ebb9..2e601a9 100644 --- a/Avalonia.Notification.Samples/ViewModels/ViewModelBase.cs +++ b/Avalonia.Notification.Samples/ViewModels/ViewModelBase.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ReactiveUI; +using CommunityToolkit.Mvvm.ComponentModel; namespace Avalonia.Notification.Samples.ViewModels { - public class ViewModelBase : ReactiveObject + public class ViewModelBase : ObservableObject { } -} \ No newline at end of file +} diff --git a/Avalonia.Notification.Samples/Views/MainWindow.axaml.cs b/Avalonia.Notification.Samples/Views/MainWindow.axaml.cs index c6f3188..241af1b 100644 --- a/Avalonia.Notification.Samples/Views/MainWindow.axaml.cs +++ b/Avalonia.Notification.Samples/Views/MainWindow.axaml.cs @@ -1,17 +1,11 @@ -using System; -using System.Threading.Tasks; using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Layout; -using Avalonia.Media; -namespace Avalonia.Notification.Samples.Views +namespace Avalonia.Notification.Samples.Views; + +public partial class MainWindow : Window { - public partial class MainWindow : Window + public MainWindow() { - public MainWindow() - { - InitializeComponent(); - } + InitializeComponent(); } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/ContentLocation.cs b/Notification.Avalonia/ContentLocation.cs index e768c78..61bbf8a 100644 --- a/Notification.Avalonia/ContentLocation.cs +++ b/Notification.Avalonia/ContentLocation.cs @@ -10,5 +10,5 @@ public enum ContentLocation Left, Right, Main, - AboveBadge -} \ No newline at end of file + AboveBadge, +} diff --git a/Notification.Avalonia/Controls/NotificationMessage.cs b/Notification.Avalonia/Controls/NotificationMessage.cs index ded1831..94a3377 100644 --- a/Notification.Avalonia/Controls/NotificationMessage.cs +++ b/Notification.Avalonia/Controls/NotificationMessage.cs @@ -1,11 +1,8 @@ using System.Collections.ObjectModel; -using Avalonia.Animation; using Avalonia.Controls; -using Avalonia.Controls.Presenters; using Avalonia.Controls.Primitives; using Avalonia.Media; using Avalonia.Reactive; -using Avalonia.Styling; namespace Avalonia.Notification.Controls; @@ -462,4 +459,4 @@ public NotificationMessage() this.Foreground = new BrushConverter().ConvertFromString("#DDDDDD") as IBrush; this.Classes.Add("notificationMessage"); } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/Controls/NotificationMessageButton.cs b/Notification.Avalonia/Controls/NotificationMessageButton.cs index c98d035..67905c3 100644 --- a/Notification.Avalonia/Controls/NotificationMessageButton.cs +++ b/Notification.Avalonia/Controls/NotificationMessageButton.cs @@ -1,57 +1,54 @@ using Avalonia.Controls; -namespace Avalonia.Notification.Controls +namespace Avalonia.Notification.Controls; + +/// +/// The notification message button. +/// +/// +/// +public class NotificationMessageButton : Button, INotificationMessageButton { /// - /// The notification message button. + /// Initializes a new instance of the class. /// - /// - /// - public class NotificationMessageButton : Button, INotificationMessageButton + public NotificationMessageButton() : this(null) { - /// - /// Initializes a new instance of the class. - /// - public NotificationMessageButton() - : this(null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The content. - public NotificationMessageButton(object content) - { - this.Content = content; - } - - /// - /// Called when a is clicked. - /// - protected override void OnClick() - { - base.OnClick(); - this.Callback?.Invoke(this); - } + } - /// - /// Initializes the class. - /// - static NotificationMessageButton() - { - // TODO - //DefaultStyleKeyProperty.OverrideMetadata(typeof(NotificationMessageButton), new FrameworkPropertyMetadata(typeof(NotificationMessageButton))); - } + /// + /// Initializes a new instance of the class. + /// + /// The content. + public NotificationMessageButton(object content) + { + this.Content = content; + } + /// + /// Called when a is clicked. + /// + protected override void OnClick() + { + base.OnClick(); + this.Callback?.Invoke(this); + } - /// - /// Gets or sets the callback. - /// - /// - /// The callback. - /// - public Action Callback { get; set; } + /// + /// Initializes the class. + /// + static NotificationMessageButton() + { + // TODO + //DefaultStyleKeyProperty.OverrideMetadata(typeof(NotificationMessageButton), new FrameworkPropertyMetadata(typeof(NotificationMessageButton))); } -} \ No newline at end of file + + /// + /// Gets or sets the callback. + /// + /// + /// The callback. + /// + public Action Callback { get; set; } +} diff --git a/Notification.Avalonia/Controls/NotificationMessageContainer.cs b/Notification.Avalonia/Controls/NotificationMessageContainer.cs index 87e7ef8..d8ed904 100644 --- a/Notification.Avalonia/Controls/NotificationMessageContainer.cs +++ b/Notification.Avalonia/Controls/NotificationMessageContainer.cs @@ -1,129 +1,124 @@ -using System.Runtime.CompilerServices; -using Avalonia.Animation; -using Avalonia.Collections; -using Avalonia.Controls; +using Avalonia.Controls; using Avalonia.Reactive; -namespace Avalonia.Notification.Controls +namespace Avalonia.Notification.Controls; + +/// +/// The notification message container. +/// +/// +public class NotificationMessageContainer : ItemsControl { /// - /// The notification message container. + /// Gets or sets the manager. /// - /// - public class NotificationMessageContainer : ItemsControl + /// + /// The manager. + /// + public INotificationMessageManager Manager { - /// - /// Gets or sets the manager. - /// - /// - /// The manager. - /// - public INotificationMessageManager Manager - { - get => (INotificationMessageManager)this.GetValue(ManagerProperty); - set => this.SetValue(ManagerProperty, value); - } - - /// - /// The manager property. - /// - public static readonly StyledProperty ManagerProperty = - AvaloniaProperty.Register("Manager"); + get => GetValue(ManagerProperty); + set => SetValue(ManagerProperty, value); + } + /// + /// The manager property. + /// + public static readonly StyledProperty ManagerProperty = + AvaloniaProperty.Register(nameof(Manager)); - //TODO - /// - /// Managers the property changed callback. - /// - /// The dependency object. - /// The instance containing the event data. - /// Dependency object is not of valid type - expected NotificationMessageContainer. - private static void ManagerPropertyChangedCallback(AvaloniaObject dependencyObject, - AvaloniaPropertyChangedEventArgs dependencyPropertyChangedEventArgs) - { - if (!(dependencyObject is NotificationMessageContainer @this)) - throw new NullReferenceException("Dependency object is not of valid type " + - nameof(NotificationMessageContainer)); + //TODO + /// + /// Managers the property changed callback. + /// + /// The dependency object. + /// The instance containing the event data. + /// Dependency object is not of valid type - expected NotificationMessageContainer. + private static void ManagerPropertyChangedCallback(AvaloniaObject dependencyObject, + AvaloniaPropertyChangedEventArgs dependencyPropertyChangedEventArgs) + { + if (!(dependencyObject is NotificationMessageContainer @this)) + throw new NullReferenceException("Dependency object is not of valid type " + + nameof(NotificationMessageContainer)); - if (dependencyPropertyChangedEventArgs.OldValue is INotificationMessageManager oldManager) - @this.DetachManagerEvents(oldManager); + if (dependencyPropertyChangedEventArgs.OldValue is INotificationMessageManager oldManager) + @this.DetachManagerEvents(oldManager); - if (dependencyPropertyChangedEventArgs.NewValue is INotificationMessageManager newManager) - @this.AttachManagerEvents(newManager); - } + if (dependencyPropertyChangedEventArgs.NewValue is INotificationMessageManager newManager) + @this.AttachManagerEvents(newManager); + } - /// - /// Attaches the manager events. - /// - /// The new manager. - private void AttachManagerEvents(INotificationMessageManager newManager) - { - newManager.OnMessageQueued += ManagerOnOnMessageQueued; - newManager.OnMessageDismissed += ManagerOnOnMessageDismissed; - } + /// + /// Attaches the manager events. + /// + /// The new manager. + private void AttachManagerEvents(INotificationMessageManager newManager) + { + newManager.OnMessageQueued += ManagerOnOnMessageQueued; + newManager.OnMessageDismissed += ManagerOnOnMessageDismissed; + } - /// - /// Detaches the manager events. - /// - /// The old manager. - private void DetachManagerEvents(INotificationMessageManager oldManager) - { - oldManager.OnMessageQueued -= ManagerOnOnMessageQueued; - oldManager.OnMessageDismissed -= ManagerOnOnMessageDismissed; - } + /// + /// Detaches the manager events. + /// + /// The old manager. + private void DetachManagerEvents(INotificationMessageManager oldManager) + { + oldManager.OnMessageQueued -= ManagerOnOnMessageQueued; + oldManager.OnMessageDismissed -= ManagerOnOnMessageDismissed; + } - /// - /// Manager on message dismissed. - /// - /// The sender. - /// The instance containing the event data. - /// Can't use both ItemsSource and Items collection at the same time. - private void ManagerOnOnMessageDismissed(object sender, NotificationMessageManagerEventArgs args) - { - /*if (this.Items != null) - throw new InvalidOperationException( - "Can't use both ItemsSource and Items collection at the same time.");*/ + /// + /// Manager on message dismissed. + /// + /// The sender. + /// The instance containing the event data. + /// Can't use both ItemsSource and Items collection at the same time. + private void ManagerOnOnMessageDismissed(object sender, NotificationMessageManagerEventArgs args) + { + /*if (this.Items != null) + throw new InvalidOperationException( + "Can't use both ItemsSource and Items collection at the same time.");*/ - this.RemoveMessage(args.Message); - } + this.RemoveMessage(args.Message); + } - private void RemoveMessage(INotificationMessage message) - { - (this.Items).Remove(message); - } + private void RemoveMessage(INotificationMessage message) + { + this.Items.Remove(message); + } - /// - /// Manager on message queued. - /// - /// The sender. - /// The instance containing the event data. - /// Can't use both ItemsSource and Items collection at the same time. - private void ManagerOnOnMessageQueued(object sender, NotificationMessageManagerEventArgs args) - { - /*if (this.Items != ture) - throw new InvalidOperationException( - "Can't use both ItemsSource and Items collection at the same time.");*/ + /// + /// Manager on message queued. + /// + /// The sender. + /// The instance containing the event data. + /// Can't use both ItemsSource and Items collection at the same time. + private void ManagerOnOnMessageQueued(object sender, NotificationMessageManagerEventArgs args) + { + /*if (this.Items != ture) + throw new InvalidOperationException( + "Can't use both ItemsSource and Items collection at the same time.");*/ - (this.Items).Add(args.Message); + this.Items.Add(args.Message); - if (args.Message is INotificationAnimation animatableMessage) + if (args.Message is INotificationAnimation animatableMessage) + { + if (animatableMessage.Animates) { - if (animatableMessage.Animates) - { - animatableMessage.AnimatableElement.StartAnimation = true; - } + animatableMessage.AnimatableElement.StartAnimation = true; } } + } - /// - /// Initializes the class. - /// - static NotificationMessageContainer() - { - ManagerProperty.Changed.Subscribe( - new AnonymousObserver>( - x => ManagerPropertyChangedCallback(x.Sender, x))); - //DefaultStyleKeyProperty.OverrideMetadata(typeof(NotificationMessageContainer), new FrameworkPropertyMetadata(typeof(NotificationMessageContainer))); - } + /// + /// Initializes the class. + /// + static NotificationMessageContainer() + { + ManagerProperty.Changed.Subscribe( + new AnonymousObserver>( + x => ManagerPropertyChangedCallback(x.Sender, x))); + //DefaultStyleKeyProperty.OverrideMetadata(typeof(NotificationMessageContainer), new FrameworkPropertyMetadata(typeof(NotificationMessageContainer))); } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/INotificationAnimation.cs b/Notification.Avalonia/INotificationAnimation.cs index 437001d..676f740 100644 --- a/Notification.Avalonia/INotificationAnimation.cs +++ b/Notification.Avalonia/INotificationAnimation.cs @@ -1,34 +1,30 @@ -using Avalonia.Controls; -using Avalonia.Controls.Primitives; +namespace Avalonia.Notification; -namespace Avalonia.Notification +/// +/// The animation properties for a notification message or some +/// other item. +/// +public interface INotificationAnimation { /// - /// The animation properties for a notification message or some - /// other item. + /// Set DismissAnimation /// - public interface INotificationAnimation - { - /// - /// Set DismissAnimation - /// - bool DismissAnimation { get; set; } + bool DismissAnimation { get; set; } - /// - /// Set StartAnimation - /// - bool StartAnimation { get; set; } + /// + /// Set StartAnimation + /// + bool StartAnimation { get; set; } - /// - /// Gets or sets whether the item animates in and out. - /// - bool Animates { get; set; } + /// + /// Gets or sets whether the item animates in and out. + /// + bool Animates { get; set; } - /// - /// Gets the animatable UIElement. - /// Typically this is the whole Control object so that the entire - /// item can be animated. - /// - INotificationAnimation AnimatableElement { get; } - } -} \ No newline at end of file + /// + /// Gets the animatable UIElement. + /// Typically this is the whole Control object so that the entire + /// item can be animated. + /// + INotificationAnimation AnimatableElement { get; } +} diff --git a/Notification.Avalonia/INotificationMessage.cs b/Notification.Avalonia/INotificationMessage.cs index b8f120c..390f4ce 100644 --- a/Notification.Avalonia/INotificationMessage.cs +++ b/Notification.Avalonia/INotificationMessage.cs @@ -1,163 +1,162 @@ using System.Collections.ObjectModel; using Avalonia.Media; -namespace Avalonia.Notification +namespace Avalonia.Notification; + +/// +/// The notification message. +/// +public interface INotificationMessage { /// - /// The notification message. - /// - public interface INotificationMessage - { - /// - /// Gets or sets the brush of the text. - /// - /// - /// The text brush. - /// - IBrush Foreground { get; set; } - - /// - /// Gets or sets the background. - /// - /// - /// The background. - /// - IBrush Background { get; set; } - - /// - /// Gets or sets the accent brush. - /// - /// - /// The accent brush. - /// - IBrush AccentBrush { get; set; } - - /// - /// Gets or sets the badge accent brush. - /// - /// - /// The badge accent brush. - /// - IBrush BadgeAccentBrush { get; set; } - - /// - /// Gets or sets the badge text. - /// - /// - /// The badge text. - /// - string BadgeText { get; set; } - - /// - /// Gets or sets the badge visibility. - /// - /// - /// The badge visibility. - /// - bool BadgeVisibility { get; set; } - - /// - /// Gets or sets the button accent brush. - /// - /// - /// The button accent brush. - /// - IBrush ButtonAccentBrush { get; set; } - - /// - /// Gets or sets the buttons. - /// - /// - /// The buttons. - /// - ObservableCollection Buttons { get; set; } - - /// - /// Gets or sets the header. - /// - /// - /// The header. - /// - string Header { get; set; } - - /// - /// Gets or sets the header visibility. - /// - /// - /// The header visibility. - /// - bool HeaderVisibility { get; set; } - - /// - /// Gets or sets the message. - /// - /// - /// The message. - /// - string Message { get; set; } - - /// - /// Gets or sets the message visibility. - /// - /// - /// The message visibility. - /// - bool MessageVisibility { get; set; } - - /// - /// Gets or sets the content of the overlay. - /// - /// - /// The content of the overlay. - /// - object OverlayContent { get; set; } - - /// - /// Gets or sets the content of the top additional content area. - /// - /// - /// The content of the top additional content area. - /// - object AdditionalContentTop { get; set; } - - /// - /// Gets or sets the content of the bottom additional content area. - /// - /// - /// The additional content. - /// - object AdditionalContentBottom { get; set; } - - /// - /// Gets or sets the content of the left additional content area. - /// - /// - /// The additional content. - /// - object AdditionalContentLeft { get; set; } - - /// - /// Gets or sets the content of the right additional content area. - /// - /// - /// The additional content. - /// - object AdditionalContentRight { get; set; } - - /// - /// Gets or sets the content of the center additional content area. - /// - /// - /// The additional content. - /// - object AdditionalContentMain { get; set; } - - /// - /// Gets or sets the content of the over badge additional content area. - /// - /// - /// The additional content. - /// - object AdditionalContentOverBadge { get; set; } - } -} \ No newline at end of file + /// Gets or sets the brush of the text. + /// + /// + /// The text brush. + /// + IBrush Foreground { get; set; } + + /// + /// Gets or sets the background. + /// + /// + /// The background. + /// + IBrush Background { get; set; } + + /// + /// Gets or sets the accent brush. + /// + /// + /// The accent brush. + /// + IBrush AccentBrush { get; set; } + + /// + /// Gets or sets the badge accent brush. + /// + /// + /// The badge accent brush. + /// + IBrush BadgeAccentBrush { get; set; } + + /// + /// Gets or sets the badge text. + /// + /// + /// The badge text. + /// + string BadgeText { get; set; } + + /// + /// Gets or sets the badge visibility. + /// + /// + /// The badge visibility. + /// + bool BadgeVisibility { get; set; } + + /// + /// Gets or sets the button accent brush. + /// + /// + /// The button accent brush. + /// + IBrush ButtonAccentBrush { get; set; } + + /// + /// Gets or sets the buttons. + /// + /// + /// The buttons. + /// + ObservableCollection Buttons { get; set; } + + /// + /// Gets or sets the header. + /// + /// + /// The header. + /// + string Header { get; set; } + + /// + /// Gets or sets the header visibility. + /// + /// + /// The header visibility. + /// + bool HeaderVisibility { get; set; } + + /// + /// Gets or sets the message. + /// + /// + /// The message. + /// + string Message { get; set; } + + /// + /// Gets or sets the message visibility. + /// + /// + /// The message visibility. + /// + bool MessageVisibility { get; set; } + + /// + /// Gets or sets the content of the overlay. + /// + /// + /// The content of the overlay. + /// + object OverlayContent { get; set; } + + /// + /// Gets or sets the content of the top additional content area. + /// + /// + /// The content of the top additional content area. + /// + object AdditionalContentTop { get; set; } + + /// + /// Gets or sets the content of the bottom additional content area. + /// + /// + /// The additional content. + /// + object AdditionalContentBottom { get; set; } + + /// + /// Gets or sets the content of the left additional content area. + /// + /// + /// The additional content. + /// + object AdditionalContentLeft { get; set; } + + /// + /// Gets or sets the content of the right additional content area. + /// + /// + /// The additional content. + /// + object AdditionalContentRight { get; set; } + + /// + /// Gets or sets the content of the center additional content area. + /// + /// + /// The additional content. + /// + object AdditionalContentMain { get; set; } + + /// + /// Gets or sets the content of the over badge additional content area. + /// + /// + /// The additional content. + /// + object AdditionalContentOverBadge { get; set; } +} diff --git a/Notification.Avalonia/INotificationMessageButton.cs b/Notification.Avalonia/INotificationMessageButton.cs index 5e34ff2..4ed3eb9 100644 --- a/Notification.Avalonia/INotificationMessageButton.cs +++ b/Notification.Avalonia/INotificationMessageButton.cs @@ -28,4 +28,4 @@ public interface INotificationMessageButton /// The callback. /// Action Callback { get; set; } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/INotificationMessageFactory.cs b/Notification.Avalonia/INotificationMessageFactory.cs index 01e5778..b91b0a4 100644 --- a/Notification.Avalonia/INotificationMessageFactory.cs +++ b/Notification.Avalonia/INotificationMessageFactory.cs @@ -16,4 +16,4 @@ public interface INotificationMessageFactory /// /// Returns new instance of notification message button. INotificationMessageButton GetButton(); -} \ No newline at end of file +} diff --git a/Notification.Avalonia/INotificationMessageManager.cs b/Notification.Avalonia/INotificationMessageManager.cs index 2fc47c1..8eab93b 100644 --- a/Notification.Avalonia/INotificationMessageManager.cs +++ b/Notification.Avalonia/INotificationMessageManager.cs @@ -34,4 +34,4 @@ public interface INotificationMessageManager /// /// The message. void Dismiss(INotificationMessage message); -} \ No newline at end of file +} diff --git a/Notification.Avalonia/Notification.Avalonia.csproj b/Notification.Avalonia/Notification.Avalonia.csproj index d00f91b..3f0763d 100644 --- a/Notification.Avalonia/Notification.Avalonia.csproj +++ b/Notification.Avalonia/Notification.Avalonia.csproj @@ -1,31 +1,36 @@ - + + + + netstandard2.0 + enable + enable + latest + true + https://github.com/AvaloniaCommunity/Avalonia.Notification + https://github.com/AvaloniaCommunity/Avalonia.Notification/blob/master/LICENSE + https://github.com/AvaloniaCommunity/Avalonia.Notification + git + Notification.Avalonia + Notification.Avalonia + Lary + Avalonia.Notification + 2.1.0 + + + + + Designer + + + + + + Designer + + + + + + - - net8.0 - enable - enable - preview - true - https://github.com/AvaloniaCommunity/Avalonia.Notification - https://github.com/AvaloniaCommunity/Avalonia.Notification/blob/master/LICENSE - https://github.com/AvaloniaCommunity/Avalonia.Notification - git - Notification.Avalonia - Notification.Avalonia - Lary - Avalonia.Notification - 2.1.0 - - - - Designer - - - - Designer - - - - - diff --git a/Notification.Avalonia/NotificationMessageBuilder.cs b/Notification.Avalonia/NotificationMessageBuilder.cs index d811941..afeea6e 100644 --- a/Notification.Avalonia/NotificationMessageBuilder.cs +++ b/Notification.Avalonia/NotificationMessageBuilder.cs @@ -247,4 +247,4 @@ public DismissNotificationMessage(NotificationMessageBuilder builder) /// public NotificationMessageBuilder Builder { get; set; } } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/NotificationMessageBuilderLinq.cs b/Notification.Avalonia/NotificationMessageBuilderLinq.cs index 3522281..84da91c 100644 --- a/Notification.Avalonia/NotificationMessageBuilderLinq.cs +++ b/Notification.Avalonia/NotificationMessageBuilderLinq.cs @@ -230,7 +230,7 @@ public static NotificationMessageBuilder WithButton( /// The builder. /// The callback. /// - /// Returns the action that will call manager dismiss for notification + /// Returns the action that will call manager dismiss for notification /// message builder when called and then call the callback action. /// private static Action DismissBefore( @@ -250,7 +250,7 @@ private static Action DismissBefore( /// The builder. /// The callback. /// - /// Returns the action that will call manager dismiss for notification + /// Returns the action that will call manager dismiss for notification /// message in builder when button is clicked and then call the callback action. /// private static Action DismissBefore( @@ -294,39 +294,39 @@ public static NotificationMessageBuilder WithAdditionalContent( switch (contentLocation) { case ContentLocation.Top: - { - builder.SetAdditionalContentTop(additionalContent); - break; - } + { + builder.SetAdditionalContentTop(additionalContent); + break; + } case ContentLocation.Bottom: - { - builder.SetAdditionalContentBottom(additionalContent); - break; - } + { + builder.SetAdditionalContentBottom(additionalContent); + break; + } case ContentLocation.Left: - { - builder.SetAdditionalContentLeft(additionalContent); - break; - } + { + builder.SetAdditionalContentLeft(additionalContent); + break; + } case ContentLocation.Right: - { - builder.SetAdditionalContentRight(additionalContent); - break; - } + { + builder.SetAdditionalContentRight(additionalContent); + break; + } case ContentLocation.Main: - { - builder.SetAdditionalContentMain(additionalContent); - break; - } + { + builder.SetAdditionalContentMain(additionalContent); + break; + } case ContentLocation.AboveBadge: - { - builder.SetAdditionalContentOverBadge(additionalContent); - break; - } + { + builder.SetAdditionalContentOverBadge(additionalContent); + break; + } default: - { - break; - } + { + break; + } } @@ -364,4 +364,4 @@ public static NotificationMessageBuilder Animates( return builder; } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/NotificationMessageFactory.cs b/Notification.Avalonia/NotificationMessageFactory.cs index 393590a..eb73934 100644 --- a/Notification.Avalonia/NotificationMessageFactory.cs +++ b/Notification.Avalonia/NotificationMessageFactory.cs @@ -29,4 +29,4 @@ public INotificationMessageButton GetButton() { return new NotificationMessageButton(); } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/NotificationMessageManager.cs b/Notification.Avalonia/NotificationMessageManager.cs index e17378e..fa5c097 100644 --- a/Notification.Avalonia/NotificationMessageManager.cs +++ b/Notification.Avalonia/NotificationMessageManager.cs @@ -1,5 +1,3 @@ -using Avalonia.Animation; - namespace Avalonia.Notification; /// @@ -8,7 +6,7 @@ namespace Avalonia.Notification; /// public class NotificationMessageManager : AvaloniaObject, INotificationMessageManager { - private readonly List queuedMessages = new List(); + private readonly List queuedMessages = []; /// @@ -97,4 +95,4 @@ private void TriggerMessageDismissed(INotificationMessage message) { this.OnMessageDismissed?.Invoke(this, new NotificationMessageManagerEventArgs(message)); } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/NotificationMessageManagerEventArgs.cs b/Notification.Avalonia/NotificationMessageManagerEventArgs.cs index aa0cba4..366892a 100644 --- a/Notification.Avalonia/NotificationMessageManagerEventArgs.cs +++ b/Notification.Avalonia/NotificationMessageManagerEventArgs.cs @@ -1,27 +1,26 @@ -namespace Avalonia.Notification +namespace Avalonia.Notification; + +/// +/// The notification message manager event arguments. +/// +/// +public class NotificationMessageManagerEventArgs : EventArgs { /// - /// The notification message manager event arguments. + /// Gets or sets the message. /// - /// - public class NotificationMessageManagerEventArgs : EventArgs - { - /// - /// Gets or sets the message. - /// - /// - /// The message. - /// - public INotificationMessage Message { get; set; } + /// + /// The message. + /// + public INotificationMessage Message { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// The message. - public NotificationMessageManagerEventArgs(INotificationMessage message) - { - this.Message = message; - } + /// + /// Initializes a new instance of the class. + /// + /// The message. + public NotificationMessageManagerEventArgs(INotificationMessage message) + { + this.Message = message; } -} \ No newline at end of file +} diff --git a/Notification.Avalonia/NotificationMessageManagerEventHandler.cs b/Notification.Avalonia/NotificationMessageManagerEventHandler.cs index fe33a52..168fbfe 100644 --- a/Notification.Avalonia/NotificationMessageManagerEventHandler.cs +++ b/Notification.Avalonia/NotificationMessageManagerEventHandler.cs @@ -7,4 +7,4 @@ /// The instance containing the event data. public delegate void NotificationMessageManagerEventHandler( object sender, - NotificationMessageManagerEventArgs args); \ No newline at end of file + NotificationMessageManagerEventArgs args); diff --git a/Notification.Avalonia/Themes/Generic.xaml b/Notification.Avalonia/Themes/Generic.xaml index 5671df3..26ecacf 100644 --- a/Notification.Avalonia/Themes/Generic.xaml +++ b/Notification.Avalonia/Themes/Generic.xaml @@ -30,8 +30,7 @@ - - \ No newline at end of file +