Beispiel #1
0
        private void flowLayoutPanel_DragDrop(object sender, DragEventArgs e)
        {
            //HarrProgressBar data = (HarrProgressBar)e.Data.GetData(typeof(HarrProgressBar));
            PB data = (PB)e.Data.GetData(typeof(PB));
            FlowLayoutPanel _destination = (FlowLayoutPanel)sender;
            FlowLayoutPanel _source      = (FlowLayoutPanel)data.Parent;

            Point p1 = _destination.PointToClient(new Point(e.X, e.Y));

            if (p1.Y > 0)
            {
                if (_destination == garbagePanel || _destination == TFLP)
                {
                    data.Dispose();
                    ExpanderApp.Expander ex = new ExpanderApp.Expander();
                    ex.Expand(); ex = new ExpanderApp.Expander();
                    ex = (Expander)_source.Parent;
                    ex.Collapse();
                    ex.Expand();

                    if (_source.Controls.Count <= 0)
                    {
                        if (_source.Parent.Controls.Count <= 2)
                        {
                            _source.Parent.Dispose();
                        }
                        else
                        {
                            _source.Dispose();
                        }
                    }
                    _destination.Invalidate();
                    _source.Invalidate();
                }
                else if (_source != _destination)
                {
                    // Add control to panel
                    _destination.Controls.Add(data);
                    //_destination.Width = _destination.Width - 8;
                    data.Size = new Size(_destination.Width - 2, data.Height);

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

                    // Invalidate to paint!
                    if (_source.Controls.Count <= 0)
                    {
                        if (_source.Parent.Controls.Count <= 2)
                        {
                            _source.Parent.Dispose();
                        }
                        else
                        {
                            _source.Dispose();
                        }
                    }
                    _source.Invalidate();
                    Console.WriteLine(_destination.Parent.ToString());
                    ExpanderApp.Expander ex = new ExpanderApp.Expander();
                    ex = (Expander)_destination.Parent;
                    ex.Collapse();

                    ex.Expand(); ex = new ExpanderApp.Expander();
                    ex = (Expander)_source.Parent;
                    ex.Collapse();
                    ex.Expand();
                    _destination.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     = _destination.PointToClient(new Point(e.X, e.Y));
                    var   item  = _destination.GetChildAtPoint(p);
                    int   index = _destination.Controls.GetChildIndex(item, false);
                    _destination.Controls.SetChildIndex(data, index);


                    ExpanderApp.Expander ex = new ExpanderApp.Expander();
                    ex.Expand(); ex = new ExpanderApp.Expander();
                    ex = (Expander)_source.Parent;
                    ex.Collapse();
                    ex.Expand();
                    _destination.Invalidate();
                }
                FadeIn(TFLP, 1);
            }
            FadeIn(TFLP, 1);
            //garbagePanel.Visible = false;
        }
Beispiel #2
0
        public static Label CreateLabelHeader(Expander expander, string text, Color backColor, Image collapsedImage = null, Image expandedImage = null, int height = 25, Font font = null)
        {
            Label headerLabel = new Label();
            headerLabel.Text = text;
            headerLabel.AutoSize = false;
            headerLabel.Height = height;
            if (font != null)
                headerLabel.Font = font;
            headerLabel.TextAlign = ContentAlignment.MiddleLeft;
            if (collapsedImage != null && expandedImage != null)
            {
                headerLabel.Image = collapsedImage;
                headerLabel.ImageAlign = ContentAlignment.MiddleRight;
            }
            headerLabel.BackColor = backColor;

            if (collapsedImage != null && expandedImage != null)
            {
                expander.StateChanged += delegate { headerLabel.Image = expander.Expanded ? collapsedImage : expandedImage; };
            }

            headerLabel.Click += delegate { expander.Toggle(); };

            expander.Header = headerLabel;

            return headerLabel;
        }
Beispiel #3
0
 public static Label CreateLabelHeader(Expander expander, string text, Color backColor, Image collapsedImage)
 {
     return(CreateLabelHeader(expander, text, backColor, collapsedImage, null, 25, null));
 }
Beispiel #4
0
 public static Label CreateLabelHeader(Expander expander, string text, Color backColor, Image collapsedImage, Image expandedImage, int height)
 {
     return(CreateLabelHeader(expander, text, backColor, collapsedImage, expandedImage, height, null));
 }
Beispiel #5
0
 public static Label CreateLabelHeader(Expander expander, string text, Color backColor)
 {
     return(CreateLabelHeader(expander, text, backColor, null, null, 25, null));
 }