public void SetFrameSize(CGSize newFrameSize, bool animating) { CGRect newFrame = FrameForNewSizePinnedToTopLeft(newFrameSize); if (animating) { NSAnimation animation = new NSViewAnimation(new [] { NSDictionary.FromObjectsAndKeys( #if MONOMAC new object[] { this, NSValue.FromRectangleF(Frame), NSValue.FromRectangleF(newFrame) }, #else new object[] { this, NSValue.FromCGRect(Frame), NSValue.FromCGRect(newFrame) }, #endif new object[] { NSViewAnimation.TargetKey, NSViewAnimation.StartFrameKey, NSViewAnimation.EndFrameKey } ) }); animation.AnimationBlockingMode = NSAnimationBlockingMode.Nonblocking; animation.Duration = 0.25; animation.StartAnimation(); } else { Superview.SetNeedsDisplayInRect(Frame); Frame = newFrame; NeedsDisplay = true; } }
bool detachViewToWindow(bool enable) { bool viewChanged = false; var rootView = getRootView(); if (enable && initialSuperview == null) { initialIndex = Array.IndexOf(Superview.Subviews, this); initialSuperview = Superview; var newFrame = Superview.ConvertRectToView(initialFrame, rootView); rootView.Add(this); setFrame(newFrame); viewChanged = true; } else if (!enable) { if (initialSuperview != null) { initialSuperview.InsertSubview(this, initialIndex); viewChanged = true; } setFrame(initialFrame); initialSuperview = null; } return(viewChanged); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); lastTimeStamp = evt.Timestamp; Superview.BringSubviewToFront(this); lastLocation = Center; }
public void TrackingStarted(object sender, TrackingEventArgs e) { var button = (ButtonView)sender; UIGraphics.BeginImageContext(button.Bounds.Size); button.Layer.RenderInContext(UIGraphics.GetCurrentContext()); UIImage image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); if (trackingImageView == null) { trackingImageView = new UIImageView(CGRect.Empty); Superview.AddSubview(trackingImageView); trackingImageView.Alpha = 0.5f; } trackingImageView.Image = image; trackingImageView.SizeToFit(); CGRect frame = trackingImageView.Frame; var newFrame = new CGRect(Superview.ConvertPointFromView(button.Frame.Location, this), frame.Size); trackingImageView.Frame = newFrame; if (ButtonSelectedEvent != null) { ButtonSelectedEvent(button); } }
public override void TouchesEnded(NSSet touches, UIEvent evt) { if (string.IsNullOrEmpty(_disabled) && !_confirmed) { var point = (touches.AnyObject as UITouch).LocationInView(this.Superview); if (!Frame.Contains(point)) { Lighten(); base.TouchesCancelled(touches, evt); } else if (Selected) { Lighten(); _confirmed = true; _cancelOverlay.RemoveFromSuperview(); _cancelOverlay = null; base.TouchesEnded(touches, evt); } else { Lighten(); Selected = true; _cancelOverlay = UIButton.FromType(UIButtonType.Custom); _cancelOverlay.Frame = new RectangleF(0, 0, 1024, 1024); _cancelOverlay.AddTarget(delegate { Cancel(); }, UIControlEvent.TouchDown); Superview.AddSubview(_cancelOverlay); Superview.BringSubviewToFront(this); } } }
public override void InvalidateLayout() { base.InvalidateLayout(); NeedsLayout = true; InvalidateIntrinsicContentSize(); Superview.InvalidateIntrinsicContentSize(); InvalidateRender(); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); lastTimeStamp = evt.Timestamp; Superview.BringSubviewToFront(this); lastLocation = Center; lastMoveLocation = (touches.AnyObject as UITouch).LocationInView(this); }
void Show() { Superview.BringSubviewToFront(this); Animate(0.3, delegate { Alpha = 1.0f; }); }
internal void StartAnimating() { _activitySpinner.StartAnimating(); Hidden = false; Superview.BringSubviewToFront(this); }
internal void StopAnimating() { _activitySpinner.StopAnimating(); Hidden = true; Superview.SendSubviewToBack(this); }
public override void MovedToSuperview() { base.MovedToSuperview(); var maxHeightConstraint = NSLayoutConstraint.Create(this, NSLayoutAttribute.Height, NSLayoutRelation.LessThanOrEqual, Superview, NSLayoutAttribute.Height, 0.3f, 0.0f); Superview?.AddConstraint(maxHeightConstraint); }
private protected override void OnLoaded() { base.OnLoaded(); // TODO: Find a proper way to decide whether a CommandBar exists on canvas (within Page), or is mapped to the UINavigationController's NavigationBar. CommandBar?commandBar = null; _commandBar?.TryGetTarget(out commandBar); if (_commandBar == null) { commandBar = TemplatedParent as CommandBar; _commandBar = new WeakReference <CommandBar?>(commandBar); _navigationBar = commandBar?.GetRenderer(RendererFactory).Native; } else { _navigationBar = commandBar?.ResetRenderer(RendererFactory).Native; } if (_navigationBar == null) { throw new InvalidOperationException("No NavigationBar from renderer"); } _navigationBar.SetNeedsLayout(); var navigationBarSuperview = _navigationBar?.Superview; // Allows the UINavigationController's NavigationBar instance to be moved to the Page. This feature // is used in the context of the sample application to test NavigationBars outside of a NativeFramePresenter for // UI Testing. In general cases, this should not happen as the bar may be moved back to to this presenter while // another page is already visible, making this bar overlay on top of another. if (FeatureConfiguration.CommandBar.AllowNativePresenterContent && (navigationBarSuperview == null || navigationBarSuperview is NativeCommandBarPresenter)) { Content = _navigationBar; } var statusBar = StatusBar.GetForCurrentView(); statusBar.Showing += OnStatusBarChanged; statusBar.Hiding += OnStatusBarChanged; _statusBarSubscription.Disposable = Disposable.Create(() => { statusBar.Showing -= OnStatusBarChanged; statusBar.Hiding -= OnStatusBarChanged; }); // iOS doesn't automatically update the navigation bar position when the status bar visibility changes. void OnStatusBarChanged(StatusBar sender, object args) { _navigationBar !.SetNeedsLayout(); _navigationBar !.Superview.SetNeedsLayout(); } }
private void ShowPalette() { var height = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone ? 30 : 50; PaletteView.Frame = new CGRect(Frame.X, Frame.Height - height, Frame.Width, height); PaletteView.Layout(); Animate(0.5, 0.2, UIViewAnimationOptions.CurveLinear, () => Superview.Add(PaletteView), null); }
public void Show() { Animate(0.4, () => { heightConstraint.Constant = Superview.Frame.Size.Height; label.Hidden = false; button.Hidden = false; Superview.LayoutIfNeeded(); }); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); lastTimeStamp = evt.Timestamp; Superview.BringSubviewToFront(this); lastLocation = Center; (Element as eliteElements.eliteVideo).controlsShow(); }
public override UIView HitTest(CGPoint point, UIEvent uievent) { var view = base.HitTest(point, uievent); if (view != null) { Superview.BringSubviewToFront(this); } return(view); }
public void RemoveFromSuperview() { if (Superview == null) { throw new InvalidOperationException("The View does not have a Superview"); } Superview._subviews.Remove(this); Superview.SetNeedsLayout(); }
public override void MovedToSuperview() { base.MovedToSuperview(); if (IsAlignedToParentAutomatically) { if (Superview != null) { Superview.Layout(this).Bottom().Horizontally(); } } }
public override void MouseDown(NSEvent theEvent) { base.MouseDown(theEvent); var locationInSV = Superview.ConvertPointFromView(theEvent.LocationInWindow, null); if (theEvent.ClickCount == 2 && HitTest(locationInSV) == this) { Window.Zoom(this); } }
private void Show() { Superview?.LayoutIfNeeded(); verticalConstraint.Constant = 0; UIView.Animate(0.4, 0.2, UIViewAnimationOptions.TransitionNone, () => { textLabel.Alpha = 1.0f; }, (() => { })); UIView.Animate(0.4, 0, UIViewAnimationOptions.CurveEaseOut, () => Superview?.LayoutIfNeeded(), Hide); }
public override void SetNeedsLayout() { base.SetNeedsLayout(); _requiresMeasure = true; if (Superview != null) { Superview.SetNeedsLayout(); } }
public override void LayoutSubviews() { base.LayoutSubviews(); if (_blur != null && Superview != null) { _blur.Frame = Bounds; if (_blur.Superview == null) { Superview.Add(_blur); } } }
public void AddHorizontalConstraintsToSuperviewWidth() { if (base.Superview == null) { return; } UIView child = this; Superview.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[child]|", 0, null, NSDictionary.FromObjectAndKey(child, new NSString("child")))); }
public override void Draw(RectangleF rect) { base.Draw(rect); if (_blur != null) { _blur.Frame = rect; if (_blur.Superview == null) { Superview.Add(_blur); } } }
private protected override void OnLoaded() { base.OnLoaded(); // TODO: Find a proper way to decide whether a CommandBar exists on canvas (within Page), or is mapped to the UINavigationController's NavigationBar. var commandBar = _commandBar?.Target; if (commandBar == null) { commandBar = TemplatedParent as CommandBar; _commandBar = new WeakReference <CommandBar?>(commandBar); _navigationBar = commandBar?.GetRenderer(RendererFactory).Native; } else { _navigationBar = commandBar?.ResetRenderer(RendererFactory).Native; } if (_navigationBar == null) { throw new InvalidOperationException("No NavigationBar from renderer"); } _navigationBar.SetNeedsLayout(); var navigationBarSuperview = _navigationBar?.Superview; if (navigationBarSuperview == null || navigationBarSuperview is NativeCommandBarPresenter) // Prevents the UINavigationController's NavigationBar instance from being moved to the Page { Content = _navigationBar; } var statusBar = StatusBar.GetForCurrentView(); statusBar.Showing += OnStatusBarChanged; statusBar.Hiding += OnStatusBarChanged; _statusBarSubscription.Disposable = Disposable.Create(() => { statusBar.Showing -= OnStatusBarChanged; statusBar.Hiding -= OnStatusBarChanged; }); // iOS doesn't automatically update the navigation bar position when the status bar visibility changes. void OnStatusBarChanged(StatusBar sender, object args) { _navigationBar !.SetNeedsLayout(); _navigationBar !.Superview.SetNeedsLayout(); } }
public override void LayoutSubviews() { if (_shadowView != null) { if (_shadowView.Superview == null) { Superview.InsertSubviewBelow(_shadowView, this); } _shadowView?.SetNeedsLayout(); } base.LayoutSubviews(); }
private void InsertSubview(UIView view) { Superview.InsertSubviewBelow(view, this); var verticalConstraint = NSLayoutConstraint.Create(this, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, view, NSLayoutAttribute.CenterY, 1, 0); var leadingConstraint = NSLayoutConstraint.Create(this, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, view, NSLayoutAttribute.Leading, 1, 0); var trailingConstraint = NSLayoutConstraint.Create(this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, view, NSLayoutAttribute.Trailing, 1, 0); Superview.AddConstraints(new[] { verticalConstraint, leadingConstraint, trailingConstraint }); }
public override void KeyDown(NSEvent theEvent) { switch (theEvent.KeyCode) { case 36: case 76: Superview.KeyDown(theEvent); break; default: base.KeyDown(theEvent); break; } }
private void OnContentChanged(UIElement oldValue, UIElement newValue) { if (oldValue != null) { oldValue.RemoveFromSuperview(); } if (newValue != null) { AddSubview(newValue); } Superview?.SetNeedsLayout(); }
public override void InvalidateIntrinsicContentSize() { base.InvalidateIntrinsicContentSize(); if (Frame.Width == 0 && Frame.Height == 0) { // The Label hasn't actually been laid out on screen yet; no reason to request a layout return; } if (!Frame.Size.IsCloseTo(AddInsets(IntrinsicContentSize), (nfloat)0.001)) { // The text or its attributes have changed enough that the size no longer matches the set Frame. It's possible // that the Label needs to be laid out again at a different size, so we request that the parent do so. Superview?.SetNeedsLayout(); } }