/// <summary> /// Method changes status in status bar according state of last focused List view. /// </summary> private void _ChangeStatus() { // Create new status builder. StatusBuilder statusBuilder = new StatusBuilder(); // Init counters. int ordersCount = 0; int routesCount = 0; // if (SelectedItems.Count == 0) { string status = App.Current.GetString(NO_SELECTION_GRID_STATUS_FORMAT, CurrentSchedule.Routes.Count, CurrentSchedule.UnassignedOrders.Count); App.Current.MainWindow.StatusBar.SetStatus(this, status); return; } // Get counts of selected items. foreach (Object obj in SelectedItems) { if (obj is Order || (obj is Stop && ((Stop)obj).StopType == StopType.Order)) ordersCount++; // If selection contains stops and orders. else if (obj is Route) routesCount++; } if (ordersCount > 0) { // Fill selection status for orders selection. statusBuilder.FillSelectionStatusWithoutCollectionSize(CurrentSchedule.UnassignedOrders.Count, App.Current.FindString("Order"), ordersCount, this); } else if (routesCount > 0) { // Fill selection status for routes selection. statusBuilder.FillSelectionStatus(CurrentSchedule.Routes.Count, App.Current.FindString("Route"), routesCount, this); } }
protected override void _Execute(params object[] args) { Collection<Route> selected = new Collection<Route>(); foreach (Route item in _GetRoutesFromSelection()) { Route route = item.CloneNoResults() as Route; route.Vehicle = null; route.Driver = null; route.DefaultRouteID = null; selected.Add(route); } foreach (Route item in selected) { item.Name = DataObjectNamesConstructor.GetDuplicateName(item.Name, CurrentSchedule.Routes); CurrentSchedule.Routes.Add(item); } App.Current.Project.Save(); StatusBuilder statusBuilder = new StatusBuilder(); statusBuilder.FillSelectionStatusWithoutCollectionSize(CurrentSchedule.Routes.Count, (string)App.Current.FindResource("Route"), 0, OptimizePage); }
protected override void _Execute(params object[] args) { Collection<Order> selectedOrders = new Collection<Order>(); foreach (Order order in _GetUnassignedOrdersFromSelection()) { Order newOrder = order.Clone() as Order; selectedOrders.Add(newOrder); } Project project = App.Current.Project; foreach (Order order in selectedOrders) { order.Name = DataObjectNamesConstructor.GetDuplicateName(order.Name, _GetUnassignedOrdersFromSelection()); project.Orders.Add(order); } project.Save(); StatusBuilder statusBuilder = new StatusBuilder(); statusBuilder.FillSelectionStatusWithoutCollectionSize(CurrentSchedule.UnassignedOrders.Count, (string)App.Current.FindResource("Order"), 0, OptimizePage); }