private void ShowDisconnectedAnimation(bool isPaused) { View.IsVisibleCircles = true; UpdateDisconnectedUITheme(isPaused); GuiConnectButtonImage.AlphaValue = 0f; GuiConnectButtonText.AlphaValue = 0f; GuiLabelToDoDescription.AlphaValue = 0f; GuiConnectButtonImage.Hidden = false; GuiConnectButtonText.Hidden = false; UpdateToDoLabelHiddenStatus(false); NSAnimationContext.RunAnimation((NSAnimationContext context) => { context.Duration = 0.5f; ((NSView)GuiConnectButtonImage.Animator).AlphaValue = 1f; ((NSTextField)GuiConnectButtonText.Animator).AlphaValue = 1f; ((NSTextField)GuiLabelToDoDescription.Animator).AlphaValue = 1f; }, () => { }); }
void UpdateCurrentPage(bool animated = true) { ContentPage current = Carousel.CurrentPage; if (current != null) { int index = Carousel.CurrentPage != null?CarouselPage.GetIndex(Carousel.CurrentPage) : 0; if (index < 0) { index = 0; } if (SelectedIndex == index) { return; } if (animated) { NSAnimationContext.RunAnimation(context => { ((NSPageController)Animator).SelectedIndex = index; }, CompleteTransition); } else { SelectedIndex = index; } } }
partial void InterTreeSegment(NSObject sender) { var s = sender as NSSegmentedControl; if (s.IsSelectedForSegment(0) && InterTreePlotView.Frame.Width <= 20) { InterTreeSplitView.SetPositionOfDivider( (nfloat)Math.Min(674, InterTreeSplitView.Frame.Width - 300), 0); } else if (!s.IsSelectedForSegment(0)) { InterTreeSplitView.SetPositionOfDivider(0, 0); } if (s.IsSelectedForSegment(1) && InterText.Frame.Width <= 20) { NSAnimationContext.RunAnimation((NSAnimationContext a) => { a.AllowsImplicitAnimation = true; a.Duration = 0.5; InterTreeSplitView.SetPositionOfDivider(InterTreeSplitView.Frame.Width - 300, 1); }); } else if (!s.IsSelectedForSegment(1)) { NSAnimationContext.RunAnimation((NSAnimationContext a) => { a.AllowsImplicitAnimation = true; a.Duration = 0.5; InterTreeSplitView.SetPositionOfDivider(InterTreeSplitView.Frame.Width, 1); }); } }
private void AnimateButtonTextBlinking() { nfloat alpha = 0.3f; if (GuiConnectButtonText.AlphaValue < 1f) { alpha = 1f; } NSAnimationContext.RunAnimation((NSAnimationContext context) => { context.Duration = 1f; ((NSView)GuiConnectButtonText.Animator).AlphaValue = alpha; }, () => { if (__MainViewModel.ConnectionState != ServiceState.Connecting && __MainViewModel.ConnectionState != ServiceState.Disconnecting) { GuiConnectButtonText.AlphaValue = 1f; } else { AnimateButtonTextBlinking(); } }); }
private void bounce() { NSAnimationContext.RunAnimation((context) => { var newFrame = mover.Frame; newFrame.Offset(1, 0); ((NSView)mover.Animator).SetFrameOrigin(newFrame.Location); }, () => {}); }
internal void ToggleTrailingSidebar() { NSSplitViewItem splitViewItem = (NSSplitViewItem)SplitViewItems.Last().Animator; TrailingSidebarViewWidthLayoutConstraint !.Active = false; NSAnimationContext.RunAnimation(changes: context => { context.Duration = 3; splitViewItem.Collapsed = !splitViewItem.Collapsed; }, completionHandler: () => { TrailingSidebarViewWidthLayoutConstraint.Active = true; }); }
void UpdateExpandedState() { if (!Widget.Loaded) { content.Hidden = !Expanded; return; } if (EnableAnimation) { var frame = content.Frame; var controlFrame = Control.Frame; if (Expanded) { content.Frame = frame; frame.Y = 0; suspendContentSizing++; var newSize = GetPreferredSize(SizeF.MaxValue); controlFrame.Height = newSize.Height; Control.Frame = controlFrame; LayoutIfNeeded(force: true); content.Frame = new CGRect(0, controlFrame.Height - header.Frame.Height, controlFrame.Width, 0); suspendContentSizing--; frame.Height = newSize.Height - header.Frame.Height; content.Hidden = false; } else { frame.Y = Control.Frame.Height - header.Frame.Height; frame.Height = 0; } NSAnimationContext.RunAnimation(ctx => { ctx.Duration = AnimationDuration; ((NSView)content.Animator).Frame = frame; }, () => { content.Hidden = !Expanded; Callback.OnExpandedChanged(Widget, EventArgs.Empty); LayoutIfNeeded(); } ); } else { content.Hidden = !Expanded; LayoutIfNeeded(force: true); Callback.OnExpandedChanged(Widget, EventArgs.Empty); } }
private void ShowConnectedAnimation() { View.IsVisibleCircles = false; GuiConnectButtonImage.Hidden = false; GuiConnectButtonText.Hidden = false; UpdateToDoLabelHiddenStatus(false); GuiConnectButtonImage.AlphaValue = 0f; GuiLabelToDoDescription.AlphaValue = 0f; GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Disconnect"), __ConnectedButtonTextColor, NSTextAlignment.Center); GuiConnectButtonText.AlphaValue = 1f; GuiLabelToDoDescription.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Label_ClickToDisconnect"), __ToDoDescriptionTextColor, NSTextAlignment.Center); GuiConnectButtonImage.Image = NSImage.ImageNamed("buttonConnected"); var frame = GuiConnectButtonImage.Frame; CGRect oldBounds = new CGRect(0, 0, frame.Width, frame.Height); nfloat offset = frame.Width * 0.1f; CGRect newBounds = new CGRect(-offset, -offset, oldBounds.Width + offset * 2, oldBounds.Height + offset * 2); GuiConnectButtonImage.Bounds = newBounds; NSAnimationContext.RunAnimation((NSAnimationContext context) => { context.Duration = 0.5f; ((NSView)GuiConnectButtonImage.Animator).Bounds = oldBounds; ((NSView)GuiConnectButtonImage.Animator).AlphaValue = 1f; ((NSView)GuiLabelToDoDescription.Animator).AlphaValue = 1f; }, () => { GuiConnectButtonImage.Bounds = oldBounds; ShowConnectedStatusAtimation(); }); }
void tableViewSelectionDidChange(NSNotification aNotification) { nint selectedIndex = TableView.SelectedRow; if (selectedIndex < 0 || selectedIndex == PageController.SelectedIndex) { return; } // TODO: change pageControllerDidEndLiveTransition // The selection of the table view changed. We want to animate to the new selection. // However, since we are manually performing the animation, // -pageControllerDidEndLiveTransition: will not be called. We are required to // PageController.CompleteTransition() when the animation completes. NSAnimationContext.RunAnimation((NSAnimationContext context) => { ((NSPageController)PageController.Animator).SelectedIndex = selectedIndex; }, PageController.CompleteTransition); }
private void ShowDisconnectingAnimation(bool isPausing = false) { View.IsVisibleCircles = true; if (isPausing == false) { GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Disconnecting"), Colors.ConnectButtonTextColor, NSTextAlignment.Center); } else { GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Pausing"), Colors.ConnectButtonTextColor, NSTextAlignment.Center); } GuiConnectButtonText.AlphaValue = 1f; UpdateToDoLabelHiddenStatus(true); var frame = GuiConnectButtonImage.Frame; CGRect oldBounds = new CGRect(0, 0, frame.Width, frame.Height); nfloat offset = frame.Width * 0.4f; CGRect newBounds = new CGRect(-offset, -offset, oldBounds.Width + offset * 2, oldBounds.Height + offset * 2); GuiConnectButtonImage.Bounds = oldBounds; NSAnimationContext.RunAnimation((NSAnimationContext context) => { context.Duration = 0.5f; ((NSView)GuiConnectButtonImage.Animator).Bounds = newBounds; ((NSView)GuiConnectButtonImage.Animator).AlphaValue = 0f; }, () => { GuiConnectButtonImage.Bounds = oldBounds; }); AnimateButtonTextBlinking(); }
public override void AnimateDismissal(NSViewController viewController, NSViewController fromViewController) { var bottomVc = fromViewController; var topVc = viewController; topVc.View.WantsLayer = true; topVc.View.LayerContentsRedrawPolicy = NSViewLayerContentsRedrawPolicy.OnSetNeedsDisplay; NSAnimationContext.RunAnimation((context) => { context.Duration = 1; (topVc.View.Animator as NSView).AlphaValue = 0; }, () => { topVc.View.Superview.RemoveFromSuperview(); topVc.View.RemoveFromSuperview(); }); }
public override void AnimatePresentation(NSViewController viewController, NSViewController fromViewController) { var bottomVc = fromViewController; var topVc = viewController; topVc.View.WantsLayer = true; topVc.View.LayerContentsRedrawPolicy = NSViewLayerContentsRedrawPolicy.OnSetNeedsDisplay; topVc.View.AlphaValue = 1; NSVisualEffectView backgroundView = new NSVisualEffectView(); backgroundView.Material = NSVisualEffectMaterial.Sheet; backgroundView.BlendingMode = NSVisualEffectBlendingMode.WithinWindow; backgroundView.AddSubview(topVc.View); backgroundView.AlphaValue = 0; bottomVc.View.AddSubview(backgroundView); backgroundView.LeadingAnchor.ConstraintEqualToAnchor(bottomVc.View.LeadingAnchor).Active = true; backgroundView.TopAnchor.ConstraintEqualToAnchor(bottomVc.View.TopAnchor).Active = true; backgroundView.BottomAnchor.ConstraintEqualToAnchor(bottomVc.View.BottomAnchor).Active = true; backgroundView.TrailingAnchor.ConstraintEqualToAnchor(bottomVc.View.TrailingAnchor).Active = true; topVc.View.LeadingAnchor.ConstraintEqualToAnchor(backgroundView.LeadingAnchor).Active = true; topVc.View.TopAnchor.ConstraintEqualToAnchor(backgroundView.TopAnchor).Active = true; topVc.View.BottomAnchor.ConstraintEqualToAnchor(backgroundView.BottomAnchor).Active = true; topVc.View.TrailingAnchor.ConstraintEqualToAnchor(backgroundView.TrailingAnchor).Active = true; backgroundView.Frame = bottomVc.View.Frame; topVc.View.Frame = bottomVc.View.Frame; NSAnimationContext.RunAnimation((context) => { context.Duration = 1; (backgroundView.Animator as NSView).AlphaValue = 1; }); }