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

        internal WpfChildController(GuiChildPresenter presenter, GuiViewController parent, Type targetType) : base(presenter)
        {               //****************************************
            ContentControl ParentControl;

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

            _TargetType = targetType;

            if (parent is WpfChildController)
            {
                ParentControl = ((WpfChildController)parent).UserControl;
            }
            else if (parent is WpfFormController)
            {
                ParentControl = ((WpfFormController)parent).Window;
            }
            else
            {
                throw new ArgumentException("Not a WPF controller");
            }

            _UserControl             = WalkControls(ParentControl, targetType);
            _UserControl.DataContext = Presenter;
            _UserControl.Resources.Add("Proximity.Gui.Presentation.GuiPresenter", Presenter);
        }
        //****************************************

        public GtkChildController(GuiChildPresenter presenter, GuiViewController parent, Type targetType) : base(presenter)
        {               //****************************************
            Container ParentWidget;

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

            if (parent is GtkChildController)
            {
                ParentWidget = ((GtkChildController)parent).Control;
            }
            else if (parent is GtkFormController)
            {
                ParentWidget = ((GtkFormController)parent).Window;
            }
            else
            {
                throw new ArgumentException("Not a Gtk controller");
            }

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

            // Search the widgets underneath the parent for our desired user-control
            _Control = WalkWidgets(ParentWidget, targetType);

            //****************************************
        }
        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;
        }
        internal void AttachController(GuiPresenter parent, GuiChildPresenter presenter, UserControl control)
        {
            var MyParentView = GetView(parent);

            var MyController = new WinChildController(presenter, MyParentView, control);

            SetView(presenter, MyController);
        }
Beispiel #6
0
        internal GuiChildController GetChildController(GuiChildPresenter presenter, GuiViewController parent)
        {               //****************************************
            Type ViewType;

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

            if (!_PresenterMappings.TryGetValue(presenter.GetType(), out ViewType))
            {
                throw new ArgumentException(string.Format("Component {0} does not have any Views for Presenter {1}", _Component.Name, presenter.GetType().FullName));
            }

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

            Log.Verbose("Attaching Child Controller {0} to Presenter {1}", ViewType.Name, presenter.GetType().Name);

            return(GuiService.Toolkit.FindChildController(presenter, parent, ViewType));
        }
Beispiel #7
0
        //****************************************

        private string GetTitle(GuiChildPresenter presenter)
        {               //****************************************
            object PropertyValue = WinBindingSource.GetFromPath(presenter, _DisplayPath);

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

            if (_Converter != null)
            {
                return((string)_Converter.ConvertTo(PropertyValue, typeof(string), null));
            }
            else if (PropertyValue is string)
            {
                return((string)PropertyValue);
            }
            else if (PropertyValue != null)
            {
                return(PropertyValue.ToString());
            }
            else
            {
                return("");
            }
        }
Beispiel #8
0
 public override GuiChildController FindChildController(GuiChildPresenter presenter, GuiViewController parent, Type childType)
 {
     return(new GtkChildController(presenter, parent, childType));
 }
        //****************************************

        /// <summary>
        /// Creates a new Gui Child Controller
        /// </summary>
        /// <param name="presenter">The child presenter who will manage this controller</param>
        protected GuiChildController(GuiChildPresenter presenter) : base(presenter)
        {
            _Parent = presenter.Parent.View;
        }
Beispiel #10
0
 public abstract GuiChildController FindChildController(GuiChildPresenter presenter, GuiViewController parent, Type childType);