private MonoBehaviour SetViewFromEnum(Views viewEnum, Action <ViewControllerBase> intermediateActn = null) { if (_currentViewController != null) { Destroy(_currentViewController.gameObject); _currentViewController = null; } GameObject prefab = ViewPrefabs[(int)viewEnum]; if (prefab) { // Set main view to playlist GameObject viewGO = Instantiate(prefab, _viewsParent); // Get view controller base, invoke any action _currentViewController = viewGO.GetComponent <ViewControllerBase>(); if (!_currentViewController) { Debug.LogError($"View '{viewEnum}' doesn't inherit from ViewControllerBase!"); } intermediateActn?.Invoke(_currentViewController); return(_currentViewController); } return(null); }
public void Navigate(ViewControllerBase viewcontroller) { if (Window != null) { nav = new UINavigationController(viewcontroller); Window.RootViewController = nav; } }
public void NavigateWithSlide(ViewControllerBase viewcontroller) { if (Window != null) { splitView = new SplitViewContoller(viewcontroller); Window.RootViewController = splitView; Window.MakeKeyAndVisible(); } }
public SplitViewContoller(ViewControllerBase control) : base() { menuView = new MenuController(); ViewControllers = new UIViewController[] { menuView, control }; menuView.RowClicked += (object sender, MenuController.RowClickedEventArgs e) => { var navigate = FactorySingleton.Factory.Get <NavigationService>(); switch (e.Item) { case Utils.EXIT_REQUEST: { navigate.Navigate(new LoginViewController()); break; } case Utils.LIST_VACATION: { navigate.Navigate(new VacationViewController()); break; } default: { var createVacationController = new CreateVacationViewController(); createVacationController.ID = 0; createVacationController.TypeVacation = e.Item; navigate.Navigate(createVacationController); break; } } }; WillHideViewController += (object sender, UISplitViewHideEventArgs e) => { }; WillShowViewController += (object sender, UISplitViewShowEventArgs e) => { }; ShouldHideViewController = (svc, viewController, inOrientation) => { return(inOrientation == UIInterfaceOrientation.Portrait || inOrientation == UIInterfaceOrientation.PortraitUpsideDown); }; }
public TableSource(List <VTSModel> items, ViewControllerBase owner) { tableItems = items; this.owner = owner; trash = owner.Localize("trash"); }
protected virtual void Start() { currentView = this; }
private static void OnControllerChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { Window w = sender as Window; if (w == null) { //sender is a child element w = Window.GetWindow(sender); } if (w != null) { ViewControllerBase controller = e.NewValue as ViewControllerBase; if (controller != null) { EventHandler <WindowShouldCloseEventArgs> windowShouldClose = null; windowShouldClose = (x, y) => { //check if the call is on the same thread as the window //need to marshal onto UI thread if (!w.Dispatcher.CheckAccess()) { //different thread so invoke async on the dispatcher's thread w.Dispatcher.Invoke(windowShouldClose, x, y); } else { //ok thread is being called on the same thread as the window //now check if the current thread is modal, this should mean that the window was shown using ShowDialog if (ComponentDispatcher.IsThreadModal) { //window should be Modal, i.e. a child window that is owned by a parent window try { //set the DialogResult value, close this window and return to the parent window //this will throw if the Window was not shown using ShowDialog w.DialogResult = y.DialogResult; } catch (InvalidOperationException) { } } w.Close(); } }; controller.WindowShouldClose += windowShouldClose; EventHandler closed = null; closed = (x, y) => { w.ClearValue(ViewControllerBehaviour.ControllerProperty); controller.WindowShouldClose -= windowShouldClose; w.Closed -= closed; controller.OnWindowClosed(); }; w.Closed += closed; EventHandler activated = (x, y) => controller.OnWindowActivated(); w.Activated += activated; EventHandler deactivated = (x, y) => controller.OnWindowDeactivated(); w.Deactivated += deactivated; } } }