Exemplo n.º 1
0
 public static Form layout(this Form parentForm, MdiLayout layout)
 {
     return(parentForm.invokeOnThread(() => {
         parentForm.LayoutMdi(layout);
         return parentForm;
     }));
 }
Exemplo n.º 2
0
        public void LayoutMdi(MdiLayout value)
        {
            if (Handle == IntPtr.Zero)
            {
                return;
            }

            switch (value)
            {
            case MdiLayout.Cascade:
                User32.SendMessageW(this, User32.WM.MDICASCADE);
                break;

            case MdiLayout.TileVertical:
                User32.SendMessageW(this, User32.WM.MDITILE, (IntPtr)User32.MDITILE.VERTICAL);
                break;

            case MdiLayout.TileHorizontal:
                User32.SendMessageW(this, User32.WM.MDITILE, (IntPtr)User32.MDITILE.HORIZONTAL);
                break;

            case MdiLayout.ArrangeIcons:
                User32.SendMessageW(this, User32.WM.MDIICONARRANGE);
                break;
            }
        }
Exemplo n.º 3
0
        private void tssbtLayout_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;

            if (item == lockToolStripMenuItem)
            {
                LayoutLock = !LayoutLock;
                lockToolStripMenuItem.Checked = !LayoutLock;
                return;
            }
            else if (item == horizontalToolStripMenuItem)
            {
                tssbtLayout.Image = horizontalToolStripMenuItem.Image;
                CurrentLayoutItem = MdiLayout.TileHorizontal;
                LayoutRcvWindows(CurrentLayoutItem);
            }
            else if (item == verticalToolStripMenuItem)
            {
                tssbtLayout.Image = verticalToolStripMenuItem.Image;
                CurrentLayoutItem = MdiLayout.TileVertical;
                LayoutRcvWindows(CurrentLayoutItem);
            }
            else if (item == stackToolStripMenuItem)
            {
                tssbtLayout.Image = stackToolStripMenuItem.Image;
                CurrentLayoutItem = MdiLayout.Cascade;
                LayoutRcvWindows(CurrentLayoutItem);
            }
        }
Exemplo n.º 4
0
        // Lay out the children in this MDI client.
        public void LayoutMdi(MdiLayout value)
        {
            IToolkitMdiClient mdi = (toolkitWindow as IToolkitMdiClient);

            if (mdi != null)
            {
                switch (value)
                {
                case MdiLayout.Cascade:
                {
                    mdi.Cascade();
                }
                break;

                case MdiLayout.TileHorizontal:
                {
                    mdi.TileHorizontally();
                }
                break;

                case MdiLayout.TileVertical:
                {
                    mdi.TileVertically();
                }
                break;

                case MdiLayout.ArrangeIcons:
                {
                    mdi.ArrangeIcons();
                }
                break;
                }
            }
        }
Exemplo n.º 5
0
        /// <include file='doc\MDIClient.uex' path='docs/doc[@for="MdiClient.LayoutMdi"]/*' />
        /// <devdoc>
        ///     Arranges the MDI child forms according to value, which should be a
        ///     member of the MdiLayout enum.
        /// </devdoc>
        public void LayoutMdi(MdiLayout value)
        {
            if (Handle == IntPtr.Zero)
            {
                return;
            }

            switch (value)
            {
            case MdiLayout.Cascade:
                SendMessage(Interop.WindowMessages.WM_MDICASCADE, 0, 0);
                break;

            case MdiLayout.TileVertical:
                SendMessage(Interop.WindowMessages.WM_MDITILE, NativeMethods.MDITILE_VERTICAL, 0);
                break;

            case MdiLayout.TileHorizontal:
                SendMessage(Interop.WindowMessages.WM_MDITILE, NativeMethods.MDITILE_HORIZONTAL, 0);
                break;

            case MdiLayout.ArrangeIcons:
                SendMessage(Interop.WindowMessages.WM_MDIICONARRANGE, 0, 0);
                break;
            }
        }
Exemplo n.º 6
0
 public WindowLayoutToolStripMenuItem(Logger logger, FormMain target, MdiLayout layout)
 {
     _logger = logger;
     _target = target;
     _layout = layout;
     _logger.Trace($"{nameof(WindowLayoutToolStripMenuItem)} is constructed for");
     _logger.Info($"target main form: {_target.Name}/{_target.Text}, layout style: {_layout}.");
 }
Exemplo n.º 7
0
        public void LayoutMdi(MdiLayout mdiLayout)
        {
            var point = new Point(0, 0);

            switch (mdiLayout)
            {
            case MdiLayout.Cascade:
                foreach (var mdiChildWindow in Children)
                {
                    mdiChildWindow.State       = StateWindow.Normal;
                    mdiChildWindow.IsMaximized = false;
                    mdiChildWindow.SetLocation(point);

                    point.X += 20;
                    point.Y += 20;
                }
                break;

            case MdiLayout.TileHorizontal:
                var widthWindow = ScrollViewerRoot.ViewportWidth / Children.Count;
                foreach (var mdiChildWindow in Children)
                {
                    mdiChildWindow.State       = StateWindow.Normal;
                    mdiChildWindow.IsMaximized = false;
                    mdiChildWindow.SetLocation(point);

                    mdiChildWindow.Width  = widthWindow;
                    mdiChildWindow.Height = ScrollViewerRoot.ViewportHeight;

                    point.X += widthWindow;
                }
                break;

            case MdiLayout.TileVertical:
                var windowHeight = ScrollViewerRoot.ViewportHeight / Children.Count;
                foreach (var mdiChildWindow in Children)
                {
                    mdiChildWindow.State       = StateWindow.Normal;
                    mdiChildWindow.IsMaximized = false;

                    mdiChildWindow.Width  = ScrollViewerRoot.ViewportWidth;
                    mdiChildWindow.Height = windowHeight;

                    mdiChildWindow.SetLocation(point);
                    point.Y += windowHeight;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("mdiLayout", mdiLayout, null);
            }

            PerformLayout();
        }
Exemplo n.º 8
0
 public static void ChangeLayout(MdiLayout layoutPattern)
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         MainWindow mw = (MainWindow)Application.Current.MainWindow;
         mw.ContainerWindow.MdiLayout = layoutPattern;
     }
     else
     {
         Application.Current.Dispatcher.Invoke((Action)(() => { ChangeLayout(layoutPattern); }));
     }
 }
Exemplo n.º 9
0
        /////////////////////////////////////////////////////////////////////////////////

        #region [ Public Methods ]

        /// <summary>
        /// Arranges the multiple-document interface (MDI) child forms within the MDI
        /// parent form.
        /// </summary>
        ///
        public void LayoutMdi(MdiLayout layout)
        {
            switch (layout)
            {
            case MdiLayout.Cascade:
                LayoutMdiCascade();
                break;

            case MdiLayout.TileHorizontal:
                throw new NotImplementedException();

            case MdiLayout.TileVertical:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 10
0
        private void StackingChildForms(MdiLayout mDiLayout, params Form[] childWindows)
        {
            //Minimize all others winow
            var parentForm = (XtraForm)this.GridControl.TopLevelControl;

            foreach (Form child in parentForm.MdiChildren)
            {
                child.WindowState = FormWindowState.Minimized;
            }
            foreach (Form child in childWindows)
            {
                child.WindowState = FormWindowState.Normal;
            }

            parentForm.LayoutMdi(mDiLayout);
        }
Exemplo n.º 11
0
        public static string Layout(string layoutPattern)
        {
            if (!String.IsNullOrWhiteSpace(layoutPattern))
            {
                MdiLayout p = MdiLayout.Cascade;
                switch (layoutPattern.ToUpper()[0])
                {
                case 'C': p = MdiLayout.Cascade; break;

                case 'H': p = MdiLayout.TileHorizontal; break;

                case 'V': p = MdiLayout.TileVertical; break;

                default: return("");
                }
                MainWindow.ChangeLayout(p);
            }
            return("");
        }
        public void LayoutMdi(MdiLayout value)
        {
            if (base.Handle != IntPtr.Zero)
            {
                switch (value)
                {
                    case MdiLayout.Cascade:
                        base.SendMessage(0x227, 0, 0);
                        return;

                    case MdiLayout.TileHorizontal:
                        base.SendMessage(550, 1, 0);
                        return;

                    case MdiLayout.TileVertical:
                        base.SendMessage(550, 0, 0);
                        return;

                    case MdiLayout.ArrangeIcons:
                        base.SendMessage(0x228, 0, 0);
                        return;
                }
            }
        }
Exemplo n.º 13
0
        public void LayoutRcvWindows(MdiLayout layout)
        {
            int          index = 0;
            IDockContent pre   = null;
            DockStyle    style = DockStyle.Fill;

            dockPanel.SuspendLayout(true);

            switch (layout)
            {
            case MdiLayout.TileHorizontal:
                style = DockStyle.Bottom;
                break;

            case MdiLayout.TileVertical:
                style = DockStyle.Right;
                break;

            case MdiLayout.Cascade:
            default:
                style = DockStyle.Fill;
                break;
            }

            foreach (IDockContent document in dockPanel.DocumentsToArray())
            {
                if (0 != index)
                {
                    document.DockHandler.DockTo(pre.DockHandler.Pane, style, index);
                }
                index++;
                pre = document;
            }

            dockPanel.ResumeLayout(true, true);
        }
Exemplo n.º 14
0
        public void LayoutMdi(MdiLayout value)
        {
            if (base.Handle != IntPtr.Zero)
            {
                switch (value)
                {
                case MdiLayout.Cascade:
                    base.SendMessage(0x227, 0, 0);
                    return;

                case MdiLayout.TileHorizontal:
                    base.SendMessage(550, 1, 0);
                    return;

                case MdiLayout.TileVertical:
                    base.SendMessage(550, 0, 0);
                    return;

                case MdiLayout.ArrangeIcons:
                    base.SendMessage(0x228, 0, 0);
                    return;
                }
            }
        }
Exemplo n.º 15
0
	// Lay out the children in this MDI client.
	public void LayoutMdi(MdiLayout value)
			{
				IToolkitMdiClient mdi = (toolkitWindow as IToolkitMdiClient);
				if(mdi != null)
				{
					switch(value)
					{
						case MdiLayout.Cascade:
						{
							mdi.Cascade();
						}
						break;

						case MdiLayout.TileHorizontal:
						{
							mdi.TileHorizontally();
						}
						break;

						case MdiLayout.TileVertical:
						{
							mdi.TileVertically();
						}
						break;

						case MdiLayout.ArrangeIcons:
						{
							mdi.ArrangeIcons();
						}
						break;
					}
				}
			}
Exemplo n.º 16
0
		private void AlignMdiChildWindows(MdiLayout layout)
		{
			int numberOfChildren = MdiChildren.Length - 1;
			if ((0 == numberOfChildren) || (layout == MdiLayout.Cascade))
				return;

			int maxNumberToLayout = (8 < numberOfChildren) ? 8 : numberOfChildren;
			int clientWidth = GetMdiClientWidth();
			int clientHeight = GetMdiClientHeight();

			int left = m_policySetExplorer.Right;
			int top = ClientRectangle.Top;
			int count = 1;
			foreach (Form childForm in MdiChildren)
			{
				if (childForm is MDIChildForm)
				{
					childForm.Dock = DockStyle.None;
					childForm.Left = left;
					childForm.Top = top;
					if (layout == MdiLayout.TileVertical)
					{
						childForm.Width = (clientWidth / maxNumberToLayout);
						childForm.Height = clientHeight;
						left = childForm.Right;
					}
					else if (layout == MdiLayout.TileHorizontal)
					{
						childForm.Width = clientWidth;
						childForm.Height = (clientHeight / maxNumberToLayout);
						top = childForm.Bottom;
					}

					if (0 == (count++ % maxNumberToLayout))
					{
						left = m_policySetExplorer.Right;
						top = ClientRectangle.Top;
					}
				}
			}
		}
Exemplo n.º 17
0
        private void barButtonItemLayout_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            MdiLayout layout = (MdiLayout)Enum.Parse(typeof(MdiLayout), e.Item.Tag.ToString());

            this.LayoutMdi(layout);
        }
Exemplo n.º 18
0
		public void LayoutMdi(MdiLayout value) {
			if (mdi_container != null) {
				mdi_container.LayoutMdi(value);
			}
		}
Exemplo n.º 19
0
        /// <summary>
        /// Dependency property event once the MDI layout value has changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void MdiLayoutValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            MdiContainer mdiContainer = (MdiContainer)sender;
            MdiLayout    value        = (MdiLayout)e.NewValue;

            if (value == MdiLayout.ArrangeIcons ||
                mdiContainer.Children.Count < 1)
            {
                return;
            }

            // 1. WindowState.Maximized -> WindowState.Normal
            List <MdiChild> minimizedWindows = new List <MdiChild>(),
                            normalWindows    = new List <MdiChild>();

            foreach (MdiChild mdiChild in mdiContainer.Children)
            {
                switch (mdiChild.WindowState)
                {
                case WindowState.Minimized:
                    minimizedWindows.Add(mdiChild);
                    break;

                case WindowState.Maximized:
                    mdiChild.WindowState = WindowState.Normal;
                    normalWindows.Add(mdiChild);
                    break;

                default:
                    normalWindows.Add(mdiChild);
                    break;
                }
            }

            minimizedWindows.Sort(new MdiChildComparer());
            normalWindows.Sort(new MdiChildComparer());

            // 2. Arrange minimized windows
            double containerHeight = mdiContainer.InnerHeight;

            for (int i = 0; i < minimizedWindows.Count; i++)
            {
                MdiChild mdiChild = minimizedWindows[i];
                int      capacity = Convert.ToInt32(mdiContainer.ActualWidth) / MdiChild.MinimizedWidth,
                         row      = i / capacity + 1,
                         col      = i % capacity;
                containerHeight = mdiContainer.InnerHeight - MdiChild.MinimizedHeight * row;
                double newLeft = MdiChild.MinimizedWidth * col;
                mdiChild.Position = new Point(newLeft, containerHeight);
            }

            // 3. Resize & arrange normal windows
            switch (value)
            {
            case MdiLayout.Cascade: {
                double newWidth     = mdiContainer.ActualWidth * 0.58,     // should be non-linear formula here
                       newHeight    = containerHeight * 0.67,
                       windowOffset = 0;
                foreach (MdiChild mdiChild in normalWindows)
                {
                    if (mdiChild.Resizable)
                    {
                        mdiChild.Width  = newWidth;
                        mdiChild.Height = newHeight;
                    }
                    mdiChild.Position = new Point(windowOffset, windowOffset);

                    windowOffset += WindowOffset;
                    if (windowOffset + mdiChild.Width > mdiContainer.ActualWidth)
                    {
                        windowOffset = 0;
                    }
                    if (windowOffset + mdiChild.Height > containerHeight)
                    {
                        windowOffset = 0;
                    }
                }
            }
            break;

            case MdiLayout.TileHorizontal: {
                int cols = (int)Math.Sqrt(normalWindows.Count),
                    rows = normalWindows.Count / cols;

                List <int> col_count = new List <int>();       // windows per column
                for (int i = 0; i < cols; i++)
                {
                    if (normalWindows.Count % cols > cols - i - 1)
                    {
                        col_count.Add(rows + 1);
                    }
                    else
                    {
                        col_count.Add(rows);
                    }
                }

                double newWidth   = mdiContainer.ActualWidth / cols,
                       newHeight  = containerHeight / col_count[0],
                       offsetTop  = 0,
                       offsetLeft = 0;

                for (int i = 0, col_index = 0, prev_count = 0; i < normalWindows.Count; i++)
                {
                    if (i >= prev_count + col_count[col_index])
                    {
                        prev_count += col_count[col_index++];
                        offsetLeft += newWidth;
                        offsetTop   = 0;
                        newHeight   = containerHeight / col_count[col_index];
                    }

                    MdiChild mdiChild = normalWindows[i];
                    if (mdiChild.Resizable)
                    {
                        mdiChild.Width  = newWidth;
                        mdiChild.Height = newHeight;
                    }
                    mdiChild.Position = new Point(offsetLeft, offsetTop);
                    offsetTop        += newHeight;
                }
            }
            break;

            case MdiLayout.TileVertical: {
                int rows = (int)Math.Sqrt(normalWindows.Count),
                    cols = normalWindows.Count / rows;

                List <int> col_count = new List <int>();       // windows per column
                for (int i = 0; i < cols; i++)
                {
                    if (normalWindows.Count % cols > cols - i - 1)
                    {
                        col_count.Add(rows + 1);
                    }
                    else
                    {
                        col_count.Add(rows);
                    }
                }

                double newWidth   = mdiContainer.ActualWidth / cols,
                       newHeight  = containerHeight / col_count[0],
                       offsetTop  = 0,
                       offsetLeft = 0;

                for (int i = 0, col_index = 0, prev_count = 0; i < normalWindows.Count; i++)
                {
                    if (i >= prev_count + col_count[col_index])
                    {
                        prev_count += col_count[col_index++];
                        offsetLeft += newWidth;
                        offsetTop   = 0;
                        newHeight   = containerHeight / col_count[col_index];
                    }

                    MdiChild mdiChild = normalWindows[i];
                    if (mdiChild.Resizable)
                    {
                        mdiChild.Width  = newWidth;
                        mdiChild.Height = newHeight;
                    }
                    mdiChild.Position = new Point(offsetLeft, offsetTop);
                    offsetTop        += newHeight;
                }
            }
            break;
            }
            mdiContainer.InvalidateSize();
            mdiContainer.MdiLayout = MdiLayout.ArrangeIcons;
        }
	// Methods
	public void LayoutMdi(MdiLayout value) {}
Exemplo n.º 21
0
 private void toolStripLabel1_Click(object sender, EventArgs e)
 {
     this.LayoutMdi(MdiLayout.TileHorizontal);
     current_layout = MdiLayout.TileHorizontal;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Layouts the MDI.
 /// </summary>
 /// <param name="layout">The layout.</param>
 private void LayoutMdi(MdiLayout layout)
 {
     SetLayoutMode(WindowLayoutMode.Windowed);
     MdiManager.MdiParent = null;
     Shell.LayoutMdi(layout);
 }
Exemplo n.º 23
0
 public static void LayoutMdi(this UpgradeHelpers.Interfaces.ILogicView <UpgradeHelpers.Interfaces.IViewModel> _Form, MdiLayout value)
 {
     throw new NotImplementedException("This is an automatic generated code, please implement the requested logic.");
 }
Exemplo n.º 24
0
 /// <summary>
 /// Set's Layout of Mdi Mode
 /// </summary>
 /// <param name="layout">one of the values of <see cref="MdiLayout"/> enum</param>
 public void LayoutMdi(MdiLayout layout)
 {
     SetMdiMode(MdiMode.Windowed);
     TabbedMdiManager.MdiParent = null;
     parentMdiForm.LayoutMdi(layout);
 }
Exemplo n.º 25
0
        private void LayoutChildren(MdiLayout layout)
        {
            var children = MdiChildren.Where(c => c.Visible).ToList();

            if (children.Count == 0)
            {
                return;
            }

            // размеры окна
            var mdiSize = GetMdiClientWindow().ClientSize;

            if (mdiSize.Height < 40)
            {
                mdiSize = new Size(mdiSize.Width, 40);
            }
            if (mdiSize.Width < 65)
            {
                mdiSize = new Size(65, mdiSize.Height);
            }

            var       capH = SystemInformation.CaptionHeight;
            const int capW = 60;

            // одно окошко развернуть во всю ширину
            if (children.Count == 1)
            {
                children[0].WindowState = FormWindowState.Normal;
                children[0].Location    = new Point(0, 0);
                children[0].Size        = mdiSize;
                return;
            }

            // упорядочить каскадом
            if (layout == MdiLayout.Cascade)
            {
                const int maxInRow = 6;

                var delta   = capH * Math.Min(maxInRow - 1, children.Count - 1);
                var wSize   = new Size(mdiSize.Width - delta, mdiSize.Height - delta);
                var leftTop = new Point(0, 0);
                var counter = 0;
                foreach (var window in children)
                {
                    window.WindowState = FormWindowState.Normal;
                    window.Location    = leftTop;
                    window.Size        = wSize;
                    leftTop            = new Point(leftTop.X + capH, leftTop.Y + capH);
                    counter++;
                    if (counter == maxInRow)
                    {
                        leftTop = new Point(0, 0);
                    }
                }
                return;
            }

            // дать окошкам больше места
            if (mdiSize.Height < 90)
            {
                mdiSize = new Size(mdiSize.Width, 90);
            }
            if (mdiSize.Width < 120)
            {
                mdiSize = new Size(120, mdiSize.Height);
            }

            // выстроить окошки в линию по вертикали или по горизонтали
            if (children.Count < 4)
            {
                var w       = layout == MdiLayout.TileHorizontal ? mdiSize.Width / children.Count : mdiSize.Width;
                var h       = layout == MdiLayout.TileVertical ? mdiSize.Height / children.Count : mdiSize.Height;
                var wSize   = new Size(w, h);
                var stepX   = layout == MdiLayout.TileHorizontal ? w : 0;
                var stepY   = layout == MdiLayout.TileVertical ? h : 0;
                var leftTop = new Point(0, 0);
                foreach (var window in children)
                {
                    window.WindowState = FormWindowState.Normal;
                    window.Location    = leftTop;
                    window.Size        = wSize;
                    leftTop            = new Point(leftTop.X + stepX, leftTop.Y + stepY);
                }
                return;
            }

            // дать окошкам еще больше места и расположить в виде таблицы
            if (mdiSize.Height < 120)
            {
                mdiSize = new Size(mdiSize.Width, 120);
            }
            if (mdiSize.Width < 160)
            {
                mdiSize = new Size(160, mdiSize.Height);
            }

            // посчитать количество строк и столбцов
            var rows = (int)Math.Sqrt(children.Count);
            var cols = children.Count / rows;
            var mod  = children.Count - cols * rows;

            if (mod > 0)
            {
                cols++;
            }

            // разместить
            var ht         = mdiSize.Height / rows;
            var wd         = mdiSize.Width / cols;
            var size       = new Size(wd, ht);
            var top        = 0;
            var childIndex = 0;

            for (var row = 0; row < rows; row++)
            {
                var left = 0;
                for (var col = 0; col < cols; col++)
                {
                    var child = children[childIndex++];
                    child.WindowState = FormWindowState.Normal;
                    child.Location    = new Point(left, top);
                    child.Size        = size;

                    left += wd;
                }
                top += ht;
                var itemsLeft = children.Count - childIndex;
                if (itemsLeft > 0 && itemsLeft < cols)
                {
                    cols = itemsLeft;
                    wd   = mdiSize.Width / cols;
                    size = new Size(wd, ht);
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Dependency property event once the MDI layout value has changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void MdiLayoutValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            MdiContainer mdiContainer = (MdiContainer)sender;
            MdiLayout    value        = (MdiLayout)e.NewValue;

            if (value == MdiLayout.ArrangeIcons ||
                mdiContainer.Children.Count < 1)
            {
                return;
            }

            // 1. WindowState.Maximized -> WindowState.Normal
            List <MdiChild> minimizedWindows = new List <MdiChild>(),
                            normalWindows    = new List <MdiChild>();

            foreach (MdiChild mdiChild in mdiContainer.Children)
            {
                switch (mdiChild.WindowState)
                {
                case WindowState.Minimized:
                    minimizedWindows.Add(mdiChild);
                    break;

                case WindowState.Maximized:
                    mdiChild.WindowState = WindowState.Normal;
                    normalWindows.Add(mdiChild);
                    break;

                default:
                    normalWindows.Add(mdiChild);
                    break;
                }
            }

            minimizedWindows.Sort(new MdiChildComparer());
            normalWindows.Sort(new MdiChildComparer());

            // 2. Arrange minimized windows
            double containerHeight = mdiContainer.InnerHeight;

            for (int i = 0; i < minimizedWindows.Count; i++)
            {
                MdiChild mdiChild = minimizedWindows[i];
                int      capacity = Convert.ToInt32(mdiContainer.InnerWidth) / mdiChild.MinimizedWidth,
                         row      = i / capacity + 1,
                         col      = i % capacity;
                containerHeight = mdiContainer.InnerHeight - mdiChild.MinimizedHeight * row;
                double newLeft = mdiChild.MinimizedWidth * col;
                mdiChild.Position = new Point(newLeft, containerHeight);
            }

            // 3. Resize & arrange normal windows
            switch (value)
            {
            case MdiLayout.Cascade:
            {
                double newWidth     = mdiContainer.InnerWidth * 0.58,                             // should be non-linear formula here
                       newHeight    = containerHeight * 0.67,
                       windowOffset = 0;
                foreach (MdiChild mdiChild in normalWindows)
                {
                    if (mdiChild.Resizable)
                    {
                        mdiChild.Width  = newWidth;
                        mdiChild.Height = newHeight;
                    }
                    mdiChild.Position = new Point(windowOffset, windowOffset);

                    windowOffset += WindowOffset;
                    if (windowOffset + mdiChild.Width > mdiContainer.InnerWidth)
                    {
                        windowOffset = 0;
                    }
                    if (windowOffset + mdiChild.Height > containerHeight)
                    {
                        windowOffset = 0;
                    }
                }
            }
            break;

            case MdiLayout.TileHorizontal:
            {
                var _h = mdiContainer.MinimizedAreaHeight;

                int cols = Math.Max((int)Math.Sqrt(normalWindows.Count), 1);
                int rows = normalWindows.Count / cols;

                rows = Math.Min(rows, mdiContainer.MdiLayoutMaxRow);
                cols = (int)Math.Ceiling((double)normalWindows.Count / (double)rows);

                double w = Math.Max(mdiContainer.InnerWidth / cols, 0);
                double h = Math.Max((mdiContainer.InnerHeight - _h) / rows, 0);

                int count = 0;
                foreach (var item in normalWindows)
                {
                    item.Position = new Point((int)(count % cols) * w, (int)(count / cols) * h);
                    if (w == 0 && h == 0)
                    {
                        item.Width  = item.MinimizedWidth;
                        item.Height = item.MinimizedHeight;
                    }
                    else
                    {
                        item.Width  = w;
                        item.Height = h;
                    }
                    count++;
                }
            }
            break;

            case MdiLayout.TileVertical:
            {
                var _h = mdiContainer.MinimizedAreaHeight;

                int rows = Math.Max((int)Math.Sqrt(normalWindows.Count), 1);
                int cols = normalWindows.Count / rows;

                cols = Math.Min(cols, mdiContainer.MdiLayoutMaxCol);
                rows = (int)Math.Ceiling((double)normalWindows.Count / (double)cols);

                double w = Math.Max(mdiContainer.InnerWidth / cols, 0);
                double h = Math.Max((mdiContainer.InnerHeight - _h) / rows, 0);

                int count = 0;
                foreach (var item in normalWindows)
                {
                    item.Position = new Point((int)(count % cols) * w, (int)(count / cols) * h);
                    if (w == 0 && h == 0)
                    {
                        item.Width  = item.MinimizedWidth;
                        item.Height = item.MinimizedHeight;
                    }
                    else
                    {
                        item.Width  = w;
                        item.Height = h;
                    }
                    count++;
                }
            }
            break;
            }
            mdiContainer.InvalidateSize();
            mdiContainer.MdiLayout = MdiLayout.ArrangeIcons;
        }
Exemplo n.º 27
0
        /// <include file='doc\MDIClient.uex' path='docs/doc[@for="MdiClient.LayoutMdi"]/*' />
        /// <devdoc>
        ///     Arranges the MDI child forms according to value, which should be a
        ///     member of the MdiLayout enum.
        /// </devdoc>
        public void LayoutMdi(MdiLayout value) {
            if (Handle == IntPtr.Zero)
                return;

            switch (value) {
                case MdiLayout.Cascade:
                    SendMessage(NativeMethods.WM_MDICASCADE, 0, 0);
                    break;
                case MdiLayout.TileVertical:
                    SendMessage(NativeMethods.WM_MDITILE, NativeMethods.MDITILE_VERTICAL, 0);
                    break;
                case MdiLayout.TileHorizontal:
                    SendMessage(NativeMethods.WM_MDITILE, NativeMethods.MDITILE_HORIZONTAL, 0);
                    break;
                case MdiLayout.ArrangeIcons:
                    SendMessage(NativeMethods.WM_MDIICONARRANGE, 0, 0);
                    break;
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Dependency property event once the MDI layout value has changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static object MdiLayoutValueChanged(DependencyObject sender, object baseValue)
        {
            MdiContainer mdiContainer = (MdiContainer)sender;
            MdiLayout    value        = (MdiLayout)baseValue;

            if (value == MdiLayout.ArrangeIcons || mdiContainer.Children.Count < 1)
            {
                return(value);
            }

            // 1. WindowState.Maximized -> WindowState.Normal
            List <MdiChild> minimizedWindows = new List <MdiChild>(),
                            normalWindows    = new List <MdiChild>();

            foreach (MdiChild mdiChild in mdiContainer.Children)
            {
                switch (mdiChild.WindowState)
                {
                case WindowState.Minimized:
                    minimizedWindows.Add(mdiChild);
                    break;

                case WindowState.Maximized:
                    mdiChild.WindowState = WindowState.Normal;
                    normalWindows.Add(mdiChild);
                    break;

                default:
                    normalWindows.Add(mdiChild);
                    break;
                }
            }

            minimizedWindows.Sort(new MdiChildComparer());
            normalWindows.Sort(new MdiChildComparer());

            // 2. Arrange minimized windows
            double containerHeight = mdiContainer.InnerHeight;

            for (int i = 0; i < minimizedWindows.Count; i++)
            {
                MdiChild mdiChild = minimizedWindows[i];
                int      capacity = Convert.ToInt32(mdiContainer.ActualWidth) / MdiChild.MinimizedWidth,
                         row      = i / capacity + 1,
                         col      = i % capacity;
                containerHeight = mdiContainer.InnerHeight - MdiChild.MinimizedHeight * row;
                double newLeft = MdiChild.MinimizedWidth * col;
                mdiChild.Position = new Point(newLeft, containerHeight);
                if (normalWindows.Count == 0)
                {
                    return(value);
                }
            }

            // 3. Resize & arrange normal windows
            switch (value)
            {
            case MdiLayout.Cascade:
            {
                double newWidth            = mdiContainer.ActualWidth - (mdiContainer.ActualWidth * 0.20); //Width - 20%
                double newHeight           = containerHeight - (containerHeight * 0.30);                   //Height - 30%
                double CurrentWindowOffset = 0;

                foreach (MdiChild mdiChild in normalWindows)
                {
                    if (mdiChild.Resizable)
                    {
                        mdiChild.Width  = newWidth;
                        mdiChild.Height = newHeight;
                    }
                    mdiChild.Position = new Point(CurrentWindowOffset, CurrentWindowOffset);

                    CurrentWindowOffset += WindowOffset;
                    if (CurrentWindowOffset + mdiChild.Width > mdiContainer.ActualWidth)
                    {
                        CurrentWindowOffset = 0;
                    }

                    if (CurrentWindowOffset + mdiChild.Height > containerHeight)
                    {
                        CurrentWindowOffset = 0;
                    }
                }
            }
            break;

            case MdiLayout.TileHorizontal:
            {
                double cols = (int)Math.Sqrt(normalWindows.Count),
                       rows = normalWindows.Count / cols;

                List <double> col_count = new List <double>();       // windows per column
                for (int i = 0; i < cols; i++)
                {
                    if (normalWindows.Count % cols > cols - i - 1)
                    {
                        col_count.Add(rows + 1);
                    }
                    else
                    {
                        col_count.Add(rows);
                    }
                }

                double newWidth   = mdiContainer.ActualWidth / cols,
                       newHeight  = containerHeight / col_count[0],
                       offsetTop  = 0,
                       offsetLeft = 0;
                double prev_count = 0;
                for (int i = 0, col_index = 0; i < normalWindows.Count; i++)
                {
                    if (i >= prev_count + col_count[col_index])
                    {
                        prev_count += col_count[col_index++];
                        offsetLeft += newWidth;
                        offsetTop   = 0;
                        newHeight   = containerHeight / col_count[col_index];
                    }

                    MdiChild mdiChild = normalWindows[i];
                    if (mdiChild.Resizable)
                    {
                        mdiChild.Width  = newWidth;
                        mdiChild.Height = newHeight;
                    }
                    mdiChild.Position = new Point(offsetLeft, offsetTop);
                    offsetTop        += newHeight;
                }
            }
            break;

            case MdiLayout.TileVertical:
            {
                double rows = Math.Sqrt(normalWindows.Count),
                       cols = normalWindows.Count / rows;

                List <double> col_count = new List <double>();       // windows per column
                for (int i = 0; i < cols; i++)
                {
                    if (normalWindows.Count % cols > cols - i - 1)
                    {
                        col_count.Add(rows + 1);
                    }
                    else
                    {
                        col_count.Add(rows);
                    }
                }

                double newWidth   = mdiContainer.ActualWidth / cols,
                       newHeight  = containerHeight / col_count[0],
                       offsetTop  = 0,
                       offsetLeft = 0;
                double prev_count = 0;
                for (int i = 0, col_index = 0; i < normalWindows.Count; i++)
                {
                    if (i >= prev_count + col_count[col_index])
                    {
                        prev_count += col_count[col_index++];
                        offsetLeft += newWidth;
                        offsetTop   = 0;
                        newHeight   = containerHeight / col_count[col_index];
                    }

                    MdiChild mdiChild = normalWindows[i];
                    if (mdiChild.Resizable)
                    {
                        mdiChild.Width  = newWidth;
                        mdiChild.Height = newHeight;
                    }
                    mdiChild.Position = new Point(offsetLeft, offsetTop);
                    offsetTop        += newHeight;
                }
            }
            break;
            }
            mdiContainer.UpdateScrollInfo();
            return(value);
        }
 public void LayoutMdi(MdiLayout value)
 {
 }
 public void LayoutMdi(MdiLayout value)
 {
     if (this.ctlClient != null)
     {
         this.ctlClient.LayoutMdi(value);
     }
 }
Exemplo n.º 31
0
 public void LayoutMdi(MdiLayout value)
 {
     throw null;
 }
Exemplo n.º 32
0
Arquivo: Form.cs Projeto: mind0n/hive
 /// <include file='doc\Form.uex' path='docs/doc[@for="Form.LayoutMdi"]/*' />
 /// <devdoc>
 ///    <para> Arranges the Multiple Document Interface
 ///       (MDI) child forms according to value.</para>
 /// </devdoc>
 public void LayoutMdi(MdiLayout value) {
     if (ctlClient == null){
         return;
     }
     ctlClient.LayoutMdi(value);
 }
Exemplo n.º 33
0
        private void LayoutChildren(MdiLayout layout)
        {
            var children = MdiChildren.Where(c => c.Visible).ToList();
            if (children.Count == 0) return;

            // размеры окна
            var mdiSize = GetMdiClientWindow().ClientSize;
            if (mdiSize.Height < 40)
                mdiSize = new Size(mdiSize.Width, 40);
            if (mdiSize.Width < 65)
                mdiSize = new Size(65, mdiSize.Height);

            var capH = SystemInformation.CaptionHeight;
            const int capW = 60;

            // одно окошко развернуть во всю ширину
            if (children.Count == 1)
            {
                children[0].WindowState = FormWindowState.Normal;
                children[0].Location = new Point(0, 0);
                children[0].Size = mdiSize;
                return;
            }

            // упорядочить каскадом
            if (layout == MdiLayout.Cascade)
            {
                const int maxInRow = 6;

                var delta = capH * Math.Min(maxInRow - 1, children.Count - 1);
                var wSize = new Size(mdiSize.Width - delta, mdiSize.Height - delta);
                var leftTop = new Point(0, 0);
                var counter = 0;
                foreach (var window in children)
                {
                    window.WindowState = FormWindowState.Normal;
                    window.Location = leftTop;
                    window.Size = wSize;
                    leftTop = new Point(leftTop.X + capH, leftTop.Y + capH);
                    counter++;
                    if (counter == maxInRow)
                        leftTop = new Point(0, 0);
                }
                return;
            }

            // дать окошкам больше места
            if (mdiSize.Height < 90)
                mdiSize = new Size(mdiSize.Width, 90);
            if (mdiSize.Width < 120)
                mdiSize = new Size(120, mdiSize.Height);

            // выстроить окошки в линию по вертикали или по горизонтали
            if (children.Count < 4)
            {
                var w = layout == MdiLayout.TileHorizontal ? mdiSize.Width / children.Count : mdiSize.Width;
                var h = layout == MdiLayout.TileVertical ? mdiSize.Height / children.Count : mdiSize.Height;
                var wSize = new Size(w, h);
                var stepX = layout == MdiLayout.TileHorizontal ? w : 0;
                var stepY = layout == MdiLayout.TileVertical ? h : 0;
                var leftTop = new Point(0, 0);
                foreach (var window in children)
                {
                    window.WindowState = FormWindowState.Normal;
                    window.Location = leftTop;
                    window.Size = wSize;
                    leftTop = new Point(leftTop.X + stepX, leftTop.Y + stepY);
                }
                return;
            }

            // дать окошкам еще больше места и расположить в виде таблицы
            if (mdiSize.Height < 120)
                mdiSize = new Size(mdiSize.Width, 120);
            if (mdiSize.Width < 160)
                mdiSize = new Size(160, mdiSize.Height);

            // посчитать количество строк и столбцов
            var rows = (int) Math.Sqrt(children.Count);
            var cols = children.Count / rows;
            var mod = children.Count - cols * rows;
            if (mod > 0) cols++;

            // разместить
            var ht = mdiSize.Height/rows;
            var wd = mdiSize.Width/cols;
            var size = new Size(wd, ht);
            var top = 0;
            var childIndex = 0;

            for (var row = 0; row < rows; row++)
            {
                var left = 0;
                for (var col = 0; col < cols; col++)
                {
                    var child = children[childIndex++];
                    child.WindowState = FormWindowState.Normal;
                    child.Location = new Point(left, top);
                    child.Size = size;

                    left += wd;
                }
                top += ht;
                var itemsLeft = children.Count - childIndex;
                if (itemsLeft > 0 && itemsLeft < cols)
                {
                    cols = itemsLeft;
                    wd = mdiSize.Width / cols;
                    size = new Size(wd, ht);
                }
            }
        }
Exemplo n.º 34
0
 public history_data_series()
 {
     InitializeComponent();
     this.IsMdiContainer = true;
     current_layout      = MdiLayout.TileHorizontal;
 }
 private void SetLayout(MdiLayout value)
 {
     layout = value;
     ForceLayout();
 }
Exemplo n.º 36
0
        public void LayoutMdi(MdiLayout value)
        {
            // Don't forget to always call ArrangeIconicWindows
            ArrangeIconicWindows(true);

            switch (value)
            {
            case MdiLayout.Cascade: {
                int i = 0;
                for (int c = Controls.Count - 1; c >= 0; c--)
                {
                    Form form = (Form)Controls [c];

                    if (form.WindowState == FormWindowState.Minimized)
                    {
                        continue;
                    }

                    if (form.WindowState == FormWindowState.Maximized)
                    {
                        form.WindowState = FormWindowState.Normal;
                    }

                    form.Width  = System.Convert.ToInt32(ClientSize.Width * 0.8);
                    form.Height = Math.Max(
                        System.Convert.ToInt32(ClientSize.Height * 0.8),
                        SystemInformation.MinimumWindowSize.Height + 2);

                    int l = 22 * i;
                    int t = 22 * i;

                    if (i != 0 && (l + form.Width > ClientSize.Width || t + form.Height > ClientSize.Height))
                    {
                        i = 0;
                        l = 22 * i;
                        t = 22 * i;
                    }

                    form.Left = l;
                    form.Top  = t;

                    i++;
                }
                break;
            }

            case MdiLayout.TileHorizontal:
            case MdiLayout.TileVertical: {
                // First count number of windows to tile
                int total = 0;

                // And space used by iconic windows
                int clientHeight = ClientSize.Height;

                for (int i = 0; i < Controls.Count; i++)
                {
                    Form form = Controls [i] as Form;

                    if (form == null)
                    {
                        continue;
                    }

                    if (!form.Visible)
                    {
                        continue;
                    }

                    if (form.WindowState == FormWindowState.Maximized)
                    {
                        form.WindowState = FormWindowState.Normal;
                    }
                    else if (form.WindowState == FormWindowState.Minimized)
                    {
                        if (form.Bounds.Top < clientHeight)
                        {
                            clientHeight = form.Bounds.Top;
                        }
                        continue;
                    }

                    total++;
                }
                if (total <= 0)
                {
                    return;
                }

                // Calculate desired height and width
                Size newSize;
                Size offset;

                if (value == MdiLayout.TileHorizontal)
                {
                    newSize = new Size(ClientSize.Width, clientHeight / total);
                    offset  = new Size(0, newSize.Height);
                }
                else
                {
                    newSize = new Size(ClientSize.Width / total, clientHeight);
                    offset  = new Size(newSize.Width, 0);
                }

                // Loop again and set the size and location.
                Point nextLocation = Point.Empty;

                for (int i = 0; i < Controls.Count; i++)
                {
                    Form form = Controls [i] as Form;

                    if (form == null)
                    {
                        continue;
                    }

                    if (!form.Visible)
                    {
                        continue;
                    }

                    if (form.WindowState == FormWindowState.Minimized)
                    {
                        continue;
                    }

                    form.Size     = newSize;
                    form.Location = nextLocation;
                    nextLocation += offset;
                }

                break;
            }
            }
        }
Exemplo n.º 37
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     this.LayoutMdi(MdiLayout.TileVertical);
     current_layout = MdiLayout.TileVertical;
 }
Exemplo n.º 38
0
	// Layout the MDI children of this form.
	public void LayoutMdi(MdiLayout value)
			{
				if(mdiClient != null)
				{
					mdiClient.LayoutMdi(value);
				}
			}
Exemplo n.º 39
0
		public void LayoutMdi (MdiLayout value) {

			// Don't forget to always call ArrangeIconicWindows 
			ArrangeIconicWindows (true);

			switch (value) {
			case MdiLayout.Cascade: {
				int i = 0;
				for (int c = Controls.Count - 1; c >= 0; c--) {
					Form form = (Form) Controls [c];

					if (form.WindowState == FormWindowState.Minimized)
						continue;

					if (form.WindowState == FormWindowState.Maximized)
						form.WindowState = FormWindowState.Normal;

					form.Width = System.Convert.ToInt32 (ClientSize.Width * 0.8);
					form.Height = Math.Max (
								System.Convert.ToInt32 (ClientSize.Height * 0.8),
								SystemInformation.MinimumWindowSize.Height + 2);

					int l = 22 * i;
					int t = 22 * i;

					if (i != 0 && (l + form.Width > ClientSize.Width || t + form.Height > ClientSize.Height)) {
						i = 0;
						l = 22 * i;
						t = 22 * i;
					}

					form.Left = l;
					form.Top = t;

					i++;
				}
				break;
				}
			case MdiLayout.TileHorizontal:
			case MdiLayout.TileVertical: {
				// First count number of windows to tile
				int total = 0;
				
				// And space used by iconic windows
				int clientHeight = ClientSize.Height;
				
				for (int i = 0; i < Controls.Count; i++) {
					Form form = Controls [i] as Form;
					
					if (form == null)
						continue;
					
					if (!form.Visible)
						continue;

					if (form.WindowState == FormWindowState.Maximized)
						form.WindowState = FormWindowState.Normal;
					else if (form.WindowState == FormWindowState.Minimized) {
						if (form.Bounds.Top < clientHeight)
							clientHeight = form.Bounds.Top;
						continue;
					}
						
					total++;
				}
				if (total <= 0)
					return;

				// Calculate desired height and width
				Size newSize;
				Size offset;

				if (value == MdiLayout.TileHorizontal) {
					newSize = new Size(ClientSize.Width, clientHeight / total);
					offset = new Size (0, newSize.Height);
				} else {
					newSize = new Size(ClientSize.Width / total, clientHeight);
					offset = new Size (newSize.Width, 0);
				}
				
				// Loop again and set the size and location.
				Point nextLocation = Point.Empty;
				
				for (int i = 0; i < Controls.Count; i++) {
					Form form = Controls [i] as Form;

					if (form == null)
						continue;

					if (!form.Visible)
						continue;

					if (form.WindowState == FormWindowState.Minimized)
						continue;

					form.Size = newSize;
					form.Location = nextLocation;
					nextLocation += offset;
				}
				
				break;
				}
			}
		}
Exemplo n.º 40
0
 /// <summary>
 /// Layouts the MDI.
 /// </summary>
 /// <param name="layout">The layout.</param>
 private void LayoutMdi(MdiLayout layout)
 {
     SetLayoutMode(WindowLayoutMode.Windowed);
     MdiManager.MdiParent = null;
     Shell.LayoutMdi(layout);
 }
Exemplo n.º 41
0
		private void DoCustomLayout(MdiLayout layout)
		{
			int policySetExplorerWidth = m_policySetExplorer.Width;

			DisableChildDocking();

			m_policySetExplorer.Width = policySetExplorerWidth;
			m_policySetExplorer.Dock = DockStyle.Left;

			switch (layout)
			{
				case MdiLayout.Cascade:
					DoCustomCascade();
					break;
				case MdiLayout.TileHorizontal:
				case MdiLayout.TileVertical:
					AlignMdiChildWindows(layout);
					break;
				default:
					LayoutMdi(layout);
					break;
			}
		}