Beispiel #1
0
        static WindowBase()
        {
            IsVisibleProperty.OverrideDefaultValue <WindowBase>(false);
            IsVisibleProperty.Changed.AddClassHandler <WindowBase>((x, e) => x.IsVisibleChanged(e));


            TopmostProperty.Changed.AddClassHandler <WindowBase>((w, e) => w.PlatformImpl?.SetTopmost((bool)e.NewValue !));
        }
Beispiel #2
0
        static WindowBase()
        {
            IsVisibleProperty.OverrideDefaultValue <WindowBase>(false);
            IsVisibleProperty.Changed.AddClassHandler <WindowBase>(x => x.IsVisibleChanged);

            MinWidthProperty.Changed.AddClassHandler <WindowBase>((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size((double)e.NewValue, w.MinHeight), new Size(w.MaxWidth, w.MaxHeight)));
            MinHeightProperty.Changed.AddClassHandler <WindowBase>((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size(w.MinWidth, (double)e.NewValue), new Size(w.MaxWidth, w.MaxHeight)));
            MaxWidthProperty.Changed.AddClassHandler <WindowBase>((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size(w.MinWidth, w.MinHeight), new Size((double)e.NewValue, w.MaxHeight)));
            MaxHeightProperty.Changed.AddClassHandler <WindowBase>((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size(w.MinWidth, w.MinHeight), new Size(w.MaxWidth, (double)e.NewValue)));
        }
Beispiel #3
0
        /// <summary>
        /// Called when the visibility of the view has changed.
        /// </summary>
        protected virtual void VisibilityChanged()
        {
            if (AlphaProperty.IsUndefined(this, UIViewTemplates.Default) &&
                IsVisibleProperty.IsUndefined(this, UIViewTemplates.Default) &&
                RaycastBlockModeProperty.IsUndefined(this, UIViewTemplates.Default) &&
                IsInteractableProperty.IsUndefined(this, UIViewTemplates.Default))
            {
                return;
            }

            // to change alpha, visibility and raycast we need a canvas group attached
            if (CanvasGroup == null)
            {
                var canvasGroup = GameObject.GetComponent <CanvasGroup>();
                CanvasGroup = canvasGroup == null?GameObject.AddComponent <CanvasGroup>() : canvasGroup;
            }

            // set alpha value
            var alpha = AlphaProperty.IsUndefined(this) ? 1 : Alpha;

            CanvasGroup.alpha = IsVisible ? alpha : 0;

            // set raycast block mode
            if (RaycastBlockMode == RaycastBlockMode.Always)
            {
                CanvasGroup.blocksRaycasts = true;
            }
            else if (RaycastBlockMode == RaycastBlockMode.Never)
            {
                CanvasGroup.blocksRaycasts = false;
            }
            else
            {
                CanvasGroup.blocksRaycasts = (IsVisible && alpha > 0);
            }

            if (IsInteractableProperty.IsUndefined(this))
            {
                CanvasGroup.interactable = IsVisible && alpha > 0;
            }
            else
            {
                CanvasGroup.interactable = IsInteractable;
            }
        }
Beispiel #4
0
 set => SetValue(IsVisibleProperty, value);
Beispiel #5
0
 static CompoundVisual3D()
 {
     IsVisibleProperty.OverrideMetadata(typeof(CompoundVisual3D), new PropertyMetadata(OnIsVisibleChanged));
 }
Beispiel #6
0
 static WindowBase()
 {
     IsVisibleProperty.OverrideDefaultValue <WindowBase>(false);
     IsVisibleProperty.Changed.AddClassHandler <WindowBase>(x => x.IsVisibleChanged);
 }
Beispiel #7
0
 set => this.SetValue(IsVisibleProperty, value);