private void CancelButton_Tap(object sender, System.Windows.Input.GestureEventArgs e) { SoundNotificationsTime.Visibility = System.Windows.Visibility.Collapsed; CancelButton.Visibility = System.Windows.Visibility.Collapsed; App.Current.IsPushOn = true; App.Current.PushNotificationsSwitchTimer.Dispose(); try { var op = new AccountSetSilenceMode(App.Current.PushNotifications.ChannelUri, 0, isOk => { }); op.Execute(); HourTimeOutButton.IsEnabled = true; EightHoursTimeOutButton.IsEnabled = true; } catch (Exception ex) { Debug.WriteLine("CancelButton_Tap failed: " + ex.Message); } }
public void Initialize() { _waitHandle = new ManualResetEvent(false); UpdateFriends(); // Get friends from the web. _waitHandle.WaitOne();// Wait here until friends will be loaded. _waitHandle.Reset(); UpdateCurrentUserInfo(); _waitHandle.WaitOne(); _waitHandle.Reset(); var users = _usersCache.GetItems(); foreach (var item in users) OtherUsers.Add(item); _InitializeDialogsList(); _waitHandle.WaitOne(); _waitHandle.Reset(); _ReinitializeCounters(); _waitHandle.WaitOne(); _waitHandle.Reset(); // Check if after last switching of Silence mode it is still should be silent. if (!_settings.IsPushOn && DateTime.Now < _settings.PushTurnOnTime) { // Turn on push notifications when time occurs. TimeSpan temp = _settings.PushTurnOnTime - DateTime.Now; var op = new AccountSetSilenceMode(App.Current.PushNotifications.ChannelUri, temp.Seconds, isOk => { }); op.Execute(); } }
private void EightHoursTimeOutButton_Tap(object sender, System.Windows.Input.GestureEventArgs e) { TimeSpan temp = new TimeSpan(8, 0, 0);//8,0,0 DateTime destination = DateTime.Now + temp; SoundNotificationsTime.Text = string.Format(AppResources.SoundNotificationsDisabledUntilFormatMessage, destination.ToShortTimeString()); SoundNotificationsTime.Visibility = System.Windows.Visibility.Visible; CancelButton.Visibility = System.Windows.Visibility.Visible; App.Current.PushTurnOnTime = destination; App.Current.IsPushOn = false; try { var op = new AccountSetSilenceMode(App.Current.PushNotifications.ChannelUri, temp.Seconds, isOk => { }); op.Execute(); EightHoursTimeOutButton.IsEnabled = false; } catch (Exception ex) { Debug.WriteLine("AccountSetSilenceMode 8 hours failed: " + ex.Message); } App.Current.PushNotificationsSwitchTimer = new Timer(state => { App.Current.IsPushOn = true; App.Current.PushNotificationsSwitchTimer.Dispose(); if (SoundNotificationsTime != null && CancelButton != null) { Dispatcher.BeginInvoke(() => { SoundNotificationsTime.Visibility = System.Windows.Visibility.Collapsed; CancelButton.Visibility = System.Windows.Visibility.Collapsed; EightHoursTimeOutButton.IsEnabled = true; }); } }, null, Convert.ToInt32(temp.TotalMilliseconds), -1); }