Hi Xamarin,
I'm an experienced WinForms and WPF C# developer. I just got my first mac and I'm busy figuring things out.
There is an app that I've written that is heavily plugin based. The WPF version is completely GUI-less except for a login screen that it presents at the very beginning of the app - and even this login screen is loaded by a plugin.
Anyways, I'm trying to figure out the Cocoa "version" of this code:
var Login = new frmLogin();
Login.ShowDialog();
I specifically don't want there to be a "main" storyboard.
I've created a new Storyboard (named "Storyboard1") and put a new window in it. I have the following classes:
Window Controller: Window1Controller
Window: Window1
Story Board Controller: Storyboard1ViewController
I understand that I need to call StoryBoard.InstantiateControllerWithIdentifier(...) to get the Window1 Controller, but it seems as though whatever string I pass, gives me an error.
What should I pass?
Here's the code I'm using to try to figure out what I should use for the controller name.
using System.Linq;
using System;
namespace Test3 {
static class MainClass {
static void Main(string[] args) {
NSApplication.Init();
var StoryBoards = new[] { "Storyboard1", "Storyboard2" };
var Controllers = new[] {
"ViewController",
"Window1Controller", "Window2Controller",
"Storyboard1ViewController", "Storyboard2ViewController"
};
var items =
from x in StoryBoards
from y in Controllers
let Result = LoadController(x, y)
where Result != null
select new {
Storyboard = x,
Controllers = y,
Result = Result
}
;
var Values = items.ToList();
}
private static object LoadController(string StoryBoard, string Controller) {
var ret = default(object);
try {
var sb = NSStoryboard.FromName(StoryBoard, null);
var con = sb.InstantiateControllerWithIdentifier(Controller);
ret = con;
} catch (Exception ex) {
ret = ex;
}
return ret;
}
}
}