2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
19 using System.Reflection;
24 /// Pre-created window which prepares features that takes time in advance.
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class PreloadedWindow : Window
29 static PreloadedWindow s_precreated;
31 internal PreloadedWindow(bool useBaseLayout=true) : base("PreloadWindow")
35 InitializeBaseLayout();
37 BackButtonPressed += DummyHandler;
38 BackButtonPressed -= DummyHandler;
39 void DummyHandler(object sender, System.EventArgs e) { }
41 if (Elementary.GetProfile() == "wearable")
43 WarmupWearableWidgets();
47 public Layout BaseLayout
53 public Conformant BaseConformant
59 public object BaseCircleSurface
66 public void InitializeBaseLayout()
68 var conformant = new Conformant(this);
69 BaseConformant = conformant;
72 var layout = new Layout(conformant);
73 layout.SetTheme("layout", "application", "default");
77 conformant.SetContent(BaseLayout);
80 public void WarmupWidgets()
82 new Entry(this).Unrealize();
83 new Scroller(this).Unrealize();
84 new Box(this).Unrealize();
85 new Label(this).Unrealize();
86 new GenList(this).Unrealize();
87 new Button(this).Unrealize();
88 new Check(this).Unrealize();
89 new Naviframe(this).Unrealize();
90 new Slider(this).Unrealize();
91 new Spinner(this).Unrealize();
92 new ProgressBar(this).Unrealize();
93 new GestureLayer(this).Unrealize();
94 new Polygon(this).Unrealize();
95 new Image(this).Unrealize();
96 //TODO: Consider to call Image.LoadAsync()
99 public void WarmupWearableWidgets()
103 Assembly assem = Assembly.Load("ElmSharp.Wearable");
104 var type = assem.GetType("ElmSharp.Wearable.Preload");
105 type.GetMethod("WarmupWidgets", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { this });
109 Console.WriteLine(e.ToString());
110 Console.WriteLine("Fail to preload ElmSharp.Wearable");
114 public static PreloadedWindow GetInstance()
116 var instance = s_precreated;
121 public static PreloadedWindow PeekInstance()