diff --git a/samples/WpfSamplesHost/BarChart.cs b/samples/WpfSamplesHost/BarChart.cs index 93be77a..efce316 100644 --- a/samples/WpfSamplesHost/BarChart.cs +++ b/samples/WpfSamplesHost/BarChart.cs @@ -7,7 +7,7 @@ using Microsoft.StandardUI; namespace SimpleControls.Wpf { - public class BarChart : StandardControl, IBarChart + public class BarChart : StandardControl, IBarChart { public static readonly System.Windows.DependencyProperty EntriesProperty = PropertyUtils.Register(nameof(Entries), typeof(IEnumerable), typeof(BarChart), null); public static readonly System.Windows.DependencyProperty BackgroundColorProperty = PropertyUtils.Register(nameof(BackgroundColor), typeof(ColorWpf), typeof(BarChart), ColorWpf.Default); diff --git a/samples/WpfSamplesHost/PointChart.cs b/samples/WpfSamplesHost/PointChart.cs index 9420c20..d47e695 100644 --- a/samples/WpfSamplesHost/PointChart.cs +++ b/samples/WpfSamplesHost/PointChart.cs @@ -7,7 +7,7 @@ using Microsoft.StandardUI; namespace SimpleControls.Wpf { - public class PointChart : StandardControl, IPointChart + public class PointChart : StandardControl, IPointChart { public static readonly System.Windows.DependencyProperty EntriesProperty = PropertyUtils.Register(nameof(Entries), typeof(IEnumerable), typeof(PointChart), null); public static readonly System.Windows.DependencyProperty BackgroundColorProperty = PropertyUtils.Register(nameof(BackgroundColor), typeof(ColorWpf), typeof(PointChart), ColorWpf.Default); diff --git a/src/StandardUI.WPF/StandardControl.cs b/src/StandardUI.WPF/StandardControl.cs index c73b809..15a6260 100644 --- a/src/StandardUI.WPF/StandardControl.cs +++ b/src/StandardUI.WPF/StandardControl.cs @@ -4,13 +4,13 @@ using System.Windows.Media; namespace Microsoft.StandardUI.Wpf { - public class StandardControl : System.Windows.Controls.Control, IControl, IStandardControlEnvironmentPeer where T : IControl + public class StandardControl : System.Windows.Controls.Control, IControl, IStandardControlEnvironmentPeer { - private StandardControlImplementation _implementation; + private StandardControlImplementation _implementation; private StandardUIFrameworkElement? _buildContent; private bool _invalid = true; - protected void InitImplementation(StandardControlImplementation implementation) + protected void InitImplementation(StandardControlImplementation implementation) { _implementation = implementation; } diff --git a/src/StandardUI/Controls/StandardControlImplementation.cs b/src/StandardUI/Controls/StandardControlImplementation.cs index 96b0d8a..3f9ca91 100644 --- a/src/StandardUI/Controls/StandardControlImplementation.cs +++ b/src/StandardUI/Controls/StandardControlImplementation.cs @@ -2,13 +2,13 @@ namespace Microsoft.StandardUI.Controls { - public abstract class StandardControlImplementation where T : IControl + public abstract class StandardControlImplementation { - public T Control { get; } + IStandardControlEnvironmentPeer _environmentPeer; - public StandardControlImplementation(T control) + public StandardControlImplementation(IStandardControlEnvironmentPeer environmentPeer) { - Control = control; + _environmentPeer = environmentPeer; } /// @@ -69,7 +69,7 @@ namespace Microsoft.StandardUI.Controls protected virtual Size MeasureOverride(Size availableSize) { - IUIElement? buildContent = EnvironmentPeer.BuildContent; + IUIElement? buildContent = _environmentPeer.BuildContent; // By default, return the size of the content if (buildContent != null) @@ -83,7 +83,7 @@ namespace Microsoft.StandardUI.Controls protected virtual Size ArrangeOverride(Size finalSize) { - IUIElement? buildContent = EnvironmentPeer.BuildContent; + IUIElement? buildContent = _environmentPeer.BuildContent; // By default, give all the space to the content if (buildContent != null) @@ -94,7 +94,15 @@ namespace Microsoft.StandardUI.Controls return finalSize; } + } - private IStandardControlEnvironmentPeer EnvironmentPeer => (IStandardControlEnvironmentPeer)Control; + public abstract class StandardControlImplementation : StandardControlImplementation where T : IControl + { + public T Control { get; } + + public StandardControlImplementation(T control) : base((IStandardControlEnvironmentPeer)control) + { + Control = control; + } } } diff --git a/src/StandardUI/Controls/StandardUserControlImplementation.cs b/src/StandardUI/Controls/StandardUserControlImplementation.cs deleted file mode 100644 index 1523562..0000000 --- a/src/StandardUI/Controls/StandardUserControlImplementation.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Microsoft.StandardUI.Controls -{ - public class StandardUserControlImplementation : StandardControlImplementation where TControl : IControl - { - public StandardUserControlImplementation(TControl control) : base(control) - { - } - - public IUIElement? Content { get; set; } - - protected override Size MeasureOverride(Size availableSize) - { - // By default, return the size of the content - if (Content != null) - { - Content.Measure(availableSize); - return Content.DesiredSize; - } - - return new Size(0.0, 0.0); - } - - protected override Size ArrangeOverride(Size finalSize) - { - // By default, give all the space to the content - if (Content != null) - { - Rect finalRect = new Rect(0, 0, finalSize.Width, finalSize.Height); - Content.Arrange(finalRect); - } - - return finalSize; - } - } -}