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:
parent
32e80c3d05
commit
5683fd44df
@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
using Artemis.Core.Services;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a layer brush registration
|
||||
/// Represents a layer brush registration returned by calling <see cref="ILayerBrushService.RegisterLayerBrush"/>
|
||||
/// </summary>
|
||||
public class LayerBrushRegistration
|
||||
{
|
||||
|
||||
@ -116,6 +116,7 @@ namespace Artemis.UI.Shared
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AttachView(UIElement view)
|
||||
{
|
||||
if (View != null)
|
||||
@ -131,6 +132,7 @@ namespace Artemis.UI.Shared
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public UIElement View { get; set; }
|
||||
}
|
||||
}
|
||||
@ -5,11 +5,16 @@ using Artemis.UI.Shared.Services;
|
||||
|
||||
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
|
||||
{
|
||||
private readonly IDataModelUIService _dataModelUIService;
|
||||
|
||||
public DataModelVisualizationRegistration(IDataModelUIService dataModelUIService,
|
||||
internal DataModelVisualizationRegistration(IDataModelUIService dataModelUIService,
|
||||
RegistrationType registrationType,
|
||||
Plugin plugin,
|
||||
Type supportedType,
|
||||
@ -25,12 +30,30 @@ namespace Artemis.UI.Shared
|
||||
Plugin.Disabled += InstanceOnDisabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of registration, either a display or an input
|
||||
/// </summary>
|
||||
public RegistrationType RegistrationType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin that registered the visualization
|
||||
/// </summary>
|
||||
public Plugin Plugin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type supported by the visualization
|
||||
/// </summary>
|
||||
public Type SupportedType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view model type of the visualization
|
||||
/// </summary>
|
||||
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()
|
||||
{
|
||||
@ -38,7 +61,7 @@ namespace Artemis.UI.Shared
|
||||
Plugin.Disabled -= InstanceOnDisabled;
|
||||
}
|
||||
|
||||
private void InstanceOnDisabled(object sender, EventArgs e)
|
||||
private void InstanceOnDisabled(object? sender, EventArgs e)
|
||||
{
|
||||
if (RegistrationType == RegistrationType.Input)
|
||||
_dataModelUIService.RemoveDataModelInput(this);
|
||||
@ -47,9 +70,19 @@ namespace Artemis.UI.Shared
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a type of data model visualization registration
|
||||
/// </summary>
|
||||
public enum RegistrationType
|
||||
{
|
||||
/// <summary>
|
||||
/// A visualization used for displaying values
|
||||
/// </summary>
|
||||
Display,
|
||||
|
||||
/// <summary>
|
||||
/// A visualization used for inputting values
|
||||
/// </summary>
|
||||
Input
|
||||
}
|
||||
}
|
||||
@ -10,9 +10,6 @@ using Artemis.UI.Shared.Services;
|
||||
using MaterialDesignColors.ColorManipulation;
|
||||
using Stylet;
|
||||
|
||||
// Remove, annoying while working on it
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Artemis.UI.Shared.Input
|
||||
{
|
||||
public class DataModelDynamicViewModel : PropertyChangedBase, IDisposable
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,54 +4,66 @@ using Artemis.UI.Shared.Services;
|
||||
|
||||
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
|
||||
{
|
||||
private int _index;
|
||||
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);
|
||||
ListType = listType;
|
||||
DisplayViewModel = displayViewModel;
|
||||
}
|
||||
|
||||
public DataModelListPropertyViewModel(Type listType) : base(null, null, null)
|
||||
internal DataModelListPropertyViewModel(Type listType) : base(null, null, null)
|
||||
{
|
||||
DataModel = ListPredicateWrapperDataModel.Create(listType);
|
||||
ListType = listType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the element within the list
|
||||
/// </summary>
|
||||
public int 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
|
||||
{
|
||||
get => _listType;
|
||||
set => SetAndNotify(ref _listType, value);
|
||||
private set => SetAndNotify(ref _listType, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override object GetCurrentValue()
|
||||
{
|
||||
return DisplayValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||
{
|
||||
// Display value gets updated by parent, don't do anything if it is null
|
||||
if (DisplayValue == null)
|
||||
return;
|
||||
|
||||
((ListPredicateWrapperDataModel)DataModel).UntypedValue = DisplayValue;
|
||||
((ListPredicateWrapperDataModel) DataModel).UntypedValue = DisplayValue;
|
||||
|
||||
if (DisplayViewModel == null)
|
||||
DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(DisplayValue.GetType(), PropertyDescription, true);
|
||||
|
||||
ListType = DisplayValue.GetType();
|
||||
UpdateDisplayParameters();
|
||||
DisplayViewModel?.UpdateValue(DisplayValue);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -7,44 +7,69 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a view model that visualizes a list data model property
|
||||
/// </summary>
|
||||
public class DataModelListViewModel : DataModelVisualizationViewModel
|
||||
{
|
||||
private string _countDisplay;
|
||||
private IEnumerable _list;
|
||||
private int _listCount;
|
||||
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>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the list that is being visualized
|
||||
/// </summary>
|
||||
public IEnumerable 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
|
||||
{
|
||||
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
|
||||
{
|
||||
get => _displayValueType;
|
||||
set => SetAndNotify(ref _displayValueType, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a human readable display count
|
||||
/// </summary>
|
||||
public string CountDisplay
|
||||
{
|
||||
get => _countDisplay;
|
||||
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)
|
||||
{
|
||||
if (Parent != null && !Parent.IsVisualizationExpanded)
|
||||
@ -101,7 +126,7 @@ namespace Artemis.UI.Shared
|
||||
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
|
||||
DataModelDisplayViewModel typeViewModel = dataModelUIService.GetDataModelDisplayViewModel(listType, PropertyDescription);
|
||||
|
||||
@ -5,27 +5,38 @@ using Artemis.UI.Shared.Services;
|
||||
|
||||
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
|
||||
{
|
||||
private object _displayValue;
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
get => _displayValue;
|
||||
set => SetAndNotify(ref _displayValue, value);
|
||||
private set => SetAndNotify(ref _displayValue, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||
{
|
||||
DisplayValueType = DataModelPath?.GetPropertyType();
|
||||
@ -48,6 +59,7 @@ namespace Artemis.UI.Shared
|
||||
dataModelVisualizationViewModel.Update(dataModelUIService, configuration);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override object GetCurrentValue()
|
||||
{
|
||||
if (Parent == null || Parent.IsRootViewModel || IsRootViewModel)
|
||||
|
||||
@ -5,34 +5,49 @@ using Artemis.UI.Shared.Services;
|
||||
|
||||
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
|
||||
{
|
||||
private object _displayValue;
|
||||
private DataModelDisplayViewModel _displayViewModel;
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
get => _displayViewModel;
|
||||
set => SetAndNotify(ref _displayViewModel, value);
|
||||
internal set => SetAndNotify(ref _displayViewModel, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||
{
|
||||
if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel)
|
||||
@ -47,11 +62,6 @@ namespace Artemis.UI.Shared
|
||||
DisplayValue = GetCurrentValue();
|
||||
DisplayValueType = DisplayValue != null ? DisplayValue.GetType() : DataModelPath.GetPropertyType();
|
||||
|
||||
UpdateDisplayParameters();
|
||||
}
|
||||
|
||||
protected void UpdateDisplayParameters()
|
||||
{
|
||||
DisplayViewModel?.UpdateValue(DisplayValue);
|
||||
}
|
||||
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,9 @@ using Stylet;
|
||||
|
||||
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
|
||||
{
|
||||
private const int MaxDepth = 4;
|
||||
@ -34,42 +37,75 @@ namespace Artemis.UI.Shared
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data model path to the property this view model is visualizing
|
||||
/// </summary>
|
||||
public DataModelPath DataModelPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string representation of the path backing this model
|
||||
/// </summary>
|
||||
public string Path => DataModelPath?.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property depth of the view model
|
||||
/// </summary>
|
||||
public int Depth { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data model backing this view model
|
||||
/// </summary>
|
||||
public DataModel DataModel
|
||||
{
|
||||
get => _dataModel;
|
||||
protected set => SetAndNotify(ref _dataModel, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property description of the property this view model is visualizing
|
||||
/// </summary>
|
||||
public DataModelPropertyAttribute PropertyDescription
|
||||
{
|
||||
get => _propertyDescription;
|
||||
protected set => SetAndNotify(ref _propertyDescription, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent of this view model
|
||||
/// </summary>
|
||||
public DataModelVisualizationViewModel Parent
|
||||
{
|
||||
get => _parent;
|
||||
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
|
||||
{
|
||||
get => _children;
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
? string.Join(" › ", DataModelPath.Segments.Select(s => s.GetPropertyDescription()?.Name ?? s.Identifier))
|
||||
: null;
|
||||
@ -91,6 +130,10 @@ namespace Artemis.UI.Shared
|
||||
/// <param name="configuration">The configuration to apply while updating</param>
|
||||
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()
|
||||
{
|
||||
if (IsRootViewModel)
|
||||
@ -99,6 +142,12 @@ namespace Artemis.UI.Shared
|
||||
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)
|
||||
{
|
||||
if (filteredTypes != null)
|
||||
@ -154,7 +203,7 @@ namespace Artemis.UI.Shared
|
||||
return;
|
||||
|
||||
Type modelType = IsRootViewModel ? DataModel.GetType() : DataModelPath.GetPropertyType();
|
||||
|
||||
|
||||
// Add missing static children
|
||||
foreach (PropertyInfo propertyInfo in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance).OrderBy(t => t.MetadataToken))
|
||||
{
|
||||
@ -252,8 +301,14 @@ namespace Artemis.UI.Shared
|
||||
|
||||
#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()
|
||||
{
|
||||
UpdateRequested?.Invoke(this, EventArgs.Empty);
|
||||
@ -261,14 +316,4 @@ namespace Artemis.UI.Shared
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class DataModelUpdateConfiguration
|
||||
{
|
||||
public bool CreateEventChildren { get; }
|
||||
|
||||
public DataModelUpdateConfiguration(bool createEventChildren)
|
||||
{
|
||||
CreateEventChildren = createEventChildren;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,12 +2,16 @@
|
||||
|
||||
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 _showToString;
|
||||
|
||||
public DefaultDataModelDisplayViewModel()
|
||||
internal DefaultDataModelDisplayViewModel()
|
||||
{
|
||||
ShowNull = true;
|
||||
}
|
||||
@ -15,7 +19,7 @@ namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display
|
||||
public bool ShowToString
|
||||
{
|
||||
get => _showToString;
|
||||
set => SetAndNotify(ref _showToString, value);
|
||||
private set => SetAndNotify(ref _showToString, value);
|
||||
}
|
||||
|
||||
public bool ShowNull
|
||||
|
||||
@ -7,47 +7,74 @@ namespace Artemis.UI.Shared
|
||||
/// </summary>
|
||||
public static class SizeObserver
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets whether the element should be observed
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ObserveProperty = DependencyProperty.RegisterAttached(
|
||||
"Observe",
|
||||
typeof(bool),
|
||||
typeof(SizeObserver),
|
||||
new FrameworkPropertyMetadata(OnObserveChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the observed width of the element
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ObservedWidthProperty = DependencyProperty.RegisterAttached(
|
||||
"ObservedWidth",
|
||||
typeof(double),
|
||||
typeof(SizeObserver));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the observed height of the element
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ObservedHeightProperty = DependencyProperty.RegisterAttached(
|
||||
"ObservedHeight",
|
||||
typeof(double),
|
||||
typeof(SizeObserver));
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the provided <paramref name="frameworkElement" /> is being observed
|
||||
/// </summary>
|
||||
public static bool GetObserve(FrameworkElement frameworkElement)
|
||||
{
|
||||
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)
|
||||
{
|
||||
frameworkElement.SetValue(ObserveProperty, observe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the observed width of the the provided <paramref name="frameworkElement" />
|
||||
/// </summary>
|
||||
public static double GetObservedWidth(FrameworkElement frameworkElement)
|
||||
{
|
||||
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)
|
||||
{
|
||||
frameworkElement.SetValue(ObservedWidthProperty, observedWidth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the observed height of the the provided <paramref name="frameworkElement" />
|
||||
/// </summary>
|
||||
public static double GetObservedHeight(FrameworkElement frameworkElement)
|
||||
{
|
||||
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)
|
||||
{
|
||||
frameworkElement.SetValue(ObservedHeightProperty, observedHeight);
|
||||
@ -63,7 +90,9 @@ namespace Artemis.UI.Shared
|
||||
UpdateObservedSizesForFrameworkElement(frameworkElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
frameworkElement.SizeChanged -= OnFrameworkElementSizeChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnFrameworkElementSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
|
||||
@ -1,15 +1,22 @@
|
||||
using System;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Input;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data about selection events raised by <see cref="DataModelDynamicViewModel" />
|
||||
/// </summary>
|
||||
public class DataModelInputDynamicEventArgs : EventArgs
|
||||
{
|
||||
public DataModelPath DataModelPath { get; }
|
||||
|
||||
public DataModelInputDynamicEventArgs(DataModelPath dataModelPath)
|
||||
internal DataModelInputDynamicEventArgs(DataModelPath dataModelPath)
|
||||
{
|
||||
DataModelPath = dataModelPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data model path that was selected
|
||||
/// </summary>
|
||||
public DataModelPath DataModelPath { get; }
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,21 @@
|
||||
using System;
|
||||
using Artemis.UI.Shared.Input;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data about submit events raised by <see cref="DataModelStaticViewModel" />
|
||||
/// </summary>
|
||||
public class DataModelInputStaticEventArgs : EventArgs
|
||||
{
|
||||
public object Value { get; }
|
||||
|
||||
public DataModelInputStaticEventArgs(object value)
|
||||
internal DataModelInputStaticEventArgs(object value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value that was submitted
|
||||
/// </summary>
|
||||
public object Value { get; }
|
||||
}
|
||||
}
|
||||
@ -3,20 +3,30 @@ using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data on profile related events raised by the profile editor
|
||||
/// </summary>
|
||||
public class ProfileEventArgs : EventArgs
|
||||
{
|
||||
public ProfileEventArgs(Profile profile)
|
||||
internal ProfileEventArgs(Profile profile)
|
||||
{
|
||||
Profile = profile;
|
||||
}
|
||||
|
||||
public ProfileEventArgs(Profile profile, Profile previousProfile)
|
||||
internal ProfileEventArgs(Profile profile, Profile previousProfile)
|
||||
{
|
||||
Profile = profile;
|
||||
PreviousProfile = previousProfile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile the event was raised for
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@ -3,20 +3,30 @@ using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data on profile element related events raised by the profile editor
|
||||
/// </summary>
|
||||
public class RenderProfileElementEventArgs : EventArgs
|
||||
{
|
||||
public RenderProfileElementEventArgs(RenderProfileElement renderProfileElement)
|
||||
internal RenderProfileElementEventArgs(RenderProfileElement renderProfileElement)
|
||||
{
|
||||
RenderProfileElement = renderProfileElement;
|
||||
}
|
||||
|
||||
public RenderProfileElementEventArgs(RenderProfileElement renderProfileElement, RenderProfileElement previousRenderProfileElement)
|
||||
internal RenderProfileElementEventArgs(RenderProfileElement renderProfileElement, RenderProfileElement previousRenderProfileElement)
|
||||
{
|
||||
RenderProfileElement = renderProfileElement;
|
||||
PreviousRenderProfileElement = previousRenderProfileElement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile element the event was raised for
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ using Artemis.UI.Shared.Services;
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a property input registration, registered through <see cref="IProfileEditorService.RegisterPropertyInput"/>
|
||||
/// Represents a property input registration registered through <see cref="IProfileEditorService.RegisterPropertyInput"/>
|
||||
/// </summary>
|
||||
public class PropertyInputRegistration
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user