/// <summary> /// Download Complete Action /// </summary> /// <param name="info"> /// The info. /// </param> private void DownloadComplete(DownloadStatus info) { this.UpdateAvailable = false; this.UpdateMessage = info.WasSuccessful ? Resources.OptionsViewModel_UpdateDownloaded : Resources.OptionsViewModel_UpdateFailed; Process.Start(Path.Combine(Path.GetTempPath(), "handbrake-setup.exe")); Execute.OnUIThread(() => Application.Current.Shutdown()); }
protected override void InnerCompleted(object sender, ResultCompletionEventArgs args) { base.InnerCompleted(sender, args); Executer.OnUIThread(() => this.OnCompleted(new ResultCompletionEventArgs { WasCancelled = args.WasCancelled, Error = args.Error })); }
/// <summary> /// The queue processor queue completed event handler. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void QueueProcessorQueueCompleted(object sender, QueueCompletedEventArgs e) { if (e.WasManuallyStopped) { return; } if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PlaySoundWhenQueueDone)) { this.PlayWhenDoneSound(); } if (this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction) == "Do nothing") { return; } // Give the user the ability to cancel the shutdown. Default 60 second timer. ICountdownAlertViewModel titleSpecificView = IoC.Get <ICountdownAlertViewModel>(); Execute.OnUIThread( () => { titleSpecificView.SetAction(this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction)); this.windowManager.ShowDialog(titleSpecificView); }); if (!titleSpecificView.IsCancelled) { // Do something whent he encode ends. switch (this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction)) { case "Shutdown": Process.Start("Shutdown", "-s -t 60"); break; case "Log off": Win32.ExitWindowsEx(0, 0); break; case "Suspend": Application.SetSuspendState(PowerState.Suspend, true, true); break; case "Hibernate": Application.SetSuspendState(PowerState.Hibernate, true, true); break; case "Lock System": Win32.LockWorkStation(); break; case "Quit HandBrake": Execute.OnUIThread(() => System.Windows.Application.Current.Shutdown()); break; } } }
/// <summary> /// The show mini status display. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ShowMiniStatusDisplay(object sender, EventArgs e) { IMiniViewModel titleSpecificView = IoC.Get <IMiniViewModel>(); IWindowManager windowManager = IoC.Get <IWindowManager>(); Execute.OnUIThread( () => { titleSpecificView.Activate(); windowManager.ShowWindow(titleSpecificView); }); }
public void ClearCompleted() { Execute.OnUIThread( () => { List <QueueTask> deleteList = this.queue.Where(task => task.Status == QueueItemStatus.Completed).ToList(); foreach (QueueTask item in deleteList) { this.queue.Remove(item); } this.InvokeQueueChanged(EventArgs.Empty); }); }
/// <summary> /// The encode service_ encode completed. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The EncodeCompletedEventArgs. /// </param> private void EncodeService_EncodeCompleted(object sender, EncodeCompletedEventArgs e) { // Send the file to the users requested applicaiton if (e.Successful) { this.SendToApplication(e.FileName); } // Allow the system to sleep again. Execute.OnUIThread(() => { if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PreventSleep)) { Win32.AllowSleep(); } }); }
/// <summary> /// Removes the range. /// </summary> /// <param name = "items">The items.</param> public virtual void RemoveRange(IEnumerable <T> items) { Execute.OnUIThread(() => { var previousNotificationSetting = IsNotifying; IsNotifying = false; foreach (var item in items) { var index = IndexOf(item); if (index >= 0) { RemoveItemBase(index); } } IsNotifying = previousNotificationSetting; OnPropertyChanged(new PropertyChangedEventArgs("Count")); OnPropertyChanged(new PropertyChangedEventArgs("Item[]")); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); }); }
void Closing(object sender, CancelEventArgs e) { if (e.Cancel) { return; } var guard = (IGuardClose)model; if (actuallyClosing) { actuallyClosing = false; return; } bool runningAsync = false, shouldEnd = false; guard.CanClose(canClose => { Execute.OnUIThread(() => { if (runningAsync && canClose) { actuallyClosing = true; view.Close(); } else { e.Cancel = !canClose; } shouldEnd = true; }); }); if (shouldEnd) { return; } runningAsync = e.Cancel = true; }
/// <summary> /// Adds the range. /// </summary> /// <param name = "items">The items.</param> public virtual void AddRange(IEnumerable <T> items) { Execute.OnUIThread(() => { var previousNotificationSetting = IsNotifying; IsNotifying = false; var index = Count; foreach (var item in items) { InsertItemBase(index, item); index++; } IsNotifying = previousNotificationSetting; OnPropertyChanged(new PropertyChangedEventArgs("Count")); OnPropertyChanged(new PropertyChangedEventArgs("Item[]")); #if !SILVERLIGHT || WP8 OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, items.ToList())); #else OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); #endif }); }
/// <summary> /// Clears the items contained by the collection. /// </summary> protected override sealed void ClearItems() { Execute.OnUIThread(ClearItemsBase); }
/// <summary> /// Removes the item at the specified position. /// </summary> /// <param name = "index">The position used to identify the item to remove.</param> protected override sealed void RemoveItem(int index) { Execute.OnUIThread(() => RemoveItemBase(index)); }
/// <summary> /// Sets the item at the specified position. /// </summary> /// <param name = "index">The index to set the item at.</param> /// <param name = "item">The item to set.</param> protected override sealed void SetItem(int index, T item) { Execute.OnUIThread(() => SetItemBase(index, item)); }
/// <summary> /// Moves the item within the collection. /// </summary> /// <param name="oldIndex">The old position of the item.</param> /// <param name="newIndex">The new position of the item.</param> protected sealed override void MoveItem(int oldIndex, int newIndex) { Execute.OnUIThread(() => MoveItemBase(oldIndex, newIndex)); }
public void ResolveUsername(string text, string command = null) { if (IsEditingEnabled) { return; } if (string.IsNullOrEmpty(text)) { CurrentInlineBot = null; return; } var username = new TLString(text.TrimStart('@')); var users = CacheService.GetUsers(); for (var i = 0; i < users.Count; i++) { var user = users[i] as TLUser; if (user != null && user.IsInlineBot && TLString.Equals(user.UserName, username, StringComparison.OrdinalIgnoreCase)) { Execute.OnUIThread(() => { if (!string.IsNullOrEmpty(command)) { _currentInlineBot = user; GetInlineBotResults(command); } else { CurrentInlineBot = user; GetInlineBotResults(string.Empty); } }); return; } } CurrentInlineBot = null; NotifyOfPropertyChange(() => CurrentInlineBot); if (CurrentInlineBot == null) { IsWorking = true; MTProtoService.ResolveUsernameAsync(username, result => BeginOnUIThread(() => { IsWorking = false; if (!string.IsNullOrEmpty(command)) { _currentInlineBot = result.Users.FirstOrDefault(); GetInlineBotResults(command); } else { CurrentInlineBot = result.Users.FirstOrDefault(); GetInlineBotResults(string.Empty); } }), error => BeginOnUIThread(() => { IsWorking = false; Telegram.Api.Helpers.Execute.ShowDebugMessage("contacts.resolveUsername error " + error); })); } }
/// <summary> /// Inserts the item to the specified position. /// </summary> /// <param name="index">The index to insert at.</param> /// <param name="item">The item to be inserted.</param> protected override void InsertItem(int index, T item) { Execute.OnUIThread(() => InsertItemBase(index, item)); }