Example #1
0
        internal void InvalidatePanel(FlowPanel panel, Rectangle rect)
        {
            Verify.Argument.IsNotNull(panel, nameof(panel));
            Verify.Argument.IsTrue(panel.FlowControl == this, "panel", "Panel is not owned by this FlowLayoutControl.");

            var graphics = GraphicsUtility.MeasurementGraphics;
            int y        = ClientArea.Y - VScrollPos;
            int x        = ClientArea.X - HScrollPos;

            for (int i = 0; i < Panels.Count; ++i)
            {
                var p    = Panels[i];
                var size = GetPanelSize(graphics, p);
                int maxY = y + size.Height;
                if (p == panel)
                {
                    if (maxY >= ClientArea.Y)
                    {
                        var bounds = new Rectangle(x + rect.X, y + rect.Y, rect.Width, rect.Height);
                        var clip   = Rectangle.Intersect(bounds, ClientArea);
                        if (clip.Width > 0 && clip.Height > 0)
                        {
                            Invalidate(clip);
                        }
                    }
                    break;
                }
                if (maxY >= ClientArea.Bottom)
                {
                    break;
                }
                y = maxY;
            }
        }
Example #2
0
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            int x      = e.X;
            int y      = e.Y;
            int panelY = ClientArea.Y - VScrollPos;

            _mouseDownPanel = null;
            bool found = false;

            for (int i = 0; i < Panels.Count; ++i)
            {
                var panel = Panels[i];
                var size  = GetPanelSize(panel);
                int maxY  = panelY + size.Height;
                if (maxY >= y)
                {
                    _mouseDownPanel = panel;
                    _panelHover.Track(i, panel);
                    OnPanelDoubleClick(panel, x - ClientArea.X + HScrollPos, y - panelY, e.Button);
                    found = true;
                    break;
                }
                if (maxY >= ClientRectangle.Bottom)
                {
                    break;
                }
                panelY = maxY;
            }
            if (!found)
            {
                OnFreeSpaceDoubleClick(x, y, e.Button);
            }
            Focus();
            base.OnMouseDoubleClick(e);
        }
Example #3
0
 private Size GetPanelSize(Graphics graphics, FlowPanel panel, int width)
 {
     if (!_sizes.TryGetValue(panel, out var size))
     {
         size = panel.Measure(
             new FlowPanelMeasureEventArgs(graphics, width));
         _sizes.Add(panel, size);
     }
     return(size);
 }
Example #4
0
 private Size GetPanelSize(FlowPanel panel)
 {
     if (!_sizes.TryGetValue(panel, out var size))
     {
         var graphics = GraphicsUtility.MeasurementGraphics;
         size = panel.Measure(
             new FlowPanelMeasureEventArgs(graphics, ClientArea.Width));
         _sizes.Add(panel, size);
     }
     return(size);
 }
Example #5
0
 internal void InvalidatePanelSize(FlowPanel panel)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new Action <FlowPanel>(InvalidatePanelSize), panel);
     }
     else
     {
         _sizes.Remove(panel);
         NotifyContentSizeChanged();
     }
 }
Example #6
0
        private Size GetPanelSize(Graphics graphics, FlowPanel panel)
        {
            Size size;

            if (!_sizes.TryGetValue(panel, out size))
            {
                size = panel.Measure(
                    new FlowPanelMeasureEventArgs(graphics, ClientArea.Width));
                _sizes.Add(panel, size);
            }
            return(size);
        }
Example #7
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     if (_mouseDownPanel != null)
     {
         if (_mouseDownPanel.FlowControl == this)
         {
             int x      = e.X;
             int y      = e.Y;
             var bounds = GetPanelBounds(_mouseDownPanel);
             _mouseDownPanel.MouseUp(x - ClientArea.X + HScrollPos, y - bounds.Y + VScrollPos, e.Button);
         }
         _mouseDownPanel = null;
     }
     base.OnMouseUp(e);
 }
Example #8
0
        internal void ScrollIntoView(FlowPanel p)
        {
            int panelY = 0;

            for (int i = 0; i < Panels.Count; ++i)
            {
                var panel = Panels[i];
                var size  = GetPanelSize(panel);
                int maxY  = panelY + size.Height;
                if (p == panel)
                {
                    if (panelY > MaxVScrollPos)
                    {
                        panelY = MaxVScrollPos;
                    }
                    VScrollBar.Value = panelY;
                    break;
                }
                panelY = maxY;
            }
        }
Example #9
0
        internal Rectangle GetPanelBounds(FlowPanel panel)
        {
            Verify.Argument.IsNotNull(panel, nameof(panel));
            Verify.Argument.IsTrue(panel.FlowControl == this, "panel", "Panel is not owned by this FlowLayoutControl.");

            var graphics = GraphicsUtility.MeasurementGraphics;
            int y        = ClientArea.Y;

            for (int i = 0; i < Panels.Count; ++i)
            {
                var p    = Panels[i];
                var size = GetPanelSize(graphics, p);
                int maxY = y + size.Height;
                if (p == panel)
                {
                    return(new Rectangle(ClientArea.X, y, size.Width, size.Height));
                }
                y = maxY;
            }
            Assert.Fail("Panel not found.");
            return(Rectangle.Empty);
        }
Example #10
0
        protected FlowPanelHeader(FlowPanel flowPanel)
        {
            Verify.Argument.IsNotNull(flowPanel, "flowPanel");

            _flowPanel = flowPanel;
        }
Example #11
0
 protected virtual void OnPanelDoubleClick(FlowPanel panel, int x, int y, MouseButtons button)
 {
     panel.DoubleClick(x, y, button);
 }
Example #12
0
 protected virtual void OnPanelMouseDown(FlowPanel panel, int x, int y, MouseButtons button)
 {
     panel.MouseDown(x, y, button);
 }
Example #13
0
        protected FlowPanelHeader(FlowPanel flowPanel)
        {
            Verify.Argument.IsNotNull(flowPanel, "flowPanel");

            _flowPanel = flowPanel;
        }