コード例 #1
0
        void OnCompositionTargetRendering(object sender, object args)
        {
            // Get the time once
            DateTime utc = DateTime.UtcNow;

            foreach (UIElement child in uniformGrid.Children)
            {
                TimeZoneClockViewModel viewModel =
                    (child as FrameworkElement).DataContext as TimeZoneClockViewModel;
                string timeZoneKey = viewModel.TimeZoneKey;

                // Set the local time from the TimeZoneManager
                viewModel.DateTime = timeZoneManager.GetLocalTime(timeZoneKey, utc);
            }
        }
コード例 #2
0
        void OnApplicationSuspending(object sender, SuspendingEventArgs args)
        {
            appSettings.Clear();

            for (int index = 0; index < uniformGrid.Children.Count; index++)
            {
                TimeZoneClock          timeZoneClock = uniformGrid.Children[index] as TimeZoneClock;
                TimeZoneClockViewModel viewModel     =
                    timeZoneClock.DataContext as TimeZoneClockViewModel;
                string preface = index.ToString();

                appSettings[preface + "Location"]    = viewModel.Location;
                appSettings[preface + "TimeZoneKey"] = viewModel.TimeZoneKey;
                appSettings[preface + "Foreground"]  = viewModel.ForegroundName;
                appSettings[preface + "Background"]  = viewModel.BackgroundName;
            }
        }
コード例 #3
0
        async void OnDeleteMenuItem(IUICommand command)
        {
            TimeZoneClock          timeZoneClock = command.Id as TimeZoneClock;
            TimeZoneClockViewModel viewModel     = timeZoneClock.DataContext as TimeZoneClockViewModel;

            MessageDialog msgdlg = new MessageDialog("Delete clock from collection?",
                                                     viewModel.Location);

            msgdlg.Commands.Add(new UICommand("OK"));
            msgdlg.Commands.Add(new UICommand("Cancel"));
            msgdlg.DefaultCommandIndex = 0;
            msgdlg.CancelCommandIndex  = 1;

            IUICommand msgDlgCommand = await msgdlg.ShowAsync();

            if (msgDlgCommand.Label == "OK")
            {
                uniformGrid.Children.Remove(command.Id as TimeZoneClock);
            }
        }