public void WidgetUpdateReceived(Widget widget) { if (Equals(widget.WidgetId, _widget.WidgetId)) { Debug.WriteLine("FrameWidget Udpate {0}", widget.WidgetId); } }
public void WidgetUpdateReceived(Widget widget) { if (Equals(_widget.WidgetId, widget.WidgetId)) { this.DataContext = widget; Debug.WriteLine("GroupWidget Udpate {0}", widget.WidgetId); } }
public Widget ParseWidget(XElement widgetNode) { Widget widget = new Widget(); widget.WidgetId = GetValue(widgetNode, "widgetId"); widget.Type = GetValue(widgetNode, "type"); widget.Label = GetValue(widgetNode, "label"); widget.Icon = GetValue(widgetNode, "icon"); widget.Item = ParseItem(widgetNode.Element("item")); widget.LinkedPage = ParsePage(widgetNode.Element("linkedPage")); return widget; }
public async void WidgetUpdateReceived(Widget widget) { if (this.Dispatcher.HasThreadAccess) { if (Equals(widget.WidgetId, _widget.WidgetId)) { await Task.Delay(100); // need a little delay this.DataContext = widget; } } else { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => WidgetUpdateReceived(widget)); } }
public void RegisterForUpdate() { _eventAggregator.GetEvent<WidgetEvents.WidgetUpdateEvent>().Unsubscribe(WidgetUpdateReceived); var tmpWidget = this.DataContext as Widget; if (!Equals(tmpWidget, _widget)) _widget = tmpWidget; _eventAggregator.GetEvent<WidgetEvents.WidgetUpdateEvent>().Subscribe(WidgetUpdateReceived); }
public void RegisterForUpdate() { _widget = this.DataContext as Widget; _eventAggregator.GetEvent<WidgetEvents.WidgetUpdateEvent>().Unsubscribe(WidgetUpdateReceived); _eventAggregator.GetEvent<WidgetEvents.WidgetUpdateEvent>().Subscribe(WidgetUpdateReceived); }
public static Widget ToWidget(this JsonObject jo) { var widgetId = jo.GetNamedString("widgetId", ""); var icon = jo.GetNamedString("icon", ""); var label = jo.GetNamedString("label", ""); var type = jo.GetNamedString("type", ""); var height = jo.GetNamedNumber("height", 0); var refresh = jo.GetNamedNumber("refresh", 0); var period = jo.GetNamedString("period", ""); var url = jo.GetNamedString("url", ""); Widget widget = new Widget(widgetId, label, type, icon); switch (type) { case "Switch": case "Frame": case "Group": case "Selection": case "Text": break; case "Mapview": case "WebView": //widget = widget.SetHeight(height); break; case "Chart": //widget = widget.SetChartProperties(height, refresh, period); break; case "Image": case "Video": //widget = widget.SetUrl(url); break; default: return null; } widget = widget.SetHeight(height); widget = widget.SetChartProperties(height, refresh, period); widget = widget.SetUrl(url); try { var jWidgets = jo.ToWidgetsSafe(); if (jWidgets != null) { widget.SetWidgets(jWidgets.ToWidgets()); } if (jo.ContainsKey("item")) { widget.SetItem(jo.GetNamedObject("item").ToItem()); } if (jo.ContainsKey("linkedPage")) { widget.SetLinkedPage(jo.GetNamedObject("linkedPage").ToPage()); } if (jo.ContainsKey("mappings")) { widget.SetMappings(jo.GetNamedArray("mappings").ToMappings()); } if (jo.ContainsKey("tags")) { var tags = jo.GetNamedArray("tags"); widget.SetTags(tags.Select(j => j.GetString()).ToArray()); } if (jo.ContainsKey("groupNames")) { var groupNames = jo.GetNamedArray("groupNames"); widget.SetGroupNames(groupNames.Select(j => j.GetString()).ToArray()); } } catch (Exception) { } return widget; }
public void RegisterForUpdate() { _widget = this.DataContext as Widget; App.Current.Container.Resolve<IEventAggregator>().GetEvent<WidgetEvents.WidgetUpdateEvent>().Unsubscribe(WidgetUpdateReceived); App.Current.Container.Resolve<IEventAggregator>().GetEvent<WidgetEvents.WidgetUpdateEvent>().Subscribe(WidgetUpdateReceived); }
public static Widget SetWidgets(this Widget input, Widget[] widgets) { input.Widgets = new List<Widget>(widgets); return input; }
public bool Equals(Widget widget) { return this.WidgetId == widget.WidgetId; }