private void ButtonMouseUp(object sender, EventArgs e) { PB data = (PB)sender; if (data._isDragging) { FadeIn(TFLP, 1); } else { FadeOut(TFLP, 1); } }
private void button3_Click(object sender, EventArgs e) { Random r = new Random(); Size s = new Size(REF.Width - 2, 26); PB PBA = new PB(); PBA.AllowDrag = true; PBA.Size = s; PBA.Text = "" + (r.Next(300000, 400000)).ToString(); PBA.FlatStyle = FlatStyle.Flat; PBA.Margin = new Padding(0); PBA.Padding = new Padding(0); PBA.MouseUp += new MouseEventHandler(FadeIn_MouseUp); REF.Controls.Add(PBA); /* ADD BUTTON * * Random r = new Random(); * Size s = new Size(REF.Width - 8, 47); * System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); * dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; * * PB PBA = new PB(); * PBA.ReadOnly = true; * PBA.AllowDrag = true; * PBA.RowHeadersVisible = false; * * * PBA.Columns.Add("test", " " + (r.Next(300000, 400000)).ToString());//, "Foo Text"); * //PBA.Rows[0].HeaderCell.Value = "Row Text"; * PBA.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; * //PBA.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; * //PBA.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; * //PBA.AutoSize = true; * PBA.DefaultCellStyle.SelectionBackColor = Color.White; * PBA.DefaultCellStyle.ForeColor = Color.Black; * PBA.Dock = DockStyle.Top; * PBA.Size = s; * //PBA.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; * PBA.Columns["test"].DefaultCellStyle = dataGridViewCellStyle2; * PBA.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; * REF.Controls.Add(PBA); * */ }
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; }