예제 #1
0
        public override void RunLayout(MDIContainer container)
        {
            if (container == null)
            {
                return;
            }

            if (!container.Items.Children.Any())
            {
                return;
            }

            var items           = container.Items.Children;
            var containerWidth  = container.ActualWidth;
            var containerHeight = container.ActualHeight;

            var itemWidth  = containerWidth / (double)items.Count;
            var itemHeight = containerHeight;

            for (var i = 0; i < items.Count; i++)
            {
                var item = (MDIChild)items[i];
                Canvas.SetLeft(item, i * itemWidth);
                Canvas.SetTop(item, 0);

                item.Width  = itemWidth;
                item.Height = itemHeight;
            }
        }
예제 #2
0
        public override void RunLayout(MDIContainer container)
        {
            if (container == null)
            {
                return;
            }

            if (!container.Items.Children.Any())
            {
                return;
            }

            var      items    = container.Items.Children;
            MDIChild lastItem = null;

            for (var i = 0; i < items.Count; i++)
            {
                var item = (MDIChild)items[i];
                Canvas.SetLeft(item, i * 30);
                Canvas.SetTop(item, i * 30);

                if (Resize && item.FormBorderStyle != FormBorderStyle.Fixed)
                {
                    item.Width  = container.DefaultChildWidth;
                    item.Height = container.DefaultChildHeight;
                }

                lastItem = item;
            }

            lastItem?.Activate();
        }
예제 #3
0
        public void Minimize(MDIContainer mdiContainer)
        {
            SetState(FormWindowState.Minimized);
            _previousSize     = new Size(ActualWidth, ActualHeight);
            _previousLocation = new Point(Canvas.GetLeft(this), Canvas.GetTop(this));

            Deactivate();
            VisualStateManager.GoToState(this, "Minimized", false);

            Width  = 230; // TODO Move to visual state
            Height = 48;
        }
예제 #4
0
        private static void HandleStartPosition(Control control, MDIChild child, MDIContainer mdiContainer)
        {
            double startLeft;
            double startTop;

            var startPosition = FormStartPosition.WindowsDefaultLocation;
            var apStart       = control.GetValue(FormProperties.FormStartPositionProperty);

            if (apStart != null)
            {
                startPosition = (FormStartPosition)apStart;
            }

            if (startPosition == FormStartPosition.CenterParent)
            {
                var screenWidth  = mdiContainer.ActualWidth;
                var screenHeight = mdiContainer.ActualHeight;
                var windowWidth  = child.Width;
                var windowHeight = child.Height;
                startLeft = screenWidth / 2 - windowWidth / 2;
                startTop  = screenHeight / 2 - windowHeight / 2;
            }
            else if (startPosition == FormStartPosition.CenterScreen)
            {
                var displaySize = Helpers.GetCurrentDisplaySize();

                var screenWidth  = displaySize.Width;
                var screenHeight = displaySize.Height;
                var windowWidth  = child.Width;
                var windowHeight = child.Height;
                startLeft = screenWidth / 2 - windowWidth / 2;
                startTop  = screenHeight / 2 - windowHeight / 2;
            }
            else
            {
                var screenWidth  = mdiContainer.ActualWidth;
                var screenHeight = mdiContainer.ActualHeight;
                var windowWidth  = child.Width;
                var windowHeight = child.Height;
                var maxLeft      = screenWidth / 2 - windowWidth / 2;
                var maxTop       = screenHeight / 2 - windowHeight / 2;

                var rnd = new Random();
                startLeft = rnd.Next(0, (int)maxLeft);
                startTop  = rnd.Next(0, (int)maxTop);
            }

            Canvas.SetLeft(child, startLeft);
            Canvas.SetTop(child, startTop);
        }
예제 #5
0
 private static void ConfigureMdiControl(Control control, MDIChild child, MDIContainer mdiContainer)
 {
     HandleStartPosition(control, child, mdiContainer);
 }