public void SetTimeZones(string timezones) { clocks.Clear(); string[] tzs = timezones.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); foreach (string tz in tzs) { Clock clock = new Clock(); try { string name = TZConvert.IanaToWindows(tz); clock.iana = tz; clock.timezone = TimeZoneInfo.FindSystemTimeZoneById(name); clock.name = TZNames.GetNamesForTimeZone(tz, "en").Generic.Replace(" Time", "").Replace("Coordinated ", ""); clock.abbr = TZNames.GetAbbreviationsForTimeZone(tz, "en").Generic; clock.city = ToCity(tz); clock.diff = ToDiff(clock.timezone); clock.color = clock.timezone.GetUtcOffset(DateTime.Now) == TimeZoneInfo.Local.GetUtcOffset(DateTime.Now) ? current : transparent; UpdateClock(clock); clocks.Add(clock); } catch (Exception e) { } } if (widget != null) { Windows.Foundation.Size size; size.Height = 160; size.Width = 160 * clocks.Count; widget.TryResizeWindowAsync(size); } }
private async void TryResizeWindowAsync_Click(object sender, RoutedEventArgs e) { Windows.Foundation.Size size; size.Height = int.Parse(WindowHeightBox.Text); size.Width = int.Parse(WindowWidthBox.Text); await widget.TryResizeWindowAsync(size); }
protected override void OnNavigatedTo(NavigationEventArgs e) { widget = e.Parameter as XboxGameBarWidget; widgetControl = new XboxGameBarWidgetControl(widget); if (widget != null) { Windows.Foundation.Size size; size.Height = 160; size.Width = 160 * clocks.Count; widget.TryResizeWindowAsync(size); } // Hook up events for when the ui is updated. widget.SettingsClicked += Widget_SettingsClicked; widget.RequestedOpacityChanged += Widget_RequestedOpacityChanged; SetBackgroundOpacity(); }