public void AddItem(LayerItem item) { item.Bounds = new Rectangle(0, 0, Width, 19); item.Index = Items.Count; Items.Add(item); Height += 20; }
public void InsertItem(int index, LayerItem item) { item.Bounds = new Rectangle(0, 0, Width, 19); Items.Insert(index, item); for (int i = 0; i < Items.Count; ++i) { Items[i].Index = i; } Height += 20; }
public void AddItem(string name, bool visible) { LayerItem item = new LayerItem(); item.Bounds = new Rectangle(0, 0, Width, 19); item.Visible = visible; item.Text = name; item.Index = Items.Count; Items.Add(item); Height += 20; }
private void LayerControl_DragOver(object sender, DragEventArgs e) { Point m = PointToClient(new Point(e.X, e.Y)); drag_x = m.X; drag_y = m.Y; foreach (LayerItem li in Items) { li.Hover = (m.X > li.Bounds.X && m.Y > li.Bounds.Y && m.X < li.Bounds.X + li.Bounds.Width && m.Y < li.Bounds.Y + li.Bounds.Height); if (li.Hover) { hovered_item = li; } e.Effect = DragDropEffects.Move; } Refresh(); }
private void LayerControl_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(Type)) { SelectedItem.CanUpdate = true; LayerItem li = e.Data.GetData(Type) as LayerItem; if (li != null) { HomeIndex = Items.IndexOf(li); MovedIndex = Items.IndexOf(hovered_item); if (MovedIndex == -1) { return; } Items.Remove(li); Height -= 20; InsertItem(MovedIndex, li); if (LayerChanged != null) { LayerChanged(this, li); } } } }