private async void ChangeTtlExecute() { var enabled = CacheService.Options.UseStorageOptimizer; var ttl = CacheService.Options.StorageMaxTimeFromLastAccess; var items = new[] { new SelectRadioItem(3, Locale.Declension("Days", 3), enabled && ttl == 3 * 60 * 60 * 24), new SelectRadioItem(7, Locale.Declension("Weeks", 1), enabled && ttl == 7 * 60 * 60 * 24), new SelectRadioItem(30, Locale.Declension("Months", 1), enabled && ttl == 30 * 60 * 60 * 24), new SelectRadioItem(0, Strings.Resources.KeepMediaForever, !enabled) }; var dialog = new SelectRadioPopup(items); dialog.Title = Strings.Resources.KeepMedia; dialog.PrimaryButtonText = Strings.Resources.OK; dialog.SecondaryButtonText = Strings.Resources.Cancel; var confirm = await dialog.ShowQueuedAsync(); if (confirm == ContentDialogResult.Primary && dialog.SelectedIndex is int index) { CacheService.Options.StorageMaxTimeFromLastAccess = index * 60 * 60 * 24; CacheService.Options.UseStorageOptimizer = index > 0; RaisePropertyChanged(() => FilesTtl); } }
private void OnElementPrepared(Microsoft.UI.Xaml.Controls.ItemsRepeater sender, Microsoft.UI.Xaml.Controls.ItemsRepeaterElementPreparedEventArgs args) { var item = sender.ItemsSourceView.GetAt(args.Index); if (item is User user) { var button = args.Element as Button; var content = button.Content as Grid; var title = content.Children[1] as TextBlock; title.Text = user.GetFullName(); var photo = content.Children[0] as ProfilePicture; photo.Source = PlaceholderHelper.GetUser(_protoService, user, 36); button.Click += User_Click; } else if (item is PollResultViewModel option) { var headered = args.Element as HeaderedControl; headered.Header = $"{option.Text} — {option.VotePercentage}%"; headered.Footer = Locale.Declension(option.Type is PollTypeQuiz ? "Answer" : "Vote", option.VoterCount); headered.Visibility = option.VoterCount > 0 ? Visibility.Visible : Visibility.Collapsed; } }
private void UpdateChatInviteLinkCount(ChatInviteLinkCount count, Grid content, uint phase) { var user = ViewModel.ProtoService.GetUser(count.UserId); if (user == null) { return; } if (phase == 0) { var title = content.Children[1] as TextBlock; title.Text = user.GetFullName(); } else if (phase == 1) { var subtitle = content.Children[2] as TextBlock; subtitle.Text = Locale.Declension("InviteLinkCount", count.InviteLinkCount); } else if (phase == 2) { var photo = content.Children[0] as ProfilePicture; photo.SetUser(ViewModel.ProtoService, user, 36); } }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var button = args.ItemContainer.ContentTemplateRoot as Button; var message = args.Item as Message; var content = button.Content as Grid; var title = content.Children[1] as TextBlock; var subtitle = content.Children[2] as TextBlock; var photo = content.Children[0] as ProfilePicture; var chat = ViewModel.CacheService.GetChat(message.ChatId); if (chat == null) { return; } title.Text = chat.Title; subtitle.Text = Locale.Declension("Views", message.InteractionInfo?.ViewCount ?? 0); photo.SetChat(ViewModel.ProtoService, chat, 36); button.CommandParameter = message; button.Command = ViewModel.OpenPostCommand; }
public void UpdateBasicGroup(Chat chat, BasicGroup group) { Subtitle.Text = Locale.Declension("Members", group.MemberCount); GroupInvite.Visibility = group.Status is ChatMemberStatusCreator || (group.Status is ChatMemberStatusAdministrator administrator && administrator.CanInviteUsers) || group.EveryoneIsAdministrator ? Visibility.Visible : Visibility.Collapsed; // Unused: Verified.Visibility = Visibility.Collapsed; UserPhone.Visibility = Visibility.Collapsed; Username.Visibility = Visibility.Collapsed; DescriptionPanel.Visibility = Visibility.Collapsed; UserCommonChats.Visibility = Visibility.Collapsed; UserStartSecret.Visibility = Visibility.Collapsed; SecretLifetime.Visibility = Visibility.Collapsed; SecretHashKey.Visibility = Visibility.Collapsed; GroupLeave.Visibility = Visibility.Collapsed; EventLog.Visibility = Visibility.Collapsed; Admins.Visibility = Visibility.Collapsed; Banned.Visibility = Visibility.Collapsed; Restricted.Visibility = Visibility.Collapsed; Members.Visibility = Visibility.Collapsed; }
private void OnElementPrepared(Microsoft.UI.Xaml.Controls.ItemsRepeater sender, Microsoft.UI.Xaml.Controls.ItemsRepeaterElementPreparedEventArgs args) { var button = args.Element as Button; var content = button.Content as Grid; var chat = sender.ItemsSourceView.GetAt(args.Index) as Chat; var title = content.Children[1] as TextBlock; title.Text = ViewModel.ProtoService.GetTitle(chat); if (ViewModel.CacheService.TryGetSupergroup(chat, out Supergroup supergroup)) { var subtitle = content.Children[2] as TextBlock; if (string.IsNullOrEmpty(supergroup.Username)) { subtitle.Text = Locale.Declension(supergroup.IsChannel ? "Subscribers" : "Members", supergroup.MemberCount); } else { subtitle.Text = $"@{supergroup.Username}"; } } var photo = content.Children[0] as ProfilePicture; photo.Source = PlaceholderHelper.GetChat(ViewModel.ProtoService, chat, 36); button.Command = ViewModel.LinkCommand; button.CommandParameter = chat; }
public void Update() { ProtoService.Send(new GetScopeNotificationSettings(GetScope()), result => { if (result is ScopeNotificationSettings settings) { BeginOnUIThread(() => { Alert = settings.MuteFor == 0; Preview = settings.ShowPreview; Sound = string.Empty; _disablePinnedMessage = settings.DisablePinnedMessageNotifications; _disableMention = settings.DisableMentionNotifications; }); } }); ProtoService.Send(new GetChatNotificationSettingsExceptions(GetScope(), false), result => { if (result is Telegram.Td.Api.Chats chats) { BeginOnUIThread(() => { ExceptionsCount = Locale.Declension("Chats", chats.ChatIds.Count); }); } }); }
public void UpdatePollOption(Poll poll, PollOption option) { var results = poll.IsClosed || poll.Options.Any(x => x.IsChosen); this.IsChecked = results; this.Tag = option; Ellipse.Opacity = results || option.IsBeingChosen ? 0 : 1; Percentage.Visibility = results ? Visibility.Visible : Visibility.Collapsed; Percentage.Text = $"{option.VotePercentage}%"; ToolTipService.SetToolTip(Percentage, results ? Locale.Declension("Vote", option.VoterCount) : null); Text.Text = option.Text; Zero.Visibility = results ? Visibility.Visible : Visibility.Collapsed; Votes.Maximum = results ? poll.Options.Max(x => x.VoterCount) : 1; Votes.Value = results ? option.VoterCount : 0; Loading.IsActive = option.IsBeingChosen; AutomationProperties.SetName(this, option.Text); }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; var stickerSet = args.Item as StickerSetInfo; content.Tag = stickerSet; if (args.Phase == 0) { var title = content.Children[1] as TextBlock; title.Text = stickerSet.Title; } else if (args.Phase == 1) { var subtitle = content.Children[2] as TextBlock; subtitle.Text = Locale.Declension("Stickers", stickerSet.Size); } else if (args.Phase == 2) { var photo = content.Children[0] as Image; var cover = stickerSet.Thumbnail ?? stickerSet.Covers.FirstOrDefault()?.Thumbnail; if (cover == null) { return; } var file = cover.File; if (file.Local.IsDownloadingCompleted) { if (cover.Format is ThumbnailFormatTgs) { photo.Source = PlaceholderHelper.GetLottieFrame(file.Local.Path, 0, 48, 48); } else { photo.Source = PlaceholderHelper.GetWebPFrame(file.Local.Path); } } else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { photo.Source = null; ViewModel.ProtoService.DownloadFile(file.Id, 1); } } if (args.Phase < 2) { args.RegisterUpdateCallback(OnContainerContentChanging); } args.Handled = true; }
private async void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; var stickerSet = args.Item as StickerSetInfo; var title = content.Children[1] as TextBlock; title.Text = stickerSet.Title; var subtitle = content.Children[2] as TextBlock; subtitle.Text = Locale.Declension("Stickers", stickerSet.Size); var file = stickerSet.GetThumbnail(out var outline, out _); if (file == null) { return; } if (file.Local.IsDownloadingCompleted) { if (content.Children[0] is Image photo) { photo.Source = await PlaceholderHelper.GetWebPFrameAsync(file.Local.Path, 48); ElementCompositionPreview.SetElementChildVisual(content.Children[0], null); } else if (args.Phase == 0 && content.Children[0] is LottieView lottie) { lottie.Source = UriEx.ToLocal(file.Local.Path); } } else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { if (content.Children[0] is Image photo) { photo.Source = null; } else if (args.Phase == 0 && content.Children[0] is LottieView lottie) { lottie.Source = null; } CompositionPathParser.ParseThumbnail(outline, out ShapeVisual visual, false); ElementCompositionPreview.SetElementChildVisual(content.Children[0], visual); _filesMap[file.Id].Add(stickerSet); ViewModel.ProtoService.DownloadFile(file.Id, 1); } args.Handled = true; }
private string ConvertTtl(int days) { if (days >= 365) { return(Locale.Declension("Years", days / 365)); } return(Locale.Declension("Months", days / 30)); }
private string ConvertSyncState(SyncState state, long ciccio) { //if (state is SyncStateDone done) //{ // return $"100%"; //} //else if (state is SyncStateInProgress progress) //{ // var value = (int)((progress.CurrentSeqno - progress.FromSeqno) / (double)(progress.ToSeqno - progress.FromSeqno) * 100); // return string.Format(Strings.Resources.WalletUpdatingProgress, value); //} var last = Utils.UnixTimestampToDateTime(ciccio); if (state is SyncStateInProgress inProgress) { int progress = (int)((inProgress.CurrentSeqno - inProgress.FromSeqno) / (double)(inProgress.ToSeqno - inProgress.FromSeqno) * 100); if (progress != 0 && progress != 100) { return(string.Format(Strings.Resources.WalletUpdatingProgress, progress)); } else { return(Strings.Resources.WalletUpdating); } } else { var newTime = DateTime.Now; var dt = newTime - last; if (dt.TotalSeconds < 60) { return(Strings.Resources.WalletUpdatedFewSecondsAgo); } else { String time; if (dt.TotalSeconds < 60 * 60) { time = Locale.Declension("Minutes", (int)(dt.TotalSeconds / 60)); } else if (dt.TotalSeconds < 60 * 60 * 24) { time = Locale.Declension("Hours", (int)(dt.TotalSeconds / 60 / 60)); } else { time = Locale.Declension("Days", (int)(dt.TotalSeconds / 60 / 60 / 24)); } return(string.Format(Strings.Resources.WalletUpdatedTimeAgo, time)); } } return(null); }
public object Convert(object value, Type targetType, object parameter, string language) { var count = System.Convert.ToInt32(value); if (count > 0) { return(Locale.Declension("Users", count)); } return(Strings.Resources.EmpryUsersPlaceholder); }
public object Convert(object value, Type targetType, object parameter, string language) { if (parameter is string format) { // TODO: declesion return(Locale.Declension(format, System.Convert.ToInt32(value))); } return(value); }
private async void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; var stickerSet = args.Item as StickerSetInfo; if (args.Phase == 0) { var title = content.Children[1] as TextBlock; title.Text = stickerSet.Title; } else if (args.Phase == 1) { var subtitle = content.Children[2] as TextBlock; subtitle.Text = Locale.Declension("Stickers", stickerSet.Size); } else if (args.Phase == 2) { var photo = content.Children[0] as Image; var cover = stickerSet.Covers.FirstOrDefault(); if (cover == null || cover.Thumbnail == null) { return; } var file = cover.Thumbnail.Photo; if (file.Local.IsDownloadingCompleted) { var temp = await StorageFile.GetFileFromPathAsync(file.Local.Path); var buffer = await FileIO.ReadBufferAsync(temp); photo.Source = WebPImage.DecodeFromBuffer(buffer); } else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { photo.Source = null; ViewModel.ProtoService.Send(new DownloadFile(file.Id, 1)); } } if (args.Phase < 2) { args.RegisterUpdateCallback(OnContainerContentChanging); } args.Handled = true; }
private async void Grid_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { var content = sender as Grid; var stickerSet = args.NewValue as StickerSetInfo; var title = content.Children[1] as TextBlock; var subtitle = content.Children[2] as TextBlock; var photo = content.Children[0] as Image; if (stickerSet == null) { title.Text = Strings.Resources.ChooseStickerSetNotFound; subtitle.Text = Strings.Resources.ChooseStickerSetNotFoundInfo; photo.Source = null; return; } title.Text = stickerSet.Title; subtitle.Text = Locale.Declension("Stickers", stickerSet.Size); var cover = stickerSet.Thumbnail ?? stickerSet.Covers.FirstOrDefault()?.Thumbnail; if (cover == null) { return; } var file = cover.Photo; if (file.Local.IsDownloadingCompleted) { if (stickerSet.IsAnimated) { var bitmap = PlaceholderHelper.GetLottieFrame(file.Local.Path, 0, 48, 48); if (bitmap == null) { bitmap = await PlaceholderHelper.GetWebpAsync(file.Local.Path); } photo.Source = bitmap; } else { photo.Source = await PlaceholderHelper.GetWebpAsync(file.Local.Path); } } else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { photo.Source = null; ViewModel.ProtoService.DownloadFile(file.Id, 1); } }
private void Retry_Tick(object sender, object e) { if (_passcodeService.RetryIn > 0) { RetryIn.Visibility = Visibility.Visible; RetryIn.Text = string.Format(Strings.Resources.TooManyTries, Locale.Declension("Seconds", _passcodeService.RetryIn)); } else { _retryTimer.Stop(); RetryIn.Visibility = Visibility.Collapsed; } }
public void UpdateMessage(MessageViewModel message) { _message = message; var poll = message.Content as MessagePoll; if (poll == null) { return; } Question.Text = poll.Poll.Question; Type.Text = poll.Poll.IsClosed ? Strings.Resources.FinalResults : Strings.Resources.AnonymousPoll; // No public polls for now Votes.Text = poll.Poll.TotalVoterCount > 0 ? Locale.Declension("Vote", poll.Poll.TotalVoterCount) : Strings.Resources.NoVotes; //Options.Children.Clear(); //foreach (var option in poll.Poll.Options) //{ // var button = new PollOptionControl(); // button.Click += Option_Click; // button.UpdatePollOption(poll.Poll, option); // Options.Children.Add(button); //} for (int i = 0; i < Math.Max(poll.Poll.Options.Count, Options.Children.Count); i++) { if (i < Options.Children.Count) { var button = Options.Children[i] as PollOptionControl; if (i < poll.Poll.Options.Count) { button.UpdatePollOption(poll.Poll, poll.Poll.Options[i]); } else { Options.Children.Remove(button); } } else { var button = new PollOptionControl(); button.Click += Option_Click; button.UpdatePollOption(poll.Poll, poll.Poll.Options[i]); Options.Children.Add(button); } } }
public void UpdateSupergroup(Chat chat, Supergroup group) { Subtitle.Text = Locale.Declension(group.IsChannel ? "Subscribers" : "Members", group.MemberCount); DescriptionTitle.Text = Strings.Resources.DescriptionPlaceholder; Automation.SetToolTip(Edit, group.IsChannel ? Strings.Resources.ManageChannelMenu : Strings.Resources.ManageGroupMenu); Call.Visibility = Visibility.Collapsed; Edit.Visibility = group.Status is ChatMemberStatusCreator || group.Status is ChatMemberStatusAdministrator ? Visibility.Visible : Visibility.Collapsed; Edit.Glyph = Icons.Edit; Verified.Visibility = group.IsVerified ? Visibility.Visible : Visibility.Collapsed; Username.Badge = $"{group.Username}"; Username.Visibility = string.IsNullOrEmpty(group.Username) ? Visibility.Collapsed : Visibility.Visible; Location.Visibility = group.HasLocation ? Visibility.Visible : Visibility.Collapsed; if (group.IsChannel && !(group.Status is ChatMemberStatusCreator) && !(group.Status is ChatMemberStatusLeft) && !(group.Status is ChatMemberStatusBanned)) { MiscPanel.Visibility = Visibility.Visible; GroupLeave.Visibility = Visibility.Visible; } else { MiscPanel.Visibility = Visibility.Collapsed; GroupLeave.Visibility = Visibility.Collapsed; } GroupInvite.Visibility = !group.IsChannel && group.CanInviteUsers() ? Visibility.Visible : Visibility.Collapsed; ChannelMembersPanel.Visibility = group.IsChannel && (group.Status is ChatMemberStatusCreator || group.Status is ChatMemberStatusAdministrator) ? Visibility.Visible : Visibility.Collapsed; MembersPanel.Visibility = group.IsChannel ? Visibility.Collapsed : Visibility.Visible; //Admins.Visibility = Visibility.Collapsed; //Banned.Visibility = Visibility.Collapsed; //Restricted.Visibility = Visibility.Collapsed; //Members.Visibility = Visibility.Collapsed; if (!group.IsChannel && (ViewModel.Members == null || group.MemberCount < 200 && group.MemberCount != ViewModel.Members.Count)) { ViewModel.Members = ViewModel.CreateMembers(group.Id); } // Unused: UserPhone.Visibility = Visibility.Collapsed; UserCommonChats.Visibility = Visibility.Collapsed; UserStartSecret.Visibility = Visibility.Collapsed; SecretLifetime.Visibility = Visibility.Collapsed; SecretHashKey.Visibility = Visibility.Collapsed; }
private async void ChangeTtlExecute() { var enabled = CacheService.GetOption <OptionValueBoolean>("use_storage_optimizer")?.Value ?? false; var ttl = CacheService.GetOption <OptionValueInteger>("storage_max_time_from_last_access")?.Value ?? 0; var dialog = new ContentDialog { Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style }; var stack = new StackPanel(); stack.Margin = new Thickness(12, 16, 12, 0); stack.Children.Add(new RadioButton { Tag = 3, Content = Locale.Declension("Days", 3), IsChecked = enabled && ttl == 3 * 60 * 60 * 24 }); stack.Children.Add(new RadioButton { Tag = 7, Content = Locale.Declension("Weeks", 1), IsChecked = enabled && ttl == 7 * 60 * 60 * 24 }); stack.Children.Add(new RadioButton { Tag = 30, Content = Locale.Declension("Months", 1), IsChecked = enabled && ttl == 30 * 60 * 60 * 24 }); stack.Children.Add(new RadioButton { Tag = 0, Content = Strings.Resources.KeepMediaForever, IsChecked = !enabled }); dialog.Title = Strings.Resources.KeepMedia; dialog.Content = stack; dialog.PrimaryButtonText = Strings.Resources.OK; dialog.SecondaryButtonText = Strings.Resources.Cancel; var confirm = await dialog.ShowQueuedAsync(); if (confirm == ContentDialogResult.Primary) { var mode = 0; foreach (RadioButton current in stack.Children) { if (current.IsChecked == true) { mode = (int)current.Tag; break; } } ProtoService.Send(new SetOption("storage_max_time_from_last_access", new OptionValueInteger(mode * 60 * 60 * 24))); ProtoService.Send(new SetOption("use_storage_optimizer", new OptionValueBoolean(mode > 0))); RaisePropertyChanged(() => FilesTtl); } }
private void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (MAXIMUM_OPTIONS - Items.Count <= 0) { Add.Visibility = Visibility.Collapsed; AddInfo.Text = Strings.Resources.AddAnOptionInfoMax; } else { Add.Visibility = Visibility.Visible; AddInfo.Text = string.Format(Strings.Resources.AddAnOptionInfo, Locale.Declension("Option", MAXIMUM_OPTIONS - Items.Count)); } UpdatePrimaryButton(); }
public ChatMutePopup(int mutedFor) { InitializeComponent(); Title = Strings.Resources.MuteForAlert; PrimaryButtonText = Strings.Resources.OK; SecondaryButtonText = Strings.Resources.Cancel; var duration = TimeSpan.FromSeconds(mutedFor); DaysPicker.Value = duration.Days; DaysPicker.Header = string.Format(Locale.Declension("Days", duration.Days, false), string.Empty).Trim(); HoursPicker.Value = duration.Hours; HoursPicker.Header = string.Format(Locale.Declension("Hours", duration.Hours, false), string.Empty).Trim(); }
private async void ChangeTtlExecute() { var enabled = CacheService.Options.UseStorageOptimizer; var ttl = CacheService.Options.StorageMaxTimeFromLastAccess; var dialog = new TLContentDialog(); var stack = new StackPanel(); stack.Margin = new Thickness(12, 16, 12, 0); stack.Children.Add(new RadioButton { Tag = 3, Content = Locale.Declension("Days", 3), IsChecked = enabled && ttl == 3 * 60 * 60 * 24 }); stack.Children.Add(new RadioButton { Tag = 7, Content = Locale.Declension("Weeks", 1), IsChecked = enabled && ttl == 7 * 60 * 60 * 24 }); stack.Children.Add(new RadioButton { Tag = 30, Content = Locale.Declension("Months", 1), IsChecked = enabled && ttl == 30 * 60 * 60 * 24 }); stack.Children.Add(new RadioButton { Tag = 0, Content = Strings.Resources.KeepMediaForever, IsChecked = !enabled }); dialog.Title = Strings.Resources.KeepMedia; dialog.Content = stack; dialog.PrimaryButtonText = Strings.Resources.OK; dialog.SecondaryButtonText = Strings.Resources.Cancel; var confirm = await dialog.ShowQueuedAsync(); if (confirm == ContentDialogResult.Primary) { var mode = 0; foreach (RadioButton current in stack.Children) { if (current.IsChecked == true) { mode = (int)current.Tag; break; } } CacheService.Options.StorageMaxTimeFromLastAccess = mode * 60 * 60 * 24; CacheService.Options.UseStorageOptimizer = mode > 0; RaisePropertyChanged(() => FilesTtl); } }
private string ConvertTtl(int days) { if (days < 1) { return(Strings.Resources.KeepMediaForever); } else if (days < 7) { return(Locale.Declension("Days", days)); } else if (days < 30) { return(Locale.Declension("Weeks", 1)); } return(Locale.Declension("Months", 1)); }
public void UpdateBasicGroup(Chat chat, BasicGroup group) { Subtitle.Text = Locale.Declension("Members", group.MemberCount); DescriptionTitle.Text = Strings.Resources.DescriptionPlaceholder; GroupInvite.Visibility = group.Status is ChatMemberStatusCreator || (group.Status is ChatMemberStatusAdministrator administrator && administrator.CanInviteUsers) || chat.Permissions.CanInviteUsers ? Visibility.Visible : Visibility.Collapsed; Edit.Visibility = chat.Permissions.CanChangeInfo || group.Status is ChatMemberStatusCreator || group.Status is ChatMemberStatusAdministrator ? Visibility.Visible : Visibility.Collapsed; Edit.Glyph = Icons.Edit; ToolTipService.SetToolTip(Edit, Strings.Resources.ChannelEdit); // Unused: Call.Visibility = Visibility.Collapsed; VideoCall.Visibility = Visibility.Collapsed; Verified.Visibility = Visibility.Collapsed; UserPhone.Visibility = Visibility.Collapsed; Location.Visibility = Visibility.Collapsed; Username.Visibility = Visibility.Collapsed; DescriptionPanel.Visibility = Visibility.Collapsed; //UserCommonChats.Visibility = Visibility.Collapsed; UserStartSecret.Visibility = Visibility.Collapsed; MiscPanel.Visibility = Visibility.Collapsed; SecretLifetime.Visibility = Visibility.Collapsed; SecretHashKey.Visibility = Visibility.Collapsed; GroupLeave.Visibility = Visibility.Collapsed; ChannelMembersPanel.Visibility = Visibility.Collapsed; MembersPanel.Visibility = Visibility.Collapsed; //Admins.Visibility = Visibility.Collapsed; //Banned.Visibility = Visibility.Collapsed; //Restricted.Visibility = Visibility.Collapsed; //Members.Visibility = Visibility.Collapsed; SharedMedia.Tab = new SupergroupMembersView { DataContext = ViewModel.SupergroupMembers, IsEmbedded = true }; }
private async void ChangeTtlExecute() { var dialog = new ContentDialog { Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style }; var stack = new StackPanel(); stack.Margin = new Thickness(12, 16, 12, 0); stack.Children.Add(new RadioButton { Tag = 3, Content = Locale.Declension("Days", 3), IsChecked = FilesTtl == 3 }); stack.Children.Add(new RadioButton { Tag = 7, Content = Locale.Declension("Weeks", 1), IsChecked = FilesTtl == 7 }); stack.Children.Add(new RadioButton { Tag = 30, Content = Locale.Declension("Months", 1), IsChecked = FilesTtl == 30 }); stack.Children.Add(new RadioButton { Tag = 0, Content = Strings.Resources.KeepMediaForever, IsChecked = FilesTtl == 0 }); dialog.Title = Strings.Resources.KeepMedia; dialog.Content = stack; dialog.PrimaryButtonText = Strings.Resources.OK; dialog.SecondaryButtonText = Strings.Resources.Cancel; var confirm = await dialog.ShowQueuedAsync(); if (confirm == ContentDialogResult.Primary) { var mode = 1; foreach (RadioButton current in stack.Children) { if (current.IsChecked == true) { mode = (int)current.Tag; break; } } FilesTtl = mode; } }
public PollResultsPopup(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator, IMessageDelegate delegato, long chatId, long messageId, Poll poll) { InitializeComponent(); _protoService = protoService; _delegate = delegato; Title = Strings.Resources.PollResults; Subtitle.Text = Locale.Declension(poll.Type is PollTypeQuiz ? "Answer" : "Vote", poll.TotalVoterCount); PrimaryButtonText = Strings.Resources.OK; var options = new List <PollResultViewModel>(); foreach (var option in poll.Options) { options.Add(new PollResultViewModel(chatId, messageId, poll, option, protoService, cacheService, settingsService, aggregator)); } Repeater.ItemsSource = options; }
public void UpdatePollOption(Poll poll, PollOption option) { var results = poll.IsClosed || poll.Options.Any(x => x.IsChosen); var correct = poll.Type is PollTypeQuiz quiz && quiz.CorrectOptionId == poll.Options.IndexOf(option); IsThreeState = results; IsChecked = results ? null : new bool?(false); Tag = option; _allowToggle = poll.Type is PollTypeRegular regular && regular.AllowMultipleAnswers && !results; Ellipse.Opacity = results || option.IsBeingChosen ? 0 : 1; Percentage.Visibility = results ? Visibility.Visible : Visibility.Collapsed; Percentage.Text = $"{option.VotePercentage}%"; ToolTipService.SetToolTip(Percentage, results ? Locale.Declension(poll.Type is PollTypeQuiz ? "Answer" : "Vote", option.VoterCount) : null); Text.Text = option.Text; Zero.Visibility = results ? Visibility.Visible : Visibility.Collapsed; Votes.Maximum = results ? Math.Max(poll.Options.Max(x => x.VoterCount), 1) : 1; Votes.Value = results ? option.VoterCount : 0; Loading.IsActive = option.IsBeingChosen; Tick.Visibility = (results && correct) || option.IsChosen ? Visibility.Visible : Visibility.Collapsed; if (option.IsChosen && poll.Type is PollTypeQuiz) { VisualStateManager.GoToState(LayoutRoot, correct ? "Correct" : "Wrong", false); } else { VisualStateManager.GoToState(LayoutRoot, "Normal", false); } AutomationProperties.SetName(this, option.Text); }
private string ConvertSlowModeFooter(int value) { if (value == 0) { return(Strings.Resources.SlowmodeInfoOff); } else { if (value < 60) { return(string.Format(Strings.Resources.SlowmodeInfoSelected, Locale.Declension("Seconds", value))); } else if (value < 60 * 60) { return(string.Format(Strings.Resources.SlowmodeInfoSelected, Locale.Declension("Minutes", value / 60))); } else { return(string.Format(Strings.Resources.SlowmodeInfoSelected, Locale.Declension("Hours", value / 60 / 60))); } } }
public bool UpdateChat(Chat chat) { var visible = true; var channel = chat.Type is ChatTypeSupergroup super && super.IsChannel; if (chat.PendingJoinRequests?.TotalCount > 0) { ShowHide(true); if (chat.PendingJoinRequests.UserIds.Count < 3 && chat.PendingJoinRequests.UserIds.Count < chat.PendingJoinRequests.TotalCount) { _protoService.Send(new GetChatJoinRequests(chat.Id, string.Empty, string.Empty, null, 3)); } Label.Text = Locale.Declension("JoinRequests", chat.PendingJoinRequests.TotalCount); var destination = RecentUsers.Items; var origin = chat.PendingJoinRequests.UserIds; if (destination.Count > 0 && _chat?.Id == chat.Id) { destination.ReplaceDiff(origin.Select(x => new MessageSenderUser(x))); } else { destination.Clear(); destination.AddRange(origin.Select(x => new MessageSenderUser(x))); } } else { ShowHide(false); visible = false; } _chat = chat; return(visible); }