internal WinChildController(GuiChildPresenter presenter, GuiViewController parent, Type targetType) : base(presenter)
        {               //****************************************
            Control        ParentControl;
            IWinController ParentController = parent as IWinController;

            //****************************************

            if (ParentController == null)
            {
                throw new ArgumentException("Not a WinForms controller");
            }

            ParentControl = ParentController.Control;
            ParentController.Attach(this);

            //****************************************

            // Search the controls underneath the parent for our desired UserControl
            _UserControl = WalkControls(ParentControl, targetType);

            if (_UserControl == null)
            {
                throw new InvalidOperationException("Control does not exist");
            }

            _UserControl.Enter         += OnGotFocus;
            _UserControl.HandleCreated += OnLoad;
            _UserControl.Leave         += OnLostFocus;

            //****************************************

            _Provider = ((WinToolkit)GuiService.Toolkit).GetProvider(presenter.Host);
            _ViewDef  = _Provider.GetViewDef(this.Name);
        }
        //****************************************

        internal WinChildController(GuiChildPresenter presenter, GuiViewController parent, UserControl control) : base(presenter)
        {
            if (parent is IWinController)
            {
                ((IWinController)parent).Attach(this);
            }
            else
            {
                throw new ArgumentException("Not a WinForms controller");
            }

            //****************************************

            _UserControl = control;
            _Provider    = ((WinToolkit)GuiService.Toolkit).GetProvider(presenter.Host);
            _ViewDef     = _Provider.GetViewDef(this.Name);

            //****************************************

            _UserControl.Enter += OnGotFocus;
            if (_UserControl.IsHandleCreated)
            {
                OnLoad(_UserControl, EventArgs.Empty);
            }
            else
            {
                _UserControl.HandleCreated += OnLoad;
            }

            _UserControl.Leave += OnLostFocus;
        }
        public override void Register(GuiProvider provider)
        {               //****************************************
            WinProvider MyProvider;

            //****************************************

            _Providers.Add(provider.Component.Name, MyProvider = new WinProvider(this, provider));

            MyProvider.Load();
        }
Beispiel #4
0
        //****************************************

        internal WinFormController(GuiFormPresenter presenter, Form form) : base(presenter)
        {
            _Form = form;

            form.FormClosing   += OnFormClosing;
            form.Activated     += OnGotFocus;
            form.HandleCreated += OnLoad;
            form.Deactivate    += OnLostFocus;

            //****************************************

            _Provider = ((WinToolkit)GuiService.Toolkit).GetProvider(presenter.Host);
            _ViewDef  = _Provider.GetViewDef(this.Name);
        }