Beispiel #1
0
 public void HideView()
 {
     if (viewList.Count > 1)
     {
         FormView view = ActiveView;
         viewList.Remove(view);
         viewList.Add(view);
         SwitchTo(viewList[0] as FormView);
     }
 }
Beispiel #2
0
 private void OnSwitchClick(object sender, EventArgs args)
 {
     if (sender is MenuItem)
     {
         MenuItem menuItem = sender as MenuItem;
         FormView view     = FindView(menuItem.Text);
         if (view != null)
         {
             SwitchTo(view);
         }
     }
 }
Beispiel #3
0
        public void SwitchTo(FormView view)
        {
            if (view == null)
            {
                throw new Exception("Argument cannot be null");
            }
            else if (!viewList.Contains(view))
            {
                throw new Exception("Control doesn't contain the view specified");
            }

            viewList.Remove(view);
            viewList.Insert(0, view);

            if (ActiveView != null)
            {
                ActiveView.ClearForm(BaseForm);
            }

            ActiveView = view;

            view.FillForm(BaseForm);
            view.OnSelect(new EventArgs());

            foreach (MenuItem item in ViewMenu.MenuItems)
            {
                item.Checked = false;
            }

            var menuItem = FindMenuItem(view.Text);

            if (menuItem != null)
            {
                menuItem.Checked = true;
            }

            if (ToolBar != null)
            {
                ToolBar.SetViewTools(view.Tools);
            }
            BaseForm.Invalidate();
            BaseForm.Activate();
        }
Beispiel #4
0
        public void AddView(FormView view)
        {
            if (view == null)
            {
                throw new Exception("Argument cannot be null");
            }

            if (!viewList.Contains(view))
            {
                viewList.Add(view);

                MenuItem menuItem = new MenuItem();
                menuItem.Text   = view.Text;
                menuItem.Click += new EventHandler(OnSwitchClick);
                ViewMenu.MenuItems.Add(menuItem);

                view.Container = this;
            }
            SwitchTo(view);
        }