Example #1
0
        public bool OpenScreen(String screenName
                               , string controllerName, Dictionary <String
                                                                    , object> parameters = null
                               , bool isBackCommand = false
                               , bool isRefresh     = false)
        {
            try {
                Busy = true;

                _back    = null;
                _forward = null;

                ValueStack = new ValueStack.ValueStack(_exceptionHandler);
                ValueStack.Push("common", _commonData);
                ValueStack.Push("context", this);
                ValueStack.Push("dao", DAL.DAO);

                foreach (var variable in GlobalVariables)
                {
                    ValueStack.Push(variable.Key, variable.Value);
                }

                if (parameters != null)
                {
                    foreach (KeyValuePair <String, object> item in parameters)
                    {
                        ValueStack.Push(item.Key, item.Value);
                    }
                }

                Controllers.ScreenController newController =
                    ControllerFactory.CreateInstance().CreateController <Controllers.ScreenController> (controllerName);
                ValueStack.Push("controller", newController);
                screenName = newController.GetView(screenName);

                TabOrderManager.Create(this);

                Screen scr = (Screen)Factory.ScreenFactory.CreateInstance().CreateScreen <IOSStyleSheet> (screenName, ValueStack, newController);

                if (CurrentScreen != null)
                {
                    ((IDisposable)CurrentScreen.Screen).Dispose();
                }
                CurrentScreen = new ScreenData(screenName, controllerName, scr);

                ScreenController viewController = new ScreenController(scr.View);

                if (!isRefresh)
                {
                    _controller.SetViewControllers(new UIViewController[] {
                        _controller.TopViewController
                    }, false);

                    if (!isBackCommand)
                    {
                        _controller.PushViewController(viewController, true);
                    }
                    else
                    {
                        _controller.SetViewControllers(new UIViewController[] {
                            viewController,
                            _controller.TopViewController
                        }, false);
                        _controller.PopViewControllerAnimated(true);
                    }
                }
                else
                {
                    _controller.PopViewControllerAnimated(false);
                    _controller.PushViewController(viewController, false);
                }
            } catch (Exception ex) {
                HandleException(ex);
            } finally {
                ActionHandler.Busy   = false;
                ActionHandlerEx.Busy = false;
                Busy = false;
            }
            return(true);
        }
        public bool OpenScreen(String screenName
                               , string controllerName, Dictionary <String
                                                                    , object> parameters = null
                               , bool isBackCommand = false
                               , bool isRefresh     = false)
        {
            IDisposable rootControl = null;

            try
            {
                Busy = true;

                LogManager.Logger.ScreenOpening(screenName, controllerName, parameters);

                _back    = null;
                _forward = null;

                ValueStack = ValueStackContext.Current.CreateValueStack(_exceptionHandler);
                ValueStack.Push("common", CommonData);
                ValueStack.Push("context", this);
                ValueStack.Push("dao", Dal.Dao);
                ValueStack.Push("isTablet", UIDevice.CurrentDevice.Model.Contains("iPad"));

                foreach (var variable in GlobalVariables)
                {
                    ValueStack.Push(variable.Key, variable.Value);
                }

                if (parameters != null)
                {
                    foreach (var item in parameters)
                    {
                        ValueStack.Push(item.Key, item.Value);
                    }
                }

                IScreenController newController = BusinessProcessContext.Current.CreateScreenController(controllerName);
                ValueStack.SetCurrentController(newController);
                ValueStack.Push("controller", newController);
                screenName = newController.GetView(screenName);

                TabOrderManager.Create(this);

                var scr =
                    (Screen)
                    BusinessProcessContext.Current.CreateScreenFactory()
                    .CreateScreen(screenName, ValueStack, newController, null);

                rootControl   = RootControl;
                CurrentScreen = ControlsContext.Current.CreateScreenData(screenName, controllerName, scr);

                var viewController = new ScreenController(scr.View);

                if (!isRefresh)
                {
                    _controller.SetViewControllers(new[]
                    {
                        _controller.TopViewController
                    }, false);

                    if (!isBackCommand)
                    {
                        _controller.PushViewController(viewController, true);
                    }
                    else
                    {
                        _controller.SetViewControllers(new[]
                        {
                            viewController,
                            _controller.TopViewController
                        }, false);
                        _controller.PopViewControllerAnimated(true);
                    }
                }
                else
                {
                    _controller.PopViewControllerAnimated(false);
                    _controller.PushViewController(viewController, false);
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
            finally
            {
                LogManager.Logger.ScreenOpened();

                if (rootControl != null)
                {
                    rootControl.Dispose();
                }

                GC.Collect();

                ControlsContext.Current.ActionHandlerLocker.Release();
                Busy = false;
            }
            return(true);
        }