private void PinToStart_OnLoaded(object sender, RoutedEventArgs e) { var menuItem = sender as MenuItem; if (menuItem == null) { return; } var dialog = menuItem.DataContext as TLDialogBase; if (dialog == null) { return; } var tileNavigationParam = DialogsViewModel.GetTileNavigationParam(dialog); if (tileNavigationParam == null) { menuItem.Visibility = Visibility.Collapsed; return; } var tileExists = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(tileNavigationParam)) != null; if (tileExists) { menuItem.Header = AppResources.UnpinFromStart; } else { menuItem.Header = AppResources.PinToStart; } }
//private bool isOpen; public DialogsView() { InitializeComponent(); _vm = new DialogsViewModel(); DataContext = _vm; StaticViewModel = _vm; }
private void ContinueDeleteChannel(TLChannel channel) { var dialog = CacheService.GetDialog(new TLPeerChannel { Id = channel.Id }); if (dialog != null) { CacheService.DeleteDialog(dialog); DialogsViewModel.UnpinFromStart(dialog); EventAggregator.Publish(new DialogRemovedEventArgs(dialog)); } NavigationService.RemoveBackEntry(); NavigationService.RemoveBackEntry(); NavigationService.GoBack(); }
public Dialogs() { DataContext = new DialogsViewModel(); InitializeComponent(); }
public void ProcessAsync(Action <IList <TLObject> > callback) { if (Results != null) { IsCanceled = false; callback.SafeInvoke(Results); return; } var usersSource = UsersSource; var chatsSource = ChatsSource; Execute.BeginOnThreadPool(() => { var useFastSearch = !Text.Contains(" "); var userResults = new List <TLUserBase>(usersSource.Count); foreach (var contact in usersSource) { if (IsUserValid(contact, Text) || IsUserValid(contact, TransliterateText) || IsUsernameValid(contact as IUserName, Text)) { userResults.Add(contact); } } var chatsResults = new List <TLChatBase>(chatsSource.Count); foreach (var chat in chatsSource) { if (IsChatValid(chat, Text, useFastSearch) || IsChatValid(chat, TransliterateText, useFastSearch) || IsUsernameValid(chat as IUserName, Text)) { chatsResults.Add(chat); } } Results = new List <TLObject>(userResults.Count + chatsResults.Count); UserResultsIndex = new Dictionary <int, TLUserBase>(); ChatResultsIndex = new Dictionary <int, TLChatBase>(); foreach (var userResult in userResults) { Results.Add(userResult); UserResultsIndex[userResult.Index] = userResult; if (userResult.Dialog == null) { userResult.Dialog = _cacheService.GetDialog(new TLPeerUser { Id = userResult.Id }); } } foreach (var chatResult in chatsResults) { Results.Add(chatResult); ChatResultsIndex[chatResult.Index] = chatResult; if (chatResult.Dialog == null) { TLDialogBase dialog = _cacheService.GetDialog(new TLPeerChat { Id = chatResult.Id }); if (dialog == null) { if (chatResult is TLChannel) { dialog = DialogsViewModel.GetChannel(chatResult.Id); } } chatResult.Dialog = dialog; } } Execute.BeginOnUIThread(() => callback.SafeInvoke(Results)); }); }
public void ForwardInAnimationComplete() { Execute.BeginOnThreadPool(() => { _recentResults = _recentResults ?? TLUtils.OpenObjectFromMTProtoFile <TLVector <TLResultInfo> >(_recentSyncRoot, Constants.RecentSearchResultsFileName) ?? new TLVector <TLResultInfo>(); var recent = new List <TLObject>(); foreach (var result in _recentResults) { if (result.Type.ToString() == "user") { var user = CacheService.GetUser(result.Id); if (user != null) { recent.Add(user); if (user.Dialog == null) { user.Dialog = CacheService.GetDialog(new TLPeerUser { Id = user.Id }); } } } if (result.Type.ToString() == "chat") { var chat = CacheService.GetChat(result.Id); if (chat != null) { recent.Add(chat); if (chat.Dialog == null) { TLDialogBase dialog = CacheService.GetDialog(new TLPeerChat { Id = chat.Id }); if (dialog == null) { if (chat is TLChannel) { dialog = DialogsViewModel.GetChannel(chat.Id); } } chat.Dialog = dialog; } } } } Execute.BeginOnUIThread(() => { if (!string.IsNullOrEmpty(Text)) { return; } Recent.Clear(); foreach (var recentItem in recent) { Recent.Add(recentItem); } NotifyOfPropertyChange(() => ShowRecent); }); }); }
public DialogsView() { InitializeComponent(); BindingContext = new DialogsViewModel(Navigation); }
public void DeleteAndExitGroup() { MessageBoxResult confirmation; var channel = CurrentItem as TLChannel; if (channel != null) { confirmation = MessageBox.Show(AppResources.LeaveChannelConfirmation, AppResources.Confirm, MessageBoxButton.OKCancel); if (confirmation != MessageBoxResult.OK) { return; } IsWorking = true; MTProtoService.LeaveChannelAsync( channel, result => BeginOnUIThread(() => { IsWorking = false; NavigationService.RemoveBackEntry(); var dialog = CacheService.GetDialog(new TLPeerChannel { Id = CurrentItem.Id }); if (dialog != null) { CacheService.DeleteDialog(dialog); DialogsViewModel.UnpinFromStart(dialog); EventAggregator.Publish(new DialogRemovedEventArgs(dialog)); } NavigationService.GoBack(); }), error => Execute.BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("cnannels.leaveChannel error " + error); })); return; } confirmation = MessageBox.Show(string.Format("{0}?", AppResources.DeleteAndExit), AppResources.Confirm, MessageBoxButton.OKCancel); if (confirmation != MessageBoxResult.OK) { return; } DialogsViewModel.DeleteAndExitDialogCommon( CurrentItem, MTProtoService, () => BeginOnUIThread(() => { NavigationService.RemoveBackEntry(); var dialog = CacheService.GetDialog(new TLPeerChat { Id = CurrentItem.Id }); if (dialog != null) { CacheService.DeleteDialog(dialog); DialogsViewModel.UnpinFromStart(dialog); EventAggregator.Publish(new DialogRemovedEventArgs(dialog)); } NavigationService.GoBack(); }), error => { Execute.ShowDebugMessage("DeleteAndExitGroupCommon error " + error); }); }
private void UpdateNotifySettingsAsync() { if (CurrentItem == null) { return; } var notifySettings = new TLInputPeerNotifySettings { EventsMask = new TLInt(1), MuteUntil = new TLInt(MuteUntil), ShowPreviews = new TLBool(true), Sound = string.IsNullOrEmpty(SelectedSound) ? new TLString("default") : new TLString(SelectedSound) }; IsWorking = true; MTProtoService.UpdateNotifySettingsAsync( CurrentItem.ToInputNotifyPeer(), notifySettings, result => { IsWorking = false; CurrentItem.NotifySettings = new TLPeerNotifySettings { EventsMask = new TLInt(1), MuteUntil = new TLInt(MuteUntil), ShowPreviews = notifySettings.ShowPreviews, Sound = notifySettings.Sound }; var channel = CurrentItem as TLChannel; var peer = channel != null ? (TLPeerBase) new TLPeerChannel { Id = CurrentItem.Id } : new TLPeerChat { Id = CurrentItem.Id }; TLDialogBase dialog = CacheService.GetDialog(peer); if (dialog == null) { if (channel != null) { dialog = DialogsViewModel.GetChannel(channel.Id); } } if (dialog != null) { dialog.NotifySettings = CurrentItem.NotifySettings; dialog.NotifyOfPropertyChange(() => dialog.NotifySettings); var settings = dialog.With as INotifySettings; if (settings != null) { settings.NotifySettings = CurrentItem.NotifySettings; } } CacheService.Commit(); }, error => { IsWorking = false; Execute.ShowDebugMessage("account.updateNotifySettings error: " + error); }); }