Exemplo n.º 1
0
        private void SpawnCheckListUserControl(Data.CheckListProp clProp, bool focus)
        {
            CheckListUserControl checkListUserControl = new CheckListUserControl();

            checkListUserControl.AutoSize          = true;
            checkListUserControl.AutoSizeMode      = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            checkListUserControl.BackColor         = System.Drawing.Color.Teal;
            checkListUserControl.Location          = new System.Drawing.Point(5, 5);
            checkListUserControl.Margin            = new System.Windows.Forms.Padding(5, 10, 5, 10);
            checkListUserControl.Name              = "checkListUserControl";
            checkListUserControl.Size              = new System.Drawing.Size(693, 130);
            checkListUserControl.CheckListDeleted += CheckListUserControl_CheckListDeleted;
            checkListUserControl.Reset            += CheckListUserControl_Reset;
            checkListUserControl.LoadData(clProp);
            checkListPanel.Controls.Add(checkListUserControl);
            checkListPanel.Controls.SetChildIndex(checkListUserControl, clProp.CheckList_Position);

            if (focus == true)
            {
                checkListUserControl.OnSpawned();
            }
        }
Exemplo n.º 2
0
        private void checkListPanel_DragDrop(object sender, DragEventArgs e)
        {
            CheckListUserControl data = (CheckListUserControl)e.Data.GetData(typeof(CheckListUserControl));

            if (data == null)
            {
                return;
            }
            FlowLayoutPanel target = (FlowLayoutPanel)sender;
            FlowLayoutPanel source = (FlowLayoutPanel)data.Parent;

            if (source != target)
            {
                // Add control to panel
                target.Controls.Add(data);

                // Reorder
                Point p     = target.PointToClient(new Point(e.X, e.Y));
                var   item  = target.GetChildAtPoint(p);
                int   index = target.Controls.GetChildIndex(item, false);
                target.Controls.SetChildIndex(data, index);

                // Invalidate to paint!
                target.Invalidate();
                source.Invalidate();
            }
            else
            {
                // Just add the control to the new panel.
                // No need to remove from the other panel, this changes the Control.Parent property.
                Point p     = target.PointToClient(new Point(e.X, e.Y));
                var   item  = target.GetChildAtPoint(p);
                int   index = target.Controls.GetChildIndex(item, false);
                target.Controls.SetChildIndex(data, index);
                target.Invalidate();

                ResetCheckListPos();
            }
        }