Custom FlowLayoutPanel: Get inside elements posotion and / or Rectangle

2

I have created a customized user control from the FlowLayoutPanel control that contains customized Panels inside, added dynamically. I want to get the position of the controls within this FlowLayoutPanel to complete the isPointOverPanel method. Any idea? Thanks in advance

{
public partial class FlowDynamicPanel : FlowLayoutPanel
{
    private PictureBox addIcon;
    List<ResizablePanel> resizablePanels;

    public FlowDynamicPanel()
    {
        resizablePanels = new List<ResizablePanel>();
        ResizablePanel rp = CreateNewPanel();
        Controls.Add(rp);
        addIcon = new PictureBox
        {
            Image = Resource1.adIcon,
            Size = new Size(100, 100),
            SizeMode = PictureBoxSizeMode.StretchImage,
            BorderStyle = BorderStyle.FixedSingle
        };
        addIcon.MouseClick += AddIcon_MouseClick;
        this.Controls.Add(addIcon);
        InitializeComponent();
    }

    private void AddIcon_MouseClick(object sender, MouseEventArgs e)
    {
        Controls.Add(CreateNewPanel());
        Controls.SetChildIndex(addIcon, Controls.Count);
    }

    private ResizablePanel CreateNewPanel()
    {

        ResizablePanel _newRp = new ResizablePanel
        {
            Size = new Size(40, 40),
            BorderStyle = BorderStyle.FixedSingle
        };
        resizablePanels.Add(_newRp);
        return _newRp;
    }


   public ResizablePanel IsPointOverPanel(Point p)
    {
      //Obtener la posición de los paneles dentro de this y comprobar si p esta dentro.
    }

    
asked by Iván Valdés 15.03.2018 в 22:52
source

0 answers