Enhance the Preloading Precedure and Fixed the issue to throw InvalideOperationExcept...
author유리나/Common Platform Lab(SR)/Staff Engineer/삼성전자 <rina6350.you@samsung.com>
Tue, 16 Jun 2020 07:23:43 +0000 (16:23 +0900)
committer안주원/Common Platform Lab(SR)/Principal Engineer/삼성전자 <juwon.ahn@samsung.com>
Tue, 16 Jun 2020 07:23:43 +0000 (16:23 +0900)
* Enhance the Preloading Precedure and Fixed the
issue to throw InvalideOperationException if SetFlags is called

* [HR] register sourceinfo before triggering change (#10933)

- fixes #10803

* [Tizen] Enhance the Page.ToolbarItem (#11015)

* [Tizen] Fix initialize of Device Independent Pixel option (#435)

* [Tizen] Ensure the update of color after theme style changing (#436)

* Enhance the Page renderer (#324)

* Change the file mode

13 files changed:
src/XSF.Build.Tasks/CreateObjectVisitor.cs [changed mode: 0644->0755]
src/XSF.Build.Tasks/SetPropertiesVisitor.cs [changed mode: 0644->0755]
src/XSF.Build.Tasks/XamlCTask.cs [changed mode: 0644->0755]
src/XSF/Tizen.Wearable.CircularUI.Forms.Renderer/PageRenderer.cs
src/XSF/Xamarin.Forms.Platform.Tizen/Forms.cs
src/XSF/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
src/XSF/Xamarin.Forms.Platform.Tizen/Renderers/PageRenderer.cs
src/XSF/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs
src/XSF/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
src/XSF/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs
src/XSF/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs [changed mode: 0644->0755]
src/XSF/Xamarin.Forms.Xaml/CreateValuesVisitor.cs [changed mode: 0644->0755]
src/XSF/Xamarin.Forms.Xaml/XamlLoader.cs

old mode 100644 (file)
new mode 100755 (executable)
index 1149a4e..08d84d4
@@ -58,7 +58,7 @@ namespace Xamarin.Forms.Build.Tasks
                                Context.Body.Variables.Add(vardef);
 
                                Context.IL.Append(PushValueFromLanguagePrimitive(typedef, node));
-                               Context.IL.Emit(OpCodes.Stloc, vardef);
+                               Context.IL.Emit(Stloc, vardef);
                                return;
                        }
 
@@ -80,13 +80,15 @@ namespace Xamarin.Forms.Build.Tasks
                                Context.Body.Variables.Add(vardef);
 
                                Context.IL.Append(il);
-                               Context.IL.Emit(OpCodes.Stloc, vardef);
+                               Context.IL.Emit(Stloc, vardef);
 
                                //clean the node as it has been fully exhausted
                                foreach (var prop in node.Properties)
                                        if (!node.SkipProperties.Contains(prop.Key))
                                                node.SkipProperties.Add(prop.Key);
                                node.CollectionItems.Clear();
+
+                               Context.IL.Append(RegisterSourceInfo(Context, node));
                                return;
                        }
 
@@ -219,9 +221,11 @@ namespace Xamarin.Forms.Build.Tasks
                                                if (!node.SkipProperties.Contains(prop.Key))
                                                        node.SkipProperties.Add(prop.Key);
                                        node.CollectionItems.Clear();
+                                       Context.IL.Append(RegisterSourceInfo(Context, node));
 
                                        return;
                                }
+                               Context.IL.Append(RegisterSourceInfo(Context, node));
                        }
                }
 
@@ -238,6 +242,7 @@ namespace Xamarin.Forms.Build.Tasks
                        Context.Body.Variables.Add(vardef);
                        Context.IL.Emit(OpCodes.Ldarg_0);
                        Context.IL.Emit(OpCodes.Stloc, vardef);
+                       Context.IL.Append(RegisterSourceInfo(Context, node));
                }
 
                public void Visit(ListNode node, INode parentNode)
@@ -537,5 +542,53 @@ namespace Xamarin.Forms.Build.Tasks
                                break;
                        }
                }
+
+               internal static IEnumerable<Instruction> RegisterSourceInfo(ILContext context, INode valueNode)
+               {
+                       if (!context.DefineDebug)
+                               yield break;
+                       if (!(valueNode is IXmlLineInfo lineInfo))
+                               yield break;
+                       if (!(valueNode is IElementNode elementNode))
+                               yield break;
+                       if (context.Variables[elementNode].VariableType.IsValueType)
+                               yield break;
+
+                       var module = context.Body.Method.Module;
+
+                       yield return Create(Ldloc, context.Variables[elementNode]);     //target
+
+                       yield return Create(Ldstr, context.XamlFilePath);
+                       yield return Create(Ldstr, ";assembly=");
+                       yield return Create(Ldstr, context.Module.Assembly.Name.Name);
+                       yield return Create(Call, module.ImportMethodReference(("mscorlib", "System", "String"),
+                                                                                                                                  methodName: "Concat",
+                                                                                                                                  parameterTypes: new[] {
+                                                                                                                                          ("mscorlib", "System", "String"),
+                                                                                                                                          ("mscorlib", "System", "String"),
+                                                                                                                                          ("mscorlib", "System", "String"),
+                                                                                                                                  },
+                                                                                                                                  isStatic: true));
+
+
+                       yield return Create(Ldc_I4, (int)UriKind.RelativeOrAbsolute);
+                       yield return Create(Newobj, module.ImportCtorReference(("System", "System", "Uri"),
+                                                                                                                                  parameterTypes: new[] {
+                                                                                                                                          ("mscorlib", "System", "String"),
+                                                                                                                                          ("System", "System", "UriKind"),
+                                                                                                                                  }));     //uri
+
+                       yield return Create(Ldc_I4, lineInfo.LineNumber);               //lineNumber
+                       yield return Create(Ldc_I4, lineInfo.LinePosition);             //linePosition
+
+                       yield return Create(Call, module.ImportMethodReference(("Xamarin.Forms.Core", "Xamarin.Forms.Xaml.Diagnostics", "VisualDiagnostics"),
+                                                                                                                                  methodName: "RegisterSourceInfo",
+                                                                                                                                  parameterTypes: new[] {
+                                                                                                                                          ("mscorlib", "System", "Object"),
+                                                                                                                                          ("System", "System", "Uri"),
+                                                                                                                                          ("mscorlib", "System", "Int32"),
+                                                                                                                                          ("mscorlib", "System", "Int32")},
+                                                                                                                                  isStatic: true));
+               }
        }
 }
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index da254b0..c0ed05a
@@ -892,66 +892,19 @@ namespace Xamarin.Forms.Build.Tasks
 
                        //If it's a BP, SetValue ()
                        if (CanSetValue(bpRef, attached, valueNode, iXmlLineInfo, context))
-                               return SetValue(parent, bpRef, valueNode, iXmlLineInfo, context).Concat(RegisterSourceInfo(context, valueNode));
+                               return SetValue(parent, bpRef, valueNode, iXmlLineInfo, context);
 
                        //If it's a property, set it
                        if (CanSet(parent, localName, valueNode, context))
-                               return Set(parent, localName, valueNode, iXmlLineInfo, context).Concat(RegisterSourceInfo(context, valueNode));
+                               return Set(parent, localName, valueNode, iXmlLineInfo, context);
 
                        //If it's an already initialized property, add to it
                        if (CanAdd(parent, propertyName, valueNode, iXmlLineInfo, context))
-                               return Add(parent, propertyName, valueNode, iXmlLineInfo, context).Concat(RegisterSourceInfo(context, valueNode));
+                               return Add(parent, propertyName, valueNode, iXmlLineInfo, context);
 
                        throw new XamlParseException($"No property, bindable property, or event found for '{localName}', or mismatching type between value and property.", iXmlLineInfo);
                }
 
-               internal static IEnumerable<Instruction> RegisterSourceInfo(ILContext context, INode valueNode)
-               {
-                       if (!context.DefineDebug)
-                               yield break;
-                       if (!(valueNode is IXmlLineInfo lineInfo))
-                               yield break;
-                       if (!(valueNode is IElementNode elementNode))
-                               yield break;
-                       if (context.Variables[elementNode].VariableType.IsValueType)
-                               yield break;
-
-                       var module = context.Body.Method.Module;
-
-                       yield return Create(Ldloc, context.Variables[elementNode]);             //target
-
-                       yield return Create(Ldstr, context.XamlFilePath);
-                       yield return Create(Ldstr, ";assembly=");
-                       yield return Create(Ldstr, context.Module.Assembly.Name.Name);
-                       yield return Create(Call, module.ImportMethodReference(("mscorlib", "System", "String"),
-                                                                                                                                  methodName: "Concat",
-                                                                                                                                  parameterTypes: new[] {
-                                                                                                                                          ("mscorlib", "System", "String"),
-                                                                                                                                          ("mscorlib", "System", "String"),
-                                                                                                                                          ("mscorlib", "System", "String"),
-                                                                                                                                  },
-                                                                                                                                  isStatic: true));
-
-
-                       yield return Create(Ldc_I4, (int)UriKind.RelativeOrAbsolute);
-                       yield return Create(Newobj, module.ImportCtorReference(("System", "System", "Uri"),
-                                                                                                                                  parameterTypes: new[] {
-                                                                                                                                          ("mscorlib", "System", "String"),
-                                                                                                                                          ("System", "System", "UriKind"),
-                                                                                                                                  }));         //uri
-
-                       yield return Create(Ldc_I4, lineInfo.LineNumber);                               //lineNumber
-                       yield return Create(Ldc_I4, lineInfo.LinePosition);             //linePosition
-
-                       yield return Create(Call, module.ImportMethodReference(("XSF", "Xamarin.Forms.Xaml.Diagnostics", "VisualDiagnostics"),
-                                                                                                                                  methodName: "RegisterSourceInfo",
-                                                                                                                                  parameterTypes: new[] {
-                                                                                                                                          ("mscorlib", "System", "Object"),
-                                                                                                                                          ("System", "System", "Uri"),
-                                                                                                                                          ("mscorlib", "System", "Int32"),
-                                                                                                                                          ("mscorlib", "System", "Int32")},
-                                                                                                                                  isStatic: true));
-               }
 
                public static IEnumerable<Instruction> GetPropertyValue(VariableDefinition parent, XmlName propertyName, ILContext context, IXmlLineInfo lineInfo, out TypeReference propertyType)
                {
old mode 100644 (file)
new mode 100755 (executable)
index a190cd5..4137c34
@@ -345,8 +345,6 @@ namespace Xamarin.Forms.Build.Tasks
                                rootnode.Accept(new SetResourcesVisitor(visitorContext), null);
                                rootnode.Accept(new SetPropertiesVisitor(visitorContext, true), null);
 
-                               il.Append(SetPropertiesVisitor.RegisterSourceInfo(visitorContext, rootnode));
-
                                il.Emit(Ret);
                                initComp.Body = body;
                                exception = null;
index c2bc4fb..f03d802 100644 (file)
  * limitations under the License.
  */
 
+using System;
+using ElmSharp.Wearable;
 using Xamarin.Forms;
 using Xamarin.Forms.Platform.Tizen;
 using Xamarin.Forms.Platform.Tizen.Native.Watch;
 using XPageRenderer = Xamarin.Forms.Platform.Tizen.PageRenderer;
 using CPageRenderer = Tizen.Wearable.CircularUI.Forms.Renderer.PageRenderer;
+using EColor = ElmSharp.Color;
+using NPage = Xamarin.Forms.Platform.Tizen.Native.Page;
+using NLayoutEventArgs = Xamarin.Forms.Platform.Tizen.Native.LayoutEventArgs;
+using XForms = Xamarin.Forms.Forms;
+using System.Collections.Specialized;
 
 [assembly: ExportRenderer(typeof(Page), typeof(CPageRenderer))]
 namespace Tizen.Wearable.CircularUI.Forms.Renderer
 {
-       public class PageRenderer : XPageRenderer
+       // TODO: need to change the implementation to inhert the PageRenderer later
+       public class PageRenderer : VisualElementRenderer<Page>
        {
-               protected override FormsMoreOptionItem CreateMoreOptionItem(ToolbarItem item)
+               NPage _page;
+               Lazy<MoreOption> _moreOption;
+
+               public PageRenderer()
+               {
+                       RegisterPropertyHandler(Page.BackgroundImageSourceProperty, UpdateBackgroundImage);
+               }
+
+               protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
+               {
+                       if (null == _page)
+                       {
+                               _page = new NPage(XForms.NativeParent);
+                               _page.LayoutUpdated += OnLayoutUpdated;
+                               SetNativeView(_page);
+                       }
+                       base.OnElementChanged(e);
+               }
+
+               protected override void OnElementReady()
+               {
+                       _moreOption = new Lazy<MoreOption>(CreateMoreOption);
+                       if (Element.ToolbarItems is INotifyCollectionChanged items)
+                       {
+                               items.CollectionChanged += OnToolbarCollectionChanged;
+                       }
+                       if (Element.ToolbarItems.Count > 0)
+                       {
+                               UpdateToolbarItems(true);
+                       }
+               }
+
+               protected override void Dispose(bool disposing)
+               {
+                       if (disposing)
                {
-                       var moreOptionItem = base.CreateMoreOptionItem(item);
+                               if (_page != null)
+                               {
+                                       _page.LayoutUpdated -= OnLayoutUpdated;
+                               }
+
+                               if (Element.ToolbarItems is INotifyCollectionChanged items)
+                               {
+                                       items.CollectionChanged -= OnToolbarCollectionChanged;
+                               }
+
+                               if (_moreOption.IsValueCreated)
+                               {
+                                       _moreOption.Value.Clicked -= OnMoreOptionItemClicked;
+                                       _moreOption.Value.Closed -= SendMoreOptionClosed;
+                                       _moreOption.Value.Opened -= SendMoreOptionOpened;
+                                       _moreOption.Value.Items.Clear();
+                                       _moreOption.Value.Unrealize();
+                               }
+                       }
+                       base.Dispose(disposing);
+               }
+
+               protected override void UpdateBackgroundColor(bool initialize)
+               {
+                       if (initialize && Element.BackgroundColor.IsDefault)
+                               return;
+
+                       // base.UpdateBackgroundColor() is not called on purpose, we don't want the regular background setting
+                       if (Element.BackgroundColor.IsDefault || Element.BackgroundColor.A == 0)
+                               _page.Color = EColor.Transparent;
+                       else
+                               _page.Color = Element.BackgroundColor.ToNative();
+               }
+
+               protected override void UpdateLayout()
+               {
+                       // empty on purpose
+               }
+
+               protected virtual FormsMoreOptionItem CreateMoreOptionItem(ToolbarItem item)
+               {
+                       var moreOptionItem = new FormsMoreOptionItem
+                       {
+                               MainText = item.Text,
+                               ToolbarItem = item
+                       };
+                       var icon = item.IconImageSource as FileImageSource;
+                       if (icon != null)
+                       {
+                               var img = new ElmSharp.Image(_moreOption.Value);
+                               img.Load(ResourcePath.GetPath(icon));
+                               moreOptionItem.Icon = img;
+                       }
                        if (item is CircleToolbarItem circleToolbarItem)
                        {
                                moreOptionItem.SubText = circleToolbarItem.SubText;
                        }
                        return moreOptionItem;
                }
+
+               protected virtual void OnMoreOptionClosed()
+               {
+               }
+
+               protected virtual void OnMoreOptionOpened()
+               {
+               }
+
+               void UpdateBackgroundImage(bool initialize)
+               {
+                       if (initialize && Element.BackgroundImageSource.IsNullOrEmpty())
+                               return;
+
+                       // TODO: investigate if we can use the other image source types: stream, font, uri
+
+                       var bgImage = Element.BackgroundImageSource as FileImageSource;
+                       if (bgImage.IsNullOrEmpty())
+                               _page.File = null;
+                       else
+                               _page.File = ResourcePath.GetPath(bgImage);
+               }
+
+               void OnLayoutUpdated(object sender, NLayoutEventArgs e)
+               {
+                       Element.Layout(e.Geometry.ToDP());
+
+                       if (_moreOption != null && _moreOption.IsValueCreated)
+                       {
+                               _moreOption.Value.Geometry = _page.Geometry;
+                       }
+               }
+
+               MoreOption CreateMoreOption()
+               {
+                       var moreOption = new MoreOption(_page);
+                       moreOption.Geometry = _page.Geometry;
+                       _page.Children.Add(moreOption);
+                       moreOption.Show();
+                       moreOption.Clicked += OnMoreOptionItemClicked;
+                       moreOption.Closed += SendMoreOptionClosed;
+                       moreOption.Opened += SendMoreOptionOpened;
+                       return moreOption;
+               }
+
+               void SendMoreOptionClosed(object sender, EventArgs e)
+               {
+                       OnMoreOptionClosed();
+               }
+
+               void SendMoreOptionOpened(object sender, EventArgs e)
+               {
+                       OnMoreOptionOpened();
+               }
+
+               void OnToolbarCollectionChanged(object sender, EventArgs eventArgs)
+               {
+                               UpdateToolbarItems(false);
+               }
+
+               void UpdateToolbarItems(bool initialize)
+               {
+                       //clear existing more option items and add toolbar item again on purpose.
+                       if (!initialize && _moreOption.Value.Items.Count > 0)
+                       {
+                               _moreOption.Value.Items.Clear();
+                       }
+
+                       if (Element.ToolbarItems.Count > 0)
+                       {
+                               _moreOption.Value.Show();
+                               foreach (var item in Element.ToolbarItems)
+                               {
+                                       _moreOption.Value.Items.Add(CreateMoreOptionItem(item));
+                               }
+                       }
+                       else
+                       {
+                               _moreOption.Value.Hide();
+                       }
+               }
+
+               void OnMoreOptionItemClicked(object sender, MoreOptionItemEventArgs e)
+               {
+                       var formsMoreOptionItem = e.Item as FormsMoreOptionItem;
+                       if (formsMoreOptionItem != null)
+                       {
+                               ((IMenuItemController)formsMoreOptionItem.ToolbarItem)?.Activate();
+                       }
+                       _moreOption.Value.IsOpened = false;
+               }
        }
 }
\ No newline at end of file
index fca91da..930f32a 100644 (file)
@@ -120,6 +120,11 @@ namespace Xamarin.Forms
 
                        readonly string profile;
 
+                       static int ScreenWidth;
+
+                       static int ScreenHeight;
+
+
                        public override Size PixelScreenSize
                        {
                                get
@@ -152,35 +157,10 @@ namespace Xamarin.Forms
                                }
                        }
 
-                       public TizenDeviceInfo() : this(getScreenWidth(), getScreenHeight())
+                       public TizenDeviceInfo()
                        {
-                       }
-
-                       static int getScreenWidth()
-                       {
-                               if (TSystemInfo.TryGetValue("http://tizen.org/feature/screen.width", out int width))
-                               {
-                                       return width;
-                               }
-                               else
-                               {
-                                       throw new InvalidOperationException("Can not get screen.Width");
-                               }
-                       }
-                       static int getScreenHeight()
-                       {
-                               if (TSystemInfo.TryGetValue("http://tizen.org/feature/screen.height", out int height))
-                               {
-                                       return height;
-                               }
-                               else
-                               {
-                                       throw new InvalidOperationException("Can not get screen.Height");
-                               }
-                       }
-                       TizenDeviceInfo(int width, int height)
-                       {
-                               pixelScreenSize = new Size(width, height);
+                               int width = GetScreenWidth();
+                               int height = GetScreenHeight();
 
                                scalingFactor = 1.0;  // scaling is disabled, we're using pixels as Xamarin's geometry units
                                if (s_useDeviceIndependentPixel)
@@ -188,13 +168,31 @@ namespace Xamarin.Forms
                                        scalingFactor = s_dpi.Value / 160.0;
                                }
 
+                               pixelScreenSize = new Size(width, height);
                                scaledScreenSize = new Size(width / scalingFactor, height / scalingFactor);
                                profile = s_profile.Value;
                        }
 
-                       public TizenDeviceInfo RefreshByDIP()
+                       internal static int GetScreenWidth(bool systemCall = false)
                        {
-                               return new TizenDeviceInfo((int)pixelScreenSize.Width, (int)pixelScreenSize.Height);
+                               int width = 0;
+                               if (systemCall)
+                               {
+                                       TSystemInfo.TryGetValue("http://tizen.org/feature/screen.width", out width);
+                                       ScreenWidth = width;
+                               }
+                               return ScreenWidth;
+                       }
+
+                       internal static int GetScreenHeight(bool systemCall = false)
+                       {
+                               int height = 0;
+                               if (systemCall)
+                               {
+                                       TSystemInfo.TryGetValue("http://tizen.org/feature/screen.height", out height);
+                                       ScreenHeight = height;
+                               }
+                               return ScreenHeight;
                        }
                }
 
@@ -382,41 +380,73 @@ namespace Xamarin.Forms
 
                public static void Init(InitializationOptions options)
                {
+                       s_useDeviceIndependentPixel = options?.UseDeviceIndependentPixel ?? false;
                        SetupInit(options.Context, options);
                }
 
+               static void PreloadInit()
+               {
+                       Internals.Log.Listeners.Add(new XamarinLogListener());
+                       if (System.Threading.SynchronizationContext.Current == null)
+                       {
+                               TizenSynchronizationContext.Initialize();
+                       }
+
+                       Elementary.Initialize();
+                       Elementary.ThemeOverlay();
+                       Utility.AppendGlobalFontPath(@"/usr/share/fonts");
+
+                       Device.PlatformServices = new TizenPlatformServices();
+                       if (Device.info != null)
+                       {
+                               ((TizenDeviceInfo)Device.info).Dispose();
+                               Device.info = null;
+                       }
+
+                       TizenDeviceInfo.GetScreenWidth(true);
+                       TizenDeviceInfo.GetScreenHeight(true);
+
+                       StaticRegistrar.RegisterHandlers(CircularUIForms.StaticHandlers);
+                       CircularUIForms.RegisterDependencyService();
+                       TizenPlatformServices.AppDomain.CurrentDomain.AddAssembly(Assembly.GetAssembly(typeof(Xamarin.Forms.View)));
+                       Registrar.RegisterAll(new Type[]
+                       {
+                                               typeof(ExportRendererAttribute),
+                                               typeof(ExportImageSourceHandlerAttribute),
+                                               typeof(ExportCellAttribute),
+                                               typeof(ExportHandlerAttribute),
+                                               typeof(ExportFontAttribute)
+                       });
+               }
+
                static void SetupInit(CoreApplication application, InitializationOptions options = null)
                {
                        Context = application;
 
                        if (!IsInitialized)
                        {
-                               Internals.Log.Listeners.Add(new XamarinLogListener());
-                               if (System.Threading.SynchronizationContext.Current == null)
+                               if (!IsPreloaded)
                                {
-                                       TizenSynchronizationContext.Initialize();
-                               }
+                                       Internals.Log.Listeners.Add(new XamarinLogListener());
+                                       if (System.Threading.SynchronizationContext.Current == null)
+                                       {
+                                               TizenSynchronizationContext.Initialize();
+                                       }
 
-                               Elementary.Initialize();
-                               Elementary.ThemeOverlay();
-                               Utility.AppendGlobalFontPath(@"/usr/share/fonts");
+                                       Elementary.Initialize();
+                                       Elementary.ThemeOverlay();
+                                       Utility.AppendGlobalFontPath(@"/usr/share/fonts");
 
-                               Device.PlatformServices = new TizenPlatformServices();
-                               if (Device.info != null)
-                               {
-                                       ((TizenDeviceInfo)Device.info).Dispose();
-                                       Device.info = null;
+                                       Device.PlatformServices = new TizenPlatformServices();
+                                       if (Device.info != null)
+                                       {
+                                               ((TizenDeviceInfo)Device.info).Dispose();
+                                               Device.info = null;
+                                       }
                                }
-
                                Device.Info = new Forms.TizenDeviceInfo();
                                Device.SetFlags(s_flags);
                        }
-                       else if (Device.info != null)
-                       {
-                               var info = ((TizenDeviceInfo)Device.info).RefreshByDIP();
-                               ((TizenDeviceInfo)Device.info).Dispose();
-                               Device.info = info;
-                       }
 
                        string profile = ((TizenDeviceInfo)Device.Info).Profile;
                        if (profile == "mobile")
@@ -440,18 +470,17 @@ namespace Xamarin.Forms
                                Device.SetIdiom(TargetIdiom.Unsupported);
                        }
 
-                       if (!Forms.IsInitialized && !Forms.IsPreloaded)
+                       if (!Forms.IsPreloaded)
                        {
                                StaticRegistrar.RegisterHandlers(CircularUIForms.StaticHandlers);
                                CircularUIForms.RegisterDependencyService();
                                TizenPlatformServices.AppDomain.CurrentDomain.AddAssembly(Assembly.GetAssembly(typeof(Xamarin.Forms.View)));
                        }
 
-                       if (!Forms.IsInitialized || Forms.IsPreloaded)
+                       if (!Forms.IsInitialized)
                        {
                                if (options != null)
                                {
-                                       s_useDeviceIndependentPixel = options.UseDeviceIndependentPixel;
                                        s_platformType = options.PlatformType;
                                        s_useMessagingCenter = options.UseMessagingCenter;
                                        OptionalFeatureValues.UseStyle = options.UseStyle;
@@ -660,7 +689,7 @@ namespace Xamarin.Forms
                public static EvasObject Preload()
                {
                        var dummyApp = new DummyFormsApplication();
-                       Init(dummyApp, false);
+                       PreloadInit();
                        IsPreloaded = true;
 
                        var locale = TSystemSetting.LocaleLanguage;
index 8ef72b9..8b182cd 100644 (file)
@@ -63,6 +63,7 @@ namespace Xamarin.Forms.Platform.Tizen
                        {
                                (Control as IButton)?.UpdateStyle(style);
                                ((IVisualElementController)Element).NativeSizeChanged();
+                               UpdateBackgroundColor(false);
                        }
                }
 
index 0f4622f..55fcf17 100644 (file)
@@ -151,6 +151,7 @@ namespace Xamarin.Forms.Platform.Tizen
                MoreOption CreateMoreOption()
                {
                        var moreOption = new MoreOption(_page);
+                       moreOption.Geometry = _page.Geometry;
                        _page.Children.Add(moreOption);
                        moreOption.Show();
                        moreOption.Clicked += OnMoreOptionItemClicked;
@@ -171,11 +172,8 @@ namespace Xamarin.Forms.Platform.Tizen
 
                void OnToolbarCollectionChanged(object sender, EventArgs eventArgs)
                {
-                       if (Element.ToolbarItems.Count > 0 || _moreOption.IsValueCreated)
-                       {
                                UpdateToolbarItems(false);
                        }
-               }
 
                void UpdateToolbarItems(bool initialize)
                {
@@ -185,11 +183,19 @@ namespace Xamarin.Forms.Platform.Tizen
                                _moreOption.Value.Items.Clear();
                        }
 
+                       if (Element.ToolbarItems.Count > 0)
+                       {
+                               _moreOption.Value.Show();
                        foreach (var item in Element.ToolbarItems)
                        {
                                _moreOption.Value.Items.Add(CreateMoreOptionItem(item));
                        }
                }
+                       else
+                       {
+                               _moreOption.Value.Hide();
+                       }
+               }
 
                void OnMoreOptionItemClicked(object sender, MoreOptionItemEventArgs e)
                {
index c7098c8..2c6301a 100644 (file)
@@ -56,7 +56,11 @@ namespace Xamarin.Forms.Platform.Tizen
                {
                        var themeStyle = SpecificVE.GetStyle(Element);
                        if (!string.IsNullOrEmpty(themeStyle))
+                       {
                                Control.Style = themeStyle;
+                               UpdateBackgroundColor(false);
+                               UpdateProgressColor(false);
+                       }
                }
 
                void UpdateAll()
index 4fe4300..fe01f2a 100644 (file)
@@ -69,6 +69,9 @@ namespace Xamarin.Forms.Platform.Tizen
                                        break;
                        }
                        ((IVisualElementController)Element).NativeSizeChanged();
+                       UpdateBackgroundColor(false);
+                       UpdateOnColor(false);
+                       UpdateColor();
                }
 
                protected virtual void UpdateColor()
index f5c851a..3576df9 100644 (file)
@@ -155,6 +155,10 @@ namespace Xamarin.Forms.Platform.Tizen
                        {
                                _toolbar.Style = style;
                                ((IVisualElementController)Element).NativeSizeChanged();
+                               UpdateBackgroundColor(false);
+                               UpdateBarBackgroundColor(false);
+                               UpdateSelectedTabColor(false);
+                               UpdateUnselectedTabColor(false);
                        }
                }
 
old mode 100644 (file)
new mode 100755 (executable)
index a939fb0..0d86b5f
@@ -344,27 +344,17 @@ namespace Xamarin.Forms.Xaml
                        if (xpe == null && TrySetBinding(xamlelement, property, localName, value, lineInfo, out xpe))
                                return;
 
-                       var assemblyName = (context.RootAssembly ?? rootElement.GetType().GetTypeInfo().Assembly)?.GetName().Name;
                        //If it's a BindableProberty, SetValue
-                       if (xpe == null && TrySetValue(xamlelement, property, attached, value, lineInfo, serviceProvider, out xpe)) {
-                               if (!(node is ValueNode) && value != null && !value.GetType().GetTypeInfo().IsValueType && XamlFilePathAttribute.GetFilePathForObject(context.RootElement) is string path)
-                                       VisualDiagnostics.RegisterSourceInfo(value, new Uri($"{path};assembly={assemblyName}", UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
+                       if (xpe == null && TrySetValue(xamlelement, property, attached, value, lineInfo, serviceProvider, out xpe))
                                return;
-                       }
 
                        //If we can assign that value to a normal property, let's do it
-                       if (xpe == null && TrySetProperty(xamlelement, localName, value, lineInfo, serviceProvider, context, out xpe)) {
-                               if (!(node is ValueNode) && value != null && !value.GetType().GetTypeInfo().IsValueType && XamlFilePathAttribute.GetFilePathForObject(context.RootElement) is string path)
-                                       VisualDiagnostics.RegisterSourceInfo(value, new Uri($"{path};assembly={assemblyName}", UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
+                       if (xpe == null && TrySetProperty(xamlelement, localName, value, lineInfo, serviceProvider, context, out xpe))
                                return;
-                       }
 
                        //If it's an already initialized property, add to it
-                       if (xpe == null && TryAddToProperty(xamlelement, propertyName, value, xKey, lineInfo, serviceProvider, context, out xpe)) {
-                               if (!(node is ValueNode) && value != null && !value.GetType().GetTypeInfo().IsValueType && XamlFilePathAttribute.GetFilePathForObject(context.RootElement) is string path)
-                                       VisualDiagnostics.RegisterSourceInfo(value, new Uri($"{path};assembly={assemblyName}", UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
+                       if (xpe == null && TryAddToProperty(xamlelement, propertyName, value, xKey, lineInfo, serviceProvider, context, out xpe))
                                return;
-                       }
 
                        xpe = xpe ?? new XamlParseException($"Cannot assign property \"{localName}\": Property does not exist, or is not assignable, or mismatching type between value and property", lineInfo);
                        if (context.ExceptionHandler != null)
old mode 100644 (file)
new mode 100755 (executable)
index d507d73..1197b1f
@@ -150,6 +150,11 @@ namespace Xamarin.Forms.Xaml
                                        name = name.Substring(name.LastIndexOf(':') + 1);
                                XamlLoader.ValueCreatedCallback(new XamlLoader.CallbackTypeInfo { XmlNamespace = node.XmlType.NamespaceUri, XmlTypeName = name }, value);
                        }
+
+                       var assemblyName = (Context.RootAssembly ?? Context.RootElement?.GetType().GetTypeInfo().Assembly)?.GetName().Name;
+                       if (assemblyName != null && value != null && !value.GetType().GetTypeInfo().IsValueType && XamlFilePathAttribute.GetFilePathForObject(Context.RootElement) is string path)
+                               Diagnostics.VisualDiagnostics.RegisterSourceInfo(value, new Uri($"{path};assembly={assemblyName}", UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
+
                }
 
                public void Visit(RootNode node, INode parentNode)
@@ -163,6 +168,10 @@ namespace Xamarin.Forms.Xaml
                                else
                                        NameScope.SetNameScope(bindable, node.NameScopeRef?.NameScope);
                        }
+
+                       var assemblyName = (Context.RootAssembly ?? Context.RootElement.GetType().GetTypeInfo().Assembly)?.GetName().Name;
+                       if (rnode.Root != null && !rnode.Root.GetType().GetTypeInfo().IsValueType && XamlFilePathAttribute.GetFilePathForObject(Context.RootElement) is string path)
+                               Diagnostics.VisualDiagnostics.RegisterSourceInfo(rnode.Root, new Uri($"{path};assembly={assemblyName}", UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
                }
 
                public void Visit(ListNode node, INode parentNode)
index 5bd7cfc..8a25864 100644 (file)
@@ -91,10 +91,6 @@ namespace Xamarin.Forms.Xaml
                                        }
 
                                        var rootnode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), view, (IXmlNamespaceResolver)reader) { LineNumber = ((IXmlLineInfo)reader).LineNumber, LinePosition = ((IXmlLineInfo)reader).LinePosition };
-                                       if (XamlFilePathAttribute.GetFilePathForObject(view) is string path) {
-                                               VisualDiagnostics.RegisterSourceInfo(view, new Uri($"{path};assembly={view.GetType().GetTypeInfo().Assembly.GetName().Name}", UriKind.Relative), ((IXmlLineInfo)rootnode).LineNumber, ((IXmlLineInfo)rootnode).LinePosition);
-                                               VisualDiagnostics.SendVisualTreeChanged(null, view);
-                                       }
                                        XamlParser.ParseXaml(rootnode, reader);
 #pragma warning disable 0618
                                        var doNotThrow = ResourceLoader.ExceptionHandler2 != null || Internals.XamlLoader.DoNotThrowOnExceptions;
@@ -105,6 +101,9 @@ namespace Xamarin.Forms.Xaml
                                                RootAssembly = rootAssembly ?? view.GetType().GetTypeInfo().Assembly,
                                                ExceptionHandler = doNotThrow ? ehandler : (Action<Exception>)null
                                        }, useDesignProperties);
+
+                                       VisualDiagnostics.SendVisualTreeChanged(null, view);
+
                                        break;
                                }
                        }
@@ -141,14 +140,10 @@ namespace Xamarin.Forms.Xaml
                                        var cvv = new CreateValuesVisitor(visitorContext);
                                        cvv.Visit((ElementNode)rootnode, null);
                                        inflatedView = rootnode.Root = visitorContext.Values[rootnode];
-                                       if (XamlFilePathAttribute.GetFilePathForObject(inflatedView) is string path)
-                                       {
-                                               VisualDiagnostics.RegisterSourceInfo(inflatedView, new Uri($"{path};assembly={inflatedView.GetType().GetTypeInfo().Assembly.GetName().Name}", UriKind.Relative), ((IXmlLineInfo)rootnode).LineNumber, ((IXmlLineInfo)rootnode).LinePosition);
-                                               VisualDiagnostics.SendVisualTreeChanged(null, inflatedView);
-                                       }
                                        visitorContext.RootElement = inflatedView as BindableObject;
 
                                        Visit(rootnode, visitorContext, useDesignProperties);
+                                       VisualDiagnostics.SendVisualTreeChanged(null, inflatedView);
                                        break;
                                }
                        }