Fixed compilation issues on UWP/WPF

This commit is contained in:
Jon Lipsky 2019-07-09 17:13:18 -05:00
Родитель 50290a238d
Коммит 28eb642a3f
27 изменённых файлов: 295 добавлений и 84 удалений

Просмотреть файл

@ -1,13 +1,24 @@
using System.Drawing;
using Size = Windows.Foundation.Size;
using System.Numerics;
using UWPSize = Windows.Foundation.Size;
namespace HotUI.UWP
{
public static class FoundationExtensions
{
public static Size ToSize(this Size size)
public static Size ToSize(this Vector2 size)
{
return new Size((float)size.X, (float)size.Y);
}
public static Size ToSize(this UWPSize size)
{
return new Size((float) size.Width, (float) size.Height);
}
public static UWPSize ToSize(this Size size)
{
return new UWPSize((float)size.Width, (float)size.Height);
}
}
}

Просмотреть файл

@ -5,7 +5,7 @@ using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using HotUI.Layout;
using Size = Windows.Foundation.Size;
using UwpSize = Windows.Foundation.Size;
namespace HotUI.UWP.Handlers
{
@ -60,6 +60,13 @@ namespace HotUI.UWP.Handlers
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void SetView(View view)
{
_view = view as AbstractLayout;
@ -137,19 +144,20 @@ namespace HotUI.UWP.Handlers
private void LayoutSubviews()
{
_layoutManager.Layout(this, this, _view);
var measure = _layoutManager.Measure(this, this, _view, ActualSize.ToSize());
_layoutManager.Layout(this, this, _view, measure);
}
protected override Size MeasureOverride(Size availableSize)
protected override UwpSize MeasureOverride(UwpSize availableSize)
{
var size = new Size();
var size = new UwpSize();
foreach (var child in Children)
{
if (child is Windows.UI.Xaml.Controls.ListView listView)
{
var sizeToUse = GetMeasuredSize(listView, availableSize);
child.Measure(sizeToUse);
var sizeToUse = GetMeasuredSize(listView, availableSize.ToSize());
child.Measure(sizeToUse.ToSize());
size.Height = Math.Max(child.DesiredSize.Height, size.Height);
size.Width = Math.Max(child.DesiredSize.Width, size.Width);
}
@ -169,7 +177,7 @@ namespace HotUI.UWP.Handlers
return availableSize;
}
protected override Size ArrangeOverride(Size finalSize)
protected override UwpSize ArrangeOverride(UwpSize finalSize)
{
Width = finalSize.Width;
Height = finalSize.Height;
@ -177,5 +185,10 @@ namespace HotUI.UWP.Handlers
return finalSize;
}
public Size Measure(UIElement view, Size available)
{
return view.DesiredSize.ToSize();
}
}
}

Просмотреть файл

@ -9,6 +9,14 @@ namespace HotUI.UWP.Handlers
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void SetView(View view)
{
_view = view as AbstractLayout;

Просмотреть файл

@ -9,7 +9,7 @@ namespace HotUI.UWP.Handlers
{
public class ButtonHandler : UWPButton, IUIElement
{
public static readonly PropertyMapper<Button, UIElement, ButtonHandler> Mapper = new PropertyMapper<Button, UIElement, ButtonHandler>()
public static readonly PropertyMapper<Button> Mapper = new PropertyMapper<Button>()
{
[nameof(Button.Text)] = MapTextProperty
};
@ -23,7 +23,15 @@ namespace HotUI.UWP.Handlers
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
_button = null;
@ -42,8 +50,9 @@ namespace HotUI.UWP.Handlers
private void HandleClick(object sender, RoutedEventArgs e) => _button?.OnClick();
public static bool MapTextProperty(UWPButton nativeButton, Button virtualButton)
public static bool MapTextProperty(IViewHandler viewHandler, Button virtualButton)
{
var nativeButton = (UWPButton)viewHandler.NativeView;
nativeButton.Content = virtualButton.Text;
return true;
}

Просмотреть файл

@ -13,7 +13,15 @@ namespace HotUI.UWP
public UIElement View =>_view;
public void Remove (View view)
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove (View view)
{
ContentView = null;
}

Просмотреть файл

@ -12,7 +12,7 @@ namespace HotUI.UWP.Handlers
{
public class ImageHandler : IUIElement
{
public static readonly PropertyMapper<Image, UIElement, ImageHandler> Mapper = new PropertyMapper<Image, UIElement, ImageHandler>()
public static readonly PropertyMapper<Image> Mapper = new PropertyMapper<Image>()
{
[nameof(Image.Source)] = MapSourceProperty
};
@ -27,7 +27,15 @@ namespace HotUI.UWP.Handlers
}
public UIElement View => NativeImageView;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -43,8 +51,9 @@ namespace HotUI.UWP.Handlers
Mapper.UpdateProperty(this, _image, property);
}
public static bool MapSourceProperty(ImageHandler nativeView, Image virtualView)
public static bool MapSourceProperty(IViewHandler viewHandler, Image virtualView)
{
var nativeView = (ImageHandler)viewHandler;
nativeView.UpdateSource(virtualView.Source);
return true;
}

Просмотреть файл

@ -9,7 +9,7 @@ namespace HotUI.UWP.Handlers
{
public class ListViewHandler : UWPListView, IUIElement
{
public static readonly PropertyMapper<ListView, UIElement, ListViewHandler> Mapper = new PropertyMapper<ListView, UIElement, ListViewHandler>()
public static readonly PropertyMapper<ListView> Mapper = new PropertyMapper<ListView>()
{
[nameof(Text.Value)] = MapListProperty
};
@ -17,7 +17,14 @@ namespace HotUI.UWP.Handlers
internal ListView listView;
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -33,11 +40,12 @@ namespace HotUI.UWP.Handlers
Mapper.UpdateProperty(this, listView, property);
}
public static bool MapListProperty(ListViewHandler nativeView, ListView virtualView)
public static bool MapListProperty(IViewHandler viewHandler, ListView virtualView)
{
var nativeView = (UWPListView)viewHandler.NativeView;
foreach (var item in virtualView.List)
{
nativeView.Items?.Add(new ListViewHandlerItem(nativeView, item));
nativeView.Items?.Add(new ListViewHandlerItem((ListViewHandler)viewHandler, item));
}
return true;
}

Просмотреть файл

@ -8,7 +8,7 @@ namespace HotUI.UWP.Handlers
{
public class ScrollViewHandler : IUIElement
{
public static readonly PropertyMapper<ScrollView, UIElement, UWPScrollView> Mapper = new PropertyMapper<ScrollView, UIElement, UWPScrollView>()
public static readonly PropertyMapper<ScrollView> Mapper = new PropertyMapper<ScrollView>()
{
};
@ -23,6 +23,14 @@ namespace HotUI.UWP.Handlers
public UIElement View => _nativeScrollView;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -36,12 +44,12 @@ namespace HotUI.UWP.Handlers
_nativeScrollView.Content = _content;
}
Mapper.UpdateProperties(_nativeScrollView, _virtualScrollView);
Mapper.UpdateProperties(this, _virtualScrollView);
}
public void UpdateValue(string property, object value)
{
Mapper.UpdateProperty(_nativeScrollView, _virtualScrollView, property);
Mapper.UpdateProperty(this, _virtualScrollView, property);
}
}
}

Просмотреть файл

@ -9,7 +9,7 @@ namespace HotUI.UWP.Handlers
{
public class TextFieldHandler : UWPTextField, IUIElement
{
public static readonly PropertyMapper<TextField, UIElement, TextFieldHandler> Mapper = new PropertyMapper<TextField, UIElement, TextFieldHandler>()
public static readonly PropertyMapper<TextField> Mapper = new PropertyMapper<TextField>()
{
[nameof(TextField.Text)] = MapTextProperty
};
@ -17,7 +17,15 @@ namespace HotUI.UWP.Handlers
private TextField _textField;
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -33,8 +41,9 @@ namespace HotUI.UWP.Handlers
Mapper.UpdateProperty(this, _textField, property);
}
public static bool MapTextProperty(UWPTextField nativeView, TextField virtualView)
public static bool MapTextProperty(IViewHandler viewHandler, TextField virtualView)
{
var nativeView = (UWPTextField)viewHandler.NativeView;
nativeView.Text = virtualView.Text;
return true;
}

Просмотреть файл

@ -9,7 +9,7 @@ namespace HotUI.UWP.Handlers
{
public class TextHandler : IUIElement
{
public static readonly PropertyMapper<Text, UIElement, UWPLabel> Mapper = new PropertyMapper<Text, UIElement, UWPLabel>()
public static readonly PropertyMapper<Text> Mapper = new PropertyMapper<Text>()
{
[nameof(Text.Value)] = MapValueProperty
};
@ -24,6 +24,13 @@ namespace HotUI.UWP.Handlers
public UIElement View => _textBlock;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -31,16 +38,17 @@ namespace HotUI.UWP.Handlers
public void SetView(View view)
{
_text = view as Text;
Mapper.UpdateProperties(_textBlock, _text);
Mapper.UpdateProperties(this, _text);
}
public void UpdateValue(string property, object value)
{
Mapper.UpdateProperty(_textBlock, _text, property);
Mapper.UpdateProperty(this, _text, property);
}
public static bool MapValueProperty(UWPLabel nativeView, Text virtualView)
public static bool MapValueProperty(IViewHandler viewHandler, Text virtualView)
{
var nativeView = (UWPLabel)viewHandler.NativeView;
nativeView.Text = virtualView.Value;
return true;
}

Просмотреть файл

@ -7,7 +7,7 @@ namespace HotUI.UWP
{
public class ToggleHandler : IUIElement
{
public static readonly PropertyMapper<Toggle, UIElement, ToggleSwitch> Mapper = new PropertyMapper<Toggle, UIElement, ToggleSwitch> ()
public static readonly PropertyMapper<Toggle> Mapper = new PropertyMapper<Toggle> ()
{
[nameof(Toggle.IsOn)] = MapIsOnProperty
};
@ -25,6 +25,13 @@ namespace HotUI.UWP
public UIElement View => _nativeToggle;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
_virtualToggle = null;
@ -33,16 +40,17 @@ namespace HotUI.UWP
public void SetView(View view)
{
_virtualToggle = view as Toggle;
Mapper.UpdateProperties(_nativeToggle, _virtualToggle);
Mapper.UpdateProperties(this, _virtualToggle);
}
public void UpdateValue(string property, object value)
{
Mapper.UpdateProperty(_nativeToggle, _virtualToggle, property);
Mapper.UpdateProperty(this, _virtualToggle, property);
}
public static bool MapIsOnProperty(ToggleSwitch nativeView, Toggle virtualView)
public static bool MapIsOnProperty(IViewHandler viewHandler, Toggle virtualView)
{
var nativeView = (ToggleSwitch)viewHandler.NativeView;
nativeView.IsOn = virtualView.IsOn;
return true;
}

Просмотреть файл

@ -9,7 +9,7 @@ namespace HotUI.UWP.Handlers
{
public class ViewHandler : IUIElement
{
public static readonly PropertyMapper<View, UIElement, ViewHandler> Mapper = new PropertyMapper<View, UIElement, ViewHandler>()
public static readonly PropertyMapper<View> Mapper = new PropertyMapper<View>()
{
};
@ -21,6 +21,14 @@ namespace HotUI.UWP.Handlers
public UIElement View => _body;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
_view = null;

Просмотреть файл

@ -1,13 +1,18 @@
using System.Drawing;
using Size = System.Windows.Size;
using WPFSize = System.Windows.Size;
namespace HotUI.WPF
{
public static class DrawingExtensions
{
public static Size ToSize(this Size size)
public static Size ToSize(this WPFSize size)
{
return new Size((float) size.Width, (float) size.Height);
return new Size((float)size.Width, (float)size.Height);
}
public static WPFSize ToSize(this Size size)
{
return new WPFSize((float)size.Width, (float)size.Height);
}
}
}

Просмотреть файл

@ -4,11 +4,11 @@ using System.Drawing;
using System.Windows;
using System.Windows.Controls;
using HotUI.Layout;
using Size = System.Windows.Size;
using WPFSize = System.Windows.Size;
namespace HotUI.WPF.Handlers
{
public abstract class AbstractLayoutHandler : Panel, IUIElement, ILayoutHandler<UIElement>
public abstract class AbstractLayoutHandler : Panel, WPFViewHandler, ILayoutHandler<UIElement>
{
private readonly ILayoutManager<UIElement> _layoutManager;
private AbstractLayout _view;
@ -47,7 +47,7 @@ namespace HotUI.WPF.Handlers
public void SetSize(UIElement view, float width, float height)
{
view.RenderSize = new Size(width, height);
view.RenderSize = new WPFSize(width, height);
if (view is FrameworkElement element)
{
element.Width = view.RenderSize.Width;
@ -62,6 +62,14 @@ namespace HotUI.WPF.Handlers
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void SetView(View view)
{
_view = view as AbstractLayout;
@ -139,12 +147,13 @@ namespace HotUI.WPF.Handlers
private void LayoutSubviews()
{
_layoutManager.Layout(this, this, _view);
var measure = _layoutManager.Measure(this, this, _view, RenderSize.ToSize());
_layoutManager.Layout(this, this, _view, measure);
}
protected override Size MeasureOverride(Size availableSize)
protected override WPFSize MeasureOverride(WPFSize availableSize)
{
var size = new Size();
var size = new WPFSize();
for (var i = 0; i < InternalChildren.Count; i++)
{
@ -152,8 +161,8 @@ namespace HotUI.WPF.Handlers
if (child is System.Windows.Controls.ListView listView)
{
var sizeToUse = GetMeasuredSize(listView, availableSize);
child.Measure(sizeToUse);
var sizeToUse = GetMeasuredSize(listView, availableSize.ToSize());
child.Measure(sizeToUse.ToSize());
size.Height = Math.Max(child.DesiredSize.Height, size.Height);
size.Width = Math.Max(child.DesiredSize.Width, size.Width);
}
@ -175,7 +184,7 @@ namespace HotUI.WPF.Handlers
private bool _inArrange = false;
protected override Size ArrangeOverride(Size finalSize)
protected override WPFSize ArrangeOverride(WPFSize finalSize)
{
if (_inArrange)
return finalSize;
@ -190,5 +199,11 @@ namespace HotUI.WPF.Handlers
return finalSize;
}
public Size Measure(UIElement view, Size available)
{
view.Measure(available.ToSize());
return view.DesiredSize.ToSize();
}
}
}

Просмотреть файл

@ -3,12 +3,20 @@ using System.Windows.Controls;
namespace HotUI.WPF.Handlers
{
public abstract class AbstractStackLayoutHandler : StackPanel, IUIElement
public abstract class AbstractStackLayoutHandler : StackPanel, WPFViewHandler
{
private AbstractLayout _view;
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void SetView(View view)
{
System.Diagnostics.Debug.WriteLine($"v SetView [{GetType().Name}] [{view.Id}]");

Просмотреть файл

@ -6,9 +6,9 @@ using WPFButton = System.Windows.Controls.Button;
namespace HotUI.WPF.Handlers
{
public class ButtonHandler : WPFButton, IUIElement
public class ButtonHandler : WPFButton, WPFViewHandler
{
public static readonly PropertyMapper<Button, UIElement, ButtonHandler> Mapper = new PropertyMapper<Button, UIElement, ButtonHandler>()
public static readonly PropertyMapper<Button> Mapper = new PropertyMapper<Button>()
{
[nameof(Button.Text)] = MapTextProperty
};
@ -22,7 +22,15 @@ namespace HotUI.WPF.Handlers
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
_button = null;
@ -44,8 +52,9 @@ namespace HotUI.WPF.Handlers
private void HandleClick(object sender, EventArgs e) => _button?.OnClick();
public static bool MapTextProperty(WPFButton nativeButton, Button virtualButton)
public static bool MapTextProperty(IViewHandler viewHandler, Button virtualButton)
{
var nativeButton = (WPFButton)viewHandler.NativeView;
nativeButton.Content = virtualButton.Text;
return true;
}

Просмотреть файл

@ -3,7 +3,7 @@ using System.Windows;
namespace HotUI.WPF
{
public class ContentViewHandler : IUIElement
public class ContentViewHandler : WPFViewHandler
{
public ContentViewHandler ()
{
@ -11,7 +11,15 @@ namespace HotUI.WPF
public UIElement View => ContentView?.Content.ToView ();
public void Remove (View view)
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove (View view)
{
ContentView = null;
}

Просмотреть файл

@ -9,9 +9,9 @@ using WPFImage = System.Windows.Controls.Image;
namespace HotUI.WPF.Handlers
{
public class ImageHandler : WPFImage, IUIElement
public class ImageHandler : WPFImage, WPFViewHandler
{
public static readonly PropertyMapper<Image, UIElement, ImageHandler> Mapper = new PropertyMapper<Image, UIElement, ImageHandler>()
public static readonly PropertyMapper<Image> Mapper = new PropertyMapper<Image>()
{
[nameof(Image.Source)] = MapSourceProperty
};
@ -20,7 +20,15 @@ namespace HotUI.WPF.Handlers
internal string CurrentSource;
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -36,8 +44,9 @@ namespace HotUI.WPF.Handlers
Mapper.UpdateProperty(this, _image, property);
}
public static bool MapSourceProperty(ImageHandler nativeView, Image virtualView)
public static bool MapSourceProperty(IViewHandler viewHandler, Image virtualView)
{
var nativeView = (ImageHandler)viewHandler;
nativeView.UpdateSource(virtualView.Source);
return true;
}

Просмотреть файл

@ -7,9 +7,9 @@ using WPFListView = System.Windows.Controls.ListView;
namespace HotUI.WPF.Handlers
{
public class ListViewHandler : WPFListView, IUIElement
public class ListViewHandler : WPFListView, WPFViewHandler
{
public static readonly PropertyMapper<ListView, UIElement, ListViewHandler> Mapper = new PropertyMapper<ListView, UIElement, ListViewHandler>()
public static readonly PropertyMapper<ListView> Mapper = new PropertyMapper<ListView>()
{
[nameof(Text.Value)] = MapListProperty
};
@ -21,7 +21,15 @@ namespace HotUI.WPF.Handlers
SelectionChanged += HandleSelectionChanged;
}
public new UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -37,8 +45,9 @@ namespace HotUI.WPF.Handlers
Mapper.UpdateProperty(this, listView, property);
}
public static bool MapListProperty(ListViewHandler nativeView, ListView virtualView)
public static bool MapListProperty(IViewHandler viewHandler, ListView virtualView)
{
var nativeView = (ListViewHandler)viewHandler;
foreach (var item in virtualView.List)
{
nativeView.Items.Add(new ListViewHandlerItem(nativeView, item));

Просмотреть файл

@ -6,9 +6,9 @@ using WPFScrollView = System.Windows.Controls.ScrollViewer;
namespace HotUI.WPF.Handlers
{
public class ScrollViewHandler : IUIElement
public class ScrollViewHandler : WPFViewHandler
{
public static readonly PropertyMapper<ScrollView, UIElement, WPFScrollView> Mapper = new PropertyMapper<ScrollView, UIElement, WPFScrollView>()
public static readonly PropertyMapper<ScrollView> Mapper = new PropertyMapper<ScrollView>()
{
};
@ -23,6 +23,14 @@ namespace HotUI.WPF.Handlers
public UIElement View => _nativeScrollView;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -36,12 +44,12 @@ namespace HotUI.WPF.Handlers
_nativeScrollView.Content = _content;
}
Mapper.UpdateProperties(_nativeScrollView, _virtualScrollView);
Mapper.UpdateProperties(this, _virtualScrollView);
}
public void UpdateValue(string property, object value)
{
Mapper.UpdateProperty(_nativeScrollView, _virtualScrollView, property);
Mapper.UpdateProperty(this, _virtualScrollView, property);
}
}
}

Просмотреть файл

@ -7,9 +7,9 @@ using WPFTextField = System.Windows.Controls.TextBox;
namespace HotUI.WPF.Handlers
{
public class TextFieldHandler : WPFTextField, IUIElement
public class TextFieldHandler : WPFTextField, WPFViewHandler
{
public static readonly PropertyMapper<TextField, UIElement, TextFieldHandler> Mapper = new PropertyMapper<TextField, UIElement, TextFieldHandler>()
public static readonly PropertyMapper<TextField> Mapper = new PropertyMapper<TextField>()
{
[nameof(TextField.Text)] = MapTextProperty
};
@ -17,7 +17,14 @@ namespace HotUI.WPF.Handlers
private TextField _textField;
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -36,8 +43,9 @@ namespace HotUI.WPF.Handlers
Mapper.UpdateProperty(this, _textField, property);
}
public static bool MapTextProperty(WPFTextField nativeView, TextField virtualView)
public static bool MapTextProperty(IViewHandler viewHandler, TextField virtualView)
{
var nativeView = (WPFTextField)viewHandler.NativeView;
nativeView.Text = virtualView.Text;
//nativeView.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
//var desiredSize = nativeView.DesiredSize;

Просмотреть файл

@ -6,9 +6,9 @@ using WPFLabel = System.Windows.Controls.Label;
namespace HotUI.WPF.Handlers
{
public class TextHandler : WPFLabel, IUIElement
public class TextHandler : WPFLabel, WPFViewHandler
{
public static readonly PropertyMapper<Text, UIElement, TextHandler> Mapper = new PropertyMapper<Text, UIElement, TextHandler>()
public static readonly PropertyMapper<Text> Mapper = new PropertyMapper<Text>()
{
[nameof(Text.Value)] = MapValueProperty
};
@ -17,6 +17,13 @@ namespace HotUI.WPF.Handlers
public UIElement View => this;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
}
@ -35,8 +42,9 @@ namespace HotUI.WPF.Handlers
Mapper.UpdateProperty(this, _text, property);
}
public static bool MapValueProperty(WPFLabel nativeView, Text virtualView)
public static bool MapValueProperty(IViewHandler viewHandler, Text virtualView)
{
var nativeView = (WPFLabel)viewHandler.NativeView;
nativeView.Content = virtualView.Value;
return true;
}

Просмотреть файл

@ -5,9 +5,9 @@ using System.Windows.Controls;
namespace HotUI.WPF
{
public class ToggleHandler : IUIElement
public class ToggleHandler : WPFViewHandler
{
public static readonly PropertyMapper<Toggle, UIElement, CheckBox> Mapper = new PropertyMapper<Toggle, UIElement, CheckBox> ()
public static readonly PropertyMapper<Toggle> Mapper = new PropertyMapper<Toggle> ()
{
[nameof(Toggle.IsOn)] = MapIsOnProperty
};
@ -25,6 +25,14 @@ namespace HotUI.WPF
public UIElement View => _nativeCheckbox;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
_virtualToggle = null;
@ -33,16 +41,17 @@ namespace HotUI.WPF
public void SetView(View view)
{
_virtualToggle = view as Toggle;
Mapper.UpdateProperties(_nativeCheckbox, _virtualToggle);
Mapper.UpdateProperties(this, _virtualToggle);
}
public void UpdateValue(string property, object value)
{
Mapper.UpdateProperty(_nativeCheckbox, _virtualToggle, property);
Mapper.UpdateProperty(this, _virtualToggle, property);
}
public static bool MapIsOnProperty(CheckBox nativeView, Toggle virtualView)
public static bool MapIsOnProperty(IViewHandler viewHandler, Toggle virtualView)
{
var nativeView = (CheckBox)viewHandler.NativeView;
nativeView.IsChecked = virtualView.IsOn;
return true;
}

Просмотреть файл

@ -8,9 +8,9 @@ using System.Windows.Controls;
namespace HotUI.WPF.Handlers
{
public class ViewHandler : Grid, IUIElement
public class ViewHandler : Grid, WPFViewHandler
{
public static readonly PropertyMapper<View, UIElement, ViewHandler> Mapper = new PropertyMapper<View, UIElement, ViewHandler>()
public static readonly PropertyMapper<View> Mapper = new PropertyMapper<View>()
{
};
@ -22,6 +22,14 @@ namespace HotUI.WPF.Handlers
public UIElement View => _body;
public object NativeView => View;
public bool HasContainer
{
get => false;
set { }
}
public void Remove(View view)
{
_view = null;

Просмотреть файл

@ -64,7 +64,7 @@
<Compile Include="HotUIPage.xaml.cs">
<DependentUpon>HotUIPage.xaml</DependentUpon>
</Compile>
<Compile Include="IUIElement.cs" />
<Compile Include="WPFViewHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI.cs" />
<Compile Include="WPFExtensions.cs" />

Просмотреть файл

@ -10,7 +10,7 @@ namespace HotUI.WPF
UI.Init();
}
public static IUIElement ToIUIElement(this View view)
public static WPFViewHandler ToIUIElement(this View view)
{
if (view == null)
return null;
@ -21,7 +21,7 @@ namespace HotUI.WPF
view.ViewHandler = handler;
}
var iUIElement = handler as IUIElement;
var iUIElement = handler as WPFViewHandler;
return iUIElement;
}

Просмотреть файл

@ -2,7 +2,7 @@
namespace HotUI.WPF
{
public interface IUIElement : IViewHandler
public interface WPFViewHandler : IViewHandler
{
UIElement View { get; }
}