Example #1
0
        private void UnloadAtIndex(int index)
        {
            if (index == 0 && EmojisRoot != null)
            {
                EmojisRoot.Deactivate();
                UnloadObject(EmojisRoot);
            }
            else if (index == 1 && AnimationsRoot != null)
            {
                var viewModel = AnimationsRoot.DataContext as AnimationDrawerViewModel;

                AnimationsRoot.Deactivate();
                UnloadObject(AnimationsRoot);

                if (viewModel != null)
                {
                    viewModel.Search(string.Empty);
                }
            }
            else if (index == 2 && StickersRoot != null)
            {
                var viewModel = StickersRoot.DataContext as StickerDrawerViewModel;

                StickersRoot.Deactivate();
                UnloadObject(StickersRoot);

                if (viewModel != null)
                {
                    viewModel.Search(string.Empty);
                }
            }
        }
Example #2
0
        private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Pivot.SelectedIndex == 0 && EmojisRoot == null)
            {
                FindName(nameof(Emojis));
                EmojisRoot.SetView(_widget);
            }

            var active = GetActiveDrawer();

            foreach (var drawer in GetDrawers())
            {
                if (drawer == active)
                {
                    drawer.Activate();
                }
                else
                {
                    drawer?.Deactivate();
                }
            }

            if (ViewModel != null)
            {
                ViewModel.Settings.Stickers.SelectedTab = active.Tab;
            }
        }
Example #3
0
        private void LoadAtIndex(Chat chat, int index, bool unload)
        {
            if (index == 0)
            {
                if (unload)
                {
                    UnloadAtIndex(1);
                    UnloadAtIndex(2);
                }

                if (EmojisRoot == null)
                {
                    FindName(nameof(EmojisRoot));
                    EmojisRoot.DataContext = EmojiDrawerViewModel.GetForCurrentView(ViewModel.SessionId);
                }

                EmojisRoot.Activate(chat);
                SettingsService.Current.Stickers.SelectedTab = StickersTab.Emoji;
            }
            else if (index == 1)
            {
                if (unload)
                {
                    UnloadAtIndex(0);
                    UnloadAtIndex(2);
                }

                if (AnimationsRoot == null)
                {
                    FindName(nameof(AnimationsRoot));
                    AnimationsRoot.DataContext           = AnimationDrawerViewModel.GetForCurrentView(ViewModel.SessionId);
                    AnimationsRoot.ItemClick             = Animations_ItemClick;
                    AnimationsRoot.ItemContextRequested += (s, args) => AnimationContextRequested?.Invoke(s, args);
                }

                AnimationsRoot.Activate(chat);
                SettingsService.Current.Stickers.SelectedTab = StickersTab.Animations;
            }
            else if (index == 2)
            {
                if (unload)
                {
                    UnloadAtIndex(0);
                    UnloadAtIndex(1);
                }

                if (StickersRoot == null)
                {
                    FindName(nameof(StickersRoot));
                    StickersRoot.DataContext           = StickerDrawerViewModel.GetForCurrentView(ViewModel.SessionId);
                    StickersRoot.ItemClick             = Stickers_ItemClick;
                    StickersRoot.ItemContextRequested += (s, args) => StickerContextRequested?.Invoke(s, args);
                    StickersRoot.ChoosingItem         += (s, args) => ChoosingSticker?.Invoke(s, args);
                }

                StickersRoot.Activate(chat);
                SettingsService.Current.Stickers.SelectedTab = StickersTab.Stickers;
            }
        }
        public void SetView(StickersPanelMode mode)
        {
            _widget = mode;

            EmojisRoot?.SetView(mode);
            VisualStateManager.GoToState(this, mode == StickersPanelMode.Overlay
                ? "FilledState"
                : mode == StickersPanelMode.Sidebar
                ? "SidebarState"
                : "NarrowState", false);
        }