///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Method gets sorted collection.
        /// </summary>
        /// <returns>Sorted collection.</returns>
        private SortedDataObjectCollection <Zone> _GetSortedCollection()
        {
            IDataObjectCollection <Zone>      zones            = (IDataObjectCollection <Zone>)App.Current.Project.Zones;
            SortedDataObjectCollection <Zone> sortedCollection = new SortedDataObjectCollection <Zone>(zones, new CreationTimeComparer <Zone>());

            return(sortedCollection);
        }
        /// <summary>
        /// Creates gantt item element for each stop and drive time between stops.
        /// </summary>
        /// <param name="route"></param>
        private void _CreateGanttItemElements(Route route)
        {
            // Sort route's tops.
            SortedDataObjectCollection <Stop> sortedStops = new SortedDataObjectCollection <Stop>(route.Stops, new StopsComparer());

            Debug.Assert(_ganttItemElements != null); // Must be initialized.

            foreach (Stop stop in sortedStops)
            {
                // Skip creating drive time element for the first stop.
                if (sortedStops.IndexOf(stop) > 0)
                {
                    _ganttItemElements.Add(new DriveTimeGanttItemElement(stop, this)); // Create drive time element previous to stop.
                }
                StopGanttItemElement newElement = new StopGanttItemElement(stop, this);

                _ganttItemElements.Add(newElement); // Add stop element.
            }

            if (_ganttItemElements.Count != 0)
            {
                // Define start time of gantt item.
                _startTime = _ganttItemElements[0].StartTime;

                // Define end time of gantt item.
                _endTime = _ganttItemElements[_ganttItemElements.Count - 1].EndTime;
            }

            // If route has not stops - add empty gantt item element to support common selection logic.
            if (sortedStops.Count == 0)
            {
                _ganttItemElements.Add(new EmptyGanttItemElement(this));
            }
        }
Exemple #3
0
        /// <summary>
        /// Inits collecton of grid items
        /// </summary>
        protected override void _InitDataGridCollection()
        {
            DataGridCollectionViewSource                  vehicleCollectionSource            = (DataGridCollectionViewSource)base.LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);
            IDataObjectCollection <VehicleSpecialty>      vehiclesSpecialtiesCollection      = (IDataObjectCollection <VehicleSpecialty>)App.Current.Project.VehicleSpecialties;
            SortedDataObjectCollection <VehicleSpecialty> sortedVehicleSpecialtiesCollection = new SortedDataObjectCollection <VehicleSpecialty>(vehiclesSpecialtiesCollection, new CreationTimeComparer <VehicleSpecialty>());

            vehicleCollectionSource.Source = sortedVehicleSpecialtiesCollection;
        }
Exemple #4
0
        /// <summary>
        /// Creates gantt items.
        /// </summary>
        private void _CreateGanttItems()
        {
            ganttControl.RemoveAllGanttItems();

            if (_optimizeAndEditPage.CurrentSchedule.Routes.Count > 0)
            {
                SortedDataObjectCollection <Route> sortedRoutes = new SortedDataObjectCollection <Route>(_optimizeAndEditPage.CurrentSchedule.Routes, new RoutesComparer());

                foreach (Route route in sortedRoutes)
                {
                    ganttControl.AddGanttItem(new RouteGanttItem(route));
                }
            }
        }
        /// <summary>
        /// Method sets grid data binding.
        /// </summary>
        private void _InitDataGridCollection()
        {
            IDataObjectCollection <Schedule> schedules = _ScheduleVersions;

            if (schedules != null)
            {
                schedules.Dispose();
            }

            schedules = (IDataObjectCollection <Schedule>)App.Current.Project.Schedules.Search(App.Current.CurrentDate, true);
            SortedDataObjectCollection <Schedule> sortedScheduleCollection = new SortedDataObjectCollection <Schedule>(schedules, new ScheduleVersionComparer());

            _DataGridSource.Source = sortedScheduleCollection;
        }
Exemple #6
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        protected override IEnumerable GetDetailsForParentItem(DataGridCollectionViewBase parentCollectionView, object parentItem)
        {
            Debug.Assert(parentItem is Route);

            IEnumerable <Stop> details = new List <Stop>();

            if (null != parentItem)
            {
                _route  = (Route)parentItem;
                details = new SortedDataObjectCollection <Stop>(_route.Stops, new StopsComparer());
            }

            return(details);
        }
        protected void _InitDataGridCollection()
        {
            try
            {
                DataGridCollectionViewSource          fuelsCollection = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);
                IDataObjectCollection <FuelType>      fuelTypes       = App.Current.Project.FuelTypes;
                SortedDataObjectCollection <FuelType> sortedFuelTypes = new SortedDataObjectCollection <FuelType>(fuelTypes, new CreationTimeComparer <FuelType>());
                fuelsCollection.Source = sortedFuelTypes;

                fuelsCollection.View.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(View_CollectionChanged);

                _isDataGridCollectionInited = true;
            }
            catch (Exception ex)
            {
                _isDataGridCollectionInited = false;
                Logger.Info(ex);
            }
        }
        /// <summary>
        /// Method inits collection of drivers.
        /// </summary>
        protected void _InitDataGridCollection()
        {
            try
            {
                DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);


                IDataObjectCollection <Driver>      collection = (IDataObjectCollection <Driver>)App.Current.Project.Drivers;
                SortedDataObjectCollection <Driver> sortedDriversCollection = new SortedDataObjectCollection <Driver>(collection, new CreationTimeComparer <Driver>());
                collectionSource.Source = sortedDriversCollection;

                _isDataGridCollectionInited = true;
            }
            catch (Exception ex)
            {
                _isDataGridCollectionInited = false;
                Logger.Info(ex);
            }
        }
        /// <summary>
        /// Method creates options.
        /// </summary>
        private void _CreateOptions(Schedule currentSchedule)
        {
            if (currentSchedule.Routes != null)
            {
                // Used to show horisontal lines in menu.
                int groupID = 0;

                List <ICommandOption> options = new List <ICommandOption>();

                // Add MoveToUnassigned orders option.
                options.Add(new MoveToUnassignedOrdersOption(groupID));

                // Start next group.
                groupID++;

                // Add MoveToBestRoute option.
                options.Add(new MoveToBestRouteCommandOption(groupID));

                // Add MoveToBestOtherRoute option.
                options.Add(new MoveToBestOtherRouteCommandOption(groupID));

                // Start next group.
                groupID++;

                // Add MoveToRoute option for each route.
                SortedDataObjectCollection <Route> sortedRoutes = new SortedDataObjectCollection <Route>(currentSchedule.Routes, new RoutesComparer());

                foreach (Route route in sortedRoutes)
                {
                    options.Add(new MoveToRouteCommandOption(groupID, route));
                }

                foreach (CommandBase option in options)
                {
                    option.Initialize(App.Current);
                }

                Options = options.ToArray();

                // Notify about option collection changed.
                _NotifyPropertyChanged(OPTIONS_PROPERTY_NAME);
            }
        }
        /// <summary>
        /// Inits collection of items
        /// </summary>
        protected void _InitDataGridCollection()
        {
            Project project = App.Current.Project;

            if (project == null)
            {
                _isDataGridCollectionInited = false;
            }
            else
            {
                DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);

                IDataObjectCollection <Vehicle>      collection = (IDataObjectCollection <Vehicle>)project.Vehicles;
                SortedDataObjectCollection <Vehicle> sortedVehiclesCollection = new SortedDataObjectCollection <Vehicle>(collection, new CreationTimeComparer <Vehicle>());
                collectionSource.Source = sortedVehiclesCollection;

                ((INotifyCollectionChanged)XceedGrid.Items).CollectionChanged += new NotifyCollectionChangedEventHandler(VehiclesPage_CollectionChanged);

                _isDataGridCollectionInited = true;
            }
        }
Exemple #11
0
        /// <summary>
        /// Method inits collection of locations.
        /// </summary>
        protected void _IniDataGridCollection()
        {
            Project project = App.Current.Project;

            if (project != null)
            {
                DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);

                IDataObjectCollection <Location>      collection = (IDataObjectCollection <Location>)project.Locations;
                SortedDataObjectCollection <Location> sortedLocationsCollection = new SortedDataObjectCollection <Location>(collection, new CreationTimeComparer <Location>());
                collectionSource.Source = sortedLocationsCollection;

                ((INotifyCollectionChanged)XceedGrid.Items).CollectionChanged += new NotifyCollectionChangedEventHandler(LocationsPage_CollectionChanged);

                _isDataGridCollectionInited = true;
                XceedGrid.SelectedItems.Clear();
            }
            else
            {
                _isDataGridCollectionInited = false;
            }
        }
        /// <summary>
        /// Method inits collection of locations.
        /// </summary>
        protected void _IniDataGridCollection()
        {
            Project project = App.Current.Project;
            if (project != null)
            {
                DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);

                IDataObjectCollection<Location> collection = (IDataObjectCollection<Location>)project.Locations;
                SortedDataObjectCollection<Location> sortedLocationsCollection = new SortedDataObjectCollection<Location>(collection, new CreationTimeComparer<Location>());
                collectionSource.Source = sortedLocationsCollection;

                ((INotifyCollectionChanged)XceedGrid.Items).CollectionChanged += new NotifyCollectionChangedEventHandler(LocationsPage_CollectionChanged);

                _isDataGridCollectionInited = true;
                XceedGrid.SelectedItems.Clear();
            }
            else
                _isDataGridCollectionInited = false;
        }
 /// <summary>
 /// Inits collecton of grid items
 /// </summary>
 protected override void _InitDataGridCollection()
 {
     DataGridCollectionViewSource driverCollectionSource = (DataGridCollectionViewSource)base.LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);
     IDataObjectCollection<DriverSpecialty> driversSpecialtiesCollection = (IDataObjectCollection<DriverSpecialty>)App.Current.Project.DriverSpecialties;
     SortedDataObjectCollection<DriverSpecialty> sortedDriverSpecialtiesCollection = new SortedDataObjectCollection<DriverSpecialty>(driversSpecialtiesCollection, new CreationTimeComparer<DriverSpecialty>());
     driverCollectionSource.Source = sortedDriverSpecialtiesCollection;
 }
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Method gets sorted collection.
 /// </summary>
 /// <returns>Sorted collection.</returns>
 private SortedDataObjectCollection<Zone> _GetSortedCollection()
 {
     IDataObjectCollection<Zone> zones = (IDataObjectCollection<Zone>)App.Current.Project.Zones;
     SortedDataObjectCollection<Zone> sortedCollection = new SortedDataObjectCollection<Zone>(zones, new CreationTimeComparer<Zone>());
     return sortedCollection;
 }
        /// <summary>
        /// Inits collection of drivers.
        /// </summary>
        private void _InitDataGridCollection()
        {
            Project project = App.Current.Project;
            if (project == null)
                _isGridCollectionLoaded = false;
            else
            {
                DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);

                IDataObjectCollection<Route> collection = (IDataObjectCollection<Route>)project.DefaultRoutes;
                SortedDataObjectCollection<Route> sortedRoutesCollection = new SortedDataObjectCollection<Route>(collection, new CreationTimeComparer<Route>());

                collectionSource.Source = sortedRoutesCollection;

                ((INotifyCollectionChanged)XceedGrid.Items).CollectionChanged += new NotifyCollectionChangedEventHandler(DefaultRoutesPage_CollectionChanged);

                _isGridCollectionLoaded = true;
            }
        }
        /// <summary>
        /// Inits routes table. Update source collection.
        /// </summary>
        /// <param name="isSingleDaySelect">Single day selected flag.</param>
        /// <param name="isChecked">Selected flag.</param>
        private void _InitRoutesTable(bool isSingleDaySelect, bool isChecked)
        {
            _viewSourceRoutes.Source = new List<SelectPropertiesWrapper>();

            string statusMessage = null;
            if (!isSingleDaySelect)
            {
                statusMessage = (0 == _schedulesToReport.Count) ? _GetMessageScheduleNotFounded() : null;
            }
            else
            {
                var routesWrap = new List<SelectPropertiesWrapper>();

                DateRangeCalendarWidget calendarWidget = _GetCalendarWidget();
                Schedule schedule = ScheduleHelper.GetCurrentScheduleByDay(calendarWidget.StartDate);
                if (!ScheduleHelper.DoesScheduleHaveBuiltRoutes(schedule))
                    statusMessage = _GetMessageScheduleNotFounded();
                else
                {
                    var sortedRoutes =
                        new SortedDataObjectCollection<Route>(schedule.Routes, new RoutesComparer());
                    foreach (Route route in sortedRoutes)
                    {
                        if ((null != route.Stops) && (0 < route.Stops.Count))
                            routesWrap.Add(new SelectPropertiesWrapper(route.Name, null, isChecked));
                    }

                    _viewSourceRoutes.Source = routesWrap;
                    statusMessage = null;
                }
            }

            App.Current.MainWindow.StatusBar.SetStatus(this, statusMessage);
        }
        /// <summary>
        /// Method creates options.
        /// </summary>
        private void _CreateOptions(Schedule currentSchedule)
        {
            if (currentSchedule.Routes != null)
            {
                // Used to show horisontal lines in menu.
                int groupID = 0;

                List<ICommandOption> options = new List<ICommandOption>();

                // Add MoveToUnassigned orders option.
                options.Add(new MoveToUnassignedOrdersOption(groupID));

                // Start next group.
                groupID++;

                // Add MoveToBestRoute option.
                options.Add(new MoveToBestRouteCommandOption(groupID));

                // Add MoveToBestOtherRoute option.
                options.Add(new MoveToBestOtherRouteCommandOption(groupID));

                // Start next group.
                groupID++;

                // Add MoveToRoute option for each route.
                SortedDataObjectCollection<Route> sortedRoutes = new SortedDataObjectCollection<Route>(currentSchedule.Routes, new RoutesComparer());

                foreach (Route route in sortedRoutes)
                    options.Add(new MoveToRouteCommandOption(groupID, route));

                foreach (CommandBase option in options)
                    option.Initialize(App.Current);

                Options = options.ToArray();

                // Notify about option collection changed.
                _NotifyPropertyChanged(OPTIONS_PROPERTY_NAME);
            }
        }
        protected void _InitDataGridCollection()
        {
            try
            {
                DataGridCollectionViewSource fuelsCollection = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);
                IDataObjectCollection<FuelType> fuelTypes = App.Current.Project.FuelTypes;
                SortedDataObjectCollection<FuelType> sortedFuelTypes = new SortedDataObjectCollection<FuelType>(fuelTypes, new CreationTimeComparer<FuelType>());
                fuelsCollection.Source = sortedFuelTypes;

                fuelsCollection.View.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(View_CollectionChanged);

                _isDataGridCollectionInited = true;
            }
            catch (Exception ex)
            {
                _isDataGridCollectionInited = false;
                Logger.Info(ex);
            }
        }
        /// <summary>
        /// Method inits collection of drivers.
        /// </summary>
        protected void _InitDataGridCollection()
        {
            try
            {
                DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);

                IDataObjectCollection<Driver> collection = (IDataObjectCollection<Driver>)App.Current.Project.Drivers;
                SortedDataObjectCollection<Driver> sortedDriversCollection = new SortedDataObjectCollection<Driver>(collection, new CreationTimeComparer<Driver>());
                collectionSource.Source = sortedDriversCollection;

                _isDataGridCollectionInited = true;
            }
            catch (Exception ex)
            {
                _isDataGridCollectionInited = false;
                Logger.Info(ex);
            }
        }