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;
            }
        }
Beispiel #2
0
        public StickerPanel()
        {
            InitializeComponent();
            DataContext = new object();

            var shadow1 = DropShadowEx.Attach(HeaderSeparator, 20, 0.25f);

            HeaderSeparator.SizeChanged += (s, args) =>
            {
                shadow1.Size = args.NewSize.ToVector2();
            };

            var protoService = TLContainer.Current.Resolve <IProtoService>();

            AnimationsRoot.DataContext           = AnimationDrawerViewModel.GetForCurrentView(protoService.SessionId);
            AnimationsRoot.ItemClick             = Animations_ItemClick;
            AnimationsRoot.ItemContextRequested += (s, args) => AnimationContextRequested?.Invoke(s, args);

            StickersRoot.DataContext           = StickerDrawerViewModel.GetForCurrentView(protoService.SessionId);
            StickersRoot.ItemClick             = Stickers_ItemClick;
            StickersRoot.ItemContextRequested += (s, args) => StickerContextRequested?.Invoke(s, args);

            EmojisRoot.DataContext = StickersRoot.DataContext;

            switch (SettingsService.Current.Stickers.SelectedTab)
            {
            case StickersTab.Emoji:
                Pivot.SelectedIndex = 0;
                break;

            case StickersTab.Animations:
                Pivot.SelectedIndex = 1;
                break;

            case StickersTab.Stickers:
                Pivot.SelectedIndex = 2;
                break;
            }

            if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "Shadow"))
            {
                var themeShadow = new ThemeShadow();
                BackgroundElement.Shadow       = themeShadow;
                BackgroundElement.Translation += new Vector3(0, 0, 32);

                themeShadow.Receivers.Add(ShadowElement);
            }
        }
        public StickerPanel()
        {
            InitializeComponent();
            DataContext = new object();

            var shadow = DropShadowEx.Attach(HeaderSeparator, 20, 0.25f);

            shadow.RelativeSizeAdjustment = Vector2.One;

            var protoService = TLContainer.Current.Resolve <IProtoService>();

            AnimationsRoot.DataContext           = AnimationDrawerViewModel.GetForCurrentView(protoService.SessionId);
            AnimationsRoot.ItemClick             = Animations_ItemClick;
            AnimationsRoot.ItemContextRequested += (s, args) => AnimationContextRequested?.Invoke(s, args);

            StickersRoot.DataContext           = StickerDrawerViewModel.GetForCurrentView(protoService.SessionId);
            StickersRoot.ItemClick             = Stickers_ItemClick;
            StickersRoot.ItemContextRequested += (s, args) => StickerContextRequested?.Invoke(s, args);

            EmojisRoot.DataContext = StickersRoot.DataContext;

            switch (SettingsService.Current.Stickers.SelectedTab)
            {
            case StickersTab.Emoji:
                Pivot.SelectedIndex = 0;
                break;

            case StickersTab.Animations:
                Pivot.SelectedIndex = 1;
                break;

            case StickersTab.Stickers:
                Pivot.SelectedIndex = 2;
                break;
            }

            if (ApiInfo.CanUseShadow)
            {
                var themeShadow = new ThemeShadow();
                BackgroundElement.Shadow       = themeShadow;
                BackgroundElement.Translation += new Vector3(0, 0, 32);

                themeShadow.Receivers.Add(ShadowElement);
            }
        }