Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
Use existing AppHost if one is already listening, rename to Program t…
Browse files Browse the repository at this point in the history
…o match template
  • Loading branch information
mythz committed Sep 23, 2015
1 parent d78f742 commit a1b6660
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/RedisReact/RedisReact.AppMac/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public class NativeHost
public void ShowAbout()
{
//Invoke native about menu item programmatically.
MainClass.MainMenu.InvokeOnMainThread (() => {
foreach (var item in MainClass.MainMenu.ItemArray()) {
Program.MainMenu.InvokeOnMainThread (() => {
foreach (var item in Program.MainMenu.ItemArray()) {
if (item.Title == "RedisReact") {
item.Submenu.PerformActionForItem(0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/RedisReact/RedisReact.AppMac/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void Initialize ()
public override void AwakeFromNib()
{
base.AwakeFromNib ();
MainClass.MainMenu = NSApplication.SharedApplication.MainMenu;
webView.MainFrameUrl = MainClass.HostUrl;
Program.MainMenu = NSApplication.SharedApplication.MainMenu;
webView.MainFrameUrl = Program.HostUrl;
webView.Frame = new System.Drawing.RectangleF(0,0,this.Frame.Width,this.Frame.Height);
this.DidResize += (sender, e) => {
webView.Frame = new System.Drawing.RectangleF(0,0,this.Frame.Width,this.Frame.Height);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System;
using System.Drawing;
using ServiceStack.Text;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;

namespace RedisReact.AppMac
{
public static class MainClass
public static class Program
{
public static string HostUrl = "http://127.0.0.1:3337/";
public static string ListenOn = "http://*:3337/";
Expand All @@ -16,8 +17,15 @@ public static class MainClass

static void Main (string[] args)
{
App = new AppHost();
App.Init().Start(ListenOn);
try
{
App = new AppHost();
App.Init().Start(ListenOn);
}
catch (Exception)
{
"Using existing AppHost found on {0}".Print(HostUrl);
}

NSApplication.Init();
NSApplication.Main(args);
Expand Down
2 changes: 1 addition & 1 deletion src/RedisReact/RedisReact.AppMac/RedisReact.AppMac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
<Compile Include="AppDelegate.cs" />
<Compile Include="AppDelegate.designer.cs" />
<Compile Include="AppHost.cs" />
<Compile Include="Main.cs" />
<Compile Include="MainWindow.cs" />
<Compile Include="MainWindow.designer.cs" />
<Compile Include="MainWindowController.cs" />
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
Expand Down

0 comments on commit a1b6660

Please sign in to comment.