NSMenu CreateSubMenuForRuntime (IRuntimeModel runtime) { if (!runtime.Children.Any ()) return null; var menu = new NSMenu { AutoEnablesItems = false, ShowsStateColumn = false, Font = NSFont.MenuFontOfSize (12), }; foreach (var item in runtime.Children) CreateMenuItem (menu, item); return menu; }
NSMenu CreateSubMenuForRuntime(IRuntimeModel runtime) { if (!runtime.Children.Any()) { return(null); } var menu = new NSMenu { AutoEnablesItems = false, ShowsStateColumn = false, Font = NSFont.MenuFontOfSize(12), }; foreach (var item in runtime.Children) { CreateMenuItem(menu, item); } return(menu); }
NSMenuItem CreateMenuItem(NSMenu menu, IRuntimeModel runtime) { NSMenuItem menuItem; string runtimeFullDisplayString; using (var mutableModel = runtime.GetMutableModel()) { runtimeFullDisplayString = mutableModel.FullDisplayString; menuItem = new NSMenuItem() { IndentationLevel = runtime.IsIndented ? 1 : 0, AttributedTitle = new NSAttributedString(mutableModel.DisplayString, new NSStringAttributes { Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont(menu.Font, NSFontTraitMask.Bold) : menu.Font, }), Enabled = mutableModel.Enabled, Hidden = !mutableModel.Visible, }; if (ActiveRuntime == runtime || (ActiveRuntime?.Children.Contains(runtime) ?? false)) { menuItem.State = NSCellStateValue.On; } } var subMenu = CreateSubMenuForRuntime(runtime); if (subMenu != null) { menuItem.Submenu = subMenu; menuItem.Enabled = true; } else { menuItem.Activated += (o2, e2) => { ActiveRuntime = runtime; }; } menu.AddItem(menuItem); return(menuItem); }
void CreateMenuItem(NSMenu menu, IRuntimeModel runtime) { var menuItem = new NSMenuItem { IndentationLevel = runtime.IsIndented ? 2 : 1, Enabled = runtime.Enabled, Hidden = !runtime.Visible, AttributedTitle = new NSAttributedString(runtime.DisplayString, new NSStringAttributes { Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont(menu.Font, NSFontTraitMask.Bold) : menu.Font, }), }; var subMenu = CreateSubMenuForRuntime(runtime); if (subMenu != null) { menuItem.Submenu = subMenu; menuItem.Enabled = true; } else { menuItem.Activated += (o2, e2) => { string old = ActiveRuntime.FullDisplayString; ActiveRuntime = runtimeModel.First(r => r.FullDisplayString == runtime.FullDisplayString); var ea = new HandledEventArgs(); if (RuntimeChanged != null) { RuntimeChanged(o2, ea); } if (ea.Handled) { ActiveRuntime = runtimeModel.First(r => r.FullDisplayString == old); } }; } menu.AddItem(menuItem); }
public void AddChild(IRuntimeModel child) { children.Add(child); }
public void AddChild (IRuntimeModel child) { children.Add (child); }
void CreateMenuItem (NSMenu menu, IRuntimeModel runtime) { var menuItem = new NSMenuItem { IndentationLevel = runtime.IsIndented ? 2 : 1, Enabled = runtime.Enabled, Hidden = !runtime.Visible, AttributedTitle = new NSAttributedString (runtime.DisplayString, new NSStringAttributes { Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont (menu.Font, NSFontTraitMask.Bold) : menu.Font, }), }; var subMenu = CreateSubMenuForRuntime (runtime); if (subMenu != null) { menuItem.Submenu = subMenu; menuItem.Enabled = true; } else { menuItem.Activated += (o2, e2) => { string old = ActiveRuntime.FullDisplayString; ActiveRuntime = runtimeModel.First (r => r.FullDisplayString == runtime.FullDisplayString); var ea = new HandledEventArgs (); if (RuntimeChanged != null) RuntimeChanged (o2, ea); if (ea.Handled) ActiveRuntime = runtimeModel.First (r => r.FullDisplayString == old); }; } menu.AddItem (menuItem); }
void CreateMenuItem (NSMenu menu, IRuntimeModel runtime) { NSMenuItem menuItem; string runtimeFullDisplayString; using (var mutableModel = runtime.GetMutableModel ()) { runtimeFullDisplayString = mutableModel.FullDisplayString; menuItem = new NSMenuItem { IndentationLevel = runtime.IsIndented ? 2 : 1, AttributedTitle = new NSAttributedString (mutableModel.DisplayString, new NSStringAttributes { Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont (menu.Font, NSFontTraitMask.Bold) : menu.Font, }), Enabled = mutableModel.Enabled, Hidden = !mutableModel.Visible, }; } var subMenu = CreateSubMenuForRuntime (runtime); if (subMenu != null) { menuItem.Submenu = subMenu; menuItem.Enabled = true; } else { menuItem.Activated += (o2, e2) => { string old; using (var activeMutableModel = ActiveRuntime.GetMutableModel ()) old = activeMutableModel.FullDisplayString; IRuntimeModel newRuntime = runtimeModel.FirstOrDefault (r => { using (var newRuntimeMutableModel = r.GetMutableModel ()) return newRuntimeMutableModel.FullDisplayString == runtimeFullDisplayString; }); if (newRuntime == null) return; ActiveRuntime = newRuntime; var ea = new HandledEventArgs (); if (RuntimeChanged != null) RuntimeChanged (o2, ea); if (ea.Handled) ActiveRuntime = runtimeModel.First (r => { using (var newRuntimeMutableModel = r.GetMutableModel ()) return newRuntimeMutableModel.FullDisplayString == old; }); }; } menu.AddItem (menuItem); }
public CommandHandler(IBoundedContextModel contextModel, IRuntimeModel runtimeModel) { this.contextModel = contextModel; this.runtimeModel = runtimeModel; }
internal TransactionalEventHandler(IBoundedContextModel boundedContextModel, IEventStore eventStore, bool cacheRuntimeModel) { this.runtimeModel = new RuntimeModel(boundedContextModel, eventStore); this.eventHandler = new EventHandler(boundedContextModel, runtimeModel); this.cacheRuntimeModel = cacheRuntimeModel; }
NSMenuItem CreateMenuItem (NSMenu menu, IRuntimeModel runtime) { NSMenuItem menuItem; string runtimeFullDisplayString; using (var mutableModel = runtime.GetMutableModel ()) { runtimeFullDisplayString = mutableModel.FullDisplayString; menuItem = new NSMenuItem () { IndentationLevel = runtime.IsIndented ? 1 : 0, AttributedTitle = new NSAttributedString (mutableModel.DisplayString, new NSStringAttributes { Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont (menu.Font, NSFontTraitMask.Bold) : menu.Font, }), Enabled = mutableModel.Enabled, Hidden = !mutableModel.Visible, }; if (ActiveRuntime == runtime || (ActiveRuntime?.Children.Contains (runtime) ?? false)) { menuItem.State = NSCellStateValue.On; } } var subMenu = CreateSubMenuForRuntime (runtime); if (subMenu != null) { menuItem.Submenu = subMenu; menuItem.Enabled = true; } else { menuItem.Activated += (o2, e2) => { ActiveRuntime = runtime; }; } menu.AddItem (menuItem); return menuItem; }