public void ClearRecentStickers() { IsWorking = true; MTProtoService.ClearRecentStickersAsync( false, result => Execute.BeginOnUIThread(() => { IsWorking = false; MTProtoService.SetMessageOnTime(2.0, AppResources.Done); var allStickers = StateService.GetAllStickers(); if (allStickers != null) { var allStickers29 = allStickers as TLAllStickers29; if (allStickers29 != null) { allStickers29.RecentlyUsed = new TLVector <TLRecentlyUsedSticker>(); EmojiControl emojiControl; if (EmojiControl.TryGetInstance(out emojiControl)) { emojiControl.ClearRecentStickers(); } StateService.SaveAllStickersAsync(allStickers29); } } }), error => Execute.BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("messages.clearRecentStickers error " + error); })); }
public void Remove(TLStickerSet set) { if (set == null) { return; } var inputSet = new TLInputStickerSetId { Id = set.Id, AccessHash = set.AccessHash }; IsWorking = true; MTProtoService.UninstallStickerSetAsync(inputSet, result => Execute.BeginOnUIThread(() => { IsWorking = false; Items.Remove(set); var emojiControl = EmojiControl.GetInstance(); emojiControl.RemoveStickerSet(inputSet); }), error => Execute.BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("messages.uninstallStickerSet error " + error); })); }
private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (_manipulationStartedArgs == null) { Touch.FrameReported -= Touch_FrameReported; return; } var point = e.GetPrimaryTouchPoint(null); if (point.Action == TouchAction.Up) { Touch.FrameReported -= Touch_FrameReported; return; } var manipulationPoint = e.GetPrimaryTouchPoint(_manipulationStartedArgs.ManipulationContainer); var length = Math.Pow(manipulationPoint.Position.X - _manipulationStartedArgs.ManipulationOrigin.X, 2.0) + Math.Pow(manipulationPoint.Position.Y - _manipulationStartedArgs.ManipulationOrigin.Y, 2.0); if (length > 30.0 * 30.0) { Touch.FrameReported -= Touch_FrameReported; return; } if (_startTime.HasValue && _startTime.Value.AddSeconds(0.5) <= DateTime.Now) { Touch.FrameReported -= Touch_FrameReported; VirtPanel.DisableVerticalScrolling(); _loadedStoryboard = EmojiControl.GetScaleStoryboard(_fromItem, 0.85, 1.0); Preview.Visibility = Visibility.Visible; var stickerImage = _fromItem as Image; if (stickerImage != null) { PreviewImage.Source = stickerImage.Source; var stickerItem = stickerImage.DataContext as TLStickerItem; if (stickerItem != null) { Image.DataContext = stickerItem; } } var grid = Preview; grid.Children.Remove(PreviewGrid); Execute.BeginOnUIThread(() => { PreviewGrid.RenderTransform = new CompositeTransform(); PreviewGrid.Opacity = 0.0; grid.Children.Add(PreviewGrid); }); } }
private void Button_Click(object sender, RoutedEventArgs e) { Flyout emojis = new Flyout(); emojis.FlyoutPresenterStyle = (Style)App.Current.Resources["FlyoutPresenterStyle1"]; var emojiPicker = new EmojiControl(); emojis.Content = emojiPicker; emojis.ShowAt(sender as Button); emojis.Closed += (o, o1) => { emojis = null; }; emojiPicker.PickedEmoji += (o, args) => { emojis.Hide(); //if (args.names.Count > 1) //{ // int newSelectionStart = MessageEditor.SelectionStart + args.names[0].Length + args.names[1].Length + 4; // MessageEditor.Text = MessageEditor.Text.Insert(MessageEditor.SelectionStart, ":" + args.names[0] + "::" + args.names[1] + ":"); // MessageEditor.SelectionStart = newSelectionStart; //} else //{ // int newSelectionStart = MessageEditor.SelectionStart + args.names[0].Length + 2; // MessageEditor.Text = MessageEditor.Text.Insert(MessageEditor.SelectionStart, ":" + args.names[0] + ":"); // MessageEditor.SelectionStart = newSelectionStart; //} string emojiText = ""; if (args.GetType() == typeof(EmojiControl.GuildSide)) { var emoji = (EmojiControl.GuildSide)args; if (emoji.surrogates.EndsWith(".gif")) { emojiText = "<a:" + emoji.names.First() + ":" + emoji.id + ">"; } else { emojiText = "<:" + emoji.names.First() + ":" + emoji.id + ">"; } } else { emojiText = args.surrogates; } int newSelectionStart = MessageEditor.SelectionStart + emojiText.Length; MessageEditor.Text = MessageEditor.Text.Insert(MessageEditor.SelectionStart, emojiText); MessageEditor.SelectionStart = newSelectionStart; MessageEditor.Focus(FocusState.Keyboard); }; }
private void OnSmileIconClick(object sender, EventArgs e) { if (EmojiInstance == null) { // Initialize EmojiControl EmojiInstance = EmojiControl.GetInstance(); EmojiInstance.BindTextBox(InputTextBox); ContentPanel.Children.Add(EmojiInstance); // Add to view } EmojiInstance.IsOpen = !EmojiInstance.IsOpen; }
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { if (_emojiKeyboard != null) { // Destroy EmojiControl _emojiKeyboard.IsOpen = false; _emojiKeyboard.UnbindTextBox(); EmojiPlaceholder.Content = null; // Remove from view EmojiPlaceholder.Visibility = Visibility.Collapsed; _emojiKeyboard = null; } base.OnNavigatingFrom(e); }
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { base.OnNavigatingFrom(e); if (EmojiInstance == null) { return; } // Destroy EmojiControl EmojiInstance.IsOpen = false; EmojiInstance.UnbindTextBox(); ContentPanel.Children.Remove(EmojiInstance); // Remove from view EmojiInstance = null; }
public static void LogOutCommon(ITelegramEventAggregator eventAggregator, IMTProtoService mtProtoService, IUpdatesService updateService, ICacheService cacheService, IStateService stateService, IPushService pushService, INavigationService navigationService) { eventAggregator.Publish(Commands.LogOutCommand); SettingsHelper.SetValue(Constants.IsAuthorizedKey, false); SettingsHelper.RemoveValue(Constants.CurrentUserKey); mtProtoService.ClearQueue(); updateService.ClearState(); cacheService.ClearAsync(); stateService.ResetPasscode(); stateService.ClearAllStickersAsync(); stateService.ClearFeaturedStickersAsync(); stateService.ClearArchivedStickersAsync(); EmojiControl emojiControl; if (EmojiControl.TryGetInstance(out emojiControl)) { emojiControl.ClearStickersOnLogOut(); } cacheService.ClearConfigImportAsync(); SearchViewModel.DeleteRecentAsync(); Bootstrapper.UpdateMainTile(); DialogDetailsViewModel.DeleteInlineBots(); FileUtils.Delete(new object(), Constants.InlineBotsNotificationFileName); FileUtils.Delete(new object(), Constants.WebPagePreviewsFileName); var liveLocationService = IoC.Get <ILiveLocationService>(); liveLocationService.Clear(); if (navigationService.CurrentSource == navigationService.UriFor <StartupViewModel>().BuildUri() || navigationService.CurrentSource == navigationService.UriFor <SignInViewModel>().BuildUri() || navigationService.CurrentSource == navigationService.UriFor <ConfirmViewModel>().BuildUri() || navigationService.CurrentSource == navigationService.UriFor <SignUpViewModel>().BuildUri()) { return; } stateService.ClearNavigationStack = true; Telegram.Logs.Log.Write("StartupViewModel SettingsViewModel.LogOutCommon"); navigationService.UriFor <StartupViewModel>().Navigate(); }
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { if (_emojiKeyboard != null) { // Destroy EmojiControl _emojiKeyboard.IsOpen = false; _emojiKeyboard.UnbindTextBox(); _emojiKeyboard.StickerSelected -= OnStickerSelected; EmojiPlaceholder.Content = null; // Remove from view EmojiPlaceholder.Visibility = Visibility.Collapsed; AudioRecorder.Visibility = GetAudioRecorderVisibility(); //Visibility.Visible; Title.Visibility = Visibility.Visible; DialogPhoto.Visibility = Visibility.Visible; _emojiKeyboard = null; } base.OnNavigatingFrom(e); }
private void StickerPanel_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { var fromItem = _fromItem; _startTime = null; _fromItem = null; if (_storyboard != null) { _storyboard.SkipToFill(); } VirtPanel.EnableVerticalScrolling(); Preview.Visibility = Visibility.Collapsed; var st = EmojiControl.GetScaleStoryboard(_lastMouseEnter ?? fromItem, 1.0, 1.0); if (st != null) { Execute.BeginOnUIThread(st.Begin); } }
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { if (_emojiKeyboard != null) { // Destroy EmojiControl _emojiKeyboard.IsOpen = false; _emojiKeyboard.UnbindTextBox(); EmojiPlaceholder.Content = null; // Remove from view EmojiPlaceholder.Visibility = Visibility.Collapsed; _emojiKeyboard = null; } // if (e.Uri.OriginalString.EndsWith("VideoCaptureView.xaml") // || e.Uri.OriginalString.EndsWith("MapView.xaml") // || e.Uri.OriginalString.EndsWith("ShareContactView.xaml")) // { // OpenPeerDetails_OnTap(this, null); // } base.OnNavigatingFrom(e); }
public DialogDetailsView() { InitializeComponent(); AnimationContext = LayoutRoot; _sendButton.Click += (sender, args) => ViewModel.Send(); _attachButton.Click += (sender, args) => { EmojiPlaceholder.Visibility = Visibility.Collapsed; //DialogPhoto.Visibility = Visibility.Visible; //Title.Visibility = Visibility.Visible; ChooseAttachment.Focus(); ViewModel.Attach(); }; _smileButton.Click += (sender, args) => { if (_emojiKeyboard == null) { _emojiKeyboard = EmojiControl.GetInstance(); _emojiKeyboard.BindTextBox(InputMessage); EmojiPlaceholder.Content = _emojiKeyboard; _emojiKeyboard.IsOpen = true; } if (EmojiPlaceholder.Visibility == Visibility.Visible) { if (InputMessage == FocusManager.GetFocusedElement()) { _smileButtonPressed = true; EmojiPlaceholder.Opacity = 1.0; EmojiPlaceholder.Height = EmojiControl.PortraitOrientationHeight; Items.Focus(); } else { EmojiPlaceholder.Visibility = Visibility.Collapsed; //DialogPhoto.Visibility = Visibility.Visible; //Title.Visibility = Visibility.Visible; } } else { var awaitKeyboardDown = false; if (InputMessage == FocusManager.GetFocusedElement()) { awaitKeyboardDown = true; Items.Focus(); } ThreadPool.QueueUserWorkItem(state => { if (awaitKeyboardDown) { Thread.Sleep(400); } Deployment.Current.Dispatcher.BeginInvoke(() => { EmojiPlaceholder.Opacity = 1.0; EmojiPlaceholder.Visibility = Visibility.Visible; //DialogPhoto.Visibility = Visibility.Collapsed; //Title.Visibility = Visibility.Collapsed; }); }); } }; _manageButton.Click += (sender, args) => SwitchToSelectionMode(); _forwardButton.Click += (sender, args) => { var selectedItems = ViewModel.Items.Where(x => x.Id != null && x.IsSelected).ToList(); if (selectedItems.Count == 0) { return; } ViewModel.IsSelectionEnabled = false; Deployment.Current.Dispatcher.BeginInvoke(() => { try { if (Items.Visibility == Visibility.Visible) { var writeableBitmap = new WriteableBitmap(Items, null); ViewModel.With.Bitmap = writeableBitmap; } } catch (Exception ex) { Telegram.Api.Helpers.Execute.ShowDebugMessage("WritableBitmap exception " + ex); } ViewModel.ForwardMessages(selectedItems); }); }; _deleteButton.Click += (sender, args) => ViewModel.DeleteMessages(); Loaded += (sender, args) => { SetRootFrameBinding(); if (!ViewModel.StateService.IsEmptyBackground) { var color = Colors.White; color.A = 254; SystemTray.ForegroundColor = color; } if (ViewModel.StateService.CurrentBackground != null) { var color = Colors.White; color.A = 254; SystemTray.ForegroundColor = color; } if (ViewModel.With is TLBroadcastChat) { _forwardButton.IsEnabled = false; } ThreadPool.QueueUserWorkItem(state => { Thread.Sleep(300); Deployment.Current.Dispatcher.BeginInvoke(() => { if (ViewModel.StateService.FocusOnInputMessage) { ViewModel.StateService.FocusOnInputMessage = false; InputMessage.Focus(); } }); }); if (ViewModel.ChooseAttachment != null) { ViewModel.ChooseAttachment.PropertyChanged += OnChooseAttachmentPropertyChanged; } if (ViewModel.ImageViewer != null) { ViewModel.ImageViewer.PropertyChanged += OnImageViewerPropertyChanged; } if (ViewModel.ImageEditor != null) { ViewModel.ImageEditor.PropertyChanged += OnImageEditorPropertyChanged; } ViewModel.PropertyChanged += OnViewModelPropertyChanged; ViewModel.ScrollToBottom += OnViewModelScrollToBottom; BuildLocalizedAppBar(); //MessageBox.Show("Time: " + timer.Elapsed); }; Unloaded += (sender, args) => { RemoveRootFrameBinding(); if (ViewModel.ChooseAttachment != null) { ViewModel.ChooseAttachment.PropertyChanged -= OnChooseAttachmentPropertyChanged; } if (ViewModel.ImageViewer != null) { ViewModel.ImageViewer.PropertyChanged -= OnImageViewerPropertyChanged; } if (ViewModel.ImageEditor != null) { ViewModel.ImageEditor.PropertyChanged -= OnImageEditorPropertyChanged; } ViewModel.ScrollToBottom -= OnViewModelScrollToBottom; ViewModel.PropertyChanged -= OnViewModelPropertyChanged; }; }
protected override void RenderDiscord(DiscordInline element, IRenderContext context) { if (!(context is InlineRenderContext localContext)) { throw new RenderContextIncorrectException(); } if (Channel != null) { var guild = Channel.Guild; var client = Channel.Discord as DiscordClient; if (element.DiscordType != DiscordInline.MentionType.Emote) { var run = new Run() { FontWeight = FontWeights.Bold }; if (element.DiscordType == DiscordInline.MentionType.User) { var user = guild != null ? (guild.Members.TryGetValue(element.Id, out var memb) ? memb : null) : client.TryGetCachedUser(element.Id, out var u) ? u : null; if (user != null) { run.Text = IsSystemMessage ? user.DisplayName : $"@{user.DisplayName}"; run.Foreground = GetDiscordBrush(user.Color); } else { run.Text = $"<@{element.Id}>"; } } else if (element.DiscordType == DiscordInline.MentionType.Role) { if (Channel.Guild != null && Channel.Guild.Roles.TryGetValue(element.Id, out var role)) { run.Text = $"@{role.Name}"; run.Foreground = GetDiscordBrush(role.Color); } else { run.Text = $"<@&{element.Id}>"; } } else if (element.DiscordType == DiscordInline.MentionType.Channel) { if (client.TryGetCachedChannel(element.Id, out var channel) && !(channel is DiscordDmChannel)) { run.Text = $"#{channel.Name}"; } else { run.Text = $"#deleted-channel"; } } localContext.InlineCollection.Add(run); } else { var border = RootElement.FindParent <Border>(); var uri = $"https://cdn.discordapp.com/emojis/{element.Id}?size=128"; var ui = new InlineUIContainer() { FontSize = IsHuge ? 42 : 24 }; var size = IsHuge ? 48 : 24; var image = new EmojiControl() { Emoji = DiscordEmoji.FromGuildEmote(App.Discord, element.Id, element.Text), Size = size, MaxWidth = size * 3, RenderTransform = IsHuge ? null : new TranslateTransform() { Y = 8 } }; ToolTipService.SetToolTip(image, element.Text); ui.Child = image; RootElement.Margin = new Thickness(0, 0, 0, 4); localContext.InlineCollection.Add(ui); if (!IsHuge && RootElement.RenderTransform is not TranslateTransform tt) { RootElement.Margin = new Thickness(0, -8, 0, 0); } } } }
public static void NavigateToStickers(IMTProtoService mtProtoService, IStateService stateService, TLInputStickerSetBase inputStickerSet) { #if WP8 if (mtProtoService != null) { Execute.BeginOnUIThread(() => { var frame = Application.Current.RootVisual as TelegramTransitionFrame; if (frame != null) { frame.OpenBlockingProgress(); } stateService.GetAllStickersAsync(cachedStickers => { mtProtoService.GetStickerSetAsync(inputStickerSet, stickerSet => Execute.BeginOnUIThread(() => { if (frame != null) { frame.CloseBlockingProgress(); } var emoticons = new Dictionary <long, string>(); for (var i = 0; i < stickerSet.Packs.Count; i++) { var emoticon = stickerSet.Packs[i].Emoticon.ToString(); foreach (var document in stickerSet.Packs[i].Documents) { emoticons[document.Value] = emoticon; } } stickerSet.Set.Stickers = new TLVector <TLObject>(); for (var i = 0; i < stickerSet.Documents.Count; i++) { var document22 = stickerSet.Documents[i] as TLDocument22; if (document22 != null) { string emoticon; if (emoticons.TryGetValue(document22.Id.Value, out emoticon)) { document22.Emoticon = emoticon; } stickerSet.Set.Stickers.Add(new TLStickerItem { Document = document22 }); } } var isCancelVisible = true; var allStickers29 = cachedStickers as TLAllStickers29; if (allStickers29 != null) { isCancelVisible = allStickers29.Sets.FirstOrDefault(x => x.Id.Value == stickerSet.Set.Id.Value) == null; } ShowMessagePrompt(isCancelVisible, stickerSet.Set, prompt => { if (prompt == PopUpResult.Ok && isCancelVisible) { mtProtoService.InstallStickerSetAsync(inputStickerSet, result => Execute.BeginOnUIThread(() => { var instance = EmojiControl.GetInstance(); instance.AddStickerSet(stickerSet); mtProtoService.SetMessageOnTime(2.0, AppResources.NewStickersAdded); }), error => Execute.BeginOnUIThread(() => { if (error.CodeEquals(ErrorCode.BAD_REQUEST)) { if (error.TypeEquals(ErrorType.STICKERSET_INVALID)) { MessageBox.Show(AppResources.StickersNotFound, AppResources.Error, MessageBoxButton.OK); } else { Execute.ShowDebugMessage("messages.importChatInvite error " + error); } } else { Execute.ShowDebugMessage("messages.importChatInvite error " + error); } })); } }); }), error => Execute.BeginOnUIThread(() => { if (frame != null) { frame.CloseBlockingProgress(); } if (error.CodeEquals(ErrorCode.BAD_REQUEST)) { if (error.TypeEquals(ErrorType.STICKERSET_INVALID)) { MessageBox.Show(AppResources.StickersNotFound, AppResources.Error, MessageBoxButton.OK); } else { Execute.ShowDebugMessage("messages.getStickerSet error " + error); } } else { Execute.ShowDebugMessage("messages.getStickerSet error " + error); } })); }); }); } #endif }
public void AddToFavedStickers(TLMessageBase messageBase) { if (messageBase == null) { return; } var message = messageBase as TLMessage; if (message == null || !message.IsSticker()) { return; } var mediaDocument = message.Media as TLMessageMediaDocument; if (mediaDocument == null) { return; } var document = mediaDocument.Document as TLDocument22; if (document != null) { var allStickers = StateService.GetAllStickers() as TLAllStickers43; if (allStickers != null) { var favedStickers = allStickers.FavedStickers; if (favedStickers != null) { var unfave = favedStickers.Documents.FirstOrDefault(x => x.Index == document.Index) != null; MTProtoService.FaveStickerAsync(new TLInputDocument { Id = document.Id, AccessHash = document.AccessHash }, new TLBool(unfave), result => Execute.BeginOnUIThread(() => { if (unfave) { favedStickers.RemoveSticker(document); } else { favedStickers.AddSticker(document); } allStickers.FavedStickers = favedStickers; StateService.SaveAllStickersAsync(allStickers); EmojiControl emojiControl; if (unfave) { MTProtoService.GetFavedStickersAsync(allStickers.FavedStickers.Hash, result2 => { var favedStickers2 = result2 as TLFavedStickers; if (favedStickers2 != null) { allStickers.FavedStickers = favedStickers; StateService.SaveAllStickersAsync(allStickers); Execute.BeginOnUIThread(() => { if (EmojiControl.TryGetInstance(out emojiControl)) { emojiControl.ResetFavedStickers(); } }); } }, error2 => { }); } if (EmojiControl.TryGetInstance(out emojiControl)) { emojiControl.ResetFavedStickers(); } }), error => { }); } } } }
public SecretDialogDetailsView() { _timer = System.Diagnostics.Stopwatch.StartNew(); InitializeComponent(); _sendButton.Click += (sender, args) => ViewModel.Send(); _attachButton.Click += (sender, args) => { EmojiPlaceholder.Visibility = Visibility.Collapsed; Self.Focus(); ViewModel.Attach(); }; _manageButton.Click += (sender, args) => SwitchToSelectionMode(); _deleteButton.Click += (sender, args) => { ViewModel.DeleteMessages(); SwitchToNormalMode(); }; _smileButton.Click += (sender, args) => { if (_emojiKeyboard == null) { _emojiKeyboard = EmojiControl.GetInstance(); _emojiKeyboard.BindTextBox(InputMessage); EmojiPlaceholder.Content = _emojiKeyboard; _emojiKeyboard.IsOpen = true; } if (EmojiPlaceholder.Visibility == Visibility.Visible) { if (InputMessage == FocusManager.GetFocusedElement()) { _smileButtonPressed = true; Items.Focus(); EmojiPlaceholder.Opacity = 1.0; EmojiPlaceholder.Height = EmojiControl.PortraitOrientationHeight; } else { EmojiPlaceholder.Visibility = Visibility.Collapsed; } } else { var awaitKeyboardDown = false; if (InputMessage == FocusManager.GetFocusedElement()) { awaitKeyboardDown = true; Items.Focus(); } ThreadPool.QueueUserWorkItem(state => { if (awaitKeyboardDown) { Thread.Sleep(400); } Deployment.Current.Dispatcher.BeginInvoke(() => { EmojiPlaceholder.Visibility = Visibility.Visible; }); }); } }; Loaded += OnLoaded; Unloaded += OnUnloaded; }
public void ReorderStickerSets() { if (_allStickers == null) { return; } if (_delayedItems != null && _delayedItems.Count > 0) { return; } var oldHash = TLUtils.ToTLInt(_allStickers.Hash); var newHash = TLUtils.GetAllStickersHash(Items); if (oldHash.Value != newHash) { var order = new TLVector <TLLong>(); foreach (var item in Items) { order.Add(item.Id); } Execute.ShowDebugMessage("ReorderStickers"); IsWorking = true; MTProtoService.ReorderStickerSetsAsync(false, order, result => BeginOnUIThread(() => { IsWorking = false; var allStickers = _allStickers as TLAllStickers32; if (allStickers != null) { allStickers.Hash = new TLString(newHash.ToString(CultureInfo.InvariantCulture)); allStickers.Sets = new TLVector <TLStickerSetBase>(Items); var sets = new Dictionary <long, TLVector <TLDocumentBase> >(); for (var i = 0; i < allStickers.Documents.Count; i++) { var document22 = allStickers.Documents[i] as TLDocument22; if (document22 != null) { var stickerSetId = document22.StickerSet as TLInputStickerSetId; if (stickerSetId != null) { TLVector <TLDocumentBase> stickers; if (sets.TryGetValue(stickerSetId.Id.Value, out stickers)) { stickers.Add(document22); } else { sets[stickerSetId.Id.Value] = new TLVector <TLDocumentBase> { document22 }; } } } } var documents = new TLVector <TLDocumentBase>(); for (var i = 0; i < allStickers.Sets.Count; i++) { TLVector <TLDocumentBase> stickers; if (sets.TryGetValue(allStickers.Sets[i].Id.Value, out stickers)) { foreach (var sticker in stickers) { documents.Add(sticker); } } } allStickers.Documents = documents; EmojiControl emojiControl; if (EmojiControl.TryGetInstance(out emojiControl)) { emojiControl.ReorderStickerSets(); } StateService.SaveAllStickersAsync(allStickers); } }), error => BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("messages.reorderStickerSets error " + error); })); } }
public SecretDialogDetailsView() { _timer = System.Diagnostics.Stopwatch.StartNew(); InitializeComponent(); //Full HD OptimizeFullHD(); _sendButton.Click += (sender, args) => ViewModel.Send(); _attachButton.Click += (sender, args) => { EmojiPlaceholder.Visibility = Visibility.Collapsed; AudioRecorder.Visibility = GetAudioRecorderVisibility(); //Visibility.Visible; Title.Visibility = Visibility.Visible; DialogPhoto.Visibility = Visibility.Visible; Self.Focus(); ViewModel.Attach(); }; _manageButton.Click += (sender, args) => SwitchToSelectionMode(); _deleteButton.Click += (sender, args) => { ViewModel.DeleteMessages(); SwitchToNormalMode(); }; _smileButton.Click += (sender, args) => { if (_emojiKeyboard == null) { _emojiKeyboard = EmojiControl.GetInstance(); _emojiKeyboard.BindTextBox(InputMessage, true); _emojiKeyboard.StickerSelected += OnStickerSelected; EmojiPlaceholder.Content = _emojiKeyboard; _emojiKeyboard.IsOpen = true; } if (EmojiPlaceholder.Visibility == Visibility.Visible) { if (InputMessage == FocusManager.GetFocusedElement()) { Items.Focus(); _smileButtonPressed = true; EmojiPlaceholder.Opacity = 1.0; EmojiPlaceholder.Height = EmojiControl.PortraitOrientationHeight; } else { EmojiPlaceholder.Visibility = Visibility.Collapsed; AudioRecorder.Visibility = GetAudioRecorderVisibility(); //Visibility.Visible; Title.Visibility = Visibility.Visible; DialogPhoto.Visibility = Visibility.Visible; } } else { var awaitKeyboardDown = false; if (InputMessage == FocusManager.GetFocusedElement()) { awaitKeyboardDown = true; Items.Focus(); } Telegram.Api.Helpers.Execute.BeginOnThreadPool(() => { if (awaitKeyboardDown) { Thread.Sleep(400); } Telegram.Api.Helpers.Execute.BeginOnUIThread(() => { EmojiPlaceholder.Visibility = Visibility.Visible; AudioRecorder.Visibility = Visibility.Collapsed; Title.Visibility = Visibility.Collapsed; DialogPhoto.Visibility = Visibility.Collapsed; }); }); } }; Loaded += OnLoaded; Unloaded += OnUnloaded; }
private void StickerPanel_MouseEnter(object sender, MouseEventArgs e) { if (Preview.Visibility == Visibility.Collapsed) { return; } //DebugText.Text = sender.GetHashCode().ToString(); var st1 = EmojiControl.GetScaleStoryboard(_lastMouseEnter ?? _fromItem, 1.0, 1.0); _lastMouseEnter = e.OriginalSource as FrameworkElement; var stickerImage = e.OriginalSource as Image; if (stickerImage != null) { PreviewImage.Source = stickerImage.Source; var stickerItem = stickerImage.DataContext as TLStickerItem; if (stickerItem != null) { Image.DataContext = stickerItem; } PreviewGrid.DataContext = Image.DataContext; } var duration = .5; var easingFunction = new ElasticEase { Oscillations = 1, Springiness = 10.0, EasingMode = EasingMode.EaseOut }; var storyboard = new Storyboard(); var doubleAnimation = new DoubleAnimation(); doubleAnimation.From = 0.0; doubleAnimation.To = 0.0; doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(duration)); doubleAnimation.EasingFunction = easingFunction; Storyboard.SetTarget(doubleAnimation, PreviewGrid); Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)")); storyboard.Children.Add(doubleAnimation); var doubleAnimation2 = new DoubleAnimation(); doubleAnimation2.From = 0.0; //position.Y; doubleAnimation2.To = 0.0; doubleAnimation2.Duration = new Duration(TimeSpan.FromSeconds(duration)); doubleAnimation2.EasingFunction = easingFunction; Storyboard.SetTarget(doubleAnimation2, PreviewGrid); Storyboard.SetTargetProperty(doubleAnimation2, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)")); storyboard.Children.Add(doubleAnimation2); var doubleAnimation3 = new DoubleAnimation(); doubleAnimation3.From = 1.0; doubleAnimation3.To = 1.0; doubleAnimation3.Duration = new Duration(TimeSpan.FromSeconds(duration)); doubleAnimation3.EasingFunction = easingFunction; Storyboard.SetTarget(doubleAnimation3, PreviewGrid); Storyboard.SetTargetProperty(doubleAnimation3, new PropertyPath("Opacity")); storyboard.Children.Add(doubleAnimation3); var doubleAnimation4 = new DoubleAnimation(); doubleAnimation4.From = 2.4; doubleAnimation4.To = 2.6; doubleAnimation4.Duration = new Duration(TimeSpan.FromSeconds(duration)); doubleAnimation4.EasingFunction = easingFunction; Storyboard.SetTarget(doubleAnimation4, PreviewGrid); Storyboard.SetTargetProperty(doubleAnimation4, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.ScaleY)")); storyboard.Children.Add(doubleAnimation4); var doubleAnimation5 = new DoubleAnimation(); doubleAnimation5.From = 2.4; doubleAnimation5.To = 2.6; doubleAnimation5.Duration = new Duration(TimeSpan.FromSeconds(duration)); doubleAnimation5.EasingFunction = easingFunction; Storyboard.SetTarget(doubleAnimation5, PreviewGrid); Storyboard.SetTargetProperty(doubleAnimation5, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.ScaleX)")); storyboard.Children.Add(doubleAnimation5); storyboard.Begin(); _storyboard = storyboard; var st2 = EmojiControl.GetScaleStoryboard(_lastMouseEnter, 0.85, 1.0); if (st1 != null || st2 != null) { Execute.BeginOnUIThread(() => { if (st1 != null) { st1.Begin(); } if (st2 != null) { st2.Begin(); } }); } }