Esempio n. 1
0
        public void Add(Controller controller)
        {
            if (controllerList.Contains(controller))
            {
                if (this.controllerList.Count > 0)
                {
                    this.controllerList.Remove(controller);
                }
            }

            if (current == null || this.controllerList.Count == 0)
            {
                this.controllerList.AddFirst(controller);
                this.current = controllerList.First;
            }
            else
            {
                if (this.current.Value != controller)
                {
                    try
                    {
                        this.current = controllerList.AddAfter(current, controller);
                    }
                    catch (InvalidOperationException ex)
                    {
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Adds controller to the cache
 /// </summary>
 /// <param name="controller">Controller instance.</param>
 public static void Add(Controller controller)
 {
     if (!controllerCache.ContainsKey(controller.Name))
     {
         controllerCache.Add(controller.Name, controller);
     }
     else
     {
         throw new ArgumentException("Controller already exists.");
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Removes controller from the cache
 /// </summary>
 /// <param name="controller">Controller instance.</param>
 public static void Remove(Controller controller)
 {
     if (controllerCache.ContainsKey(controller.Name))
     {
         controllerCache.Remove(controller.Name);
     }
     else
     {
         throw new ArgumentException("Controller doesn't exist.");
     }
 }
Esempio n. 4
0
        ///// <summary>
        ///// Navigates to the view/controller in a modal fashion.
        ///// </summary>
        ///// <param name="controller">The name of the controller.</param>
        ///// <returns>The DialogResult from the displayed view.</returns>
        //public static DialogResult NavigateFormDialog(Controller controller)
        //{
        //    string name = controller.Name;
        //    if (!controllerCache.ContainsKey(name))
        //    {
        //        controllerCache.Add(name, controller);
        //    }
        //    history.Add(controller);
        //    DialogResult result = controller.View.ShowDialog();
        //    history.GoBack();
        //    return result;
        //}
        //        /// <summary>
        ///// Navigates to the view/controller in a modal fashion for Control realization.
        ///// </summary>
        ///// <param name="controller">The name of the controller.</param>
        ///// <returns>The DialogResult from the displayed view.</returns>
        //public static void NavigateControlDialog(Controller controller)
        //{
        //    string name = controller.Name;
        //    if (!controllerCache.ContainsKey(name))
        //    {
        //        controllerCache.Add(name, controller);
        //    }
        //    history.Add(controller);
        //    controller.View.ShowDialog();
        //}
        ///// <summary>
        ///// Navigates to the controller.
        ///// </summary>
        ///// <param name="controller">An instance of the controller.</param>
        //public static void Navigate(Controller controller)
        //{
        //    string name = controller.Name;
        //    if (!controllerCache.ContainsKey(name))
        //    {
        //        controllerCache.Add(name, controller);
        //    }
        //    else
        //    {
        //        controllerCache.Remove(name);
        //        controllerCache.Add(name, controller);
        //    }
        //    Controller currentController = history.GetCurrent();
        //    controller.View.Show();
        //    if (currentController != null)
        //    {
        //        currentController.View.Hide();
        //    }
        //    history.Add(controller);
        //}
        /// <summary>
        /// Navigates to the controller.
        /// </summary>
        /// <param name="controller">An instance of the contoller.</param>
        /// <param name="parameters">An array of the parameters.</param>
        public static void Navigate(Controller controller, params object[] parameters)
        {
            string name = controller.GetType().Name;

            if (!controllerCache.ContainsKey(name))
            {
                controllerCache.Add(name, controller);
            }
            else
            {
                controllerCache.Remove(name);
                controllerCache.Add(name, controller);
            }

            controller.Initialize(parameters);
            controller.Activate();

            Controller currentController = history.GetCurrent();
            if (currentController != null)
            {
                currentController.Deactivate();
            }
            history.Add(controller);
        }