示例#1
0
            public override void LoadView()
            {
                View = new ContainerView(this);

                string appearance = EffectiveAppearanceName;

                NativeChild.RemoveFromSuperview();
                View.AddSubview(NativeChild);

                if (!string.IsNullOrEmpty(appearance) && appearance.IndexOf("Dark", StringComparison.Ordinal) >= 0)
                {
                    View.Appearance = NSAppearance.GetAppearance(MacSystemInformation.OsVersion < MacSystemInformation.Mojave ? NSAppearance.NameVibrantDark : new NSString("NSAppearanceNameDarkAqua"));
                }
                else
                {
                    View.Appearance = NSAppearance.GetAppearance(NSAppearance.NameAqua);
                }

                WidgetSpacing padding = 0;

                if (Backend != null)
                {
                    padding = Backend.Frontend.Padding;
                }
                View.AddConstraints(new NSLayoutConstraint [] {
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1, (nfloat)padding.Left),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Right, NSLayoutRelation.Equal, View, NSLayoutAttribute.Right, 1, -(nfloat)padding.Right),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View, NSLayoutAttribute.Top, 1, (nfloat)padding.Top),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1, -(nfloat)padding.Bottom),
                });
            }
示例#2
0
            public void WillShow(NSNotification notification)
            {
                if (parent != notification.Object)
                {
                    return;
                }
                ChildBackend.SetAutosizeMode(true);
                Child.Surface.Reallocate();
                if (BackgroundColor != null)
                {
                    if (View.Window.ContentView.Superview.Layer == null)
                    {
                        View.Window.ContentView.Superview.WantsLayer = true;
                    }
                    View.Window.ContentView.Superview.Layer.BackgroundColor = BackgroundColor;
                }
                WidgetSpacing padding = 0;

                if (Backend != null)
                {
                    padding = Backend.Frontend.Padding;
                }
                NativeChild.SetFrameOrigin(new CGPoint((nfloat)padding.Left, (nfloat)padding.Top));
                shown = true;
            }
示例#3
0
 void RemoveChild()
 {
     if (Child != null)
     {
         NativeChild.RemoveFromSuperview();
         NativeChild.SetFrameOrigin(new CGPoint(0, 0));
         ChildBackend.SetAutosizeMode(false);
         Child        = null;
         ChildBackend = null;
     }
 }