예제 #1
0
        /// <summary>
        /// Changes item's name.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        private void _ChangeName(DataGridItemEventArgs e)
        {
            // Get custom order property from event's data.
            CustomOrderProperty orderProperty = e.Item as CustomOrderProperty;

            Debug.Assert(orderProperty != null);

            // Check that item's name is null.
            if (!string.IsNullOrEmpty(orderProperty.Name))
            {
                return;
            }

            // Get new item's name.
            orderProperty.Name =
                DataObjectNamesConstructor.GetNewNameForCustomOrderProperty(_customOrderProperties, true);

            // Get current cell.
            Cell currentCell =
                _insertionRow.Cells[_customOrderPropertiesXceedGrid.CurrentContext.CurrentColumn];

            // Find TextBox inside the cell.
            TextBox textBox = XceedVisualTreeHelper.FindTextBoxInsideElement(currentCell);

            // Select contents of found text box.
            if (textBox != null)
            {
                textBox.SelectAll();
            }
        }
예제 #2
0
        /// <summary>
        /// React on match found.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _MatchFound(object sender, EventArgs e)
        {
            _SetSubPage(_matchFoundSubPage);

            mapCtrl.map.UpdateLayout();

            // Get item container.
            DependencyObject itemContainer = DataGridControl.GetContainerFromItem(CurrentItem);
            DataRow          row           = itemContainer as DataRow;

            if (row != null)
            {
                // Invoke redraw.
                ControlTemplate template = row.Cells[ADDRESS_LINE_COLUMN_INDEX].Template;
                row.Cells[ADDRESS_LINE_COLUMN_INDEX].Template = null;
                row.Cells[ADDRESS_LINE_COLUMN_INDEX].Template = template;
            }
            else
            {
                // Incorrect functionality in Xceed grid. Sometimes item container is not returned.
            }

            // Zooming to current item suspended because zooming should go after suspended zoom
            // restoring in mapextentmanager. Suspended zoom restoring invoked in case of saved
            // old extent(zoom was changed by mouse) and because of map control size changed
            // after showing subpage.
            Dispatcher.BeginInvoke(new Action <Location>(delegate(Location item)
            {
                _ZoomOnLocation(item);
            }
                                                         ),
                                   DispatcherPriority.Background, CurrentItem);

            // Do not need to finish editing there if match was found by tool.
            if (_skipStartGeocoding)
            {
                // Do nothing.
            }
            else
            {
                _skipStartGeocoding = true;
                try
                {
                    DataGridControl.EndEdit();
                }
                catch
                {
                    // Exception in cycle end editing.
                }
                _skipStartGeocoding = false;
            }

            // If current location has no name - get next name for it.
            if (string.IsNullOrWhiteSpace(CurrentItem.Name))
            {
                CurrentItem.Name = DataObjectNamesConstructor.GetNameForNewDataObject(
                    _locations, CurrentItem, true);
            }
        }
예제 #3
0
        /// <summary>
        /// Create location and switch of address validation.
        /// </summary>
        /// <returns></returns>
        private Location _CreateLocationWithFakeNameAndWithoutValidation()
        {
            // Create new location with whitespace name. Do so to cheat validation, so there would
            // be no yellow ! at location name.
            Location location = new Location();

            location.Name = DataObjectNamesConstructor.GetNewWhiteSpacesName(_locations);

            // Turn off address validation.
            location.IsAddressValidationEnabled = false;

            return(location);
        }
        /// <summary>
        /// Duplicates vehicles
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            List <Vehicle> selectedVehicles = new List <Vehicle>();

            foreach (Vehicle vehicle in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedVehicles.Add(vehicle);
            }

            foreach (Vehicle vehicle in selectedVehicles)
            {
                Vehicle veh = vehicle.Clone() as Vehicle;
                veh.Name = DataObjectNamesConstructor.GetDuplicateName(vehicle.Name, project.Vehicles);
                project.Vehicles.Add(veh);
            }

            App.Current.Project.Save();
        }
예제 #5
0
        /// <summary>
        /// React on beginning edit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Event args.</param>
        private void _BeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            // If location has no or whitespace name - get new name for it
            // and turn on validation on address fields.
            Location location = e.Item as Location;

            if (string.IsNullOrWhiteSpace(location.Name))
            {
                location.Name = DataObjectNamesConstructor.GetNameForNewDataObject(
                    _locations, location, true);
            }

            (e.Item as Location).IsAddressValidationEnabled = true;

            _geocodablePage.OnBeginningEdit(e);
            e.Handled = true;

            CurrentItem.Address.PropertyChanged += new PropertyChangedEventHandler(_AddressPropertyChanged);
            CurrentItem.PropertyChanged         += new PropertyChangedEventHandler(_CurrentItemPropertyChanged);
        }
예제 #6
0
        /// <summary>
        /// Duplicates locations
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            List <Location> selectedLocations = new List <Location>();

            foreach (Location loc in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedLocations.Add(loc);
            }

            foreach (Location location in selectedLocations)
            {
                Location loc = location.Clone() as Location;
                loc.Name = DataObjectNamesConstructor.GetDuplicateName(location.Name, project.Locations);
                project.Locations.Add(loc);
            }

            App.Current.Project.Save();
        }
예제 #7
0
        /// <summary>
        /// Duplicates driver specialties
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            List <DriverSpecialty> selectedSpecialties = new List <DriverSpecialty>();

            foreach (DriverSpecialty specialty in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedSpecialties.Add(specialty);
            }

            foreach (DriverSpecialty driverSpecialty in selectedSpecialties)
            {
                DriverSpecialty ds = driverSpecialty.Clone() as DriverSpecialty;
                ds.Name = DataObjectNamesConstructor.GetDuplicateName(driverSpecialty.Name, project.DriverSpecialties);
                project.DriverSpecialties.Add(ds);
            }

            App.Current.Project.Save();
        }
예제 #8
0
        /// <summary>
        /// Duplicates default routes
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            List <Route> selectedRoutes = new List <Route>();

            foreach (Route route in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedRoutes.Add(route);
            }

            foreach (Route route in selectedRoutes)
            {
                Route newRoute = route.Clone() as Route;
                newRoute.Name = DataObjectNamesConstructor.GetDuplicateName(route.Name, project.DefaultRoutes);
                project.DefaultRoutes.Add(newRoute);
            }

            App.Current.Project.Save();
        }
예제 #9
0
        /// <summary>
        /// Duplicates zones
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            List <Zone> selectedZones = new List <Zone>();

            foreach (Zone zone in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedZones.Add(zone);
            }

            foreach (Zone zone in selectedZones)
            {
                Zone zn = zone.Clone() as Zone;
                zn.Name = DataObjectNamesConstructor.GetDuplicateName(zone.Name, project.Zones);
                project.Zones.Add(zn);
            }

            App.Current.Project.Save();
        }
        /// <summary>
        /// Change the name of the project.
        /// </summary>
        /// <param name="e">DataGridItemEventArgs.</param>
        private void _ChangeNewProjectName(DataGridItemEventArgs e)
        {
            // Check that item's name is null.
            if (!string.IsNullOrEmpty((e.Item as ProjectDataWrapper).Name))
            {
                return;
            }

            // Get new project name.
            (e.Item as ProjectDataWrapper).Name = DataObjectNamesConstructor.GetNewNameForProject();

            // Find TextBox inside the cell and select new name.
            Cell    currentCell = _InsertionRow.Cells[XceedGrid.CurrentContext.CurrentColumn];
            TextBox textBox     = XceedVisualTreeHelper.FindTextBoxInsideElement(currentCell);

            if (textBox != null)
            {
                textBox.SelectAll();
            }
        }
        /// <summary>
        /// Duplicates vehicles
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            List <VehicleSpecialty> selectedSpecialties = new List <VehicleSpecialty>();

            foreach (VehicleSpecialty specialty in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedSpecialties.Add(specialty);
            }

            foreach (VehicleSpecialty vehicleSpecialty in selectedSpecialties)
            {
                VehicleSpecialty vs = vehicleSpecialty.Clone() as VehicleSpecialty;
                vs.Name = DataObjectNamesConstructor.GetDuplicateName(vehicleSpecialty.Name, project.VehicleSpecialties);
                project.VehicleSpecialties.Add(vs);
            }

            App.Current.Project.Save();
        }
예제 #12
0
        /// <summary>
        /// Duplicates mobile devices
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            List <MobileDevice> selectedMobileDevices = new List <MobileDevice>();

            foreach (MobileDevice md in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedMobileDevices.Add(md);
            }

            foreach (MobileDevice mobileDevice in selectedMobileDevices)
            {
                MobileDevice md = mobileDevice.Clone() as MobileDevice;
                md.Name = DataObjectNamesConstructor.GetDuplicateName(mobileDevice.Name, project.MobileDevices);
                project.MobileDevices.Add(md);
            }

            App.Current.Project.Save();
        }
예제 #13
0
        /// <summary>
        /// Duplicates drivers
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            List <Driver> selectedDrivers = new List <Driver>();

            foreach (Driver driver in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedDrivers.Add(driver);
            }

            foreach (Driver driver in selectedDrivers)
            {
                Driver dr = driver.Clone() as Driver;
                dr.Name = DataObjectNamesConstructor.GetDuplicateName(driver.Name, project.Drivers);
                project.Drivers.Add(dr);
            }

            App.Current.Project.Save();
        }
예제 #14
0
        /// <summary>
        /// Change item's name.
        /// </summary>
        /// <param name="e">DataGridItemEventArgs.</param>
        private void _ChangeName(Xceed.Wpf.DataGrid.DataGridItemEventArgs e)
        {
            // Check that item's name is null.
            if (!string.IsNullOrEmpty((e.Item as Route).Name))
            {
                return;
            }

            // Get new item's name.
            (e.Item as Route).Name = DataObjectNamesConstructor.GetNameForNewDataObject(
                App.Current.Project.DefaultRoutes, e.Item as Route, true);

            // Find TextBox inside the cell and select new name.
            Cell    currentCell = _InsertionRow.Cells[XceedGrid.CurrentContext.CurrentColumn];
            TextBox textBox     = XceedVisualTreeHelper.FindTextBoxInsideElement(currentCell);

            if (textBox != null)
            {
                textBox.SelectAll();
            }
        }
예제 #15
0
        /// <summary>
        /// Change item's name.
        /// </summary>
        /// <param name="e">DataGridItemEventArgs.</param>
        private void _ChangeName(Xceed.Wpf.DataGrid.DataGridItemEventArgs e)
        {
            // Check that item's name is null.
            if (!string.IsNullOrEmpty((e.Item as Order).Name))
            {
                return;
            }

            (e.Item as Order).Name = DataObjectNamesConstructor.GetNameForNewDataObject(
                (IDataObjectCollection <Order>)_collectionSource.Source, e.Item as Order, false);

            Cell currentCell = _ordersInsertionRow.Cells[OrdersGrid.CurrentContext.CurrentColumn];

            // Find TextBox inside the cell and select new name.
            TextBox textBox = XceedVisualTreeHelper.FindTextBoxInsideElement(currentCell);

            if (textBox != null)
            {
                textBox.SelectAll();
            }
        }
예제 #16
0
        /// <summary>
        /// Duplicates barriers
        /// </summary>
        protected override void _Duplicate()
        {
            Project project = App.Current.Project;

            // get barriers collection from barrier manager
            ICollection <Barrier> barriers = App.Current.Project.Barriers.Search(App.Current.CurrentDate);

            List <Barrier> selectedBarriers = new List <Barrier>();

            foreach (Barrier barrier in ((ISupportSelection)ParentPage).SelectedItems)
            {
                selectedBarriers.Add(barrier);
            }

            foreach (Barrier barrier in selectedBarriers)
            {
                Barrier bar = barrier.Clone() as Barrier;
                bar.Name = DataObjectNamesConstructor.GetDuplicateName(barrier.Name, barriers);
                project.Barriers.Add(bar);
            }

            App.Current.Project.Save();
        }
예제 #17
0
        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);
        }