using XForms = Xamarin.Forms.Forms;
using CCircularListView = global::Tizen.Wearable.CircularUI.Forms.CircleListView;
+using System;
[assembly: ExportRenderer(typeof(Tizen.Wearable.CircularUI.Forms.CircleListView), typeof(Tizen.Wearable.CircularUI.Forms.Renderer.CircleListViewRenderer))]
if (Control == null)
{
var surface = this.GetSurface();
- SetNativeControl(new CircleListView(XForms.NativeParent, surface));
-
+ SetNativeControl(NativeFactory.GetNativeControl(typeof(CircleListView), surface) as CircleListView);
Control.ItemSelected += OnListViewItemSelected;
}
using System.ComponentModel;
using System.Threading.Tasks;
using ElmSharp;
+using ElmSharp.Wearable;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Tizen;
using Xamarin.Forms.Platform.Tizen.Native;
if (Control == null)
{
var surface = this.GetSurface();
- SetNativeControl(new ElmSharp.Wearable.CircleScroller(XForms.NativeParent, surface));
+ SetNativeControl(NativeFactory.GetNativeControl(typeof(CircleScroller), surface) as CircleScroller);
InitControl();
Control.Scrolled += OnScrolled;
_scrollCanvas = new Xamarin.Forms.Platform.Tizen.Native.Box(Control);
using System;
using System.Collections.Generic;
using ElmSharp;
+using ElmSharp.Wearable;
using XForms = Xamarin.Forms.Forms;
namespace Tizen.Wearable.CircularUI.Forms.Renderer
class NativeFactory
{
static List<NativeCirclePage> circlePages = new List<NativeCirclePage>();
+ static Dictionary<CircleSurface, CircleListView> circleListviews = new Dictionary<CircleSurface, CircleListView>();
+ static Dictionary<CircleSurface, CircleScroller> circleScrollers = new Dictionary<CircleSurface, CircleScroller>();
const int lfrequency = 3;
public static void PrecreateNatives(EvasObject window)
var page = new NativeCirclePage(window);
page.Hide();
circlePages.Add(page);
+
+ var listview = new CircleListView(window, page.Surface);
+ listview.Hide();
+ circleListviews.Add(page.Surface, listview);
+
+ var scroller = new CircleScroller(window, page.Surface);
+ scroller.Hide();
+ circleScrollers.Add(page.Surface, scroller);
}
}
- public static EvasObject GetNativeControl(Type type)
+ public static EvasObject GetNativeControl(Type type, CircleSurface surface = null)
{
if (type == typeof(NativeCirclePage))
{
}
return new NativeCirclePage(XForms.NativeParent);
}
+ else if (type == typeof(CircleListView))
+ {
+ var listview = circleListviews[surface];
+ if (listview != null)
+ {
+ return listview;
+ }
+ return new CircleListView(XForms.NativeParent, surface);
+ }
+ else if (type == typeof(CircleScroller))
+ {
+ var scroller = circleScrollers[surface];
+ if (scroller != null)
+ {
+ return scroller;
+ }
+ return new CircleScroller(XForms.NativeParent, surface);
+ }
return Activator.CreateInstance(type, new[] { XForms.NativeParent }) as EvasObject;
}
}
{
static List<Label> labels = new List<Label>();
static List<Image> images = new List<Image>();
+ static List<Watch.WatchButton> buttons = new List<Watch.WatchButton>();
+ static List<EditfieldEntry> editfieldEntrys = new List<EditfieldEntry>();
static List<Canvas> canvases = new List<Canvas>();
static List<Page> pages = new List<Page>();
- const int hfrequency = 6;
+ const int hfrequency = 20;
+ const int mfrequency = 6;
const int lfrequency = 3;
public static void PrecreateNatives(EvasObject window)
{
for (int i = 0; i < hfrequency; i++)
{
- var label = new Label(window);
- label.Hide();
- labels.Add(label);
-
var image = new Image(window);
image.Hide();
images.Add(image);
}
+ for (int i = 0; i < mfrequency; i++)
+ {
+ var label = new Label(window);
+ label.Hide();
+ labels.Add(label);
+ }
+
for (int i = 0; i < lfrequency; i++)
{
var page = new Page(window);
var canvas = new Canvas(window);
canvas.Hide();
canvases.Add(canvas);
+
+ var button = new Native.Watch.WatchButton(window);
+ button.Hide();
+ buttons.Add(button);
+
+ var editfield = new EditfieldEntry(window);
+ editfield.Hide();
+ editfieldEntrys.Add(editfield);
}
}
}
return new Image(Forms.NativeParent);
}
+ else if (type == typeof(Watch.WatchButton))
+ {
+ if (buttons.Count >= 1)
+ {
+ Watch.WatchButton native = buttons[buttons.Count - 1];
+ buttons.RemoveAt(buttons.Count - 1);
+ return native;
+ }
+ return new Watch.WatchButton(Forms.NativeParent);
+ }
+ else if (type == typeof(EditfieldEntry))
+ {
+ if (editfieldEntrys.Count >= 1)
+ {
+ EditfieldEntry native = editfieldEntrys[editfieldEntrys.Count - 1];
+ editfieldEntrys.RemoveAt(editfieldEntrys.Count - 1);
+ return native;
+ }
+ return new EditfieldEntry(Forms.NativeParent);
+ }
else if (type == typeof(Canvas))
{
if (canvases.Count >= 1)
images.RemoveAt(images.Count - 1);
native.Unrealize();
}
- for (int i = 0; i < pages.Count; i++)
+ for (int i = 0; i < buttons.Count; i++)
{
- Page native = pages[pages.Count - 1];
- pages.RemoveAt(pages.Count - 1);
+ Button native = buttons[buttons.Count - 1];
+ buttons.RemoveAt(buttons.Count - 1);
native.Unrealize();
}
for (int i = 0; i < canvases.Count; i++)
canvases.RemoveAt(canvases.Count - 1);
native.Unrealize();
}
+ for (int i = 0; i < pages.Count; i++)
+ {
+ Page native = pages[pages.Count - 1];
+ pages.RemoveAt(pages.Count - 1);
+ native.Unrealize();
+ }
}
}
}
\ No newline at end of file
protected virtual EButton CreateNativeControl()
{
- return new Native.Watch.WatchButton(Forms.NativeParent);
+ return NativeFactory.GetNativeControl(typeof(Native.Watch.WatchButton)) as Native.Watch.WatchButton;
}
protected override Size MinimumSize()
using System;
+using Xamarin.Forms.Platform.Tizen.Native;
using IEntry = Xamarin.Forms.Platform.Tizen.Native.IEntry;
using EEntry = ElmSharp.Entry;
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Entry;
protected virtual EEntry CreateNativeControl()
{
- return new Native.EditfieldEntry(Forms.NativeParent)
- {
- IsSingleLine = true,
- };
+ var entry = NativeFactory.GetNativeControl(typeof(Native.EditfieldEntry)) as Native.EditfieldEntry;
+ entry.IsSingleLine = true;
+ return entry;
}
protected override void Dispose(bool disposing)
{
if (Control == null)
{
- SetNativeControl(new Native.Image(Forms.NativeParent));
+ var image = NativeFactory.GetNativeControl(typeof(Native.Image)) as Native.Image;
+ SetNativeControl(image);
}
base.OnElementChanged(e);
}