1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Shared UI - More XML comments!

This commit is contained in:
Robert 2020-11-20 19:30:38 +01:00
parent 32e80c3d05
commit 5683fd44df
18 changed files with 289 additions and 78 deletions

View File

@ -1,10 +1,11 @@
using System; using System;
using Artemis.Core.LayerBrushes; using Artemis.Core.LayerBrushes;
using Artemis.Core.Services;
namespace Artemis.Core namespace Artemis.Core
{ {
/// <summary> /// <summary>
/// Represents a layer brush registration /// Represents a layer brush registration returned by calling <see cref="ILayerBrushService.RegisterLayerBrush"/>
/// </summary> /// </summary>
public class LayerBrushRegistration public class LayerBrushRegistration
{ {

View File

@ -116,6 +116,7 @@ namespace Artemis.UI.Shared
{ {
} }
/// <inheritdoc />
public void AttachView(UIElement view) public void AttachView(UIElement view)
{ {
if (View != null) if (View != null)
@ -131,6 +132,7 @@ namespace Artemis.UI.Shared
}); });
} }
/// <inheritdoc />
public UIElement View { get; set; } public UIElement View { get; set; }
} }
} }

View File

@ -5,11 +5,16 @@ using Artemis.UI.Shared.Services;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Represents a layer brush registered through
/// <see cref="IDataModelUIService.RegisterDataModelInput{T}" /> or
/// <see cref="IDataModelUIService.RegisterDataModelDisplay{T}" />
/// </summary>
public class DataModelVisualizationRegistration public class DataModelVisualizationRegistration
{ {
private readonly IDataModelUIService _dataModelUIService; private readonly IDataModelUIService _dataModelUIService;
public DataModelVisualizationRegistration(IDataModelUIService dataModelUIService, internal DataModelVisualizationRegistration(IDataModelUIService dataModelUIService,
RegistrationType registrationType, RegistrationType registrationType,
Plugin plugin, Plugin plugin,
Type supportedType, Type supportedType,
@ -25,12 +30,30 @@ namespace Artemis.UI.Shared
Plugin.Disabled += InstanceOnDisabled; Plugin.Disabled += InstanceOnDisabled;
} }
/// <summary>
/// Gets the type of registration, either a display or an input
/// </summary>
public RegistrationType RegistrationType { get; } public RegistrationType RegistrationType { get; }
/// <summary>
/// Gets the plugin that registered the visualization
/// </summary>
public Plugin Plugin { get; } public Plugin Plugin { get; }
/// <summary>
/// Gets the type supported by the visualization
/// </summary>
public Type SupportedType { get; } public Type SupportedType { get; }
/// <summary>
/// Gets the view model type of the visualization
/// </summary>
public Type ViewModelType { get; } public Type ViewModelType { get; }
public IReadOnlyCollection<Type> CompatibleConversionTypes { get; internal set; } /// <summary>
/// Gets a read only collection of types this visualization can convert to and from
/// </summary>
public IReadOnlyCollection<Type>? CompatibleConversionTypes { get; internal set; }
internal void Unsubscribe() internal void Unsubscribe()
{ {
@ -38,7 +61,7 @@ namespace Artemis.UI.Shared
Plugin.Disabled -= InstanceOnDisabled; Plugin.Disabled -= InstanceOnDisabled;
} }
private void InstanceOnDisabled(object sender, EventArgs e) private void InstanceOnDisabled(object? sender, EventArgs e)
{ {
if (RegistrationType == RegistrationType.Input) if (RegistrationType == RegistrationType.Input)
_dataModelUIService.RemoveDataModelInput(this); _dataModelUIService.RemoveDataModelInput(this);
@ -47,9 +70,19 @@ namespace Artemis.UI.Shared
} }
} }
/// <summary>
/// Represents a type of data model visualization registration
/// </summary>
public enum RegistrationType public enum RegistrationType
{ {
/// <summary>
/// A visualization used for displaying values
/// </summary>
Display, Display,
/// <summary>
/// A visualization used for inputting values
/// </summary>
Input Input
} }
} }

View File

@ -10,9 +10,6 @@ using Artemis.UI.Shared.Services;
using MaterialDesignColors.ColorManipulation; using MaterialDesignColors.ColorManipulation;
using Stylet; using Stylet;
// Remove, annoying while working on it
#pragma warning disable 1591
namespace Artemis.UI.Shared.Input namespace Artemis.UI.Shared.Input
{ {
public class DataModelDynamicViewModel : PropertyChangedBase, IDisposable public class DataModelDynamicViewModel : PropertyChangedBase, IDisposable

View File

@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.UI.Shared.Input
{
/// <summary>
/// Interaction logic for DataModelStaticView.xaml
/// </summary>
public partial class DataModelStaticView : UserControl
{
public DataModelStaticView()
{
InitializeComponent();
}
}
}

View File

@ -4,54 +4,66 @@ using Artemis.UI.Shared.Services;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Represents a view model that visualizes a single data model property contained in a
/// <see cref="DataModelListViewModel" />
/// </summary>
public class DataModelListPropertyViewModel : DataModelPropertyViewModel public class DataModelListPropertyViewModel : DataModelPropertyViewModel
{ {
private int _index; private int _index;
private Type _listType; private Type _listType;
public DataModelListPropertyViewModel(Type listType, DataModelDisplayViewModel displayViewModel) : base(null, null, null) internal DataModelListPropertyViewModel(Type listType, DataModelDisplayViewModel displayViewModel) : base(null, null, null)
{ {
DataModel = ListPredicateWrapperDataModel.Create(listType); DataModel = ListPredicateWrapperDataModel.Create(listType);
ListType = listType; ListType = listType;
DisplayViewModel = displayViewModel; DisplayViewModel = displayViewModel;
} }
public DataModelListPropertyViewModel(Type listType) : base(null, null, null) internal DataModelListPropertyViewModel(Type listType) : base(null, null, null)
{ {
DataModel = ListPredicateWrapperDataModel.Create(listType); DataModel = ListPredicateWrapperDataModel.Create(listType);
ListType = listType; ListType = listType;
} }
/// <summary>
/// Gets the index of the element within the list
/// </summary>
public int Index public int Index
{ {
get => _index; get => _index;
set => SetAndNotify(ref _index, value); internal set => SetAndNotify(ref _index, value);
} }
/// <summary>
/// Gets the type of elements contained in the list
/// </summary>
public Type ListType public Type ListType
{ {
get => _listType; get => _listType;
set => SetAndNotify(ref _listType, value); private set => SetAndNotify(ref _listType, value);
} }
/// <inheritdoc />
public override object GetCurrentValue() public override object GetCurrentValue()
{ {
return DisplayValue; return DisplayValue;
} }
/// <inheritdoc />
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration) public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
{ {
// Display value gets updated by parent, don't do anything if it is null // Display value gets updated by parent, don't do anything if it is null
if (DisplayValue == null) if (DisplayValue == null)
return; return;
((ListPredicateWrapperDataModel)DataModel).UntypedValue = DisplayValue; ((ListPredicateWrapperDataModel) DataModel).UntypedValue = DisplayValue;
if (DisplayViewModel == null) if (DisplayViewModel == null)
DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(DisplayValue.GetType(), PropertyDescription, true); DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(DisplayValue.GetType(), PropertyDescription, true);
ListType = DisplayValue.GetType(); ListType = DisplayValue.GetType();
UpdateDisplayParameters(); DisplayViewModel?.UpdateValue(DisplayValue);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -7,44 +7,69 @@ using Stylet;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Represents a view model that visualizes a list data model property
/// </summary>
public class DataModelListViewModel : DataModelVisualizationViewModel public class DataModelListViewModel : DataModelVisualizationViewModel
{ {
private string _countDisplay; private string _countDisplay;
private IEnumerable _list;
private int _listCount;
private Type _displayValueType; private Type _displayValueType;
private IEnumerable _list;
private BindableCollection<DataModelVisualizationViewModel> _listChildren;
private int _listCount;
internal DataModelListViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath) : base(dataModel, parent, dataModelPath) internal DataModelListViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath)
: base(dataModel, parent, dataModelPath)
{ {
ListChildren = new BindableCollection<DataModelVisualizationViewModel>(); ListChildren = new BindableCollection<DataModelVisualizationViewModel>();
} }
/// <summary>
/// Gets the instance of the list that is being visualized
/// </summary>
public IEnumerable List public IEnumerable List
{ {
get => _list; get => _list;
set => SetAndNotify(ref _list, value); private set => SetAndNotify(ref _list, value);
} }
/// <summary>
/// Gets amount of elements in the list that is being visualized
/// </summary>
public int ListCount public int ListCount
{ {
get => _listCount; get => _listCount;
set => SetAndNotify(ref _listCount, value); private set => SetAndNotify(ref _listCount, value);
} }
/// <summary>
/// Gets the type of elements this list contains and that must be displayed as children
/// </summary>
public Type DisplayValueType public Type DisplayValueType
{ {
get => _displayValueType; get => _displayValueType;
set => SetAndNotify(ref _displayValueType, value); set => SetAndNotify(ref _displayValueType, value);
} }
/// <summary>
/// Gets a human readable display count
/// </summary>
public string CountDisplay public string CountDisplay
{ {
get => _countDisplay; get => _countDisplay;
set => SetAndNotify(ref _countDisplay, value); set => SetAndNotify(ref _countDisplay, value);
} }
public BindableCollection<DataModelVisualizationViewModel> ListChildren { get; set; } /// <summary>
/// Gets a list of child view models that visualize the elements in the list
/// </summary>
public BindableCollection<DataModelVisualizationViewModel> ListChildren
{
get => _listChildren;
private set => SetAndNotify(ref _listChildren, value);
}
/// <inheritdoc />
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration) public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
{ {
if (Parent != null && !Parent.IsVisualizationExpanded) if (Parent != null && !Parent.IsVisualizationExpanded)
@ -101,7 +126,7 @@ namespace Artemis.UI.Shared
return $"[List] {DisplayPath ?? Path} - {ListCount} item(s)"; return $"[List] {DisplayPath ?? Path} - {ListCount} item(s)";
} }
protected DataModelVisualizationViewModel CreateListChild(IDataModelUIService dataModelUIService, Type listType) private DataModelVisualizationViewModel CreateListChild(IDataModelUIService dataModelUIService, Type listType)
{ {
// If a display VM was found, prefer to use that in any case // If a display VM was found, prefer to use that in any case
DataModelDisplayViewModel typeViewModel = dataModelUIService.GetDataModelDisplayViewModel(listType, PropertyDescription); DataModelDisplayViewModel typeViewModel = dataModelUIService.GetDataModelDisplayViewModel(listType, PropertyDescription);

View File

@ -5,27 +5,38 @@ using Artemis.UI.Shared.Services;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Represents a view model that visualizes a class (POCO) data model property containing child properties
/// </summary>
public class DataModelPropertiesViewModel : DataModelVisualizationViewModel public class DataModelPropertiesViewModel : DataModelVisualizationViewModel
{ {
private object _displayValue; private object _displayValue;
private Type _displayValueType; private Type _displayValueType;
internal DataModelPropertiesViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath) : base(dataModel, parent, dataModelPath) internal DataModelPropertiesViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath)
: base(dataModel, parent, dataModelPath)
{ {
} }
/// <summary>
/// Gets the type of the property that is being visualized
/// </summary>
public Type DisplayValueType public Type DisplayValueType
{ {
get => _displayValueType; get => _displayValueType;
set => SetAndNotify(ref _displayValueType, value); private set => SetAndNotify(ref _displayValueType, value);
} }
/// <summary>
/// Gets the value of the property that is being visualized
/// </summary>
public object DisplayValue public object DisplayValue
{ {
get => _displayValue; get => _displayValue;
set => SetAndNotify(ref _displayValue, value); private set => SetAndNotify(ref _displayValue, value);
} }
/// <inheritdoc />
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration) public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
{ {
DisplayValueType = DataModelPath?.GetPropertyType(); DisplayValueType = DataModelPath?.GetPropertyType();
@ -48,6 +59,7 @@ namespace Artemis.UI.Shared
dataModelVisualizationViewModel.Update(dataModelUIService, configuration); dataModelVisualizationViewModel.Update(dataModelUIService, configuration);
} }
/// <inheritdoc />
public override object GetCurrentValue() public override object GetCurrentValue()
{ {
if (Parent == null || Parent.IsRootViewModel || IsRootViewModel) if (Parent == null || Parent.IsRootViewModel || IsRootViewModel)

View File

@ -5,34 +5,49 @@ using Artemis.UI.Shared.Services;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Represents a view model that visualizes a single data model property contained in a
/// <see cref="DataModelPropertiesViewModel" />
/// </summary>
public class DataModelPropertyViewModel : DataModelVisualizationViewModel public class DataModelPropertyViewModel : DataModelVisualizationViewModel
{ {
private object _displayValue; private object _displayValue;
private DataModelDisplayViewModel _displayViewModel;
private Type _displayValueType; private Type _displayValueType;
private DataModelDisplayViewModel _displayViewModel;
internal DataModelPropertyViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath) : base(dataModel, parent, dataModelPath) internal DataModelPropertyViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath)
: base(dataModel, parent, dataModelPath)
{ {
} }
/// <summary>
/// Gets the value of the property that is being visualized
/// </summary>
public object DisplayValue public object DisplayValue
{ {
get => _displayValue; get => _displayValue;
set => SetAndNotify(ref _displayValue, value); internal set => SetAndNotify(ref _displayValue, value);
} }
/// <summary>
/// Gets the type of the property that is being visualized
/// </summary>
public Type DisplayValueType public Type DisplayValueType
{ {
get => _displayValueType; get => _displayValueType;
set => SetAndNotify(ref _displayValueType, value); protected set => SetAndNotify(ref _displayValueType, value);
} }
/// <summary>
/// Gets the view model used to display the display value
/// </summary>
public DataModelDisplayViewModel DisplayViewModel public DataModelDisplayViewModel DisplayViewModel
{ {
get => _displayViewModel; get => _displayViewModel;
set => SetAndNotify(ref _displayViewModel, value); internal set => SetAndNotify(ref _displayViewModel, value);
} }
/// <inheritdoc />
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration) public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
{ {
if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel) if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel)
@ -47,11 +62,6 @@ namespace Artemis.UI.Shared
DisplayValue = GetCurrentValue(); DisplayValue = GetCurrentValue();
DisplayValueType = DisplayValue != null ? DisplayValue.GetType() : DataModelPath.GetPropertyType(); DisplayValueType = DisplayValue != null ? DisplayValue.GetType() : DataModelPath.GetPropertyType();
UpdateDisplayParameters();
}
protected void UpdateDisplayParameters()
{
DisplayViewModel?.UpdateValue(DisplayValue); DisplayViewModel?.UpdateValue(DisplayValue);
} }

View File

@ -0,0 +1,22 @@
namespace Artemis.UI.Shared
{
/// <summary>
/// Represents a configuration to use while updating a <see cref="DataModelVisualizationViewModel" />
/// </summary>
public class DataModelUpdateConfiguration
{
/// <summary>
/// Creates a new instance of the <see cref="DataModelUpdateConfiguration" /> class
/// </summary>
/// <param name="createEventChildren">A boolean indicating whether or not event children should be created</param>
public DataModelUpdateConfiguration(bool createEventChildren)
{
CreateEventChildren = createEventChildren;
}
/// <summary>
/// Gets a boolean indicating whether or not event children should be created
/// </summary>
public bool CreateEventChildren { get; }
}
}

View File

@ -10,6 +10,9 @@ using Stylet;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Represents a base class for a view model that visualizes a part of the data model
/// </summary>
public abstract class DataModelVisualizationViewModel : PropertyChangedBase public abstract class DataModelVisualizationViewModel : PropertyChangedBase
{ {
private const int MaxDepth = 4; private const int MaxDepth = 4;
@ -34,42 +37,75 @@ namespace Artemis.UI.Shared
PropertyDescription = DataModelPath?.GetPropertyDescription() ?? DataModel.DataModelDescription; PropertyDescription = DataModelPath?.GetPropertyDescription() ?? DataModel.DataModelDescription;
} }
/// <summary>
/// Gets a boolean indicating whether this view model is at the root of the data model
/// </summary>
public bool IsRootViewModel { get; protected set; } public bool IsRootViewModel { get; protected set; }
/// <summary>
/// Gets the data model path to the property this view model is visualizing
/// </summary>
public DataModelPath DataModelPath { get; } public DataModelPath DataModelPath { get; }
/// <summary>
/// Gets a string representation of the path backing this model
/// </summary>
public string Path => DataModelPath?.Path; public string Path => DataModelPath?.Path;
/// <summary>
/// Gets the property depth of the view model
/// </summary>
public int Depth { get; private set; } public int Depth { get; private set; }
/// <summary>
/// Gets the data model backing this view model
/// </summary>
public DataModel DataModel public DataModel DataModel
{ {
get => _dataModel; get => _dataModel;
protected set => SetAndNotify(ref _dataModel, value); protected set => SetAndNotify(ref _dataModel, value);
} }
/// <summary>
/// Gets the property description of the property this view model is visualizing
/// </summary>
public DataModelPropertyAttribute PropertyDescription public DataModelPropertyAttribute PropertyDescription
{ {
get => _propertyDescription; get => _propertyDescription;
protected set => SetAndNotify(ref _propertyDescription, value); protected set => SetAndNotify(ref _propertyDescription, value);
} }
/// <summary>
/// Gets the parent of this view model
/// </summary>
public DataModelVisualizationViewModel Parent public DataModelVisualizationViewModel Parent
{ {
get => _parent; get => _parent;
protected set => SetAndNotify(ref _parent, value); protected set => SetAndNotify(ref _parent, value);
} }
/// <summary>
/// Gets or sets a bindable collection containing the children of this view model
/// </summary>
public BindableCollection<DataModelVisualizationViewModel> Children public BindableCollection<DataModelVisualizationViewModel> Children
{ {
get => _children; get => _children;
set => SetAndNotify(ref _children, value); set => SetAndNotify(ref _children, value);
} }
/// <summary>
/// Gets a boolean indicating whether the property being visualized matches the types last provided to
/// <see cref="ApplyTypeFilter" />
/// </summary>
public bool IsMatchingFilteredTypes public bool IsMatchingFilteredTypes
{ {
get => _isMatchingFilteredTypes; get => _isMatchingFilteredTypes;
set => SetAndNotify(ref _isMatchingFilteredTypes, value); private set => SetAndNotify(ref _isMatchingFilteredTypes, value);
} }
/// <summary>
/// Gets or sets a boolean indicating whether the visualization is expanded, exposing the <see cref="Children" />
/// </summary>
public bool IsVisualizationExpanded public bool IsVisualizationExpanded
{ {
get => _isVisualizationExpanded; get => _isVisualizationExpanded;
@ -80,6 +116,9 @@ namespace Artemis.UI.Shared
} }
} }
/// <summary>
/// Gets a user-friendly representation of the <see cref="DataModelPath" />
/// </summary>
public virtual string DisplayPath => DataModelPath != null public virtual string DisplayPath => DataModelPath != null
? string.Join(" ", DataModelPath.Segments.Select(s => s.GetPropertyDescription()?.Name ?? s.Identifier)) ? string.Join(" ", DataModelPath.Segments.Select(s => s.GetPropertyDescription()?.Name ?? s.Identifier))
: null; : null;
@ -91,6 +130,10 @@ namespace Artemis.UI.Shared
/// <param name="configuration">The configuration to apply while updating</param> /// <param name="configuration">The configuration to apply while updating</param>
public abstract void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration); public abstract void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration);
/// <summary>
/// Gets the current value of the property being visualized
/// </summary>
/// <returns>The current value of the property being visualized</returns>
public virtual object GetCurrentValue() public virtual object GetCurrentValue()
{ {
if (IsRootViewModel) if (IsRootViewModel)
@ -99,6 +142,12 @@ namespace Artemis.UI.Shared
return DataModelPath.GetValue(); return DataModelPath.GetValue();
} }
/// <summary>
/// Determines whether the provided types match the type of the property being visualized and sets the result in
/// <see cref="IsMatchingFilteredTypes" />
/// </summary>
/// <param name="looseMatch">Whether the type may be a loose match, meaning it can be cast or converted</param>
/// <param name="filteredTypes">The types to filter</param>
public void ApplyTypeFilter(bool looseMatch, params Type[] filteredTypes) public void ApplyTypeFilter(bool looseMatch, params Type[] filteredTypes)
{ {
if (filteredTypes != null) if (filteredTypes != null)
@ -154,7 +203,7 @@ namespace Artemis.UI.Shared
return; return;
Type modelType = IsRootViewModel ? DataModel.GetType() : DataModelPath.GetPropertyType(); Type modelType = IsRootViewModel ? DataModel.GetType() : DataModelPath.GetPropertyType();
// Add missing static children // Add missing static children
foreach (PropertyInfo propertyInfo in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance).OrderBy(t => t.MetadataToken)) foreach (PropertyInfo propertyInfo in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance).OrderBy(t => t.MetadataToken))
{ {
@ -252,8 +301,14 @@ namespace Artemis.UI.Shared
#region Events #region Events
public event EventHandler UpdateRequested; /// <summary>
/// Occurs when an update to the property this view model visualizes is requested
/// </summary>
public event EventHandler? UpdateRequested;
/// <summary>
/// Invokes the <see cref="UpdateRequested" /> event
/// </summary>
protected virtual void OnUpdateRequested() protected virtual void OnUpdateRequested()
{ {
UpdateRequested?.Invoke(this, EventArgs.Empty); UpdateRequested?.Invoke(this, EventArgs.Empty);
@ -261,14 +316,4 @@ namespace Artemis.UI.Shared
#endregion #endregion
} }
public class DataModelUpdateConfiguration
{
public bool CreateEventChildren { get; }
public DataModelUpdateConfiguration(bool createEventChildren)
{
CreateEventChildren = createEventChildren;
}
}
} }

View File

@ -2,12 +2,16 @@
namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display
{ {
public class DefaultDataModelDisplayViewModel : DataModelDisplayViewModel<object> /// <summary>
/// Represents the default data model display view model that is used when no display viewmodel specific for the type
/// is registered
/// </summary>
internal class DefaultDataModelDisplayViewModel : DataModelDisplayViewModel<object>
{ {
private bool _showNull; private bool _showNull;
private bool _showToString; private bool _showToString;
public DefaultDataModelDisplayViewModel() internal DefaultDataModelDisplayViewModel()
{ {
ShowNull = true; ShowNull = true;
} }
@ -15,7 +19,7 @@ namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display
public bool ShowToString public bool ShowToString
{ {
get => _showToString; get => _showToString;
set => SetAndNotify(ref _showToString, value); private set => SetAndNotify(ref _showToString, value);
} }
public bool ShowNull public bool ShowNull

View File

@ -7,47 +7,74 @@ namespace Artemis.UI.Shared
/// </summary> /// </summary>
public static class SizeObserver public static class SizeObserver
{ {
/// <summary>
/// Gets or sets whether the element should be observed
/// </summary>
public static readonly DependencyProperty ObserveProperty = DependencyProperty.RegisterAttached( public static readonly DependencyProperty ObserveProperty = DependencyProperty.RegisterAttached(
"Observe", "Observe",
typeof(bool), typeof(bool),
typeof(SizeObserver), typeof(SizeObserver),
new FrameworkPropertyMetadata(OnObserveChanged)); new FrameworkPropertyMetadata(OnObserveChanged));
/// <summary>
/// Gets or sets the observed width of the element
/// </summary>
public static readonly DependencyProperty ObservedWidthProperty = DependencyProperty.RegisterAttached( public static readonly DependencyProperty ObservedWidthProperty = DependencyProperty.RegisterAttached(
"ObservedWidth", "ObservedWidth",
typeof(double), typeof(double),
typeof(SizeObserver)); typeof(SizeObserver));
/// <summary>
/// Gets or sets the observed height of the element
/// </summary>
public static readonly DependencyProperty ObservedHeightProperty = DependencyProperty.RegisterAttached( public static readonly DependencyProperty ObservedHeightProperty = DependencyProperty.RegisterAttached(
"ObservedHeight", "ObservedHeight",
typeof(double), typeof(double),
typeof(SizeObserver)); typeof(SizeObserver));
/// <summary>
/// Gets whether the provided <paramref name="frameworkElement" /> is being observed
/// </summary>
public static bool GetObserve(FrameworkElement frameworkElement) public static bool GetObserve(FrameworkElement frameworkElement)
{ {
return (bool) frameworkElement.GetValue(ObserveProperty); return (bool) frameworkElement.GetValue(ObserveProperty);
} }
/// <summary>
/// Sets whether the provided <paramref name="frameworkElement" /> is being observed
/// </summary>
public static void SetObserve(FrameworkElement frameworkElement, bool observe) public static void SetObserve(FrameworkElement frameworkElement, bool observe)
{ {
frameworkElement.SetValue(ObserveProperty, observe); frameworkElement.SetValue(ObserveProperty, observe);
} }
/// <summary>
/// Gets the observed width of the the provided <paramref name="frameworkElement" />
/// </summary>
public static double GetObservedWidth(FrameworkElement frameworkElement) public static double GetObservedWidth(FrameworkElement frameworkElement)
{ {
return (double) frameworkElement.GetValue(ObservedWidthProperty); return (double) frameworkElement.GetValue(ObservedWidthProperty);
} }
/// <summary>
/// Sets the observed width of the the provided <paramref name="frameworkElement" />
/// </summary>
public static void SetObservedWidth(FrameworkElement frameworkElement, double observedWidth) public static void SetObservedWidth(FrameworkElement frameworkElement, double observedWidth)
{ {
frameworkElement.SetValue(ObservedWidthProperty, observedWidth); frameworkElement.SetValue(ObservedWidthProperty, observedWidth);
} }
/// <summary>
/// Gets the observed height of the the provided <paramref name="frameworkElement" />
/// </summary>
public static double GetObservedHeight(FrameworkElement frameworkElement) public static double GetObservedHeight(FrameworkElement frameworkElement)
{ {
return (double) frameworkElement.GetValue(ObservedHeightProperty); return (double) frameworkElement.GetValue(ObservedHeightProperty);
} }
/// <summary>
/// Sets the observed height of the the provided <paramref name="frameworkElement" />
/// </summary>
public static void SetObservedHeight(FrameworkElement frameworkElement, double observedHeight) public static void SetObservedHeight(FrameworkElement frameworkElement, double observedHeight)
{ {
frameworkElement.SetValue(ObservedHeightProperty, observedHeight); frameworkElement.SetValue(ObservedHeightProperty, observedHeight);
@ -63,7 +90,9 @@ namespace Artemis.UI.Shared
UpdateObservedSizesForFrameworkElement(frameworkElement); UpdateObservedSizesForFrameworkElement(frameworkElement);
} }
else else
{
frameworkElement.SizeChanged -= OnFrameworkElementSizeChanged; frameworkElement.SizeChanged -= OnFrameworkElementSizeChanged;
}
} }
private static void OnFrameworkElementSizeChanged(object sender, SizeChangedEventArgs e) private static void OnFrameworkElementSizeChanged(object sender, SizeChangedEventArgs e)

View File

@ -1,15 +1,22 @@
using System; using System;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Shared.Input;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Provides data about selection events raised by <see cref="DataModelDynamicViewModel" />
/// </summary>
public class DataModelInputDynamicEventArgs : EventArgs public class DataModelInputDynamicEventArgs : EventArgs
{ {
public DataModelPath DataModelPath { get; } internal DataModelInputDynamicEventArgs(DataModelPath dataModelPath)
public DataModelInputDynamicEventArgs(DataModelPath dataModelPath)
{ {
DataModelPath = dataModelPath; DataModelPath = dataModelPath;
} }
/// <summary>
/// Gets the data model path that was selected
/// </summary>
public DataModelPath DataModelPath { get; }
} }
} }

View File

@ -1,14 +1,21 @@
using System; using System;
using Artemis.UI.Shared.Input;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Provides data about submit events raised by <see cref="DataModelStaticViewModel" />
/// </summary>
public class DataModelInputStaticEventArgs : EventArgs public class DataModelInputStaticEventArgs : EventArgs
{ {
public object Value { get; } internal DataModelInputStaticEventArgs(object value)
public DataModelInputStaticEventArgs(object value)
{ {
Value = value; Value = value;
} }
/// <summary>
/// The value that was submitted
/// </summary>
public object Value { get; }
} }
} }

View File

@ -3,20 +3,30 @@ using Artemis.Core;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Provides data on profile related events raised by the profile editor
/// </summary>
public class ProfileEventArgs : EventArgs public class ProfileEventArgs : EventArgs
{ {
public ProfileEventArgs(Profile profile) internal ProfileEventArgs(Profile profile)
{ {
Profile = profile; Profile = profile;
} }
public ProfileEventArgs(Profile profile, Profile previousProfile) internal ProfileEventArgs(Profile profile, Profile previousProfile)
{ {
Profile = profile; Profile = profile;
PreviousProfile = previousProfile; PreviousProfile = previousProfile;
} }
/// <summary>
/// Gets the profile the event was raised for
/// </summary>
public Profile Profile { get; } public Profile Profile { get; }
public Profile PreviousProfile { get; }
/// <summary>
/// If applicable, the previous active profile before the event was raised
/// </summary>
public Profile? PreviousProfile { get; }
} }
} }

View File

@ -3,20 +3,30 @@ using Artemis.Core;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary>
/// Provides data on profile element related events raised by the profile editor
/// </summary>
public class RenderProfileElementEventArgs : EventArgs public class RenderProfileElementEventArgs : EventArgs
{ {
public RenderProfileElementEventArgs(RenderProfileElement renderProfileElement) internal RenderProfileElementEventArgs(RenderProfileElement renderProfileElement)
{ {
RenderProfileElement = renderProfileElement; RenderProfileElement = renderProfileElement;
} }
public RenderProfileElementEventArgs(RenderProfileElement renderProfileElement, RenderProfileElement previousRenderProfileElement) internal RenderProfileElementEventArgs(RenderProfileElement renderProfileElement, RenderProfileElement previousRenderProfileElement)
{ {
RenderProfileElement = renderProfileElement; RenderProfileElement = renderProfileElement;
PreviousRenderProfileElement = previousRenderProfileElement; PreviousRenderProfileElement = previousRenderProfileElement;
} }
/// <summary>
/// Gets the profile element the event was raised for
/// </summary>
public RenderProfileElement RenderProfileElement { get; } public RenderProfileElement RenderProfileElement { get; }
public RenderProfileElement PreviousRenderProfileElement { get; }
/// <summary>
/// If applicable, the previous active profile element before the event was raised
/// </summary>
public RenderProfileElement? PreviousRenderProfileElement { get; }
} }
} }

View File

@ -5,7 +5,7 @@ using Artemis.UI.Shared.Services;
namespace Artemis.UI.Shared namespace Artemis.UI.Shared
{ {
/// <summary> /// <summary>
/// Represents a property input registration, registered through <see cref="IProfileEditorService.RegisterPropertyInput"/> /// Represents a property input registration registered through <see cref="IProfileEditorService.RegisterPropertyInput"/>
/// </summary> /// </summary>
public class PropertyInputRegistration public class PropertyInputRegistration
{ {