Пример #1
0
        /// <summary>
        /// Method to find a view by its name or create a new one
        /// if nothing was found.
        /// </summary>
        #endregion
        protected IView FindOrCreateView(string viewName)
        {
            IView result = views[viewName] as IView;

            if (result == null)
            {
                WinformsViewInfo viewInf = ViewInfos[viewName] as WinformsViewInfo;
                if (viewInf == null)
                {
                    throw new ViewInfoNotFoundException(viewName);
                }
                result = CreateHelper.Create(ViewInfos[viewName].ViewType) as IView;
                if (result == null)
                {
                    throw new ViewCreationException(viewName,
                                                    ViewInfos[viewName].ViewType);
                }
                result.ViewName = viewName;
                if (result is UserControl)
                {
                    InitializeUserControlView(result as UserControl);
                }
                else if (result is Form)
                {
                    InitializeFormView(result as Form, viewInf);
                }
            }
            return(result);
        }
Пример #2
0
 protected override void InitializeFormView(Form form, WinformsViewInfo viewInf)
 {
     base.InitializeFormView(form, viewInf);
     // If it's main form then access its content panel.
     if (form is MainForm)
     {
         contentPanel = form.Controls["contentPanel"] as OutlookPanelEx;
     }
 }
Пример #3
0
        private WinformsViewInfo GetViewInfo(string viewName)
        {
            WinformsViewInfo viewInf = ViewInfos[viewName] as WinformsViewInfo;

            if (viewInf == null)
            {
                viewInf = new WinformsViewInfo(ViewInfos[viewName].ViewName, ViewInfos[viewName].ViewType);
            }
            return(viewInf);
        }
Пример #4
0
        public void FixtureSetUp()
        {
            ViewInfosByTaskCollection viewInfsByTask = viewInfsProvider.GetFromAssembly(
                Assembly.GetExecutingAssembly());

            view1Info = viewInfsByTask[typeof(int)]["View1"] as WinformsViewInfo;
            view2Info = viewInfsByTask[typeof(int)]["View2"] as WinformsViewInfo;
            view3Info = viewInfsByTask[typeof(string)]["View3"] as WinformsViewInfo;
            view4Info = viewInfsByTask[typeof(int)]["View4"] as WinformsViewInfo;
            view5Info = viewInfsByTask[typeof(int)]["View5"] as WinformsViewInfo;
        }
Пример #5
0
        /// <summary>
        /// Method to initialize a view if it happens to be a form.
        /// Can be overriden in subclasses.
        /// </summary>
        #endregion
        protected virtual void InitializeFormView(Form form, WinformsViewInfo viewInf)
        {
            InitializeView(form as IView);
            form.Activated     += new EventHandler(view_ActivatedManually);
            form.Disposed      += new EventHandler(WinformsView_Disposed);
            form.IsMdiContainer = viewInf.IsMdiParent;
            string mdiParent = viewInf.MdiParent;

            if (mdiParent != null)
            {
                form.MdiParent = views[mdiParent] as Form;
            }
            NotifyInitialize(form as IView);
            InitializeChildViews(form);
        }
Пример #6
0
 /// <summary>
 /// Method to perform a general view initialization
 /// (regardless of its specific type)/
 /// </summary>
 #endregion
 protected virtual void InitializeView(IView view)
 {
     if (view.ViewName == null)
     {
         WinformsViewInfo viewInf = ViewInfos[view.GetType()] as WinformsViewInfo;
         if ((viewInf == null) || (viewInf.ViewName == null))
         {
             return;
         }
         view.ViewName = viewInf.ViewName;
     }
     views[view.ViewName] = view;
     view.Controller      = Navigator.GetController(view.ViewName);
     if (view.Controller != null)
     {
         view.Controller.View = view;
     }
 }
Пример #7
0
        /// <summary>
        /// Method to activate a view if it happens to be a form.
        /// Can be overriden in subclasses.
        /// </summary>
        #endregion
        protected virtual void ActivateFormView(IView view)
        {
            Form             form    = view as Form;
            WinformsViewInfo viewInf = ViewInfos[view.ViewName] as WinformsViewInfo;

            if (viewInf.ShowModal)
            {
                if (!form.Visible)
                {
                    form.ShowDialog();
                }
            }
            else
            {
                viewActivatedInCode = true;
                form.Show();
                form.Activate();
                viewActivatedInCode = false;
            }
        }
Пример #8
0
 protected override void InitializeFormView(Form form, WinformsViewInfo viewInf)
 {
     base.InitializeFormView(form, viewInf);
     mainFrm = form as MainForm;
 }