From 81e83e59f640ecbec910d97c2b61a1a2418c43df Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 29 Mar 2023 21:36:56 +0200 Subject: [PATCH] Fixed Artemis.UI.Shared compile errors --- src/Artemis.Core/Artemis.Core.csproj | 3 +- src/Artemis.Core/Properties/Annotations.cs | 1382 ----------------- src/Artemis.UI.Linux/Artemis.UI.Linux.csproj | 10 +- src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj | 10 +- .../Artemis.UI.Shared.csproj | 18 +- .../LostFocusNumericUpDownBindingBehavior.cs | 4 +- .../Controls/ArtemisIcon.axaml.cs | 34 +- .../DataModelPicker/DataModelPickerButton.cs | 6 +- .../Controls/DeviceVisualizer.cs | 23 +- .../Controls/DeviceVisualizerLed.cs | 9 +- .../Controls/DraggableNumberBox.axaml.cs | 30 +- .../Controls/EnumComboBox.axaml.cs | 17 +- .../Controls/GradientPicker/GradientPicker.cs | 24 +- .../GradientPicker/GradientPickerButton.cs | 15 +- .../GradientPicker/GradientPickerColorStop.cs | 32 +- .../Controls/HotkeyBox.axaml.cs | 22 +- .../ProfileConfigurationIcon.axaml.cs | 6 +- .../Controls/SelectionRectangle.cs | 27 +- .../ParentWidthPercentageConverter.cs | 4 +- .../DefaultDataModelDisplayView.axaml.cs | 2 +- .../SKColorDataModelDisplayView.axaml.cs | 2 +- .../Extensions/VisualExtensions.cs | 14 +- ...tiveCoreWindow.cs => ReactiveAppWindow.cs} | 10 +- .../Services/Builders/NotificationBuilder.cs | 4 +- .../Window/ExceptionDialogView.axaml.cs | 2 +- .../Styles/ColorPickerButton.axaml | 18 +- src/Artemis.UI.Shared/Styles/Condensed.axaml | 2 +- .../Controls/DataModelPickerButton.axaml | 20 +- .../Styles/Controls/GradientPicker.axaml | 16 +- .../Controls/GradientPickerButton.axaml | 20 +- src/Artemis.UI.Shared/Styles/TreeView.axaml | 93 +- .../Artemis.UI.Windows.csproj | 14 +- src/Artemis.UI/Artemis.UI.csproj | 26 +- .../Behaviors/SimpleContextDragBehavior.cs | 2 +- .../Behaviors/TreeItemDragBehavior.cs | 69 +- src/Artemis.UI/Controls/TimelineHeader.cs | 39 +- .../BoolPropertyInputView.axaml.cs | 2 +- .../BrushPropertyInputView.axaml.cs | 2 +- .../BrushPropertyInputViewModel.cs | 2 +- .../ColorGradientPropertyInputView.axaml.cs | 2 +- .../EnumPropertyInputView.axaml.cs | 2 +- .../FloatPropertyInputView.axaml.cs | 2 +- .../FloatRangePropertyInputView.axaml.cs | 2 +- .../IntPropertyInputView.axaml.cs | 2 +- .../IntRangePropertyInputView.axaml.cs | 2 +- .../SKColorPropertyInputView.axaml.cs | 2 +- .../SKPointPropertyInputView.axaml.cs | 2 +- .../SKSizePropertyInputView.axaml.cs | 2 +- .../StringPropertyInputView.axaml.cs | 2 +- src/Artemis.UI/MainWindow.axaml.cs | 2 +- .../Screens/Debugger/DebugView.axaml.cs | 2 +- .../Device/DevicePropertiesView.axaml.cs | 2 +- .../Plugins/PluginSettingsWindowView.axaml.cs | 2 +- .../Dialogs/LayerHintsDialogView.axaml.cs | 2 +- .../BrushConfigurationWindowView.axaml.cs | 2 +- .../EffectConfigurationWindowView.axaml.cs | 2 +- .../Scripting/ScriptsDialogView.axaml.cs | 2 +- .../ProfileConfigurationEditView.axaml.cs | 2 +- .../StartupWizard/StartupWizardView.axaml.cs | 2 +- .../NodeScriptWindowView.axaml.cs | 2 +- .../Artemis.VisualScripting.csproj | 12 +- 61 files changed, 343 insertions(+), 1746 deletions(-) delete mode 100644 src/Artemis.Core/Properties/Annotations.cs rename src/Artemis.UI.Shared/{ReactiveCoreWindow.cs => ReactiveAppWindow.cs} (90%) diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index 67138efdd..db11e2724 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -39,6 +39,7 @@ + @@ -49,7 +50,7 @@ - + diff --git a/src/Artemis.Core/Properties/Annotations.cs b/src/Artemis.Core/Properties/Annotations.cs deleted file mode 100644 index c7e8987a1..000000000 --- a/src/Artemis.Core/Properties/Annotations.cs +++ /dev/null @@ -1,1382 +0,0 @@ -/* MIT License - -Copyright (c) 2016 JetBrains http://www.jetbrains.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. */ - -using System; - -#pragma warning disable 1591 -#pragma warning disable 8618 - -// ReSharper disable InheritdocConsiderUsage -// ReSharper disable UnusedMember.Global -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -// ReSharper disable IntroduceOptionalParameters.Global -// ReSharper disable MemberCanBeProtected.Global -// ReSharper disable InconsistentNaming - -namespace Artemis.Core.Properties; - -/// -/// Indicates that the value of the marked element could be null sometimes, -/// so checking for null is required before its usage. -/// -/// -/// -/// [CanBeNull] object Test() => null; -/// -/// void UseTest() { -/// var p = Test(); -/// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' -/// } -/// -/// -[AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] -public sealed class CanBeNullAttribute : Attribute -{ -} - -/// -/// Indicates that the value of the marked element can never be null. -/// -/// -/// -/// [NotNull] object Foo() { -/// return null; // Warning: Possible 'null' assignment -/// } -/// -/// -[AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] -public sealed class NotNullAttribute : Attribute -{ -} - -/// -/// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task -/// and Lazy classes to indicate that the value of a collection item, of the Task.Result property -/// or of the Lazy.Value property can never be null. -/// -/// -/// -/// public void Foo([ItemNotNull]List<string> books) -/// { -/// foreach (var book in books) { -/// if (book != null) // Warning: Expression is always true -/// Console.WriteLine(book.ToUpper()); -/// } -/// } -/// -/// -[AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] -public sealed class ItemNotNullAttribute : Attribute -{ -} - -/// -/// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task -/// and Lazy classes to indicate that the value of a collection item, of the Task.Result property -/// or of the Lazy.Value property can be null. -/// -/// -/// -/// public void Foo([ItemCanBeNull]List<string> books) -/// { -/// foreach (var book in books) -/// { -/// // Warning: Possible 'System.NullReferenceException' -/// Console.WriteLine(book.ToUpper()); -/// } -/// } -/// -/// -[AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] -public sealed class ItemCanBeNullAttribute : Attribute -{ -} - -/// -/// Indicates that the marked method builds string by the format pattern and (optional) arguments. -/// The parameter, which contains the format string, should be given in constructor. The format string -/// should be in -like form. -/// -/// -/// -/// [StringFormatMethod("message")] -/// void ShowError(string message, params object[] args) { /* do something */ } -/// -/// void Foo() { -/// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string -/// } -/// -/// -[AttributeUsage( - AttributeTargets.Constructor | AttributeTargets.Method | - AttributeTargets.Property | AttributeTargets.Delegate)] -public sealed class StringFormatMethodAttribute : Attribute -{ - /// - /// Specifies which parameter of an annotated method should be treated as the format string - /// - public StringFormatMethodAttribute([NotNull] string formatParameterName) - { - FormatParameterName = formatParameterName; - } - - [NotNull] - public string FormatParameterName { get; } -} - -/// -/// Use this annotation to specify a type that contains static or const fields -/// with values for the annotated property/field/parameter. -/// The specified type will be used to improve completion suggestions. -/// -/// -/// -/// namespace TestNamespace -/// { -/// public class Constants -/// { -/// public static int INT_CONST = 1; -/// public const string STRING_CONST = "1"; -/// } -/// -/// public class Class1 -/// { -/// [ValueProvider("TestNamespace.Constants")] public int myField; -/// public void Foo([ValueProvider("TestNamespace.Constants")] string str) { } -/// -/// public void Test() -/// { -/// Foo(/*try completion here*/);// -/// myField = /*try completion here*/ -/// } -/// } -/// } -/// -/// -[AttributeUsage( - AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, - AllowMultiple = true)] -public sealed class ValueProviderAttribute : Attribute -{ - public ValueProviderAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] - public string Name { get; } -} - -/// -/// Indicates that the function argument should be a string literal and match one -/// of the parameters of the caller function. For example, ReSharper annotates -/// the parameter of . -/// -/// -/// -/// void Foo(string param) { -/// if (param == null) -/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol -/// } -/// -/// -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class InvokerParameterNameAttribute : Attribute -{ -} - -/// -/// Indicates that the method is contained in a type that implements -/// System.ComponentModel.INotifyPropertyChanged interface and this method -/// is used to notify that some property value changed. -/// -/// -/// The method should be non-static and conform to one of the supported signatures: -/// -/// -/// NotifyChanged(string) -/// -/// -/// NotifyChanged(params string[]) -/// -/// -/// NotifyChanged{T}(Expression{Func{T}}) -/// -/// -/// NotifyChanged{T,U}(Expression{Func{T,U}}) -/// -/// -/// SetProperty{T}(ref T, T, string) -/// -/// -/// -/// -/// -/// public class Foo : INotifyPropertyChanged { -/// public event PropertyChangedEventHandler PropertyChanged; -/// -/// [NotifyPropertyChangedInvocator] -/// protected virtual void NotifyChanged(string propertyName) { ... } -/// -/// string _name; -/// -/// public string Name { -/// get { return _name; } -/// set { _name = value; NotifyChanged("LastName"); /* Warning */ } -/// } -/// } -/// -/// Examples of generated notifications: -/// -/// -/// NotifyChanged("Property") -/// -/// -/// NotifyChanged(() => Property) -/// -/// -/// NotifyChanged((VM x) => x.Property) -/// -/// -/// SetProperty(ref myField, value, "Property") -/// -/// -/// -[AttributeUsage(AttributeTargets.Method)] -public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute -{ - public NotifyPropertyChangedInvocatorAttribute() - { - } - - public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) - { - ParameterName = parameterName; - } - - [CanBeNull] - public string ParameterName { get; } -} - -/// -/// Describes dependency between method input and output. -/// -/// -///

Function Definition Table syntax:

-/// -/// FDT ::= FDTRow [;FDTRow]* -/// FDTRow ::= Input => Output | Output <= Input -/// Input ::= ParameterName: Value [, Input]* -/// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} -/// Value ::= true | false | null | notnull | canbenull -/// -/// If the method has a single input parameter, its name could be omitted.
-/// Using halt (or void/nothing, which is the same) for the method output -/// means that the method doesn't return normally (throws or terminates the process).
-/// Value canbenull is only applicable for output parameters.
-/// You can use multiple [ContractAnnotation] for each FDT row, or use single attribute -/// with rows separated by semicolon. There is no notion of order rows, all rows are checked -/// for applicability and applied per each program state tracked by the analysis engine.
-///
-/// -/// -/// -/// -/// [ContractAnnotation("=> halt")] -/// public void TerminationMethod() -/// -/// -/// -/// -/// [ContractAnnotation("null <= param:null")] // reverse condition syntax -/// public string GetName(string surname) -/// -/// -/// -/// -/// [ContractAnnotation("s:null => true")] -/// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() -/// -/// -/// -/// -/// // A method that returns null if the parameter is null, -/// // and not null if the parameter is not null -/// [ContractAnnotation("null => null; notnull => notnull")] -/// public object Transform(object data) -/// -/// -/// -/// -/// [ContractAnnotation("=> true, result: notnull; => false, result: null")] -/// public bool TryParse(string s, out Person result) -/// -/// -/// -/// -[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] -public sealed class ContractAnnotationAttribute : Attribute -{ - public ContractAnnotationAttribute([NotNull] string contract) - : this(contract, false) - { - } - - public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) - { - Contract = contract; - ForceFullStates = forceFullStates; - } - - [NotNull] - public string Contract { get; } - - public bool ForceFullStates { get; } -} - -/// -/// Indicates whether the marked element should be localized. -/// -/// -/// -/// [LocalizationRequiredAttribute(true)] -/// class Foo { -/// string str = "my string"; // Warning: Localizable string -/// } -/// -/// -[AttributeUsage(AttributeTargets.All)] -public sealed class LocalizationRequiredAttribute : Attribute -{ - public LocalizationRequiredAttribute() : this(true) - { - } - - public LocalizationRequiredAttribute(bool required) - { - Required = required; - } - - public bool Required { get; } -} - -/// -/// Indicates that the value of the marked type (or its derivatives) -/// cannot be compared using '==' or '!=' operators and Equals() -/// should be used instead. However, using '==' or '!=' for comparison -/// with null is always permitted. -/// -/// -/// -/// [CannotApplyEqualityOperator] -/// class NoEquality { } -/// -/// class UsesNoEquality { -/// void Test() { -/// var ca1 = new NoEquality(); -/// var ca2 = new NoEquality(); -/// if (ca1 != null) { // OK -/// bool condition = ca1 == ca2; // Warning -/// } -/// } -/// } -/// -/// -[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] -public sealed class CannotApplyEqualityOperatorAttribute : Attribute -{ -} - -/// -/// When applied to a target attribute, specifies a requirement for any type marked -/// with the target attribute to implement or inherit specific type or types. -/// -/// -/// -/// [BaseTypeRequired(typeof(IComponent)] // Specify requirement -/// class ComponentAttribute : Attribute { } -/// -/// [Component] // ComponentAttribute requires implementing IComponent interface -/// class MyComponent : IComponent { } -/// -/// -[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] -[BaseTypeRequired(typeof(Attribute))] -public sealed class BaseTypeRequiredAttribute : Attribute -{ - public BaseTypeRequiredAttribute([NotNull] Type baseType) - { - BaseType = baseType; - } - - [NotNull] - public Type BaseType { get; } -} - -/// -/// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), -/// so this symbol will not be reported as unused (as well as by other usage inspections). -/// -[AttributeUsage(AttributeTargets.All, Inherited = false)] -public sealed class UsedImplicitlyAttribute : Attribute -{ - public UsedImplicitlyAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) - { - } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) - { - } - - public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) - { - } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - public ImplicitUseKindFlags UseKindFlags { get; } - - public ImplicitUseTargetFlags TargetFlags { get; } -} - -/// -/// Can be applied to attributes, type parameters, and parameters of a type assignable from -/// . -/// When applied to an attribute, the decorated attribute behaves the same as . -/// When applied to a type parameter or to a parameter of type , indicates that the -/// corresponding type -/// is used implicitly. -/// -[AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter | AttributeTargets.Parameter)] -public sealed class MeansImplicitUseAttribute : Attribute -{ - public MeansImplicitUseAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) - { - } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) - { - } - - public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) - { - } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - [UsedImplicitly] - public ImplicitUseKindFlags UseKindFlags { get; } - - [UsedImplicitly] - public ImplicitUseTargetFlags TargetFlags { get; } -} - -/// -/// Specify the details of implicitly used symbol when it is marked -/// with or . -/// -[Flags] -public enum ImplicitUseKindFlags -{ - Default = Access | Assign | InstantiatedWithFixedConstructorSignature, - - /// Only entity marked with attribute considered used. - Access = 1, - - /// Indicates implicit assignment to a member. - Assign = 2, - - /// - /// Indicates implicit instantiation of a type with fixed constructor signature. - /// That means any unused constructor parameters won't be reported as such. - /// - InstantiatedWithFixedConstructorSignature = 4, - - /// Indicates implicit instantiation of a type. - InstantiatedNoFixedConstructorSignature = 8 -} - -/// -/// Specify what is considered to be used implicitly when marked -/// with or . -/// -[Flags] -public enum ImplicitUseTargetFlags -{ - Default = Itself, - Itself = 1, - - /// Members of entity marked with attribute are considered used. - Members = 2, - - /// Entity marked with attribute and all its members considered used. - WithMembers = Itself | Members -} - -/// -/// This attribute is intended to mark publicly available API -/// which should not be removed and so is treated as used. -/// -[MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] -[AttributeUsage(AttributeTargets.All, Inherited = false)] -public sealed class PublicAPIAttribute : Attribute -{ - public PublicAPIAttribute() - { - } - - public PublicAPIAttribute([NotNull] string comment) - { - Comment = comment; - } - - [CanBeNull] - public string Comment { get; } -} - -/// -/// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. -/// If the parameter is a delegate, indicates that delegate is executed while the method is executed. -/// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. -/// -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class InstantHandleAttribute : Attribute -{ -} - -/// -/// Indicates that a method does not make any observable state changes. -/// The same as System.Diagnostics.Contracts.PureAttribute. -/// -/// -/// -/// [Pure] int Multiply(int x, int y) => x * y; -/// -/// void M() { -/// Multiply(123, 42); // Waring: Return value of pure method is not used -/// } -/// -/// -[AttributeUsage(AttributeTargets.Method)] -public sealed class PureAttribute : Attribute -{ -} - -/// -/// Indicates that the return value of the method invocation must be used. -/// -/// -/// Methods decorated with this attribute (in contrast to pure methods) might change state, -/// but make no sense without using their return value.
-/// Similarly to , this attribute -/// will help detecting usages of the method when the return value in not used. -/// Additionally, you can optionally specify a custom message, which will be used when showing warnings, e.g. -/// [MustUseReturnValue("Use the return value to...")]. -///
-[AttributeUsage(AttributeTargets.Method)] -public sealed class MustUseReturnValueAttribute : Attribute -{ - public MustUseReturnValueAttribute() - { - } - - public MustUseReturnValueAttribute([NotNull] string justification) - { - Justification = justification; - } - - [CanBeNull] - public string Justification { get; } -} - -/// -/// Indicates the type member or parameter of some type, that should be used instead of all other ways -/// to get the value of that type. This annotation is useful when you have some "context" value evaluated -/// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. -/// -/// -/// -/// class Foo { -/// [ProvidesContext] IBarService _barService = ...; -/// -/// void ProcessNode(INode node) { -/// DoSomething(node, node.GetGlobalServices().Bar); -/// // ^ Warning: use value of '_barService' field -/// } -/// } -/// -/// -[AttributeUsage( - AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)] -public sealed class ProvidesContextAttribute : Attribute -{ -} - -/// -/// Indicates that a parameter is a path to a file or a folder within a web project. -/// Path can be relative or absolute, starting from web root (~). -/// -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class PathReferenceAttribute : Attribute -{ - public PathReferenceAttribute() - { - } - - public PathReferenceAttribute([NotNull] [PathReference] string basePath) - { - BasePath = basePath; - } - - [CanBeNull] - public string BasePath { get; } -} - -/// -/// An extension method marked with this attribute is processed by code completion -/// as a 'Source Template'. When the extension method is completed over some expression, its source code -/// is automatically expanded like a template at call site. -/// -/// -/// Template method body can contain valid source code and/or special comments starting with '$'. -/// Text inside these comments is added as source code when the template is applied. Template parameters -/// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. -/// Use the attribute to specify macros for parameters. -/// -/// -/// In this example, the 'forEach' method is a source template available over all values -/// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: -/// -/// [SourceTemplate] -/// public static void forEach<T>(this IEnumerable<T> xs) { -/// foreach (var x in xs) { -/// //$ $END$ -/// } -/// } -/// -/// -[AttributeUsage(AttributeTargets.Method)] -public sealed class SourceTemplateAttribute : Attribute -{ -} - -/// -/// Allows specifying a macro for a parameter of a source template. -/// -/// -/// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression -/// is defined in the property. When applied on a method, the target -/// template parameter is defined in the property. To apply the macro silently -/// for the parameter, set the property value = -1. -/// -/// -/// Applying the attribute on a source template method: -/// -/// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] -/// public static void forEach<T>(this IEnumerable<T> collection) { -/// foreach (var item in collection) { -/// //$ $END$ -/// } -/// } -/// -/// Applying the attribute on a template method parameter: -/// -/// [SourceTemplate] -/// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { -/// /*$ var $x$Id = "$newguid$" + x.ToString(); -/// x.DoSomething($x$Id); */ -/// } -/// -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] -public sealed class MacroAttribute : Attribute -{ - /// - /// Allows specifying a macro that will be executed for a source template - /// parameter when the template is expanded. - /// - [CanBeNull] - public string Expression { get; set; } - - /// - /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. - /// - /// - /// If the target parameter is used several times in the template, only one occurrence becomes editable; - /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - /// - public int Editable { get; set; } - - /// - /// Identifies the target parameter of a source template if the - /// is applied on a template method. - /// - [CanBeNull] - public string Target { get; set; } -} - -[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] -public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute -{ - public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] - public string Format { get; } -} - -[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] -public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute -{ - public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] - public string Format { get; } -} - -[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] -public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute -{ - public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] - public string Format { get; } -} - -[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] -public sealed class AspMvcMasterLocationFormatAttribute : Attribute -{ - public AspMvcMasterLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] - public string Format { get; } -} - -[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] -public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute -{ - public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] - public string Format { get; } -} - -[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] -public sealed class AspMvcViewLocationFormatAttribute : Attribute -{ - public AspMvcViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] - public string Format { get; } -} - -/// -/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter -/// is an MVC action. If applied to a method, the MVC action name is calculated -/// implicitly from the context. Use this attribute for custom wrappers similar to -/// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcActionAttribute : Attribute -{ - public AspMvcActionAttribute() - { - } - - public AspMvcActionAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] - public string AnonymousProperty { get; } -} - -/// -/// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area. -/// Use this attribute for custom wrappers similar to -/// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcAreaAttribute : Attribute -{ - public AspMvcAreaAttribute() - { - } - - public AspMvcAreaAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] - public string AnonymousProperty { get; } -} - -/// -/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is -/// an MVC controller. If applied to a method, the MVC controller name is calculated -/// implicitly from the context. Use this attribute for custom wrappers similar to -/// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcControllerAttribute : Attribute -{ - public AspMvcControllerAttribute() - { - } - - public AspMvcControllerAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] - public string AnonymousProperty { get; } -} - -/// -/// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute -/// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcMasterAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute -/// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). -/// -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class AspMvcModelTypeAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC -/// partial view. If applied to a method, the MVC partial view name is calculated implicitly -/// from the context. Use this attribute for custom wrappers similar to -/// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcPartialViewAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. -/// -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] -public sealed class AspMvcSuppressViewErrorAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. -/// Use this attribute for custom wrappers similar to -/// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcDisplayTemplateAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template. -/// Use this attribute for custom wrappers similar to -/// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcEditorTemplateAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template. -/// Use this attribute for custom wrappers similar to -/// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcTemplateAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter -/// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly -/// from the context. Use this attribute for custom wrappers similar to -/// System.Web.Mvc.Controller.View(Object). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcViewAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter -/// is an MVC view component name. -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcViewComponentAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter -/// is an MVC view component view. If applied to a method, the MVC view component view name is default. -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class AspMvcViewComponentViewAttribute : Attribute -{ -} - -/// -/// ASP.NET MVC attribute. When applied to a parameter of an attribute, -/// indicates that this parameter is an MVC action name. -/// -/// -/// -/// [ActionName("Foo")] -/// public ActionResult Login(string returnUrl) { -/// ViewBag.ReturnUrl = Url.Action("Foo"); // OK -/// return RedirectToAction("Bar"); // Error: Cannot resolve action -/// } -/// -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] -public sealed class AspMvcActionSelectorAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] -public sealed class HtmlElementAttributesAttribute : Attribute -{ - public HtmlElementAttributesAttribute() - { - } - - public HtmlElementAttributesAttribute([NotNull] string name) - { - Name = name; - } - - [CanBeNull] - public string Name { get; } -} - -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] -public sealed class HtmlAttributeValueAttribute : Attribute -{ - public HtmlAttributeValueAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] - public string Name { get; } -} - -/// -/// Razor attribute. Indicates that the marked parameter or method is a Razor section. -/// Use this attribute for custom wrappers similar to -/// System.Web.WebPages.WebPageBase.RenderSection(String). -/// -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] -public sealed class RazorSectionAttribute : Attribute -{ -} - -/// -/// Indicates how method, constructor invocation, or property access -/// over collection type affects the contents of the collection. -/// Use to specify the access type. -/// -/// -/// Using this attribute only makes sense if all collection methods are marked with this attribute. -/// -/// -/// -/// public class MyStringCollection : List<string> -/// { -/// [CollectionAccess(CollectionAccessType.Read)] -/// public string GetFirstString() -/// { -/// return this.ElementAt(0); -/// } -/// } -/// class Test -/// { -/// public void Foo() -/// { -/// // Warning: Contents of the collection is never updated -/// var col = new MyStringCollection(); -/// string x = col.GetFirstString(); -/// } -/// } -/// -/// -[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] -public sealed class CollectionAccessAttribute : Attribute -{ - public CollectionAccessAttribute(CollectionAccessType collectionAccessType) - { - CollectionAccessType = collectionAccessType; - } - - public CollectionAccessType CollectionAccessType { get; } -} - -/// -/// Provides a value for the to define -/// how the collection method invocation affects the contents of the collection. -/// -[Flags] -public enum CollectionAccessType -{ - /// Method does not use or modify content of the collection. - None = 0, - - /// Method only reads content of the collection but does not modify it. - Read = 1, - - /// Method can change content of the collection but does not add new elements. - ModifyExistingContent = 2, - - /// Method can add new elements to the collection. - UpdatedContent = ModifyExistingContent | 4 -} - -/// -/// Indicates that the marked method is assertion method, i.e. it halts the control flow if -/// one of the conditions is satisfied. To set the condition, mark one of the parameters with -/// attribute. -/// -[AttributeUsage(AttributeTargets.Method)] -public sealed class AssertionMethodAttribute : Attribute -{ -} - -/// -/// Indicates the condition parameter of the assertion method. The method itself should be -/// marked by attribute. The mandatory argument of -/// the attribute is the assertion type. -/// -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class AssertionConditionAttribute : Attribute -{ - public AssertionConditionAttribute(AssertionConditionType conditionType) - { - ConditionType = conditionType; - } - - public AssertionConditionType ConditionType { get; } -} - -/// -/// Specifies assertion type. If the assertion method argument satisfies the condition, -/// then the execution continues. Otherwise, execution is assumed to be halted. -/// -public enum AssertionConditionType -{ - /// Marked parameter should be evaluated to true. - IS_TRUE = 0, - - /// Marked parameter should be evaluated to false. - IS_FALSE = 1, - - /// Marked parameter should be evaluated to null value. - IS_NULL = 2, - - /// Marked parameter should be evaluated to not null value. - IS_NOT_NULL = 3 -} - -/// -/// Indicates that the marked method unconditionally terminates control flow execution. -/// For example, it could unconditionally throw exception. -/// -[Obsolete("Use [ContractAnnotation('=> halt')] instead")] -[AttributeUsage(AttributeTargets.Method)] -public sealed class TerminatesProgramAttribute : Attribute -{ -} - -/// -/// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, -/// .Where). This annotation allows inference of [InstantHandle] annotation for parameters -/// of delegate type by analyzing LINQ method chains. -/// -[AttributeUsage(AttributeTargets.Method)] -public sealed class LinqTunnelAttribute : Attribute -{ -} - -/// -/// Indicates that IEnumerable passed as a parameter is not enumerated. -/// Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection. -/// -/// -/// -/// static void ThrowIfNull<T>([NoEnumeration] T v, string n) where T : class -/// { -/// // custom check for null but no enumeration -/// } -/// -/// void Foo(IEnumerable<string> values) -/// { -/// ThrowIfNull(values, nameof(values)); -/// var x = values.ToList(); // No warnings about multiple enumeration -/// } -/// -/// -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class NoEnumerationAttribute : Attribute -{ -} - -/// -/// Indicates that the marked parameter is a regular expression pattern. -/// -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class RegexPatternAttribute : Attribute -{ -} - -/// -/// Prevents the Member Reordering feature from tossing members of the marked class. -/// -/// -/// The attribute must be mentioned in your member reordering patterns. -/// -[AttributeUsage( - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)] -public sealed class NoReorderAttribute : Attribute -{ -} - -/// -/// XAML attribute. Indicates the type that has ItemsSource property and should be treated -/// as ItemsControl-derived type, to enable inner items DataContext type resolve. -/// -[AttributeUsage(AttributeTargets.Class)] -public sealed class XamlItemsControlAttribute : Attribute -{ -} - -/// -/// XAML attribute. Indicates the property of some BindingBase-derived type, that -/// is used to bind some item of ItemsControl-derived type. This annotation will -/// enable the DataContext type resolve for XAML bindings for such properties. -/// -/// -/// Property should have the tree ancestor of the ItemsControl type or -/// marked with the attribute. -/// -[AttributeUsage(AttributeTargets.Property)] -public sealed class XamlItemBindingOfItemsControlAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] -public sealed class AspChildControlTypeAttribute : Attribute -{ - public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType) - { - TagName = tagName; - ControlType = controlType; - } - - [NotNull] - public string TagName { get; } - - [NotNull] - public Type ControlType { get; } -} - -[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] -public sealed class AspDataFieldAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] -public sealed class AspDataFieldsAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Property)] -public sealed class AspMethodPropertyAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] -public sealed class AspRequiredAttributeAttribute : Attribute -{ - public AspRequiredAttributeAttribute([NotNull] string attribute) - { - Attribute = attribute; - } - - [NotNull] - public string Attribute { get; } -} - -[AttributeUsage(AttributeTargets.Property)] -public sealed class AspTypePropertyAttribute : Attribute -{ - public AspTypePropertyAttribute(bool createConstructorReferences) - { - CreateConstructorReferences = createConstructorReferences; - } - - public bool CreateConstructorReferences { get; } -} - -[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] -public sealed class RazorImportNamespaceAttribute : Attribute -{ - public RazorImportNamespaceAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] - public string Name { get; } -} - -[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] -public sealed class RazorInjectionAttribute : Attribute -{ - public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName) - { - Type = type; - FieldName = fieldName; - } - - [NotNull] - public string Type { get; } - - [NotNull] - public string FieldName { get; } -} - -[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] -public sealed class RazorDirectiveAttribute : Attribute -{ - public RazorDirectiveAttribute([NotNull] string directive) - { - Directive = directive; - } - - [NotNull] - public string Directive { get; } -} - -[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] -public sealed class RazorPageBaseTypeAttribute : Attribute -{ - public RazorPageBaseTypeAttribute([NotNull] string baseType) - { - BaseType = baseType; - } - - public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName) - { - BaseType = baseType; - PageName = pageName; - } - - [NotNull] - public string BaseType { get; } - - [CanBeNull] - public string PageName { get; } -} - -[AttributeUsage(AttributeTargets.Method)] -public sealed class RazorHelperCommonAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Property)] -public sealed class RazorLayoutAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Method)] -public sealed class RazorWriteLiteralMethodAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Method)] -public sealed class RazorWriteMethodAttribute : Attribute -{ -} - -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class RazorWriteMethodParameterAttribute : Attribute -{ -} \ No newline at end of file diff --git a/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj b/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj index 7d19d5e97..86ccbb134 100644 --- a/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj +++ b/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj @@ -16,12 +16,12 @@ - - + + - - - + + + diff --git a/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj b/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj index 65ef347d2..f5f4606ce 100644 --- a/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj +++ b/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj @@ -15,12 +15,12 @@ - - + + - - - + + + diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj index 047d9906f..af6424e4c 100644 --- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -10,18 +10,18 @@ - + - - - - - + + + + + - - + + - + diff --git a/src/Artemis.UI.Shared/Behaviors/LostFocusNumericUpDownBindingBehavior.cs b/src/Artemis.UI.Shared/Behaviors/LostFocusNumericUpDownBindingBehavior.cs index 23e2bdbdb..1b6da7178 100644 --- a/src/Artemis.UI.Shared/Behaviors/LostFocusNumericUpDownBindingBehavior.cs +++ b/src/Artemis.UI.Shared/Behaviors/LostFocusNumericUpDownBindingBehavior.cs @@ -15,7 +15,7 @@ public class LostFocusNumericUpDownBindingBehavior : Behavior /// /// Gets or sets the value of the binding. /// - public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register( + public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register( nameof(Value), defaultBindingMode: BindingMode.TwoWay); static LostFocusNumericUpDownBindingBehavior() @@ -26,7 +26,7 @@ public class LostFocusNumericUpDownBindingBehavior : Behavior /// /// Gets or sets the value of the binding. /// - public double Value + public decimal? Value { get => GetValue(ValueProperty); set => SetValue(ValueProperty, value); diff --git a/src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs b/src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs index 1e3e47a1d..04aa74a0d 100644 --- a/src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs @@ -2,12 +2,12 @@ using System; using System.Text.RegularExpressions; using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Documents; using Avalonia.Layout; using Avalonia.LogicalTree; using Avalonia.Markup.Xaml; using Avalonia.Media; using Avalonia.Media.Imaging; -using Avalonia.Visuals.Media.Imaging; using Material.Icons; using Material.Icons.Avalonia; @@ -16,9 +16,9 @@ namespace Artemis.UI.Shared; /// /// Represents a control that can display an arbitrary kind of icon. /// -public class ArtemisIcon : UserControl +public partial class ArtemisIcon : UserControl { - private static readonly Regex _imageRegex = new(@"[\/.](gif|jpg|jpeg|tiff|png)$", RegexOptions.Compiled); + private static readonly Regex ImageRegex = new(@"[\/.](gif|jpg|jpeg|tiff|png)$", RegexOptions.Compiled); /// /// Creates a new instance of the class. @@ -30,12 +30,6 @@ public class ArtemisIcon : UserControl LayoutUpdated += OnLayoutUpdated; } - private static void IconChanging(IAvaloniaObject sender, bool before) - { - if (before) - ((ArtemisIcon) sender).Update(); - } - private void Update() { try @@ -54,7 +48,7 @@ public class ArtemisIcon : UserControl Content = new MaterialIcon {Kind = parsedIcon, Width = Bounds.Width, Height = Bounds.Height}; } // An URI pointing to an image - else if (_imageRegex.IsMatch(iconString)) + else if (ImageRegex.IsMatch(iconString)) { if (!Fill) Content = new Image @@ -66,7 +60,7 @@ public class ArtemisIcon : UserControl else Content = new Border { - Background = TextBlock.GetForeground(this), + Background = TextElement.GetForeground(this), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, OpacityMask = new ImageBrush(new Bitmap(iconString)) {BitmapInterpolationMode = BitmapInterpolationMode.MediumQuality} @@ -110,8 +104,7 @@ public class ArtemisIcon : UserControl /// Gets or sets the currently displayed icon as either a or an /// pointing to an SVG /// - public static readonly StyledProperty IconProperty = - AvaloniaProperty.Register(nameof(Icon), notifying: IconChanging); + public static readonly StyledProperty IconProperty = AvaloniaProperty.Register(nameof(Icon)); /// @@ -121,15 +114,18 @@ public class ArtemisIcon : UserControl public object? Icon { get => GetValue(IconProperty); - set => SetValue(IconProperty, value); + set + { + SetValue(IconProperty, value); + Update(); + } } /// /// Gets or sets a boolean indicating whether or not the icon should be filled in with the primary text color of the /// theme /// - public static readonly StyledProperty FillProperty = - AvaloniaProperty.Register(nameof(Icon), false, notifying: IconChanging); + public static readonly StyledProperty FillProperty = AvaloniaProperty.Register(nameof(Icon)); /// /// Gets or sets a boolean indicating whether or not the icon should be filled in with the primary text color of the @@ -138,7 +134,11 @@ public class ArtemisIcon : UserControl public bool Fill { get => GetValue(FillProperty); - set => SetValue(FillProperty, value); + set + { + SetValue(FillProperty, value); + Update(); + } } #endregion diff --git a/src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPickerButton.cs b/src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPickerButton.cs index 1535569cc..eb8ab30a4 100644 --- a/src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPickerButton.cs +++ b/src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPickerButton.cs @@ -46,8 +46,8 @@ public class DataModelPickerButton : TemplatedControl /// /// Gets or sets the desired flyout placement. /// - public static readonly StyledProperty PlacementProperty = - AvaloniaProperty.Register(nameof(Placement)); + public static readonly StyledProperty PlacementProperty = + AvaloniaProperty.Register(nameof(Placement)); /// /// Gets or sets data model path. @@ -133,7 +133,7 @@ public class DataModelPickerButton : TemplatedControl /// /// Gets or sets the desired flyout placement. /// - public FlyoutPlacementMode Placement + public PlacementMode Placement { get => GetValue(PlacementProperty); set => SetValue(PlacementProperty, value); diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index 1632f25a7..72189df57 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -15,7 +15,6 @@ using Avalonia.Media.Imaging; using Avalonia.Platform; using Avalonia.Rendering; using Avalonia.Threading; -using Avalonia.Visuals.Media.Imaging; namespace Artemis.UI.Shared; @@ -123,7 +122,7 @@ public class DeviceVisualizer : Control private Rect MeasureDevice() { if (Device == null) - return Rect.Empty; + return new Rect(0, 0, 0, 0); Rect deviceRect = new(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height); Geometry geometry = new RectangleGeometry(deviceRect); @@ -171,21 +170,19 @@ public class DeviceVisualizer : Control /// Gets or sets the to display /// public static readonly StyledProperty DeviceProperty = - AvaloniaProperty.Register(nameof(Device), notifying: DeviceUpdated); - - private static void DeviceUpdated(IAvaloniaObject sender, bool before) - { - if (!before) - ((DeviceVisualizer) sender).SetupForDevice(); - } - + AvaloniaProperty.Register(nameof(Device)); + /// /// Gets or sets the to display /// public ArtemisDevice? Device { get => GetValue(DeviceProperty); - set => SetValue(DeviceProperty, value); + set + { + SetValue(DeviceProperty, value); + SetupForDevice(); + } } /// @@ -302,9 +299,9 @@ public class DeviceVisualizer : Control // Render 4 times the actual size of the device to make sure things look sharp when zoomed in RenderTargetBitmap renderTargetBitmap = new(new PixelSize((int) device.RgbDevice.ActualSize.Width * 2, (int) device.RgbDevice.ActualSize.Height * 2)); - using IDrawingContextImpl context = renderTargetBitmap.CreateDrawingContext(new ImmediateRenderer(this)); + using DrawingContext context = renderTargetBitmap.CreateDrawingContext(); using Bitmap bitmap = new(device.Layout.Image.LocalPath); - context.DrawBitmap(bitmap.PlatformImpl, 1, new Rect(bitmap.Size), new Rect(renderTargetBitmap.Size), BitmapInterpolationMode.HighQuality); + context.DrawImage(bitmap, new Rect(bitmap.Size), new Rect(renderTargetBitmap.Size), BitmapInterpolationMode.HighQuality); lock (_deviceVisualizerLeds) { diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs index f1d762431..30bb72b76 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs @@ -4,8 +4,6 @@ using Artemis.Core; using Avalonia; using Avalonia.Media; using Avalonia.Media.Imaging; -using Avalonia.Platform; -using Avalonia.Visuals.Media.Imaging; using RGB.NET.Core; using Color = Avalonia.Media.Color; using Point = Avalonia.Point; @@ -40,7 +38,7 @@ internal class DeviceVisualizerLed public Rect LedRect { get; set; } public Geometry? DisplayGeometry { get; private set; } - public void DrawBitmap(IDrawingContextImpl drawingContext, double scale) + public void DrawBitmap(DrawingContext drawingContext, double scale) { if (Led.Layout?.Image == null || !File.Exists(Led.Layout.Image.LocalPath)) return; @@ -48,9 +46,8 @@ internal class DeviceVisualizerLed try { using Bitmap bitmap = new(Led.Layout.Image.LocalPath); - drawingContext.DrawBitmap( - bitmap.PlatformImpl, - 1, + drawingContext.DrawImage( + bitmap, new Rect(bitmap.Size), new Rect(Led.RgbLed.Location.X * scale, Led.RgbLed.Location.Y * scale, Led.RgbLed.Size.Width * scale, Led.RgbLed.Size.Height * scale), BitmapInterpolationMode.HighQuality diff --git a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs index c6a7ca8f7..cec9f62bb 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs @@ -14,12 +14,12 @@ namespace Artemis.UI.Shared.Controls; /// /// Represents a number box that can be mutated by dragging over it horizontally /// -public class DraggableNumberBox : UserControl +public partial class DraggableNumberBox : UserControl { /// /// Defines the property. /// - public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register(nameof(Value), defaultBindingMode: BindingMode.TwoWay, notifying: ValueChanged); + public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register(nameof(Value), defaultBindingMode: BindingMode.TwoWay); /// /// Defines the property. @@ -85,7 +85,11 @@ public class DraggableNumberBox : UserControl public double Value { get => GetValue(ValueProperty); - set => SetValue(ValueProperty, value); + set + { + SetValue(ValueProperty, value); + SetNumberBoxValue(value); + } } /// @@ -160,25 +164,21 @@ public class DraggableNumberBox : UserControl /// Occurs when the user finishes dragging over the control. /// public event TypedEventHandler? DragFinished; - - private static void ValueChanged(IAvaloniaObject sender, bool before) + + private void SetNumberBoxValue(double value) { - if (before) + if (!(Math.Abs(_numberBox.Value - Value) > 0.00001)) return; - DraggableNumberBox draggable = (DraggableNumberBox) sender; - if (!(Math.Abs(draggable._numberBox.Value - draggable.Value) > 0.00001)) - return; - - draggable._updating = true; - draggable._numberBox.Value = draggable.Value; - draggable._updating = false; + _updating = true; + _numberBox.Value = Value; + _updating = false; } private void HandleKeyUp(object? sender, KeyEventArgs e) { if (e.Key == Key.Enter || e.Key == Key.Escape) - Parent?.Focus(); + FocusManager.Instance?.Focus(Parent as IInputElement); } private void InitializeComponent() @@ -211,7 +211,7 @@ public class DraggableNumberBox : UserControl if (!_moved) { // Let our parent take focus, it would make more sense to take focus ourselves but that hides the collider - Parent?.Focus(); + FocusManager.Instance?.Focus(Parent as IInputElement); _moved = true; e.Pointer.Capture(this); DragStarted?.Invoke(this, EventArgs.Empty); diff --git a/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs b/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs index f264b595e..d7ecc43c6 100644 --- a/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs @@ -13,13 +13,12 @@ namespace Artemis.UI.Shared; /// /// Represents a combobox that can display the values of an enum. /// -public class EnumComboBox : UserControl +public partial class EnumComboBox : UserControl { /// /// Gets or sets the currently selected value /// - public static readonly StyledProperty ValueProperty = - AvaloniaProperty.Register(nameof(Value), defaultBindingMode: BindingMode.TwoWay, notifying: ValueChanged); + public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register(nameof(Value), defaultBindingMode: BindingMode.TwoWay); private readonly ObservableCollection<(Enum, string)> _currentValues = new(); private Type? _currentType; @@ -40,15 +39,11 @@ public class EnumComboBox : UserControl public object? Value { get => GetValue(ValueProperty); - set => SetValue(ValueProperty, value); - } - - private static void ValueChanged(IAvaloniaObject sender, bool before) - { - if (sender is EnumComboBox enumCombo && !before) + set { - enumCombo.UpdateValues(); - enumCombo.UpdateSelection(); + SetValue(ValueProperty, value); + UpdateValues(); + UpdateSelection(); } } diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs index 5bc9eebd5..7edb8e13b 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs +++ b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs @@ -27,7 +27,7 @@ public class GradientPicker : TemplatedControl /// Gets or sets the color gradient. /// public static readonly StyledProperty ColorGradientProperty = - AvaloniaProperty.Register(nameof(ColorGradient), notifying: ColorGradientChanged, defaultValue: ColorGradient.GetUnicornBarf()); + AvaloniaProperty.Register(nameof(ColorGradient), defaultValue: ColorGradient.GetUnicornBarf()); /// /// Gets or sets the currently selected color stop. @@ -45,7 +45,7 @@ public class GradientPicker : TemplatedControl /// Gets or sets a storage provider to use for storing and loading gradients. /// public static readonly StyledProperty StorageProviderProperty = - AvaloniaProperty.Register(nameof(StorageProvider), notifying: StorageProviderChanged); + AvaloniaProperty.Register(nameof(StorageProvider)); /// /// Gets the linear gradient brush representing the color gradient. @@ -66,7 +66,7 @@ public class GradientPicker : TemplatedControl AvaloniaProperty.RegisterDirect(nameof(EditingColorGradient), g => g.EditingColorGradient); private readonly ICommand _deleteStop; - private ColorPicker? _colorPicker; + private FAColorPicker? _colorPicker; private Button? _flipStops; private Border? _gradient; private Button? _randomize; @@ -102,7 +102,11 @@ public class GradientPicker : TemplatedControl public ColorGradient ColorGradient { get => GetValue(ColorGradientProperty); - set => SetValue(ColorGradientProperty, value); + set + { + SetValue(ColorGradientProperty, value); + ApplyToField(); + } } /// @@ -176,7 +180,7 @@ public class GradientPicker : TemplatedControl if (_randomize != null) _randomize.Click -= RandomizeOnClick; - _colorPicker = e.NameScope.Find("ColorPicker"); + _colorPicker = e.NameScope.Find("ColorPicker"); _gradient = e.NameScope.Find("Gradient"); _spreadStops = e.NameScope.Find public static readonly StyledProperty ColorGradientProperty = - AvaloniaProperty.Register(nameof(ColorGradient), notifying: ColorGradientChanged); + AvaloniaProperty.Register(nameof(ColorGradient)); /// /// Gets or sets a boolean indicating whether the gradient picker should be in compact mode or not. @@ -54,7 +53,11 @@ public class GradientPickerButton : TemplatedControl public ColorGradient? ColorGradient { get => GetValue(ColorGradientProperty); - set => SetValue(ColorGradientProperty, value); + set + { + SetValue(ColorGradientProperty, value); + Subscribe(); + } } /// @@ -105,12 +108,6 @@ public class GradientPickerButton : TemplatedControl #endregion - private static void ColorGradientChanged(IAvaloniaObject sender, bool before) - { - if (!before) - (sender as GradientPickerButton)?.Subscribe(); - } - private void Subscribe() { Unsubscribe(); diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerColorStop.cs b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerColorStop.cs index 4e4502288..4bb8aa8e2 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerColorStop.cs +++ b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerColorStop.cs @@ -16,7 +16,7 @@ internal class GradientPickerColorStop : TemplatedControl /// Gets or sets the gradient picker. /// public static readonly StyledProperty GradientPickerProperty = - AvaloniaProperty.Register(nameof(GradientPicker), notifying: Notifying); + AvaloniaProperty.Register(nameof(GradientPicker)); /// /// Gets or sets the color stop. @@ -28,8 +28,8 @@ internal class GradientPickerColorStop : TemplatedControl /// Gets or sets the position reference to use when positioning and dragging this color stop. /// If then dragging is not enabled. /// - public static readonly StyledProperty PositionReferenceProperty = - AvaloniaProperty.Register(nameof(PositionReference)); + public static readonly StyledProperty PositionReferenceProperty = + AvaloniaProperty.Register(nameof(PositionReference)); /// /// Gets the linear gradient brush representing the color gradient. @@ -47,7 +47,16 @@ internal class GradientPickerColorStop : TemplatedControl public GradientPicker? GradientPicker { get => GetValue(GradientPickerProperty); - set => SetValue(GradientPickerProperty, value); + set + { + if (GradientPicker != null) + GradientPicker.PropertyChanged -= GradientPickerOnPropertyChanged; + SetValue(GradientPickerProperty, value); + if (GradientPicker != null) + GradientPicker.PropertyChanged += GradientPickerOnPropertyChanged; + + IsSelected = ReferenceEquals(GradientPicker?.SelectedColorStop, ColorStop); + } } /// @@ -63,7 +72,7 @@ internal class GradientPickerColorStop : TemplatedControl /// Gets or sets the position reference to use when positioning and dragging this color stop. /// If then dragging is not enabled. /// - public IControl? PositionReference + public Control? PositionReference { get => GetValue(PositionReferenceProperty); set => SetValue(PositionReferenceProperty, value); @@ -85,19 +94,6 @@ internal class GradientPickerColorStop : TemplatedControl } } - private static void Notifying(IAvaloniaObject sender, bool before) - { - if (sender is not GradientPickerColorStop self) - return; - - if (before && self.GradientPicker != null) - self.GradientPicker.PropertyChanged -= self.GradientPickerOnPropertyChanged; - else if (self.GradientPicker != null) - self.GradientPicker.PropertyChanged += self.GradientPickerOnPropertyChanged; - - self.IsSelected = ReferenceEquals(self.GradientPicker?.SelectedColorStop, self.ColorStop); - } - private void GradientPickerOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) { if (GradientPicker != null && e.Property == GradientPicker.SelectedColorStopProperty) diff --git a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs index 0c50e69e4..e9e2ce0b3 100644 --- a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs @@ -17,7 +17,7 @@ namespace Artemis.UI.Shared; /// /// Represents a control that can be used to display or edit instances. /// -public class HotkeyBox : UserControl +public partial class HotkeyBox : UserControl { private readonly TextBox _displayTextBox; @@ -34,11 +34,6 @@ public class HotkeyBox : UserControl UpdateDisplayTextBox(); } - private static void HotkeyChanging(IAvaloniaObject sender, bool before) - { - ((HotkeyBox) sender).UpdateDisplayTextBox(); - } - private void DisplayTextBoxOnKeyDown(object? sender, KeyEventArgs e) { if (e.Key >= Key.LeftShift && e.Key <= Key.RightAlt) @@ -92,20 +87,17 @@ public class HotkeyBox : UserControl /// Gets or sets the currently displayed icon as either a or an /// pointing to an SVG /// - public static readonly StyledProperty HotkeyProperty = - AvaloniaProperty.Register(nameof(Hotkey), defaultBindingMode: BindingMode.TwoWay, notifying: HotkeyChanging); + public static readonly StyledProperty HotkeyProperty = AvaloniaProperty.Register(nameof(Hotkey), defaultBindingMode: BindingMode.TwoWay); /// /// Gets or sets the watermark of the hotkey box when it is empty. /// - public static readonly StyledProperty WatermarkProperty = - AvaloniaProperty.Register(nameof(Watermark)); + public static readonly StyledProperty WatermarkProperty = AvaloniaProperty.Register(nameof(Watermark)); /// /// Gets or sets a boolean indicating whether the watermark should float above the hotkey box when it is not empty. /// - public static readonly StyledProperty UseFloatingWatermarkProperty = - AvaloniaProperty.Register(nameof(UseFloatingWatermark)); + public static readonly StyledProperty UseFloatingWatermarkProperty = AvaloniaProperty.Register(nameof(UseFloatingWatermark)); /// /// Gets or sets the currently displayed icon as either a or an @@ -114,7 +106,11 @@ public class HotkeyBox : UserControl public Hotkey? Hotkey { get => GetValue(HotkeyProperty); - set => SetValue(HotkeyProperty, value); + set + { + SetValue(HotkeyProperty, value); + UpdateDisplayTextBox(); + } } /// diff --git a/src/Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml.cs b/src/Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml.cs index c119f0ab2..5313522d9 100644 --- a/src/Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml.cs @@ -3,13 +3,13 @@ using System.IO; using Artemis.Core; using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Documents; using Avalonia.Layout; using Avalonia.LogicalTree; using Avalonia.Markup.Xaml; using Avalonia.Media; using Avalonia.Media.Imaging; using Avalonia.Threading; -using Avalonia.Visuals.Media.Imaging; using Material.Icons; using Material.Icons.Avalonia; @@ -18,7 +18,7 @@ namespace Artemis.UI.Shared; /// /// Represents a control that can display the icon of a specific . /// -public class ProfileConfigurationIcon : UserControl, IDisposable +public partial class ProfileConfigurationIcon : UserControl, IDisposable { private Stream? _stream; @@ -72,7 +72,7 @@ public class ProfileConfigurationIcon : UserControl, IDisposable Content = new Border { - Background = TextBlock.GetForeground(this), + Background = TextElement.GetForeground(this), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, OpacityMask = new ImageBrush(new Bitmap(stream)) {BitmapInterpolationMode = BitmapInterpolationMode.MediumQuality} diff --git a/src/Artemis.UI.Shared/Controls/SelectionRectangle.cs b/src/Artemis.UI.Shared/Controls/SelectionRectangle.cs index d869a5730..5da12bd99 100644 --- a/src/Artemis.UI.Shared/Controls/SelectionRectangle.cs +++ b/src/Artemis.UI.Shared/Controls/SelectionRectangle.cs @@ -40,8 +40,8 @@ public class SelectionRectangle : Control /// /// Defines the property. /// - public static readonly StyledProperty InputElementProperty = - AvaloniaProperty.Register(nameof(InputElement), notifying: OnInputElementChanged); + public static readonly StyledProperty InputElementProperty = + AvaloniaProperty.Register(nameof(InputElement)); /// /// Defines the property. @@ -61,7 +61,7 @@ public class SelectionRectangle : Control private Rect? _displayRect; private bool _isSelecting; private Point _lastPosition; - private IControl? _oldInputElement; + private InputElement? _oldInputElement; private Point _startPosition; /// @@ -110,10 +110,14 @@ public class SelectionRectangle : Control /// /// Gets or sets the element that captures input for the selection rectangle. /// - public IControl? InputElement + public InputElement? InputElement { get => GetValue(InputElementProperty); - set => SetValue(InputElementProperty, value); + set + { + SetValue(InputElementProperty, value); + SubscribeToInputElement(); + } } /// @@ -162,11 +166,6 @@ public class SelectionRectangle : Control SelectionFinished?.Invoke(this, e); } - private static void OnInputElementChanged(IAvaloniaObject sender, bool before) - { - ((SelectionRectangle) sender).SubscribeToInputElement(); - } - private void ParentOnPointerMoved(object? sender, PointerEventArgs e) { // Point moved seems to trigger when the element under the mouse changes? @@ -185,13 +184,13 @@ public class SelectionRectangle : Control { e.Pointer.Capture(this); - _startPosition = e.GetPosition(Parent); - _absoluteStartPosition = e.GetPosition(VisualRoot); + _startPosition = e.GetPosition(Parent as Visual); + _absoluteStartPosition = e.GetPosition(VisualRoot as Visual); _displayRect = null; } - Point currentPosition = e.GetPosition(Parent); - Point absoluteCurrentPosition = e.GetPosition(VisualRoot); + Point currentPosition = e.GetPosition(Parent as Visual); + Point absoluteCurrentPosition = e.GetPosition(VisualRoot as Visual); _displayRect = new Rect( new Point(Math.Min(_startPosition.X, currentPosition.X), Math.Min(_startPosition.Y, currentPosition.Y)), diff --git a/src/Artemis.UI.Shared/Converters/ParentWidthPercentageConverter.cs b/src/Artemis.UI.Shared/Converters/ParentWidthPercentageConverter.cs index 2d8219d0e..4af9f7c86 100644 --- a/src/Artemis.UI.Shared/Converters/ParentWidthPercentageConverter.cs +++ b/src/Artemis.UI.Shared/Converters/ParentWidthPercentageConverter.cs @@ -15,7 +15,7 @@ public class ParentWidthPercentageConverter : IValueConverter /// public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - if (parameter is not IControl parent || value is not double percentage) + if (parameter is not Control parent || value is not double percentage) return value; return parent.Width / 100.0 * percentage; @@ -24,7 +24,7 @@ public class ParentWidthPercentageConverter : IValueConverter /// public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { - if (parameter is not IControl parent || value is not double real) + if (parameter is not Control parent || value is not double real) return value; return real / parent.Width * 100.0; diff --git a/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.axaml.cs b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.axaml.cs index 74bffd403..685f6eade 100644 --- a/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.axaml.cs +++ b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.axaml.cs @@ -6,7 +6,7 @@ namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display; /// /// Represents a default data model display view. /// -public class DefaultDataModelDisplayView : UserControl +public partial class DefaultDataModelDisplayView : UserControl { /// /// Creates a new instance of the class. diff --git a/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/SKColorDataModelDisplayView.axaml.cs b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/SKColorDataModelDisplayView.axaml.cs index 548987c18..4951fcc44 100644 --- a/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/SKColorDataModelDisplayView.axaml.cs +++ b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/SKColorDataModelDisplayView.axaml.cs @@ -7,7 +7,7 @@ namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display; /// /// Represents a data model display view used to display values. /// -public class SKColorDataModelDisplayView : UserControl +public partial class SKColorDataModelDisplayView : UserControl { /// /// Creates a new instance of the class. diff --git a/src/Artemis.UI.Shared/Extensions/VisualExtensions.cs b/src/Artemis.UI.Shared/Extensions/VisualExtensions.cs index d01649eb0..45e97e130 100644 --- a/src/Artemis.UI.Shared/Extensions/VisualExtensions.cs +++ b/src/Artemis.UI.Shared/Extensions/VisualExtensions.cs @@ -6,7 +6,7 @@ using Avalonia.VisualTree; namespace Artemis.UI.Shared.Extensions; /// -/// Provides extension methods for Avalonia's type +/// Provides extension methods for Avalonia's type /// public static class VisualExtensions { @@ -16,15 +16,15 @@ public static class VisualExtensions /// The type the children should have. /// The root visual at which to start searching. /// A recursive list of all visual children of type . - public static List GetVisualChildrenOfType(this IVisual root) + public static List GetVisualChildrenOfType(this Visual root) { List result = new(); - List? visualChildren = root.GetVisualChildren()?.ToList(); + List? visualChildren = root.GetVisualChildren()?.ToList(); if (visualChildren == null || !visualChildren.Any()) return result; - foreach (IVisual visualChild in visualChildren) + foreach (Visual visualChild in visualChildren) { if (visualChild is T toFind) result.Add(toFind); @@ -41,15 +41,15 @@ public static class VisualExtensions /// The type of data context the children should have. /// The root visual at which to start searching. /// A recursive list of all visual children with a data context of type . - public static List GetVisualChildrenOfDataContextType(this IVisual root) + public static List GetVisualChildrenOfDataContextType(this Visual root) { List result = new(); - List? visualChildren = root.GetVisualChildren()?.ToList(); + List? visualChildren = root.GetVisualChildren()?.ToList(); if (visualChildren == null || !visualChildren.Any()) return result; - foreach (IVisual visualChild in visualChildren) + foreach (Visual visualChild in visualChildren) { if (visualChild is IDataContextProvider dataContextProvider && dataContextProvider.DataContext is T toFind) result.Add(toFind); diff --git a/src/Artemis.UI.Shared/ReactiveCoreWindow.cs b/src/Artemis.UI.Shared/ReactiveAppWindow.cs similarity index 90% rename from src/Artemis.UI.Shared/ReactiveCoreWindow.cs rename to src/Artemis.UI.Shared/ReactiveAppWindow.cs index 295f4e6bb..36483f57c 100644 --- a/src/Artemis.UI.Shared/ReactiveCoreWindow.cs +++ b/src/Artemis.UI.Shared/ReactiveAppWindow.cs @@ -4,8 +4,8 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Media; using Avalonia.Media.Immutable; -using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Media; +using FluentAvalonia.UI.Windowing; using ReactiveUI; namespace Artemis.UI.Shared; @@ -17,18 +17,18 @@ namespace Artemis.UI.Shared; /// and vice versa. /// /// ViewModel type. -public class ReactiveCoreWindow : CoreWindow, IViewFor where TViewModel : class +public class ReactiveAppWindow : AppWindow, IViewFor where TViewModel : class { /// /// The ViewModel. /// public static readonly StyledProperty ViewModelProperty = AvaloniaProperty - .Register, TViewModel?>(nameof(ViewModel)); + .Register, TViewModel?>(nameof(ViewModel)); /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public ReactiveCoreWindow() + public ReactiveAppWindow() { // This WhenActivated block calls ViewModel's WhenActivated // block if the ViewModel implements IActivatableViewModel. diff --git a/src/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs b/src/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs index ccf3c741f..5ba268315 100644 --- a/src/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs +++ b/src/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs @@ -116,7 +116,7 @@ public class NotificationBuilder /// public Action Show() { - IPanel? panel = _parent.Find("NotificationContainer"); + Panel? panel = _parent.Find("NotificationContainer"); if (panel == null) throw new ArtemisSharedUIException("Can't display a notification on a window without a NotificationContainer."); @@ -202,7 +202,7 @@ public class NotificationButtonBuilder return this; } - internal IControl Build() + internal Control Build() { if (_action != null) return new Button {Content = _text, Command = ReactiveCommand.Create(() => _action()), Classes = new Classes("AppBarButton")}; diff --git a/src/Artemis.UI.Shared/Services/Window/ExceptionDialogView.axaml.cs b/src/Artemis.UI.Shared/Services/Window/ExceptionDialogView.axaml.cs index a80786d99..8b6fe08d7 100644 --- a/src/Artemis.UI.Shared/Services/Window/ExceptionDialogView.axaml.cs +++ b/src/Artemis.UI.Shared/Services/Window/ExceptionDialogView.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.Shared.Services; -internal class ExceptionDialogView : ReactiveWindow +internal partial class ExceptionDialogView : ReactiveWindow { public ExceptionDialogView() { diff --git a/src/Artemis.UI.Shared/Styles/ColorPickerButton.axaml b/src/Artemis.UI.Shared/Styles/ColorPickerButton.axaml index 411d5649e..19fdc882e 100644 --- a/src/Artemis.UI.Shared/Styles/ColorPickerButton.axaml +++ b/src/Artemis.UI.Shared/Styles/ColorPickerButton.axaml @@ -3,13 +3,13 @@ xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"> - + + ShowAcceptDismissButtons="False" /> @@ -27,19 +27,19 @@ - + @@ -48,4 +48,4 @@ - + \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Styles/Condensed.axaml b/src/Artemis.UI.Shared/Styles/Condensed.axaml index 7b9f44d08..f1afaf384 100644 --- a/src/Artemis.UI.Shared/Styles/Condensed.axaml +++ b/src/Artemis.UI.Shared/Styles/Condensed.axaml @@ -102,7 +102,7 @@ - diff --git a/src/Artemis.UI.Shared/Styles/Controls/DataModelPickerButton.axaml b/src/Artemis.UI.Shared/Styles/Controls/DataModelPickerButton.axaml index cd5bc317e..3308fedc9 100644 --- a/src/Artemis.UI.Shared/Styles/Controls/DataModelPickerButton.axaml +++ b/src/Artemis.UI.Shared/Styles/Controls/DataModelPickerButton.axaml @@ -27,20 +27,20 @@ - + diff --git a/src/Artemis.UI.Shared/Styles/Controls/GradientPicker.axaml b/src/Artemis.UI.Shared/Styles/Controls/GradientPicker.axaml index 9909d32ac..680168261 100644 --- a/src/Artemis.UI.Shared/Styles/Controls/GradientPicker.axaml +++ b/src/Artemis.UI.Shared/Styles/Controls/GradientPicker.axaml @@ -168,14 +168,14 @@ BorderBrush="{DynamicResource ButtonBorderBrush}" BorderThickness="0 0 1 0" Padding="0 0 10 0"> - + diff --git a/src/Artemis.UI.Shared/Styles/Controls/GradientPickerButton.axaml b/src/Artemis.UI.Shared/Styles/Controls/GradientPickerButton.axaml index b3f3b6213..13f5ae0a5 100644 --- a/src/Artemis.UI.Shared/Styles/Controls/GradientPickerButton.axaml +++ b/src/Artemis.UI.Shared/Styles/Controls/GradientPickerButton.axaml @@ -1,15 +1,13 @@  - + - @@ -31,14 +29,14 @@ - + Padding="0 0 12 0" + CornerRadius="{TemplateBinding CornerRadius}" + HorizontalAlignment="Stretch" + VerticalAlignment="Stretch" + HorizontalContentAlignment="Stretch" + VerticalContentAlignment="Stretch"> - + diff --git a/src/Artemis.UI.Shared/Styles/TreeView.axaml b/src/Artemis.UI.Shared/Styles/TreeView.axaml index feaf8b6a6..1543c0ef6 100644 --- a/src/Artemis.UI.Shared/Styles/TreeView.axaml +++ b/src/Artemis.UI.Shared/Styles/TreeView.axaml @@ -1,15 +1,15 @@  - + Test - + - + @@ -21,7 +21,7 @@ - + Test @@ -32,17 +32,17 @@ - + - + + + + - - - - - - - - + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj index 96d6d57fb..9d6fc1088 100644 --- a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj +++ b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj @@ -21,18 +21,18 @@ - - + + - - - + + + - - + + diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index e2619345d..799eb4dff 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -15,28 +15,28 @@ - - - - - + + + + + - - - + + + - - + + - - + + - + diff --git a/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs b/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs index 940527c75..bd3845bfa 100644 --- a/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs +++ b/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs @@ -106,7 +106,7 @@ public class SimpleContextDragBehavior : Behavior PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties; if (!properties.IsLeftButtonPressed || FocusManager.Instance?.Current is TextBox) return; - if (e.Source is not IControl control || AssociatedObject?.DataContext != control.DataContext) + if (e.Source is not Control control || AssociatedObject?.DataContext != control.DataContext) return; _dragStartPoint = e.GetPosition(null); diff --git a/src/Artemis.UI/Behaviors/TreeItemDragBehavior.cs b/src/Artemis.UI/Behaviors/TreeItemDragBehavior.cs index d06518912..912803902 100644 --- a/src/Artemis.UI/Behaviors/TreeItemDragBehavior.cs +++ b/src/Artemis.UI/Behaviors/TreeItemDragBehavior.cs @@ -2,7 +2,6 @@ using System.Collections; using Avalonia; using Avalonia.Controls; -using Avalonia.Controls.Generators; using Avalonia.Controls.Primitives; using Avalonia.Input; using Avalonia.Interactivity; @@ -14,7 +13,7 @@ namespace Artemis.UI.Behaviors; /// /// -public class TreeItemDragBehavior : Behavior +public class TreeItemDragBehavior : Behavior { /// /// @@ -31,7 +30,7 @@ public class TreeItemDragBehavior : Behavior public static readonly StyledProperty VerticalDragThresholdProperty = AvaloniaProperty.Register(nameof(VerticalDragThreshold), 3); - private IControl? _draggedContainer; + private Control? _draggedContainer; private int _draggedIndex; private bool _dragStarted; private bool _enableDrag; @@ -69,12 +68,12 @@ public class TreeItemDragBehavior : Behavior { base.OnAttached(); - if (AssociatedObject is { }) + if (AssociatedObject is not null) { - AssociatedObject.AddHandler(InputElement.PointerReleasedEvent, Released, RoutingStrategies.Tunnel); - AssociatedObject.AddHandler(InputElement.PointerPressedEvent, Pressed, RoutingStrategies.Tunnel); - AssociatedObject.AddHandler(InputElement.PointerMovedEvent, Moved, RoutingStrategies.Tunnel); - AssociatedObject.AddHandler(InputElement.PointerCaptureLostEvent, CaptureLost, RoutingStrategies.Tunnel); + AssociatedObject.AddHandler(InputElement.PointerReleasedEvent, ReleasedHandler, RoutingStrategies.Tunnel); + AssociatedObject.AddHandler(InputElement.PointerPressedEvent, PressedHandler, RoutingStrategies.Tunnel); + AssociatedObject.AddHandler(InputElement.PointerMovedEvent, MovedHandler, RoutingStrategies.Tunnel); + AssociatedObject.AddHandler(InputElement.PointerCaptureLostEvent, CaptureLostHandler, RoutingStrategies.Tunnel); } } @@ -84,16 +83,16 @@ public class TreeItemDragBehavior : Behavior { base.OnDetaching(); - if (AssociatedObject is { }) + if (AssociatedObject is not null) { - AssociatedObject.RemoveHandler(InputElement.PointerReleasedEvent, Released); - AssociatedObject.RemoveHandler(InputElement.PointerPressedEvent, Pressed); - AssociatedObject.RemoveHandler(InputElement.PointerMovedEvent, Moved); - AssociatedObject.RemoveHandler(InputElement.PointerCaptureLostEvent, CaptureLost); + AssociatedObject.RemoveHandler(InputElement.PointerReleasedEvent, ReleasedHandler); + AssociatedObject.RemoveHandler(InputElement.PointerPressedEvent, PressedHandler); + AssociatedObject.RemoveHandler(InputElement.PointerMovedEvent, MovedHandler); + AssociatedObject.RemoveHandler(InputElement.PointerCaptureLostEvent, CaptureLostHandler); } } - private void Pressed(object? sender, PointerPressedEventArgs e) + private void PressedHandler(object? sender, PointerPressedEventArgs e) { PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties; if (properties.IsLeftButtonPressed @@ -101,20 +100,20 @@ public class TreeItemDragBehavior : Behavior { _enableDrag = true; _dragStarted = false; - _start = e.GetPosition(AssociatedObject.Parent); + _start = e.GetPosition(AssociatedObject.Parent as Visual); _draggedIndex = -1; _targetIndex = -1; _itemsControl = itemsControl; _draggedContainer = AssociatedObject; - if (_draggedContainer is { }) + if (_draggedContainer is not null) SetDraggingPseudoClasses(_draggedContainer, true); AddTransforms(_itemsControl); } } - private void Released(object? sender, PointerReleasedEventArgs e) + private void ReleasedHandler(object? sender, PointerReleasedEventArgs e) { if (_dragStarted) { @@ -125,7 +124,7 @@ public class TreeItemDragBehavior : Behavior } } - private void CaptureLost(object? sender, PointerCaptureLostEventArgs e) + private void CaptureLostHandler(object? sender, PointerCaptureLostEventArgs e) { Released(); } @@ -137,19 +136,21 @@ public class TreeItemDragBehavior : Behavior RemoveTransforms(_itemsControl); - if (_itemsControl is { }) - foreach (ItemContainerInfo? container in _itemsControl.ItemContainerGenerator.Containers) - SetDraggingPseudoClasses(container.ContainerControl, true); + if (_itemsControl is not null) + { + for (int i = 0; i < _itemsControl.ItemCount; i++) + SetDraggingPseudoClasses(_itemsControl.ContainerFromIndex(i), true); + } if (_dragStarted) if (_draggedIndex >= 0 && _targetIndex >= 0 && _draggedIndex != _targetIndex) MoveDraggedItem(_itemsControl, _draggedIndex, _targetIndex); - if (_itemsControl is { }) - foreach (ItemContainerInfo? container in _itemsControl.ItemContainerGenerator.Containers) - SetDraggingPseudoClasses(container.ContainerControl, false); + if (_itemsControl is not null) + for (int i = 0; i < _itemsControl.ItemCount; i++) + SetDraggingPseudoClasses(_itemsControl.ContainerFromIndex(i), false); - if (_draggedContainer is { }) + if (_draggedContainer is not null) SetDraggingPseudoClasses(_draggedContainer, false); _draggedIndex = -1; @@ -170,7 +171,7 @@ public class TreeItemDragBehavior : Behavior foreach (object? _ in itemsControl.Items) { - IControl? container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i); + Control? container = itemsControl.ContainerFromIndex(i); if (container is not null) SetTranslateTransform(container, 0, 0); @@ -187,7 +188,7 @@ public class TreeItemDragBehavior : Behavior foreach (object? _ in itemsControl.Items) { - IControl? container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i); + Control? container = itemsControl.ContainerFromIndex(i); if (container is not null) SetTranslateTransform(container, 0, 0); @@ -208,7 +209,7 @@ public class TreeItemDragBehavior : Behavior selectingItemsControl.SelectedIndex = targetIndex; } - private void Moved(object? sender, PointerEventArgs e) + private void MovedHandler(object? sender, PointerEventArgs e) { PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties; if (properties.IsLeftButtonPressed) @@ -249,7 +250,7 @@ public class TreeItemDragBehavior : Behavior else SetTranslateTransform(_draggedContainer, 0, delta); - _draggedIndex = _itemsControl.ItemContainerGenerator.IndexFromContainer(_draggedContainer); + _draggedIndex = _itemsControl.IndexFromContainer(_draggedContainer); _targetIndex = -1; Rect draggedBounds = _draggedContainer.Bounds; @@ -268,7 +269,7 @@ public class TreeItemDragBehavior : Behavior foreach (object? _ in _itemsControl.Items) { - IControl? targetContainer = _itemsControl.ItemContainerGenerator.ContainerFromIndex(i); + Control? targetContainer = _itemsControl.ContainerFromIndex(i); if (targetContainer?.RenderTransform is null || ReferenceEquals(targetContainer, _draggedContainer)) { i++; @@ -321,16 +322,20 @@ public class TreeItemDragBehavior : Behavior } } - private void SetDraggingPseudoClasses(IControl control, bool isDragging) + private void SetDraggingPseudoClasses(Control? control, bool isDragging) { + if (control == null) + return; if (isDragging) ((IPseudoClasses) control.Classes).Add(":dragging"); else ((IPseudoClasses) control.Classes).Remove(":dragging"); } - private void SetTranslateTransform(IControl control, double x, double y) + private void SetTranslateTransform(Control? control, double x, double y) { + if (control == null) + return; TransformOperations.Builder transformBuilder = new(1); transformBuilder.AppendTranslate(x, y); control.RenderTransform = transformBuilder.Build(); diff --git a/src/Artemis.UI/Controls/TimelineHeader.cs b/src/Artemis.UI/Controls/TimelineHeader.cs index e0ecc3593..03968b234 100644 --- a/src/Artemis.UI/Controls/TimelineHeader.cs +++ b/src/Artemis.UI/Controls/TimelineHeader.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using Avalonia; using Avalonia.Controls; using Avalonia.Media; @@ -137,47 +138,47 @@ public class TimelineHeader : Control private void RenderLabel(DrawingContext drawingContext, string text, double x) { Typeface typeFace = new(FontFamily); - FormattedText formattedText = new(text, typeFace, 9, TextAlignment.Left, TextWrapping.NoWrap, Bounds.Size); + FormattedText formattedText = new(text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeFace, 9, Foreground); if (x == 0 && OffsetFirstValue) - drawingContext.DrawText(Foreground, new Point(2, 5), formattedText); + drawingContext.DrawText(formattedText, new Point(2, 5)); else - drawingContext.DrawText(Foreground, new Point(x - formattedText.Bounds.Width / 2, 5), formattedText); + drawingContext.DrawText(formattedText, new Point(x - formattedText.Width / 2, 5)); } private void UpdateTimeScale() { - object[] subds; + double[] subds; if (PixelsPerSecond > 350) - subds = new object[] {12d, 12d, 60d}; + subds = new[] {12d, 12d, 60d}; else if (PixelsPerSecond > 250) - subds = new object[] {6d, 12d, 60d}; + subds = new[] {6d, 12d, 60d}; else if (PixelsPerSecond > 200) - subds = new object[] {6d, 6d, 30d}; + subds = new[] {6d, 6d, 30d}; else if (PixelsPerSecond > 150) - subds = new object[] {4d, 4d, 20d}; + subds = new[] {4d, 4d, 20d}; else if (PixelsPerSecond > 140) - subds = new object[] {4d, 4d, 20d}; + subds = new[] {4d, 4d, 20d}; else if (PixelsPerSecond > 90) - subds = new object[] {2d, 4d, 20d}; + subds = new[] {2d, 4d, 20d}; else if (PixelsPerSecond > 60) - subds = new object[] {2d, 4d, 8d}; + subds = new[] {2d, 4d, 8d}; else if (PixelsPerSecond > 40) - subds = new object[] {1d, 2d, 10d}; + subds = new[] {1d, 2d, 10d}; else if (PixelsPerSecond > 30) - subds = new object[] {1d, 2d, 10d}; + subds = new[] {1d, 2d, 10d}; else if (PixelsPerSecond > 10) - subds = new object[] {1d / 2d, 1d / 2d, 1d / 2d}; + subds = new[] {1d / 2d, 1d / 2d, 1d / 2d}; else if (PixelsPerSecond > 4) - subds = new object[] {1d / 5d, 1d / 5d, 1d / 5d}; + subds = new[] {1d / 5d, 1d / 5d, 1d / 5d}; else if (PixelsPerSecond > 3) - subds = new object[] {1d / 10d, 1d / 10d, 1d / 5d}; + subds = new[] {1d / 10d, 1d / 10d, 1d / 5d}; else if (PixelsPerSecond > 1) - subds = new object[] {1d / 20d, 1d / 20d, 1d / 10d}; + subds = new[] {1d / 20d, 1d / 20d, 1d / 10d}; else if (PixelsPerSecond >= 1) - subds = new object[] {1d / 30d, 1d / 30d, 1d / 15d}; + subds = new[] {1d / 30d, 1d / 30d, 1d / 15d}; else // 1s per pixel - subds = new object[] {1d / 60d, 1d / 60d, 1d / 15d}; + subds = new[] {1d / 60d, 1d / 60d, 1d / 15d}; _subd1 = (double) subds[0]; // big ticks / labels _subd2 = (double) subds[1]; // medium ticks diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/BoolPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/BoolPropertyInputView.axaml.cs index 624ba9770..bc6e253bb 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/BoolPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/BoolPropertyInputView.axaml.cs @@ -3,7 +3,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class BoolPropertyInputView : ReactiveUserControl +public partial class BoolPropertyInputView : ReactiveUserControl { public BoolPropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.axaml.cs index 636515d99..8e9b25b32 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.axaml.cs @@ -3,7 +3,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class BrushPropertyInputView : ReactiveUserControl +public partial class BrushPropertyInputView : ReactiveUserControl { public BrushPropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs index 8f9ae6277..92321d8a0 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.ObjectModel; using System.Linq; +using System.Reactive.Disposables; using System.Reactive.Linq; using Artemis.Core; using Artemis.Core.LayerBrushes; @@ -11,7 +12,6 @@ using Artemis.UI.Shared.Services.Builders; using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.PropertyInput; -using Avalonia.Controls.Mixins; using Avalonia.Threading; using ReactiveUI; diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.axaml.cs index 2288a4821..7d42d2b3e 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class ColorGradientPropertyInputView : ReactiveUserControl +public partial class ColorGradientPropertyInputView : ReactiveUserControl { public ColorGradientPropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.axaml.cs index 60eab4443..321d65741 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class EnumPropertyInputView : ReactiveUserControl +public partial class EnumPropertyInputView : ReactiveUserControl { public EnumPropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml.cs index 631a05329..4ad37019d 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class FloatPropertyInputView : ReactiveUserControl +public partial class FloatPropertyInputView : ReactiveUserControl { public FloatPropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.axaml.cs index a297da606..4ff901f9d 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class FloatRangePropertyInputView : ReactiveUserControl +public partial class FloatRangePropertyInputView : ReactiveUserControl { public FloatRangePropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml.cs index e1afcd555..686ba8f13 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class IntPropertyInputView : ReactiveUserControl +public partial class IntPropertyInputView : ReactiveUserControl { public IntPropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/IntRangePropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/IntRangePropertyInputView.axaml.cs index 6aff0155f..4ba0cbebd 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/IntRangePropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/IntRangePropertyInputView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class IntRangePropertyInputView : ReactiveUserControl +public partial class IntRangePropertyInputView : ReactiveUserControl { public IntRangePropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.axaml.cs index 50b3c150e..5e1300687 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.axaml.cs @@ -5,7 +5,7 @@ using FluentAvalonia.UI.Controls; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class SKColorPropertyInputView : ReactiveUserControl +public partial class SKColorPropertyInputView : ReactiveUserControl { public SKColorPropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.axaml.cs index 4cfeefd97..ab1664aa5 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class SKPointPropertyInputView : ReactiveUserControl +public partial class SKPointPropertyInputView : ReactiveUserControl { public SKPointPropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml.cs index 9773b8daa..c118405bc 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class SKSizePropertyInputView : ReactiveUserControl +public partial class SKSizePropertyInputView : ReactiveUserControl { public SKSizePropertyInputView() { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs index 53d0c00b0..9e5f365fe 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; -public class StringPropertyInputView : ReactiveUserControl +public partial class StringPropertyInputView : ReactiveUserControl { public StringPropertyInputView() { diff --git a/src/Artemis.UI/MainWindow.axaml.cs b/src/Artemis.UI/MainWindow.axaml.cs index 336bfb46a..a8a49b6b2 100644 --- a/src/Artemis.UI/MainWindow.axaml.cs +++ b/src/Artemis.UI/MainWindow.axaml.cs @@ -13,7 +13,7 @@ using ReactiveUI; namespace Artemis.UI; -public class MainWindow : ReactiveCoreWindow +public class MainWindow : ReactiveAppWindow { private readonly Panel _rootPanel; private readonly ContentControl _sidebarContentControl; diff --git a/src/Artemis.UI/Screens/Debugger/DebugView.axaml.cs b/src/Artemis.UI/Screens/Debugger/DebugView.axaml.cs index ed16843c9..37f190fff 100644 --- a/src/Artemis.UI/Screens/Debugger/DebugView.axaml.cs +++ b/src/Artemis.UI/Screens/Debugger/DebugView.axaml.cs @@ -10,7 +10,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.Debugger; -public class DebugView : ReactiveCoreWindow +public class DebugView : ReactiveAppWindow { public DebugView() { diff --git a/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml.cs b/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml.cs index a67e142e5..a26b2a9c9 100644 --- a/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml.cs +++ b/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml.cs @@ -7,7 +7,7 @@ using Avalonia.Markup.Xaml; namespace Artemis.UI.Screens.Device; -public class DevicePropertiesView : ReactiveCoreWindow +public class DevicePropertiesView : ReactiveAppWindow { public DevicePropertiesView() { diff --git a/src/Artemis.UI/Screens/Plugins/PluginSettingsWindowView.axaml.cs b/src/Artemis.UI/Screens/Plugins/PluginSettingsWindowView.axaml.cs index 0ab658d66..626105c3e 100644 --- a/src/Artemis.UI/Screens/Plugins/PluginSettingsWindowView.axaml.cs +++ b/src/Artemis.UI/Screens/Plugins/PluginSettingsWindowView.axaml.cs @@ -8,7 +8,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.Plugins; -public class PluginSettingsWindowView : ReactiveCoreWindow +public class PluginSettingsWindowView : ReactiveAppWindow { public PluginSettingsWindowView() { diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/LayerHintsDialogView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/LayerHintsDialogView.axaml.cs index 4bb0db390..e3454e44e 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/LayerHintsDialogView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/LayerHintsDialogView.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml; namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs; -public class LayerHintsDialogView : ReactiveCoreWindow +public class LayerHintsDialogView : ReactiveAppWindow { public LayerHintsDialogView() { diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/BrushConfigurationWindowView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/BrushConfigurationWindowView.axaml.cs index 5c6049bf7..8df8901f9 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/BrushConfigurationWindowView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/BrushConfigurationWindowView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.Markup.Xaml; namespace Artemis.UI.Screens.ProfileEditor.Properties.Windows; -public class BrushConfigurationWindowView : ReactiveCoreWindow +public class BrushConfigurationWindowView : ReactiveAppWindow { private bool _canClose; diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/EffectConfigurationWindowView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/EffectConfigurationWindowView.axaml.cs index dc9cfb0cd..0fc36eefd 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/EffectConfigurationWindowView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/EffectConfigurationWindowView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.Markup.Xaml; namespace Artemis.UI.Screens.ProfileEditor.Properties.Windows; -public class EffectConfigurationWindowView : ReactiveCoreWindow +public class EffectConfigurationWindowView : ReactiveAppWindow { private bool _canClose; diff --git a/src/Artemis.UI/Screens/Scripting/ScriptsDialogView.axaml.cs b/src/Artemis.UI/Screens/Scripting/ScriptsDialogView.axaml.cs index 706a9a5b5..fc6a8787b 100644 --- a/src/Artemis.UI/Screens/Scripting/ScriptsDialogView.axaml.cs +++ b/src/Artemis.UI/Screens/Scripting/ScriptsDialogView.axaml.cs @@ -5,7 +5,7 @@ using Avalonia.Markup.Xaml; namespace Artemis.UI.Screens.Scripting; -public class ScriptsDialogView : ReactiveCoreWindow +public class ScriptsDialogView : ReactiveAppWindow { private bool _canClose; diff --git a/src/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditView.axaml.cs b/src/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditView.axaml.cs index 1ad04cdd4..14d01bd26 100644 --- a/src/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditView.axaml.cs +++ b/src/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditView.axaml.cs @@ -8,7 +8,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.Sidebar; -public class ProfileConfigurationEditView : ReactiveCoreWindow +public class ProfileConfigurationEditView : ReactiveAppWindow { public ProfileConfigurationEditView() { diff --git a/src/Artemis.UI/Screens/StartupWizard/StartupWizardView.axaml.cs b/src/Artemis.UI/Screens/StartupWizard/StartupWizardView.axaml.cs index 82229ac93..6e74c706e 100644 --- a/src/Artemis.UI/Screens/StartupWizard/StartupWizardView.axaml.cs +++ b/src/Artemis.UI/Screens/StartupWizard/StartupWizardView.axaml.cs @@ -11,7 +11,7 @@ using ReactiveUI; namespace Artemis.UI.Screens.StartupWizard; -public class StartupWizardView : ReactiveCoreWindow +public class StartupWizardView : ReactiveAppWindow { private readonly Frame _frame; diff --git a/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml.cs b/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml.cs index 1c58fe868..43e3736d0 100644 --- a/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml.cs +++ b/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml; namespace Artemis.UI.Screens.VisualScripting; -public class NodeScriptWindowView : ReactiveCoreWindow +public class NodeScriptWindowView : ReactiveAppWindow { public NodeScriptWindowView() { diff --git a/src/Artemis.VisualScripting/Artemis.VisualScripting.csproj b/src/Artemis.VisualScripting/Artemis.VisualScripting.csproj index ac5bb81ea..fedc59d0a 100644 --- a/src/Artemis.VisualScripting/Artemis.VisualScripting.csproj +++ b/src/Artemis.VisualScripting/Artemis.VisualScripting.csproj @@ -8,14 +8,14 @@ - - - + + + - - - + + +