Пример #1
0
        static TipGenerator()
        {
            _barrierAvailableCaption = (string)App.Current.FindResource("BarrierAvailableTooltipText");
            _zoneAssignmentCaption = (string)App.Current.FindResource("ZoneAssignmentTooltipText");

            _optimizeAndEditPage = (OptimizeAndEditPage)((MainWindow)App.Current.MainWindow).GetPage(PagePaths.SchedulePagePath);
        }
        /// <summary>
        /// Define whether option is enabled.
        /// </summary>
        protected override void _CheckEnabled(OptimizeAndEditPage schedulePage)
        {
            Debug.Assert(schedulePage != null);

            if (schedulePage.CurrentSchedule == null)
            {
                this.IsEnabled = false;

                return;
            }

            bool result = false;

            // If all routes locked - option should be disabled.
            foreach (Route route in schedulePage.CurrentSchedule.Routes)
            {
                if (!route.IsLocked)
                {
                    result = true;
                    break;
                }
            }

            IsEnabled = result;
        }
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="parentPage">Parent page.</param>
        public OrdersViewContextHandler(OptimizeAndEditPage parentPage)
        {
            Debug.Assert(null != parentPage);

            _parentPage = parentPage;
            _currentSchedule = parentPage.CurrentSchedule;
            _geocodablePage = parentPage.GeocodablePage;
        }
        /// <summary>
        /// Creates instance of ScheduleViewsEditingManager, initializes local field _multipleListViewManager
        /// and adds handler to ListViewsCollectionChanged event. 
        /// </summary>
        /// <param name="optimizeAndEditPage">OptimizeAndEditPage.</param>
        public ScheduleViewsEditingManager(OptimizeAndEditPage optimizeAndEditPage)
        {
            _ordersView = optimizeAndEditPage.OrdersView;
            _AddEditingEventHandlers(_ordersView);

            _routesView = optimizeAndEditPage.RoutesView;
            _AddEditingEventHandlers(_routesView);
        }
        /// <summary>
        /// Creates new instance of MoveToCommandOptionBase and add handler to schedulePage.Selection changed.
        /// </summary>
        public MoveToCommandOptionBase()
        {
            _schedulePage = (OptimizeAndEditPage)App.Current.MainWindow.GetPage(PagePaths.SchedulePagePath);
            Debug.Assert(_schedulePage != null);
            _schedulePage.SelectionChanged += new EventHandler(_SelectionChanged);

            Debug.Assert(App.Current.Solver != null);
            App.Current.Solver.AsyncSolveCompleted += new AsyncSolveCompletedEventHandler(_AsyncSolveCompleted);

            TooltipText = EnabledTooltip;
        }
 /// <summary>
 /// Checks whether command option is enabled.
 /// </summary>
 protected abstract void _CheckEnabled(OptimizeAndEditPage schedulePage);
        protected virtual void Current_ApplicationInitialized(object sender, EventArgs e)
        {
            _optimizePage = (OptimizeAndEditPage)((MainWindow)App.Current.MainWindow).GetPage(PagePaths.SchedulePagePath);

            _optimizePage.CurrentScheduleChanged += new EventHandler(optimizePage_CurrentScheduleChanged);
            _optimizePage.SelectionChanged += new EventHandler(_schedulePage_SelectionChanged);
            _optimizePage.EditBegun += new DataObjectEventHandler(_optimizePage_EditBegun);
            _optimizePage.EditCommitted += new DataObjectEventHandler(_optimizePage_EditCommitted);
            _optimizePage.EditCanceled += new ESRI.ArcLogistics.App.Pages.DataObjectEventHandler(_optimizePage_EditCanceled);
        }
        /// <summary>
        /// Creates new instance of  MoveToUnassignedOrdersOption. Inits group ID.
        /// </summary>
        /// <param name="groupId">Option group ID (to set in separate group in UI).</param>
        public MoveToUnassignedOrdersOption(int groupId)
        {
            GroupID = groupId;
            _schedulePage = (OptimizeAndEditPage)App.Current.MainWindow.GetPage(PagePaths.SchedulePagePath);
            Debug.Assert(_schedulePage != null);
            _schedulePage.SelectionChanged += new EventHandler(_SelectionChanged);

            Debug.Assert(App.Current.Solver != null);
            App.Current.Solver.AsyncSolveCompleted += new AsyncSolveCompletedEventHandler(Solver_AsyncSolveCompleted);

            _UpdateTooltip();
        }
        /// <summary>
        /// Starts operation process.
        /// </summary>
        /// <param name="args">Operation args.</param>
        /// <exception cref="Exception">Throws if any unhandles exception occurs in method.</exception>
        protected override void _Execute(params object[] args)
        {
            try
            {
                // Get current schedule.
                if (_schedulePage == null)
                    _schedulePage = (OptimizeAndEditPage)App.Current.MainWindow.GetPage(PagePaths.SchedulePagePath);

                Schedule schedule = _schedulePage.CurrentSchedule;

                ICollection<Order> selectedOrders = _GetOrdersWhichCanBeUnassignedFromSelection(_schedulePage.SelectedItems);
                ICollection<Order> orders = RoutingCmdHelpers.GetOrdersIncludingPairs(schedule, selectedOrders);
                ICollection<Route> routes = ViolationsHelper.GetRouteForUnassignOrders(schedule, orders);

                if (_CheckRoutingParams(schedule, routes, orders))
                {
                    SolveOptions options = new SolveOptions();
                    options.GenerateDirections = App.Current.MapDisplay.TrueRoute;
                    options.FailOnInvalidOrderGeoLocation = false;

                    _SetOperationStartedStatus((string)App.Current.FindResource(UNASSIGN_ORDERS), (DateTime)schedule.PlannedDate);

                    OperationsIds.Add(App.Current.Solver.UnassignOrdersAsync(schedule, orders, options));

                    // set solve started message
                    string infoMessage = RoutingMessagesHelper.GetUnassignOperationStartedMessage(orders);

                    if (!string.IsNullOrEmpty(infoMessage))
                        App.Current.Messenger.AddInfo(infoMessage);
                }
            }
            catch (RouteException e)
            {
                if (e.InvalidObjects != null) // if exception throw because any Routes or Orders are invalid
                    _ShowSolveValidationResult(e.InvalidObjects);
                else
                    _ShowErrorMsg(RoutingCmdHelpers.FormatRoutingExceptionMsg(e));
            }
            catch (Exception e)
            {
                Logger.Error(e);
                if ((e is LicenseException) || (e is AuthenticationException) || (e is CommunicationException))
                    CommonHelpers.AddRoutingErrorMessage(e);
                else
                    throw;
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="optimizeAndEditPage">Parent page.</param>
        /// <param name="timeView">Time view.</param>
        public SelectionManager(OptimizeAndEditPage optimizeAndEditPage)
        {
            _optimizeAndEditPage = optimizeAndEditPage;
            _timeView = optimizeAndEditPage.TimeView;
            _mapView = optimizeAndEditPage.MapView;
            _ordersView = optimizeAndEditPage.OrdersView;
            _routesView = optimizeAndEditPage.RoutesView;

            // Set callback for checking selection possibility.
            _mapView.mapCtrl.CanSelectCallback = _CanSelect;

            _CreateCollectionsInMultiCollectionBinding();

            _InitEventHandlers();

            _selectionChanger = new SelectionChanger(_optimizeAndEditPage);
        }
Пример #11
0
        /// <summary>
        /// Creates all necessary event handlers when application is initialized.
        /// </summary>
        /// <param name="sender">Application.</param>
        /// <param name="e">Event args.</param>
        private void _ApplicationInitialized(object sender, EventArgs e)
        {
            // Add handlers to all events to enable/disable command and update collection of options when necessary.
            App.Current.ProjectLoaded += new EventHandler(_ProjectLoaded);
            App.Current.ProjectClosing += new EventHandler(_ProjectClosing);

            _schedulePage = (OptimizeAndEditPage)App.Current.MainWindow.GetPage(PagePaths.SchedulePagePath);
            Debug.Assert(_schedulePage != null);

            if (null != _schedulePage.CurrentSchedule)
                _CreateOptions(_schedulePage.CurrentSchedule);

            _schedulePage.SelectionChanged += new EventHandler(_SchedulePageSelectionChanged);
            _schedulePage.CurrentScheduleChanged += new EventHandler(_CurrentScheduleChanged);
            _schedulePage.EditBegun += new DataObjectEventHandler(_SchedulePageEditBegun);
            _schedulePage.EditCanceled += new DataObjectEventHandler(_SchedulePageEditCanceled);
            _schedulePage.EditCommitted += new DataObjectEventHandler(_SchedulePageEditCommitted);

            App.Current.Solver.AsyncSolveCompleted += new AsyncSolveCompletedEventHandler(_AsyncSolveCompleted);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="parentPage">Optimize and edit page.</param>
        public RoutesListViewContextHandler(OptimizeAndEditPage parentPage)
        {
            Debug.Assert(null != parentPage);
            Debug.Assert(null != parentPage.CurrentSchedule);

            _parentPage = parentPage;
            _routes = parentPage.CurrentSchedule.Routes;
            _dataGridControl = parentPage.RoutesView.RoutesGrid;
            _dataGridControl.InitializingInsertionRow += new EventHandler<InitializingInsertionRowEventArgs>(xceedGrid_InitializingInsertionRow);
            _mapControl = parentPage.MapView.mapCtrl;
            _mapControl.EndEditRouteCallback = _EditEnded;
        }
        /// <summary>
        /// Define whether option is enabled.
        /// </summary>
        protected override void _CheckEnabled(OptimizeAndEditPage schedulePage)
        {
            Debug.Assert(schedulePage != null);

            // Option is enabled if all selected stops belong to the same route.
            if (!_AreAllSelectedOrdersAssignedToOneRoute(schedulePage.SelectedItems))
            {
                IsEnabled = false;
                return;
            }

            var sourceRoute = _GetSourceRoute(schedulePage.SelectedItems);

            var result =
                schedulePage.CurrentSchedule != null &&
                schedulePage.CurrentSchedule.Routes.Any(
                    route => !route.IsLocked && route != sourceRoute);

            IsEnabled = result;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="optimizeAndEditPage">Parent page.</param>
        public SelectionChanger(OptimizeAndEditPage optimizeAndEditPage)
        {
            Debug.Assert(optimizeAndEditPage != null);

            _optimizeAndEditPage = optimizeAndEditPage;
        }
 /// <summary>
 ///Checks whether option enabled.
 /// </summary>
 /// <returns></returns>
 protected override void _CheckEnabled(OptimizeAndEditPage schedulePage)
 {
     IsEnabled = !_targetRoute.IsLocked;
 }
Пример #16
0
        private void _App_ApplicationInitialized(object sender, EventArgs e)
        {
            App.Current.CurrentDateChanged +=
                new EventHandler(_ImportCmd_CurrentDateChanged);

            if (null != ParentPage)
                ParentPage.Loaded += new RoutedEventHandler(_ParentPage_Loaded);

            _schedulePage =
                (AppPages.OptimizeAndEditPage)App.Current.MainWindow.GetPage(AppPages.PagePaths.SchedulePagePath);
            _schedulePage.EditBegun +=
                new AppPages.DataObjectEventHandler(_SchedulePage_EditBegun);
            _schedulePage.EditCommitted +=
                new AppPages.DataObjectEventHandler(_SchedulePage_EditCommitted);
            _schedulePage.EditCanceled +=
                new AppPages.DataObjectEventHandler(_SchedulePage_EditCanceled);
        }