public DirectionsResultView(MapWidget mapWidget, FindCloseFacilityResultView fcfResultView, RouteResult routeResult, FindClosestResourceToolbar fcrToolbar)
        {
            InitializeComponent();
            base.DataContext = this;

            // Store a reference to the MapWidget that the toolbar has been installed to.
            _mapWidget = mapWidget;

            _closestFaculityResult = fcfResultView;
            _findClosestFacilityToolbar = fcrToolbar;

            RouteName = routeResult.Directions.RouteName;
            Summary = string.Format("{0:F1} {1}, {2}", routeResult.Directions.TotalLength, "miles", FormatTime(routeResult.Directions.TotalTime));

            List<Graphic> features = new List<Graphic>(routeResult.Directions.Features);
            features.RemoveAt(0);

            List<ManeuverViewModel> directionElements = new List<ManeuverViewModel>();
            Graphic previous = null;
            int i = 1;

            foreach (var next in features)
            {
                ManeuverViewModel maneuver = new ManeuverViewModel(previous, next, i++);
                maneuver.Graphic.MouseLeftButtonDown += Graphic_MouseLeftButtonDown;

                directionElements.Add(maneuver);
                previous = next;
            }

            Maneuvers = directionElements;
        }
Exemple #2
0
        public DirectionsResultView(MapWidget mapWidget, FindCloseFacilityResultView fcfResultView, RouteResult routeResult, FindClosestResourceToolbar fcrToolbar)
        {
            InitializeComponent();
            base.DataContext = this;

            // Store a reference to the MapWidget that the toolbar has been installed to.
            _mapWidget = mapWidget;

            _closestFaculityResult      = fcfResultView;
            _findClosestFacilityToolbar = fcrToolbar;


            RouteName = routeResult.Directions.RouteName;
            Summary   = string.Format("{0:F1} {1}, {2}", routeResult.Directions.TotalLength, "miles", FormatTime(routeResult.Directions.TotalTime));

            List <Graphic> features = new List <Graphic>(routeResult.Directions.Features);

            features.RemoveAt(0);

            List <ManeuverViewModel> directionElements = new List <ManeuverViewModel>();
            Graphic previous = null;
            int     i        = 1;

            foreach (var next in features)
            {
                ManeuverViewModel maneuver = new ManeuverViewModel(previous, next, i++);
                maneuver.Graphic.MouseLeftButtonDown += Graphic_MouseLeftButtonDown;

                directionElements.Add(maneuver);
                previous = next;
            }

            Maneuvers = directionElements;
        }
Exemple #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // When the user clicks the map tool button, begin installing zoom code.
            // Ensure the tool has a valid map to work with.
            if (ResourcesDatasource == null)
            {
                return;
            }

            if (MapWidget != null && MapWidget.Map != null && ResourcesDatasource != null && ResourceTypeField != null && BarriersDataSources != null)
            {
                // Provide a way for the user to cancel the operation, by installing a temporary toolbar.
                // This also prevents other tools from being used in the meantime.
                _findClosestResourceToolbar = new FindClosestResourceToolbar(MapWidget, ResourcesDatasource, ResourceTypeField, BarriersDataSources);
                MapWidget.SetToolbar(_findClosestResourceToolbar);
            }
            else
            {
                MessageBox.Show("Please configure this tool first!", "Error");
                return;
            }

            // Set the Checked property of the ToggleButton to false after work is complete.
            ToggleButton.IsChecked = false;
        }
        // ***********************************************************************************
        // * Initialize Find Closest Facility Result View
        // ***********************************************************************************
        public FindCloseFacilityResultView(FindClosestResourceToolbar findClosestToolbar, RouteResult[] routeResults, MapWidget mapWidget)
        {
            InitializeComponent();

            base.DataContext = this;

            // Store a reference to the MapWidget that the toolbar has been installed to.
            _mapWidget = mapWidget;

            _dirSummary             = new DirectionSummary();
            _dirSummary.From        = "From";
            _dirSummary.To          = "To";
            _dirSummary.FieldType   = "FieldType";
            _dirSummary.Rank        = "Rank";
            _dirSummary.TotalTime   = "Total Time";
            _dirSummary.TotalLength = "Total Length";
            _directions.Add(_dirSummary);

            _closestFacilityToolbar = findClosestToolbar;

            // add each route result to the result dialog.
            foreach (RouteResult routeResult in routeResults)
            {
                DirectionsFeatureSet directionsFS = routeResult.Directions;
                string routeName = directionsFS.RouteName;
                int    j         = routeName.IndexOf("-");

                _dirSummary               = new DirectionSummary();
                _dirSummary.From          = routeName.Substring(0, j - 1);
                _dirSummary.To            = routeName.Substring(j + 2);
                _dirSummary.FieldType     = _closestFacilityToolbar.FacilityType;
                _dirSummary.Rank          = directionsFS.RouteID.ToString();
                _dirSummary.TotalTime     = directionsFS.TotalDriveTime.ToString("0.0") + " minutes";
                _dirSummary.TotalLength   = directionsFS.TotalLength.ToString("0.0") + " miles";
                _dirSummary.SelectedRoute = routeResult;
                _directions.Add(_dirSummary);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // When the user clicks the map tool button, begin installing zoom code.
            // Ensure the tool has a valid map to work with.
            if (ResourcesDatasource == null)
                return;
            
            if (MapWidget != null && MapWidget.Map != null && ResourcesDatasource != null && ResourceTypeField != null && BarriersDataSources != null)
            {
                // Provide a way for the user to cancel the operation, by installing a temporary toolbar.
                // This also prevents other tools from being used in the meantime.
                _findClosestResourceToolbar = new FindClosestResourceToolbar(MapWidget, ResourcesDatasource, ResourceTypeField, BarriersDataSources);
                MapWidget.SetToolbar(_findClosestResourceToolbar);
            }
            else
            {
                MessageBox.Show("Please configure this tool first!", "Error");
                return;
            }

            // Set the Checked property of the ToggleButton to false after work is complete.
            ToggleButton.IsChecked = false;
        }
        // ***********************************************************************************
        // * Initialize Find Closest Facility Result View
        // ***********************************************************************************
        public FindCloseFacilityResultView(FindClosestResourceToolbar findClosestToolbar, RouteResult[] routeResults, MapWidget mapWidget)
        {
            InitializeComponent();

            base.DataContext = this;

            // Store a reference to the MapWidget that the toolbar has been installed to.
            _mapWidget = mapWidget;

            _dirSummary = new DirectionSummary();
            _dirSummary.From = "From";
            _dirSummary.To = "To";
            _dirSummary.FieldType = "FieldType";
            _dirSummary.Rank = "Rank";
            _dirSummary.TotalTime = "Total Time";
            _dirSummary.TotalLength = "Total Length";
            _directions.Add(_dirSummary);

            _closestFacilityToolbar = findClosestToolbar;

            // add each route result to the result dialog.
            foreach(RouteResult routeResult in routeResults)
            {
                DirectionsFeatureSet directionsFS = routeResult.Directions;
                string routeName = directionsFS.RouteName;
                int j = routeName.IndexOf("-");

                _dirSummary = new DirectionSummary();
                _dirSummary.From = routeName.Substring(0, j - 1);
                _dirSummary.To =  routeName.Substring(j + 2);
                _dirSummary.FieldType = _closestFacilityToolbar.FacilityType;
                _dirSummary.Rank = directionsFS.RouteID.ToString();
                _dirSummary.TotalTime = directionsFS.TotalDriveTime.ToString("0.0") + " minutes";
                _dirSummary.TotalLength = directionsFS.TotalLength.ToString("0.0") + " miles";
                _dirSummary.SelectedRoute = routeResult;
                _directions.Add(_dirSummary);
            }
        }