private void ParameterPanel_DragDrop(object sender, DragEventArgs e) { ParameterControl data = (ParameterControl)e.Data.GetData(typeof(ParameterControl)); FlowLayoutPanel _destination = (FlowLayoutPanel)sender; FlowLayoutPanel _source = (FlowLayoutPanel)data.Parent; if (_source != _destination) { // Add control to panel _destination.Controls.Add(data); data.Size = new Size(_destination.Width, 50); // 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! _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); _destination.Invalidate(); } }
private void UpdateActiveParameters(List <string> keys) { if (keys == null) { keys = GetActiveParameters(); } else { ParameterPanel.Controls.Clear(); } foreach (string mykey in keys) { bool found = false; foreach (ParameterControl control in this.ParameterPanel.Controls) { if (control.selectedParameter != null) { if (mykey == control.selectedParameter.GetStringPath()) { found = true; } } } if (!found) // Wenn noch nicht vorhanden { ParameterControl newControl = new ParameterControl(core, core.currentUAV.uavData.GetFromPath(mykey)); ParameterPanel.Controls.Add(newControl); } } if (count > ParameterPanel.Controls.Count) { int i; for (i = ParameterPanel.Controls.Count; i < count; i++) { ParameterControl newControl = new ParameterControl(core, null); ParameterPanel.Controls.Add(newControl); } } if (count < ParameterPanel.Controls.Count) { do { try { ParameterPanel.Controls.RemoveAt(0); } catch (Exception ex) { } } while (count < ParameterPanel.Controls.Count); } }
private void UpdateActiveParameters(List<string> keys) { if (keys == null) { keys = GetActiveParameters(); } else { ParameterPanel.Controls.Clear(); } foreach (string mykey in keys) { bool found = false; foreach (ParameterControl control in this.ParameterPanel.Controls){ if (control.selectedParameter != null) { if (mykey == control.selectedParameter.GetStringPath()) { found = true; } } } if (!found) { // Wenn noch nicht vorhanden ParameterControl newControl = new ParameterControl(core, core.currentUAV.uavData.GetFromPath(mykey)); ParameterPanel.Controls.Add(newControl); } } if (count > ParameterPanel.Controls.Count) { int i; for (i = ParameterPanel.Controls.Count; i < count; i++) { ParameterControl newControl = new ParameterControl(core, null); ParameterPanel.Controls.Add(newControl); } } if (count < ParameterPanel.Controls.Count) { do { try { ParameterPanel.Controls.RemoveAt(0); } catch (Exception ex) { } } while (count < ParameterPanel.Controls.Count); } }