public static Task ScrollToPositionAsync(this NSScrollView scrollView, PointF point, bool animate, double duration = 0.5) { if (!animate) { var nsView = scrollView.DocumentView as NSView; nsView?.ScrollPoint(point); return(Task.FromResult(true)); } TaskCompletionSource <bool> source = new TaskCompletionSource <bool>(); NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.CompletionHandler += () => { source.TrySetResult(true); }; NSAnimationContext.CurrentContext.Duration = duration; var animator = scrollView.ContentView.Animator as NSView; animator?.SetBoundsOrigin(point); NSAnimationContext.EndGrouping(); return(source.Task); }
public override void DidFinishLaunching(NSNotification notification) { SimpleAuth.Mac.WebAuthenticatorWebView.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1" AudioOutputHelper.Init(); var version = Device.SystemVersion; //window.StyleMask |= NSWindowStyle.FullSizeContentView; //window.TitlebarAppearsTransparent = true; SetupApp(); // Insert code here to initialize your application _sidebarOutlineView.SizeLastColumnToFit(); _sidebarOutlineView.WeakDataSource = this; _sidebarOutlineView.ReloadData(); _sidebarOutlineView.FloatsGroupRows = false; _sidebarOutlineView.RowSizeStyle = NSTableViewRowSizeStyle.Default; // Expand all the root items; disable the expansion animation that normally happens NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 0; _sidebarOutlineView.ExpandItem(null, true); NSAnimationContext.EndGrouping(); CheckLogin(); #pragma warning disable 4014 App.Start(); #pragma warning restore 4014 ApiManager.Shared.StartSync(); fullScreenController = new VideoPlaybackWindowController(); NotificationManager.Shared.ToggleFullScreenVideo += NotificationManager_Shared_ToggleFullScreenVideo; }
public void InitializeOutlineView() { if (DataManager == null || DataManager.PublicationResultList == null || DataManager.PublicationResultList.Count == 0) { NoResultLabel.Hidden = false; NoResultLabel.StringValue = "You have no search result."; SearchOutlineView.Hidden = true; } else { NoResultLabel.Hidden = true; //IndexOutlineView.SelectionShouldChange += (t) => true; //IndexOutlineView.EnclosingScrollView.BackgroundColor = NSColor.Clear; SearchOutlineView.EnclosingScrollView.BorderType = NSBorderType.NoBorder; SearchOutlineView.EnclosingScrollView.BackgroundColor = NSColor.White; SearchOutlineView.EnclosingScrollView.HasHorizontalScroller = false; SearchOutlineView.EnclosingScrollView.HasVerticalScroller = true; SearchOutlineView.EnclosingScrollView.ScrollerKnobStyle = NSScrollerKnobStyle.Default; SearchOutlineView.EnclosingScrollView.VerticalScroller.ControlSize = NSControlSize.Small; SearchOutlineView.GridStyleMask = NSTableViewGridStyle.None; SearchOutlineView.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.Regular; SearchOutlineView.FloatsGroupRows = true; SearchOutlineView.DataSource = new SearchOutlineDataSource(this); SearchOutlineView.Delegate = new SearchOutlineDelegate(this); NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 0; SearchOutlineView.ExpandItem(null, true); NSAnimationContext.EndGrouping(); } }
public override void KeyDown(NSEvent theEvent) { if ((theEvent.ModifierFlags & NSEventModifierMask.AlphaShiftKeyMask) == NSEventModifierMask.AlphaShiftKeyMask || (theEvent.ModifierFlags & NSEventModifierMask.ShiftKeyMask) == NSEventModifierMask.ShiftKeyMask) { NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 2.0f; } if (theEvent.Characters.ToUpper()[0] == 'A') { NSView view = Mover(); if (view.Superview == null) { // there is a problem here with AddSubview with animator //((NSView)Animator).AddSubview(view); this.AddSubview(view); } else { ((NSView)view.Animator).RemoveFromSuperview(); } } else { base.KeyDown(theEvent); } if ((theEvent.ModifierFlags & NSEventModifierMask.AlphaShiftKeyMask) == NSEventModifierMask.AlphaShiftKeyMask || (theEvent.ModifierFlags & NSEventModifierMask.ShiftKeyMask) == NSEventModifierMask.ShiftKeyMask) { NSAnimationContext.EndGrouping(); } }
public override void DidFinishLaunching(NSNotification notification) { var version = Device.SystemVersion; //window.StyleMask |= NSWindowStyle.FullSizeContentView; //window.TitlebarAppearsTransparent = true; SetupApp(); // Insert code here to initialize your application _sidebarOutlineView.SizeLastColumnToFit(); _sidebarOutlineView.WeakDataSource = this; _sidebarOutlineView.ReloadData(); _sidebarOutlineView.FloatsGroupRows = false; _sidebarOutlineView.RowSizeStyle = NSTableViewRowSizeStyle.Default; // Expand all the root items; disable the expansion animation that normally happens NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 0; _sidebarOutlineView.ExpandItem(null, true); NSAnimationContext.EndGrouping(); CheckLogin(); #pragma warning disable 4014 App.Start(); #pragma warning restore 4014 ApiManager.Shared.StartSync(); fullScreenController = new VideoPlaybackWindowController(); NotificationManager.Shared.ToggleFullScreenVideo += NotificationManager_Shared_ToggleFullScreenVideo; }
private void Faddout(NSView view) { NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 2; view.RemoveFromSuperview(); NSAnimationContext.EndGrouping(); }
private void Faddin(NSView view) { NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 2; this.View.AddSubview(view); NSAnimationContext.EndGrouping(); }
void BeginExpandCollapseAnimation() { if (!AnimationsEnabled) { NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 0; } }
/// <summary> /// Opens the panel /// </summary> public virtual void OpenPanel() { if (IsOpen) { return; } var screenRect = NSScreen.Screens[0].Frame; var statusRect = StatusRectForWindow(Window); var panelRect = Window.Frame; panelRect.X = (float)Math.Round((statusRect.Right - (statusRect.Width)) - panelRect.Width / 2f); panelRect.Y = statusRect.Top - panelRect.Height; if (panelRect.Right > (screenRect.Right - BackgroundView.ArrowHeight)) { panelRect.X -= panelRect.Right - (screenRect.Right - BackgroundView.ArrowHeight); } NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); Window.AlphaValue = 0f; Window.SetFrame(statusRect, true); Window.MakeKeyAndOrderFront(this); float openDuration = OpenDuration; #if DEBUG var currentEvent = NSApplication.SharedApplication.CurrentEvent; if (currentEvent.Type == NSEventType.LeftMouseUp) { var clearFlags = currentEvent.ModifierFlags & NSEventModifierMask.DeviceIndependentModifierFlagsMask; bool shiftPressed = clearFlags == NSEventModifierMask.ShiftKeyMask; bool shiftOptionPressed = clearFlags == (NSEventModifierMask.ShiftKeyMask | NSEventModifierMask.AlternateKeyMask); if (shiftPressed || shiftOptionPressed) { openDuration *= 10f; if (shiftOptionPressed) { Debug.WriteLine("Icon is at {0}\n\tMenu is on screen {1}\n\tWill be animated to {2}", statusRect, screenRect, panelRect); } } } #endif NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = openDuration; var animator = (NSWindow)Window.Animator; // Note the cast neccesary for MonoMac animator.SetFrame(panelRect, true); animator.AlphaValue = 1f; NSAnimationContext.EndGrouping(); IsOpen = true; StatusItemView.IsHighlighted = true; NSApplication.SharedApplication.ActivateIgnoringOtherApps(false); }
void InitializeAnimation() { NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 0f; heartImage.WantsLayer = true; heartImage.Layer.AnchorPoint = new CGPoint(0.5f, 0.5f); heartImage.Layer.Position = new CGPoint( heartImage.Layer.Frame.Size.Width / 2, heartImage.Layer.Frame.Size.Height / 2 ); NSAnimationContext.EndGrouping(); }
/// <summary> /// Closes the panel /// </summary> public virtual void ClosePanel() { if (!IsOpen) { return; } NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = CloseDuration; var animator = (NSWindow)Window.Animator; // Note the cast neccesary for MonoMac animator.AlphaValue = 0f; NSAnimationContext.EndGrouping(); IsOpen = false; StatusItemView.IsHighlighted = false; }
protected void WireUpForceUpdateSizeRequested(ICellController cell, NSView nativeCell, NSTableView tableView) { cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested; _onForceUpdateSizeRequested = (sender, e) => { var index = tableView?.RowForView(nativeCell); if (index != null) { NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 0; var indexSetRow = NSIndexSet.FromIndex(index.Value); tableView.NoteHeightOfRowsWithIndexesChanged(indexSetRow); NSAnimationContext.EndGrouping(); } }; cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested; }
public void AnimateSizeChange() { var bounds = Bounds; var frame = bounds; frame.Height = trackHeight; frame.Width *= Value; NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = .5; ((NSView)progressBackground.Animator).Frame = frame; var x = frame.Right; frame.Height = thumbHeight; frame.Width = thumbWidth; frame.X = x - (thumbWidth / 2); ((NSView)thumb.Animator).Frame = frame; NSAnimationContext.EndGrouping(); }
public void InitializeOutlineView() { if (IndexDataManager.IndexNodeList == null || IndexDataManager.IndexNodeList.Count == 0) { IndexLabel.StringValue = "Publication Index"; IndexInfoLabel.StringValue = "There are no index files available for this publication."; InfoCustomView.Hidden = false; IndexOutlineView.EnclosingScrollView.Hidden = true; } else { IndexOutlineView.EnclosingScrollView.Hidden = false; InfoCustomView.Hidden = true; //IndexOutlineView.SelectionShouldChange += (t) => true; //IndexOutlineView.EnclosingScrollView.BackgroundColor = NSColor.Clear; IndexOutlineView.DataSource = new IndexTableViewDataSources(this); IndexOutlineView.Delegate = new IndexTableViewDelegate(this); IndexOutlineView.EnclosingScrollView.BorderType = NSBorderType.NoBorder; IndexOutlineView.GridStyleMask = NSTableViewGridStyle.DashedHorizontalGridLine; IndexOutlineView.AllowsColumnSelection = false; IndexOutlineView.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.Regular; IndexOutlineView.EnclosingScrollView.HasHorizontalScroller = false; IndexOutlineView.AllowsColumnResizing = true; IndexOutlineView.EnclosingScrollView.ScrollerKnobStyle = NSScrollerKnobStyle.Default; IndexOutlineView.EnclosingScrollView.VerticalScroller.ControlSize = NSControlSize.Small; IndexOutlineView.FloatsGroupRows = true; NSAnimationContext.BeginGrouping(); NSAnimationContext.CurrentContext.Duration = 0; IndexOutlineView.ExpandItem(null, true); NSAnimationContext.EndGrouping(); } }