Beispiel #1
0
 public override void Resize(NSSplitView splitView, System.Drawing.SizeF oldSize)
 {
     SplitterHandler.ResizeSubviews(Handler, oldSize);
 }
Beispiel #2
0
        static void ResizeSubviews(SplitterHandler handler, System.Drawing.SizeF oldSize)
        {
            var splitView        = handler.Control;
            var dividerThickness = splitView.DividerThickness;
            var panel1Rect       = splitView.Subviews [0].Frame;
            var panel2Rect       = splitView.Subviews [1].Frame;
            var newFrame         = splitView.Frame;

            if (oldSize.IsEmpty)
            {
                oldSize = newFrame.Size;
            }

            if (splitView.IsVertical)
            {
                panel2Rect.Height   = panel1Rect.Height = newFrame.Height;
                panel1Rect.Location = new System.Drawing.PointF(0, 0);
                if (handler.position == null)
                {
                    panel1Rect.Width = newFrame.Width / 2;
                    panel2Rect.Width = Math.Max(0, newFrame.Width - panel1Rect.Width - dividerThickness);
                }
                else
                {
                    var pos = handler.position.Value;
                    switch (handler.fixedPanel)
                    {
                    case SplitterFixedPanel.Panel1:
                        panel1Rect.Width = Math.Max(0, Math.Min(newFrame.Width - dividerThickness, pos));
                        panel2Rect.Width = newFrame.Width - panel1Rect.Width - dividerThickness;
                        break;

                    case SplitterFixedPanel.Panel2:
                        panel2Rect.Width = Math.Max(0, Math.Min(newFrame.Width - dividerThickness, oldSize.Width - pos - dividerThickness));
                        panel1Rect.Width = newFrame.Width - panel2Rect.Width - dividerThickness;
                        break;

                    case SplitterFixedPanel.None:
                        var oldscale = newFrame.Width / oldSize.Width;
                        panel1Rect.Width = Math.Max(0, Math.Min(newFrame.Width - dividerThickness, pos * oldscale));
                        panel2Rect.Width = newFrame.Width - panel1Rect.Width - dividerThickness;
                        break;
                    }
                }
                panel2Rect.X = panel1Rect.Width + dividerThickness;
            }
            else
            {
                panel2Rect.X        = 0;
                panel2Rect.Width    = panel1Rect.Width = newFrame.Width;
                panel1Rect.Location = new System.Drawing.PointF(0, 0);
                if (handler.position == null)
                {
                    panel1Rect.Height = newFrame.Height / 2;
                    panel2Rect.Height = Math.Max(0, newFrame.Height - panel1Rect.Height - dividerThickness);
                }
                else
                {
                    var pos = handler.position.Value;
                    switch (handler.fixedPanel)
                    {
                    case SplitterFixedPanel.Panel1:
                        panel1Rect.Height = Math.Max(0, Math.Min(newFrame.Height - dividerThickness, pos));
                        panel2Rect.Height = newFrame.Height - panel1Rect.Height - dividerThickness;
                        break;

                    case SplitterFixedPanel.Panel2:
                        panel2Rect.Height = Math.Max(0, Math.Min(newFrame.Height - dividerThickness, oldSize.Height - pos - dividerThickness));
                        panel1Rect.Height = newFrame.Height - panel2Rect.Height - dividerThickness;
                        break;

                    case SplitterFixedPanel.None:
                        var oldscale = newFrame.Height / oldSize.Height;
                        panel1Rect.Height = Math.Max(0, Math.Min(newFrame.Height - dividerThickness, pos * oldscale));
                        panel2Rect.Height = newFrame.Height - panel1Rect.Height - dividerThickness;
                        break;
                    }
                }
                panel2Rect.Y = panel1Rect.Height + dividerThickness;
            }

            splitView.Subviews [0].Frame = panel1Rect;
            splitView.Subviews [1].Frame = panel2Rect;
        }
Beispiel #3
0
 public override void Resize(NSSplitView splitView, sd.SizeF oldSize)
 {
     SplitterHandler.ResizeSubviews(Handler, oldSize);
 }