Example #1
0
        public XmlUiLayoutRoot CloneRootGeometry()
        {
            var t = new XmlUiLayoutRoot();

            CopyRootGeometry(t);
            return(t);
        }
Example #2
0
 public void CopyRootGeometry(XmlUiLayoutRoot target)
 {
     target.ClientSize   = ClientSize;
     target.IsFullScreen = IsFullScreen;
     target.Location     = Location;
     target.WindowState  = WindowState;
 }
Example #3
0
 void ActivateLayoutRoot(XmlUiLayoutRoot r)
 {
     if (_ActiveLayout != null &&
         _MainForm.WindowState == r.WindowState &&
         _MainForm.ClientSize == r.ClientSize &&
         _MainForm.Location == r.Location)
     {
         // If we're already displaying a layout in _MainForm and _MainForm's geometry is still what we want,
         // keep things a bit simpler.
         var currentLayout = _ActiveLayout.Layout;
         _ActiveLayout = r;
         _Name         = r.Name;
         if (_Debug)
         {
             Console.WriteLine("UIM ActivateLayout {0}", r.Name);
         }
         ChangeLayout(currentLayout, r.Layout, _Root);
     }
     else
     {
         // From scratch, fully configure the _MainForm geometry and full layout.
         _ActiveLayout         = r;
         _Name                 = r.Name;
         _MainForm.WindowState = FormWindowState.Normal;
         _MainForm.ClientSize  = r.ClientSize;
         _FinishLayout         = new List <Action>();
         CreateLayout(r.Layout, _Root, _FinishLayout);
         var oloc = _MainForm.Location;
         _MainForm.Location = r.Location;
         var loc = _MainForm.ClientRectangle.Location;
         var ok  = false;
         foreach (var screen in Screen.AllScreens)
         {
             if (screen.Bounds.Contains(loc))
             {
                 ok = true;
                 break;
             }
         }
         if (!ok)
         {
             _MainForm.Location = oloc;
         }
         _MainForm.FormBorderStyle = (_ActiveLayout.IsFullScreen) ? FormBorderStyle.None : FormBorderStyle.Sizable;
         if (_Root.Visible)
         {
             _MainForm.WindowState = r.WindowState;
             _MainForm.Load       -= _MainForm_Load;
             _FinishLayout?.ForEach(fa => fa());
         }
         else
         {
             _MainForm.Load           += _MainForm_Load;
             _MainForm.VisibleChanged += _MainForm_VisibleChanged;
         }
     }
 }
Example #4
0
        public void ExtractAsNewLayoutAndSetActive(string newLayoutName)
        {
            var r = new XmlUiLayoutRoot();

            r.Name = newLayoutName;
            ExtractLayout(r);
            _Layouts.Add(newLayoutName.ToLower(), r);
            _ActiveLayout = r;
            _Name         = r.Name;
            OnLayoutsChanged();
        }
Example #5
0
 void ExtractLayout(XmlUiLayoutRoot r)
 {
     r.UseSuspendLayout = false;
     r.WindowState      = _MainForm.WindowState;
     r.ClientSize       = _MainForm.ClientSize;
     r.Location         = _MainForm.Location;
     r.IsFullScreen     = _MainForm.FormBorderStyle == FormBorderStyle.None;
     r.Layout           = ExtractLayout(_Root);
     if (!_Root.Visible)
     {
         r.Layout.HideMvcButton = false;
     }
 }
Example #6
0
        /// <summary>
        /// Returns a new empty UI layout with only the MainForm's window size, location, and state.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        XmlUiLayoutRoot CreateEmptyUiLayoutRoot(string name)
        {
            var r = new XmlUiLayoutRoot();

            r.Name        = name;
            r.WindowState = _MainForm.WindowState;
            r.ClientSize  = _MainForm.ClientSize;
            r.Location    = _MainForm.Location;
            r.Layout      = new XmlUiLayout {
                SelectedIndex = 0,
                HideMvcButton = false,
                HideTabs      = false,
                Tabs          = new List <string>(),
            };
            return(r);
        }