Many nice features
This commit is contained in:
17
MaterialModernWPF/Service/AdditionalMoments.cs
Normal file
17
MaterialModernWPF/Service/AdditionalMoments.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using Prism.Events;
|
||||
|
||||
namespace MaterialModernWPF.Service
|
||||
{
|
||||
public class AdditionalMoments : CalculationPackage
|
||||
{
|
||||
public AdditionalMoments(IEventAggregator eventAggregator) : base(eventAggregator)
|
||||
{
|
||||
Name = "Additional moments";
|
||||
CalculationViewType = typeof(DetailedGeometryView);
|
||||
}
|
||||
|
||||
public override string Name { get; }
|
||||
public override Type CalculationViewType { get; }
|
||||
}
|
||||
}
|
37
MaterialModernWPF/Service/CalculationPackage.cs
Normal file
37
MaterialModernWPF/Service/CalculationPackage.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using Prism.Events;
|
||||
|
||||
namespace MaterialModernWPF.Service
|
||||
{
|
||||
public abstract class CalculationPackage
|
||||
{
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private bool _isSelected;
|
||||
|
||||
public CalculationPackage(IEventAggregator eventAggregator)
|
||||
{
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set
|
||||
{
|
||||
if (Equals(_isSelected, value)) return;
|
||||
_isSelected = value;
|
||||
_eventAggregator.GetEvent<CalculationPackageSelectionChangedEvent>().Publish((this, value));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Type CalculationViewType { get; }
|
||||
}
|
||||
|
||||
public class CalculationView : UserControl
|
||||
{
|
||||
|
||||
}
|
||||
}
|
40
MaterialModernWPF/Service/CalculationPackageContainer.cs
Normal file
40
MaterialModernWPF/Service/CalculationPackageContainer.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System.Linq;
|
||||
using DryIoc;
|
||||
using Prism.Events;
|
||||
using Prism.Regions;
|
||||
|
||||
namespace MaterialModernWPF.Service
|
||||
{
|
||||
public class CalculationPackageContainer
|
||||
{
|
||||
private readonly IRegionManager _regionManager;
|
||||
private readonly IResolver _resolver;
|
||||
public CalculationPackage[] CalculationPackages { get; }
|
||||
|
||||
public CalculationPackageContainer(
|
||||
IEventAggregator eventAggregator, IRegionManager regionManager,
|
||||
IResolver resolver)
|
||||
{
|
||||
_regionManager = regionManager;
|
||||
_resolver = resolver;
|
||||
CalculationPackages = resolver.ResolveMany<CalculationPackage>().ToArray();
|
||||
eventAggregator.GetEvent<CalculationPackageSelectionChangedEvent>().Subscribe(SelectionChanged);
|
||||
}
|
||||
|
||||
private void SelectionChanged((CalculationPackage sender, bool isSelected) payload)
|
||||
{
|
||||
var viewKey = payload.sender.CalculationViewType.FullName;
|
||||
var region = _regionManager.Regions[Constants.PackagesRegion];
|
||||
if (payload.isSelected)
|
||||
{
|
||||
var view = _resolver.Resolve(payload.sender.CalculationViewType);
|
||||
region.Add(view, viewKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
var view = region.GetView(viewKey);
|
||||
region.Remove(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
using Prism.Events;
|
||||
|
||||
namespace MaterialModernWPF.Service
|
||||
{
|
||||
public class CalculationPackageSelectionChangedEvent : PubSubEvent<(CalculationPackage, bool)>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
17
MaterialModernWPF/Service/DetailedGeometryPackage.cs
Normal file
17
MaterialModernWPF/Service/DetailedGeometryPackage.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using Prism.Events;
|
||||
|
||||
namespace MaterialModernWPF.Service
|
||||
{
|
||||
public class DetailedGeometryPackage : CalculationPackage
|
||||
{
|
||||
public DetailedGeometryPackage(IEventAggregator eventAggregator) : base(eventAggregator)
|
||||
{
|
||||
Name = "Detailed Geometry";
|
||||
CalculationViewType = typeof(DetailedGeometryView);
|
||||
}
|
||||
|
||||
public override string Name { get; }
|
||||
public override Type CalculationViewType { get; }
|
||||
}
|
||||
}
|
14
MaterialModernWPF/Service/DetailedGeometryView.xaml
Normal file
14
MaterialModernWPF/Service/DetailedGeometryView.xaml
Normal file
@ -0,0 +1,14 @@
|
||||
<local:CalculationView
|
||||
x:Class="MaterialModernWPF.Service.DetailedGeometryView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:MaterialModernWPF.Service"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<GroupBox Margin="10" Header="Detailed Geometry">
|
||||
<TextBlock FontSize="100" Text="Hallo Welt" />
|
||||
</GroupBox>
|
||||
</local:CalculationView>
|
28
MaterialModernWPF/Service/DetailedGeometryView.xaml.cs
Normal file
28
MaterialModernWPF/Service/DetailedGeometryView.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MaterialModernWPF.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für DetailedGeometryView.xaml
|
||||
/// </summary>
|
||||
public partial class DetailedGeometryView : CalculationView
|
||||
{
|
||||
public DetailedGeometryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user