Example #1
0
 private void UpdateShadow()
 {
     if (SharedHelpers.IsThemeShadowAvailable())
     {
         if (IsSelected && !m_isDragging)
         {
             Shadow = (ThemeShadow)m_shadow;
         }
         else
         {
             Shadow = null;
         }
     }
 }
Example #2
0
 private void UpdateShadow()
 {
     if (SharedHelpers.IsThemeShadowAvailable())
     // TODO Uno: Can't access XamlControlsResources from Uno.UI
     //&& !Microsoft.UI.Xaml.Controls.XamlControlsResources.IsUsingControlsResourcesVersion2)
     {
         if (IsSelected && !m_isDragging)
         {
             Shadow = (ThemeShadow)m_shadow;
         }
         else
         {
             Shadow = null;
         }
     }
 }
Example #3
0
        private void InitializeTemplate()
        {
            _eventSubscriptions.Disposable = null;

            var registrations = new CompositeDisposable();

            var spinDownName = ResourceAccessor.GetLocalizedStringResource("NumberBoxDownSpinButtonName");
            var spinUpName   = ResourceAccessor.GetLocalizedStringResource("NumberBoxUpSpinButtonName");

            if (this.GetTemplateChild(c_numberBoxDownButtonName) is RepeatButton spinDown)
            {
                spinDown.Click += OnSpinDownClick;
                registrations.Add(() => spinDown.Click -= OnSpinDownClick);

                // Do localization for the down button
                if (string.IsNullOrEmpty(AutomationProperties.GetName(spinDown)))
                {
                    AutomationProperties.SetName(spinDown, spinDownName);
                }
            }

            if (GetTemplateChild(c_numberBoxUpButtonName) is RepeatButton spinUp)
            {
                spinUp.Click += OnSpinUpClick;
                registrations.Add(() => spinUp.Click -= OnSpinUpClick);

                // Do localization for the up button
                if (string.IsNullOrEmpty(AutomationProperties.GetName(spinUp)))
                {
                    AutomationProperties.SetName(spinUp, spinUpName);
                }
            }

            if (GetTemplateChild(c_numberBoxTextBoxName) is TextBox textBox)
            {
                textBox.KeyDown += OnNumberBoxKeyDown;
                registrations.Add(() => textBox.KeyDown -= OnNumberBoxKeyDown);
                textBox.KeyUp += OnNumberBoxKeyUp;
                registrations.Add(() => textBox.KeyUp -= OnNumberBoxKeyUp);

                m_textBox = textBox;
            }

            m_popup = GetTemplateChild(c_numberBoxPopupName) as Windows.UI.Xaml.Controls.Primitives.Popup;

            if (SharedHelpers.IsThemeShadowAvailable())
            {
                // UNO TODO
                //if (GetTemplateChildT(c_numberBoxPopupContentRootName) is UIElement popupRoot)
                //{
                //	if (!popupRoot.Shadow())
                //	{
                //		popupRoot.Shadow(ThemeShadow{});
                //		auto&& translation = popupRoot.Translation();

                //		const double shadowDepth = unbox_value<double>(SharedHelpers.FindResource(c_numberBoxPopupShadowDepthName, Application.Current().Resources(), box_value(c_popupShadowDepth)));

                //		popupRoot.Translation({ translation.x, translation.y, (float)shadowDepth });
                //	}
                //}
            }

            if (GetTemplateChild(c_numberBoxPopupDownButtonName) is RepeatButton popupSpinDown)
            {
                popupSpinDown.Click += OnSpinDownClick;
                registrations.Add(() => popupSpinDown.Click -= OnSpinDownClick);
            }

            if (GetTemplateChild(c_numberBoxPopupUpButtonName) is RepeatButton popupSpinUp)
            {
                popupSpinUp.Click += OnSpinUpClick;
                registrations.Add(() => popupSpinUp.Click -= OnSpinUpClick);
            }

            // .NET rounds to 12 significant digits when displaying doubles, so we will do the same.
            m_displayRounder.SignificantDigits = 12;

            UpdateSpinButtonPlacement();
            UpdateSpinButtonEnabled();

            if (ReadLocalValue(ValueProperty) == DependencyProperty.UnsetValue &&
                ReadLocalValue(TextProperty) != DependencyProperty.UnsetValue)
            {
                // If Text has been set, but Value hasn't, update Value based on Text.
                UpdateValueToText();
            }
            else
            {
                UpdateTextToValue();
            }

            _eventSubscriptions.Disposable = registrations;
        }
Example #4
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();
        }