Beispiel #1
0
        protected override void OnApplyTemplate()
        {
            _AppTile = (AppTile)this;
            _backgroundShadowReceiverGrid = (Grid)_AppTile.GetTemplateChild("BackgroundShadowReceiverGrid");

            _rootGrid         = (Grid)_AppTile.GetTemplateChild("RootGrid");
            _backgroundShadow = (ThemeShadow)_rootGrid.Resources["BackgroundShadow"];
            _iconShadow       = (ThemeShadow)_rootGrid.Resources["IconShadow"];

            _appTitle = (TextBlock)_AppTile.GetTemplateChild("AppTitle");
            _appIcon  = (Image)_AppTile.GetTemplateChild("AppIcon");
            _tileGrid = (Grid)_AppTile.GetTemplateChild("TileGrid");


            _backgroundShadow.Receivers.Add(_backgroundShadowReceiverGrid);

            //_tileGrid.Background = new AcrylicBrush() { BackgroundSource = AcrylicBackgroundSource.Backdrop, FallbackColor = TileColor, TintColor = TileColor, TintOpacity = 0.6, TintTransitionDuration = new TimeSpan(0, 0, 0, 0, 400) };
            _tileGrid.Background = new SolidColorBrush(Colors.Transparent);

            _appIcon.Source = new BitmapImage()
            {
                UriSource = new Uri(IconPath)
            };
            base.OnApplyTemplate();

            Loaded -= AppTile_Loaded;
            Loaded += AppTile_Loaded;

            _tileGrid.PointerEntered += AppTile_PointerEntered;
            _tileGrid.PointerExited  += AppTile_PointerExited;
        }
Beispiel #2
0
     public Shadow()
     {
         if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 13))
         {
             ThemeShadow = new ThemeShadow();
         }
         else
         {
             DropShadow = new AttachedCardShadow {
                 BlurRadius = 8, CornerRadius = 4, Color = Colors.Black, Offset = "0,2", Opacity = 0.15
             }
         };
     }
 }
Beispiel #3
0
        public SettingsPrivacyShowForwardedPage()
        {
            InitializeComponent();
            Title = Strings.Resources.PrivacyForwards;

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

                themeShadow.Receivers.Add(BackgroundPresenter);
                themeShadow.Receivers.Add(MessagePreview);
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #6
0
        protected override void OnApplyTemplate()
        {
            ColorControl colorControl = (ColorControl)this;
            Grid         CastGrid     = (Grid)colorControl.GetTemplateChild("ShadowCastGrid");
            ThemeShadow  Shadow       = (ThemeShadow)colorControl.GetTemplateChild("BackdropShadow");

            ControlBorder = (Border)colorControl.GetTemplateChild("ControlBorder");
            ControlBorder.PointerEntered += ControlBorder_PointerEntered;
            ControlBorder.PointerExited  += ControlBorder_PointerExited;
            ControlBorder.PointerPressed += ControlBorder_PointerPressed;

            Shadow.Receivers.Add(CastGrid);

            ColumnDefinition C = (ColumnDefinition)colorControl.GetTemplateChild("ColDef");

            C.Width = DescriptionWidth;
            base.OnApplyTemplate();
        }
Beispiel #7
0
        public static void SetThemeShadow(UIElement target, float depth, params UIElement[] recievers)
        {
            try
            {
                if (!Supports1903 || !CompositionCapabilities.GetForCurrentView().AreEffectsFast())
                {
                    return;
                }

                target.Translation = new Vector3(0, 0, depth);

                var shadow = new ThemeShadow();
                target.Shadow = shadow;
                foreach (var r in recievers)
                {
                    shadow.Receivers.Add(r);
                }
            }
            catch { }
        }
Beispiel #8
0
        private void AnimateWrapper(double depth = -600, TimeSpan?stagger = null)
        {
            wrapper.Children.Clear();
            wrapper.Width = 170 * 3;

            ThemeShadow s = new ThemeShadow();

            s.Receivers.Add(ShadowRoot);

            foreach (var i in Enumerable.Range(0, 9))
            {
                wrapper.Children.Add(new Rectangle
                {
                    Margin = new Thickness(8),
                    Height = 150,
                    Width  = 150,
                    Fill   = new SolidColorBrush(Utils.GetRandomColor()),
                    Shadow = s
                });
            }

            StoryboardFactory.CreateDepth3DIn(wrapper.Children.Cast <FrameworkElement>().OrderBy(f => Guid.NewGuid()), wrapper, depth, customStagger: stagger).Begin();
        }
        public SettingsPrivacyShowForwardedPage()
        {
            InitializeComponent();
            DataContext = TLContainer.Current.Resolve <SettingsPrivacyShowForwardedViewModel>();

            var user = ViewModel.CacheService.GetUser(ViewModel.CacheService.Options.MyId);

            if (user != null)
            {
                MessagePreview.Mockup(Strings.Resources.PrivacyForwardsMessageLine, user.GetFullName(), true, false, DateTime.Now);
            }

            BackgroundPresenter.Update(ViewModel.SessionId, ViewModel.ProtoService, ViewModel.Aggregator);

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

                themeShadow.Receivers.Add(BackgroundPresenter);
                themeShadow.Receivers.Add(MessagePreview);
            }
        }
Beispiel #10
0
        protected override void OnApplyTemplate()
        {
            var popupRadius = (CornerRadius)ResourceAccessor.ResourceLookup(this, c_overlayCornerRadiusKey);

            var tabView         = SharedHelpers.GetAncestorOfType <TabView>(VisualTreeHelper.GetParent(this));
            var internalTabView = tabView ?? null;

            Button GetCloseButton(TabView internalTabView)
            {
                var closeButton = (Button)GetTemplateChild("CloseButton");

                if (closeButton != null)
                {
                    // Do localization for the close button automation name
                    if (string.IsNullOrEmpty(AutomationProperties.GetName(closeButton)))
                    {
                        var closeButtonName = ResourceAccessor.GetLocalizedStringResource(SR_TabViewCloseButtonName);
                        AutomationProperties.SetName(closeButton, closeButtonName);
                    }

                    if (internalTabView != null)
                    {
                        // Setup the tooltip for the close button
                        var tooltip = new ToolTip();
                        tooltip.Content = internalTabView.GetTabCloseButtonTooltipText();
                        ToolTipService.SetToolTip(closeButton, tooltip);
                    }

                    closeButton.Click += OnCloseButtonClick;
                }
                return(closeButton);
            }

            m_closeButton = GetCloseButton(internalTabView);

            OnIconSourceChanged();

            if (tabView != null)
            {
                if (SharedHelpers.IsThemeShadowAvailable())
                {
                    if (internalTabView != null)
                    {
                        var shadow = new ThemeShadow();
                        if (!SharedHelpers.Is21H1OrHigher())
                        {
                            if (internalTabView.GetShadowReceiver() is UIElement shadowReceiver)
                            {
                                shadow.Receivers.Add(shadowReceiver);
                            }
                        }
                        m_shadow = shadow;

                        double shadowDepth = (double)SharedHelpers.FindInApplicationResources(TabView.c_tabViewShadowDepthName, TabView.c_tabShadowDepth);

                        var currentTranslation = Translation;
                        var translation        = new Vector3(currentTranslation.X, currentTranslation.Y, (float)shadowDepth);
                        Translation = translation;

                        UpdateShadow();
                    }
                }

                tabView.TabDragStarting  += OnTabDragStarting;
                tabView.TabDragCompleted += OnTabDragCompleted;
            }

            UpdateCloseButton();
            UpdateWidthModeVisualState();
        }
Beispiel #11
0
        public AppPopup(
            IAppPopupContent content,
            double width        = double.NaN,
            double height       = double.NaN,
            double widthMargin  = double.NaN,
            double heightMargin = double.NaN,
            double minWidth     = 0,
            double maxWidth     = double.MaxValue,
            double minHeight    = 0,
            double maxHeight    = double.MaxValue,
            bool lightDismiss   = false,
            bool useAnimation   = true,
            Action <IAppPopupContent>?opening          = null,
            Action <IAppPopupContent, object?>?closing = null)
        {
            _content      = content;
            _width        = width;
            _height       = height;
            _opening      = opening;
            _closing      = closing;
            _maxWidth     = maxWidth;
            _widthMargin  = widthMargin;
            _heightMargin = heightMargin;
            _minWidth     = minWidth;
            _maxWidth     = maxWidth;
            _minHeight    = minHeight;
            _maxHeight    = maxHeight;
            _useAnimation = useAnimation;
            var(windowWidth, windowHeight) = App.AppViewModel.GetAppWindowSizeTuple();
            UniqueId = content.UniqueId;
            content.UIContent.HorizontalAlignment = HorizontalAlignment.Stretch;
            content.UIContent.VerticalAlignment   = VerticalAlignment.Stretch;

            var themeShadow    = new ThemeShadow();
            var shadowReceiver = new Grid
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Background          = (Brush)Application.Current.Resources["ApplicationPageBackgroundThemeBrush"],
                Opacity             = 0.4
            };
            var popupContentPresenter = new ContentPresenter
            {
                Shadow              = themeShadow,
                Translation         = new Vector3(0, 0, 40),
                BorderBrush         = (Brush)Application.Current.Resources["PixevalBorderBrush"],
                Background          = (Brush)Application.Current.Resources["PixevalPanelBackgroundThemeBrush"],
                BorderThickness     = new Thickness(0.3),
                CornerRadius        = new CornerRadius(10),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Content             = content
            };

            themeShadow.Receivers.Add(shadowReceiver);

            if (lightDismiss)
            {
                shadowReceiver.Tapped += OnShadowReceiverOnTapped;
            }
            else
            {
                shadowReceiver.Tapped -= OnShadowReceiverOnTapped;
            }

            void OnShadowReceiverOnTapped(object sender, TappedRoutedEventArgs a)
            {
                PopupManager.ClosePopup(PopupManager.OpenPopups[UniqueId]);
            }

            Popup = new Popup
            {
                RequestedTheme = App.AppViewModel.AppRootFrameTheme,
                Transitions    = new TransitionCollection
                {
                    new PopupThemeTransition()
                },
                XamlRoot = App.AppViewModel.AppWindowRootFrame.XamlRoot,
                Width    = windowWidth,
                Height   = windowHeight,
                Child    = new Grid
                {
                    Children =
                    {
                        shadowReceiver, popupContentPresenter
                    }
                }
            };
            App.AppViewModel.Window.SizeChanged += WindowOnSizeChanged;
        }
        public StickersView()
        {
            InitializeComponent();

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

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

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

            var observable = Observable.FromEventPattern <TextChangedEventArgs>(FieldStickers, "TextChanged");
            var throttled  = observable.Throttle(TimeSpan.FromMilliseconds(Constants.TypingTimeout)).ObserveOnDispatcher().Subscribe(async x =>
            {
                var items = ViewModel.Stickers.SearchStickers;
                if (items != null && string.Equals(FieldStickers.Text, items.Query))
                {
                    await items.LoadMoreItemsAsync(1);
                    await items.LoadMoreItemsAsync(2);
                }
            });

            var observable2 = Observable.FromEventPattern <TextChangedEventArgs>(FieldAnimations, "TextChanged");
            var throttled2  = observable2.Throttle(TimeSpan.FromMilliseconds(Constants.TypingTimeout)).ObserveOnDispatcher().Subscribe(x =>
            {
                ViewModel.Stickers.FindAnimations(FieldAnimations.Text);
                //var items = ViewModel.Stickers.SearchStickers;
                //if (items != null && string.Equals(FieldStickers.Text, items.Query))
                //{
                //    await items.LoadMoreItemsAsync(1);
                //    await items.LoadMoreItemsAsync(2);
                //}
            });

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

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

            case Services.Settings.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);
            }
        }