diff options
Diffstat (limited to 'Xamarin.Forms.Platform.MacOS/Extensions')
9 files changed, 0 insertions, 249 deletions
diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/AlignmentExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/AlignmentExtensions.cs deleted file mode 100644 index 35d0f26c..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/AlignmentExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using AppKit; - -namespace Xamarin.Forms.Platform.MacOS -{ - internal static class AlignmentExtensions - { - internal static NSTextAlignment ToNativeTextAlignment(this TextAlignment alignment) - { - switch (alignment) - { - case TextAlignment.Center: - return NSTextAlignment.Center; - case TextAlignment.End: - return NSTextAlignment.Right; - default: - return NSTextAlignment.Left; - } - } - } -}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/ButtonExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/ButtonExtensions.cs deleted file mode 100644 index 1bdc62ae..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/ButtonExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using AppKit; - -namespace Xamarin.Forms.Platform.MacOS -{ - internal static class ButtonExtensions - { - public static NSCellImagePosition ToNSCellImagePosition(this Button control) - { - switch (control.ContentLayout.Position) - { - case Button.ButtonContentLayout.ImagePosition.Left: - return NSCellImagePosition.ImageLeft; - case Button.ButtonContentLayout.ImagePosition.Top: - return NSCellImagePosition.ImageAbove; - case Button.ButtonContentLayout.ImagePosition.Right: - return NSCellImagePosition.ImageRight; - case Button.ButtonContentLayout.ImagePosition.Bottom: - return NSCellImagePosition.ImageBelow; - default: - return NSCellImagePosition.ImageOnly; - } - } - } -}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/NSButtonExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/NSButtonExtensions.cs deleted file mode 100644 index d37f1a3d..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/NSButtonExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using AppKit; - -namespace Xamarin.Forms.Platform.MacOS -{ - public static class NSButtonExtensions - { - public static NSButton CreateButton(string text, Action activate = null) - { - return CreateButton(text, null, activate); - } - - public static NSButton CreateButton(string text, NSImage image = null, Action activate = null) - { - var btn = new NSButton { Title = text }; - btn.BezelStyle = NSBezelStyle.TexturedRounded; - - if (image != null) - btn.Image = image; - if (activate != null) - btn.Activated += (sender, e) => activate(); - return btn; - } - } -}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/NSImageExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/NSImageExtensions.cs deleted file mode 100644 index 09521731..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/NSImageExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using AppKit; - -namespace Xamarin.Forms.Platform.MacOS -{ - public static class NSImageExtensions - { - public static NSImage ResizeTo(this NSImage self, CoreGraphics.CGSize newSize) - { - if (self == null) - return null; - self.ResizingMode = NSImageResizingMode.Stretch; - var resizedImage = new NSImage(newSize); - resizedImage.LockFocus(); - self.Size = newSize; - NSGraphicsContext.CurrentContext.ImageInterpolation = NSImageInterpolation.High; - self.Draw(CoreGraphics.CGPoint.Empty, new CoreGraphics.CGRect(0, 0, newSize.Width, newSize.Height), - NSCompositingOperation.Copy, 1.0f); - resizedImage.UnlockFocus(); - return resizedImage; - } - } -}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/NSScrollViewExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/NSScrollViewExtensions.cs deleted file mode 100644 index f9104d4a..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/NSScrollViewExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Threading.Tasks; -using AppKit; -using PointF = CoreGraphics.CGPoint; - -namespace Xamarin.Forms.Platform.MacOS -{ - internal static class NSScrollViewExtensions - { - 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; - } - } -}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/NSTableViewExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/NSTableViewExtensions.cs deleted file mode 100644 index c81e31eb..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/NSTableViewExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using AppKit; - -namespace Xamarin.Forms.Platform.MacOS -{ - internal static class NSTableViewExtensions - { - public static NSTableView AsListViewLook(this NSTableView self) - { - self.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.SourceList; - - self.AllowsColumnReordering = false; - self.AllowsColumnResizing = false; - self.AllowsColumnSelection = false; - - //this is needed .. can we go around it ? - self.AddColumn(new NSTableColumn("1")); - //this line hides the header by default - self.HeaderView = new CustomNSTableHeaderView(); - return self; - } - } -}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/NSTextFieldExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/NSTextFieldExtensions.cs deleted file mode 100644 index 9905fcd5..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/NSTextFieldExtensions.cs +++ /dev/null @@ -1,46 +0,0 @@ -using AppKit; -using CoreGraphics; - -namespace Xamarin.Forms.Platform.MacOS -{ - internal static class NSTextFieldExtensions - { - public static NSTextField CreateLabel(string text) - { - var textField = new NSTextField(); - textField.StringValue = text; - textField.DrawsBackground = false; - textField.Editable = false; - textField.Bezeled = false; - textField.Selectable = false; - textField.SizeToFit(); - textField.CenterTextVertically(); - return textField; - } - - public static NSTextFieldCell CreateLabelCentered(string text) - { - var textField = new VerticallyCenteredTextFieldCell(0); - textField.StringValue = text; - textField.DrawsBackground = false; - textField.Editable = false; - textField.Bezeled = false; - textField.Selectable = false; - return textField; - } - - public static void CenterTextVertically(this NSTextField self) - { - self.CenterTextVertically(self.Frame); - } - - public static void CenterTextVertically(this NSTextField self, CGRect frame) - { - var stringHeight = self.Cell.AttributedStringValue.Size.Height; - var titleRect = self.Cell.TitleRectForBounds(frame); - var newTitleRect = new CGRect(titleRect.X, frame.Y + (frame.Height - stringHeight) / 2.0, titleRect.Width, - stringHeight); - self.Frame = newTitleRect; - } - } -}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/NSViewControllerExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/NSViewControllerExtensions.cs deleted file mode 100644 index f5562322..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/NSViewControllerExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Threading.Tasks; -using AppKit; - -namespace Xamarin.Forms.Platform.MacOS -{ - internal static class NSViewControllerExtensions - { - public static Task<T> HandleAsyncAnimation<T>(this NSViewController container, NSViewController fromViewController, - NSViewController toViewController, NSViewControllerTransitionOptions transitonOption, - Action animationFinishedCallback, T result) - { - var tcs = new TaskCompletionSource<T>(); - - container.TransitionFromViewController(fromViewController, toViewController, transitonOption, () => - { - tcs.SetResult(result); - animationFinishedCallback?.Invoke(); - }); - - return tcs.Task; - } - } -}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs b/Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs deleted file mode 100644 index 24c9a527..00000000 --- a/Xamarin.Forms.Platform.MacOS/Extensions/PageExtensions.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using AppKit; - -namespace Xamarin.Forms.Platform.MacOS -{ - public static class PageExtensions - { - public static NSViewController CreateViewController(this Page view) - { - if (!Forms.IsInitialized) - throw new InvalidOperationException("call Forms.Init() before this"); - - if (!(view.RealParent is Application)) - { - Application app = new DefaultApplication(); - app.MainPage = view; - } - - var result = new Platform(); - result.SetPage(view); - return result.ViewController; - } - - class DefaultApplication : Application - { - } - } -}
\ No newline at end of file |