private void btnTop_Click(object sender, EventArgs e) { var sel = SelectedOrders.ToArray(); foreach (var item in sel.Select(o => new { Order = o, OldIndex = ConstructionQueue.Orders.IndexOf(o), NewIndex = sel.IndexOf(o) })) { var cmd = new RearrangeOrdersCommand <ConstructionQueue>(ConstructionQueue, item.Order, item.NewIndex - item.OldIndex); newCommands.Add(cmd); cmd.Execute(); } BindQueueListView(sel); }
private void btnOrderToTop_Click(object sender, System.EventArgs e) { var order = (IOrder)lstOrdersDetail.SelectedItem; if (order != null) { var cmd = new RearrangeOrdersCommand <Fleet>( Fleet, order, -fleet.Orders.IndexOf(order)); Empire.Current.Commands.Add(cmd); cmd.Execute(); // show change locally Bind(); if (OrdersChanged != null) { OrdersChanged(); } } }
private void btnUp_Click(object sender, EventArgs e) { var sel = SelectedOrders.ToArray(); int delta; if (chkExpanded.Checked) { delta = -1; } else { delta = -FindSameItemsCountAbove(sel.First()); } foreach (var order in sel) { var cmd = new RearrangeOrdersCommand <ConstructionQueue>(ConstructionQueue, order, delta); newCommands.Add(cmd); cmd.Execute(); } BindQueueListView(sel); }