protected override void Configure() { _phoneContainer = new PhoneContainer(); _analytics = new FlurryAnalytics(); RegisterConventions(); _phoneContainer.RegisterPhoneServices(RootFrame); RegisterServices(); RegisterViews(); RegisterStorageHandlers(); RegisterNavigationCoercion(); Execute.InitializeWithDispatcher(); LoadLanguagesAsync(); Telerik.Windows.Controls.LocalizationManager.GlobalStringLoader = new ResourceLoader(); Log.Init(new DebugLogger()); InitErrorHandler(); RootFrame.Navigating += RootFrameNavigating; RootFrame.Navigated += RootFrameNavigated; }
/// <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); }); }
private void PingMainTransportAsync(TLProxyBase item, ITransport transport) { MTProtoService.PingAsync(TLLong.Random(), pong => Execute.BeginOnUIThread(() => { item.Ping = transport.Ping > 0 ? new TLInt((int)transport.Ping) : null; Set(_proxyConfig); })); }
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(); } }); }
protected override void OnActivate() { base.OnActivate(); _proxyConfig = _transportService.GetProxyConfig() as TLProxyConfig76; if (_proxyConfig != null) { _isEnabled = _proxyConfig.IsEnabled.Value; _useForCalls = _proxyConfig.UseForCalls.Value; var now = TLUtils.DateToUniversalTimeTLInt(MTProtoService.ClientTicksDelta, DateTime.Now); Items.Clear(); for (var i = 0; i < _proxyConfig.Items.Count; i++) { var item = _proxyConfig.Items[i]; item.IsSelected = i == _proxyConfig.SelectedIndex.Value; Items.Add(item); if (CheckProxy(item)) { item.Status = ProxyStatus.Connecting; item.Ping = null; _proxyChecker.CheckAsync(item, 10.0, (proxyItem, ping) => Execute.BeginOnUIThread(() => { proxyItem.Proxy.CheckTime = now; proxyItem.Proxy.Ping = ping; proxyItem.Proxy.Status = item.Ping != null ? ProxyStatus.Available : ProxyStatus.Unavailable; Set(_proxyConfig); })); } } } _transportService.TransportConnected += OnTransportConnected; _transportService.TransportConnecting += OnTransportConnecting; }
private void LoadCalls() { var timespan = Items.Count > 0 ? 1.0 : 0.0; BeginOnThreadPool(TimeSpan.FromSeconds(timespan), () => { var isAuthorized = SettingsHelper.GetValue <bool>(Constants.IsAuthorizedKey); //if (!FirstRun) //{ // return; //} if (!isAuthorized) { return; } FirstRun = false; Status = Items.Count == 0 && LazyItems.Count == 0 ? AppResources.Loading : string.Empty; var limit = 50;//Constants.DialogsSlice; MTProtoService.SearchAsync( new TLInputPeerEmpty(), TLString.Empty, null, new TLInputMessagesFilterPhoneCalls { Flags = new TLInt(0) }, new TLInt(0), new TLInt(0), new TLInt(0), new TLInt(0), new TLInt(limit), new TLInt(0), result => { CacheService.AddChats(result.Chats, results => { }); CacheService.AddUsers(result.Users, results => { }); var items = new List <TLDialogBase>(); var newMessages = result as TLMessages; if (newMessages != null) { var usersCache = new Dictionary <int, TLUserBase>(); foreach (var user in newMessages.Users) { usersCache[user.Index] = user; } var chatsCache = new Dictionary <int, TLChatBase>(); foreach (var chat in newMessages.Chats) { chatsCache[chat.Index] = chat; } foreach (var message in newMessages.Messages.OfType <TLMessageCommon>()) { var dialog = new TLDialog { TopMessage = message }; var peer = TLUtils.GetPeerFromMessage(message); if (peer is TLPeerUser) { TLUserBase user; if (!usersCache.TryGetValue(peer.Id.Value, out user)) { continue; } dialog.With = user; items.Add(dialog); } } } Telegram.Api.Helpers.Execute.BeginOnUIThread(() => { IsLastSliceLoaded = result.Messages.Count < limit; _offset = Constants.DialogsSlice; _isUpdated = true; const int maxMessagesSlice = 8; Items.Clear(); for (var i = 0; i < items.Count; i++) { if (i < maxMessagesSlice) { Items.Add(items[i]); } else { LazyItems.Add(items[i]); } } Status = Items.Count == 0 && LazyItems.Count == 0 ? AppResources.NoCallsHere : string.Empty; if (LazyItems.Count > 0) { BeginOnUIThread(() => { for (var i = 0; i < LazyItems.Count; i++) { Items.Add(LazyItems[i]); } LazyItems.Clear(); }); } }); }, error => Execute.BeginOnUIThread(() => { Telegram.Api.Helpers.Execute.ShowDebugMessage("messages.getDialogs error " + error); //_isUpdated = true; Status = string.Empty; })); }); base.OnInitialize(); }
/// <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> /// 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)); }
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); })); } }