-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#40 output preferences: (preparatory refactoring)
- Loading branch information
Showing
20 changed files
with
114 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
AltNetworkUtility.macOS/Services/Windows/AboutBoxWindowService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using AltNetworkUtility.About; | ||
using AltNetworkUtility.Services.Windows; | ||
|
||
using AppKit; | ||
|
||
using Foundation; | ||
|
||
using Xamarin.Forms.Platform.MacOS; | ||
|
||
#nullable enable | ||
|
||
namespace AltNetworkUtility.macOS.Services.Windows | ||
{ | ||
public class AboutBoxWindowService : WindowService, IAboutBoxWindowService | ||
{ | ||
public override Window Window => Window.AboutBox; | ||
|
||
public override NSWindow OpenWindow() | ||
{ | ||
return _SingleInstanceWindows.GetOrAdd(Window, _ => | ||
{ | ||
const NSWindowStyle windowStyle = NSWindowStyle.Closable | NSWindowStyle.Titled; | ||
|
||
var window = new NSWindow | ||
{ | ||
BackingType = NSBackingStore.Buffered, | ||
Level = NSWindowLevel.Normal, | ||
StyleMask = windowStyle, | ||
Title = $"About {AppDelegate.AppName}" | ||
}; | ||
|
||
window.TabbingMode = NSWindowTabbingMode.Disallowed; | ||
|
||
var page = new AboutBoxPage(); | ||
|
||
SetNSWindowFrameFromXamFormsPage(window, page); | ||
|
||
window.ContentView = page.CreateViewController().View; | ||
|
||
var windowController = new NSWindowController(window); | ||
windowController.ShowWindow(null); | ||
|
||
window.Delegate = new WindowDelegate(); | ||
|
||
ShowWindow(window); | ||
|
||
return window; | ||
}); | ||
} | ||
|
||
private class WindowDelegate : NSWindowDelegate | ||
{ | ||
public override void WillClose(NSNotification notification) | ||
{ | ||
Xamarin.Forms.DependencyService.Get<AboutBoxWindowService>().CloseWindow(); | ||
} | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
AltNetworkUtility.macOS/Services/Windows/MainWindowService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using AltNetworkUtility.MainWindow; | ||
|
||
using AppKit; | ||
|
||
using Xamarin.Forms.Platform.MacOS; | ||
|
||
#nullable enable | ||
|
||
namespace AltNetworkUtility.macOS.Services.Windows | ||
{ | ||
public class MainWindowService : WindowService | ||
{ | ||
public override Window Window => Window.MainWindow; | ||
|
||
public override NSWindow OpenWindow() | ||
{ | ||
return _SingleInstanceWindows.GetOrAdd(Window, _ => | ||
{ | ||
const NSWindowStyle windowStyle = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled; | ||
|
||
var window = new NSWindow | ||
{ | ||
BackingType = NSBackingStore.Buffered, | ||
Level = NSWindowLevel.Normal, | ||
StyleMask = windowStyle, | ||
Title = AppDelegate.AppName | ||
}; | ||
|
||
window.TabbingMode = NSWindowTabbingMode.Disallowed; | ||
|
||
var page = new MainPage(); | ||
|
||
SetNSWindowFrameFromXamFormsPage(window, page); | ||
|
||
window.ContentView = page.CreateViewController().View; | ||
|
||
var windowController = new NSWindowController(window); | ||
var appDelegate = NSApplication.SharedApplication.Delegate as AppDelegate; | ||
windowController.ShowWindow(appDelegate); | ||
|
||
ShowWindow(window); | ||
|
||
return window; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.