private void SolveServiceArea_Completed(object sender, RouteEventArgs e)
        {
            if (e.ServiceAreaPolygons != null)
            {
                foreach (Graphic g in e.ServiceAreaPolygons)
                {
                    g.Symbol = _saFillSymbol;
                    if (_graphicsLayer != null)
                    {
                        _graphicsLayer.Graphics.Add(g);
                    }
                }
            }

            if (e.ServiceAreaPolylines != null)
            {
                foreach (Graphic g in e.ServiceAreaPolylines)
                {
                    g.Symbol = _saLineSymbol;
                    if (_graphicsLayer != null)
                    {
                        _graphicsLayer.Graphics.Add(g);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void SolveServiceArea_Completed(object sender, RouteEventArgs e)
        {
            GraphicsLayer routeLayer = MyMap.Layers["MyServiceAreasGraphicsLayer"] as GraphicsLayer;

            routeLayer.Graphics.Clear();
            if (e.ServiceAreaPolygons != null)
            {
                foreach (Graphic g in e.ServiceAreaPolygons)
                {
                    SimpleFillSymbol symbol = new SimpleFillSymbol()
                    {
                        Fill            = new SolidColorBrush(Color.FromArgb(100, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))),
                        BorderBrush     = new SolidColorBrush(Colors.Transparent),
                        BorderThickness = 1
                    };

                    g.Symbol = symbol;
                    routeLayer.Graphics.Add(g);
                }
            }
            if (e.ServiceAreaPolylines != null)
            {
                foreach (Graphic g in e.ServiceAreaPolylines)
                {
                    SimpleLineSymbol symbol = new SimpleLineSymbol()
                    {
                        Color = new SolidColorBrush(Color.FromArgb(100, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))),
                        Width = 1,
                    };

                    g.Symbol = symbol;
                    routeLayer.Graphics.Add(g);
                }
            }
        }
Ejemplo n.º 3
0
        private static void Router_Jint(Client Sender, RouteEventArgs E)
        {
            string FilePath = Path.Combine(WebDirectory, E.Request.Path.TrimStart('/'));

            Boolean Exists    = File.Exists(FilePath);
            Boolean WithinDir = Path.GetFullPath(FilePath).Contains(WebDirectory);
            Boolean IsDir     = Directory.Exists(FilePath);

            if (!(Exists && WithinDir && !IsDir))
            {
                Sender.Send(Response.SendStatus(400));
                return;
            }

            //Sender.Send(Response.SendFile(FilePath, false));
            string JS = File.ReadAllText(E.Request.Path);

            Jint.Engine Engine = new Jint.Engine(cfg => cfg.AllowClr(typeof(Server).Assembly).CatchClrExceptions());

            Engine.SetValue("Request", E.Request);
            Engine.SetValue("Response", new Response());

            /* try
             * {
             *   Engine.Execute(JS);
             * }
             * catch (Exception Ex)
             * {
             *   Console.WriteLine("Uncaught exception! " + Ex.Message);
             *
             *   Req.Client.Send(Response.SendText("500 - Internal Error").GetBytes());
             * }*/
            Engine.Execute(JS);
        }
Ejemplo n.º 4
0
 public void RouteAdded(RouteEventArgs e)
 {
     if (_clear)
     {
         return;
     }
     _clear = true;
 }
        private void routeTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
            RouteResult   routeResult   = e.RouteResults[0];

            _directionsFeatureSet = routeResult.Directions;

            graphicsLayer.Graphics.Add(new Graphic()
            {
                Geometry = _directionsFeatureSet.MergedGeometry, Symbol = LayoutRoot.Resources["RouteSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            });
            TotalDistanceTextBlock.Text = string.Format("Total Distance: {0}", FormatDistance(_directionsFeatureSet.TotalLength, "miles"));
            TotalTimeTextBlock.Text     = string.Format("Total Time: {0}", FormatTime(_directionsFeatureSet.TotalTime));
            TitleTextBlock.Text         = _directionsFeatureSet.RouteName;

            int i = 1;

            foreach (Graphic graphic in _directionsFeatureSet.Features)
            {
                System.Text.StringBuilder text = new System.Text.StringBuilder();
                text.AppendFormat("{0}. {1}", i, graphic.Attributes["text"]);
                if (i > 1 && i < _directionsFeatureSet.Features.Count)
                {
                    string distance = FormatDistance(Convert.ToDouble(graphic.Attributes["length"]), "miles");
                    string time     = null;
                    if (graphic.Attributes.ContainsKey("time"))
                    {
                        time = FormatTime(Convert.ToDouble(graphic.Attributes["time"]));
                    }
                    if (!string.IsNullOrEmpty(distance) || !string.IsNullOrEmpty(time))
                    {
                        text.Append(" (");
                    }
                    text.Append(distance);
                    if (!string.IsNullOrEmpty(distance) && !string.IsNullOrEmpty(time))
                    {
                        text.Append(", ");
                    }
                    text.Append(time);
                    if (!string.IsNullOrEmpty(distance) || !string.IsNullOrEmpty(time))
                    {
                        text.Append(")");
                    }
                }
                TextBlock textBlock = new TextBlock()
                {
                    Text = text.ToString(), Tag = graphic, Margin = new Thickness(4), Cursor = Cursors.Hand
                };
                textBlock.MouseLeftButtonDown += new MouseButtonEventHandler(directionsSegment_MouseLeftButtonDown);
                DirectionsStackPanel.Children.Add(textBlock);
                i++;
            }
            MyMap.ZoomTo(Expand(_directionsFeatureSet.Extent));
        }
Ejemplo n.º 6
0
        private void routeTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            GraphicsLayer routeLayer  = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
            RouteResult   routeResult = e.RouteResults[0];

            routeResult.Route.Symbol = LayoutRoot.Resources["RouteSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;

            routeLayer.Graphics.Clear();
            Graphic lastRoute = routeResult.Route;

            routeLayer.Graphics.Add(lastRoute);
        }
        void SolveClosestFacility_Completed(object sender, RouteEventArgs e)
        {
            routeGraphicsLayer.Graphics.Clear();

            if (e.RouteResults != null)
            {
                foreach (RouteResult route in e.RouteResults)
                {
                    Graphic g = route.Route;
                    routeGraphicsLayer.Graphics.Add(g);
                }
            }
        }
        private void MyRouteTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            routeGraphicsLayer.Graphics.Clear();

            RouteResult routeResult = e.RouteResults[0];

            Graphic lastRoute = routeResult.Route;

            decimal totalTime = (decimal)lastRoute.Attributes["Total_TravelTime"];
            TotalTimeTextBlock.Text = string.Format("Total time: {0} minutes", totalTime.ToString("#0.000"));

            routeGraphicsLayer.Graphics.Add(lastRoute);
        }
        private void MyRouteTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            routeGraphicsLayer.Graphics.Clear();

            RouteResult routeResult = e.RouteResults[0];

            Graphic lastRoute = routeResult.Route;

            decimal totalTime = (decimal)lastRoute.Attributes["Total_TravelTime"];

            TotalTimeTextBlock.Text = string.Format("Total time: {0} minutes", totalTime.ToString("#0.000"));

            routeGraphicsLayer.Graphics.Add(lastRoute);
        }
Ejemplo n.º 10
0
        private void MyRouteTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            GraphicsLayer routeGraphicsLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
            routeGraphicsLayer.Graphics.Clear();

            RouteResult routeResult = e.RouteResults[0];
            routeResult.Route.Symbol = LayoutRoot.Resources["RouteSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;

            Graphic lastRoute = routeResult.Route;

            decimal totalTime = (decimal)lastRoute.Attributes["Total_TravelTime"];
            string tip = string.Format("Total Time: {0} minutes", totalTime.ToString("#0.00"));
            TimeText.Text = tip;

            routeGraphicsLayer.Graphics.Add(lastRoute);
        }
        private void MyRouteTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            routeGraphicsLayer.Graphics.Clear();

            RouteResult routeResult = e.RouteResults[0];

            Graphic lastRoute = routeResult.Route;

            decimal totalTime = (decimal)lastRoute.Attributes["Total_TravelTime"];
            TimeSpan totalTimeSpan = TimeSpan.FromMinutes(Decimal.ToDouble(totalTime));
            TotalTimeTextBlock.Text = totalTimeSpan.Minutes.ToString();

            decimal totalDistance = (decimal)lastRoute.Attributes["Shape_Length"];
            // convert meters into miles
            double totalDistanceMiles = Decimal.ToDouble(totalDistance) * 0.0006213700922;
            TotalDistanceTextBlock.Text = totalDistanceMiles.ToString("#0.0");

            routeGraphicsLayer.Graphics.Add(lastRoute);
        }
Ejemplo n.º 12
0
        private void MyRouteTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            GraphicsLayer routeGraphicsLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;

            routeGraphicsLayer.Graphics.Clear();

            RouteResult routeResult = e.RouteResults[0];

            routeResult.Route.Symbol = LayoutRoot.Resources["RouteSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;

            Graphic lastRoute = routeResult.Route;

            decimal totalTime = (decimal)lastRoute.Attributes["Total_TravelTime"];
            string  tip       = string.Format("Total Time: {0} minutes", totalTime.ToString("#0.00"));

            TimeText.Text = tip;

            routeGraphicsLayer.Graphics.Add(lastRoute);
        }
Ejemplo n.º 13
0
        private void MyRouteTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            routeGraphicsLayer.Graphics.Clear();

            RouteResult routeResult = e.RouteResults[0];

            Graphic lastRoute = routeResult.Route;

            decimal  totalTime     = (decimal)lastRoute.Attributes["Total_TravelTime"];
            TimeSpan totalTimeSpan = TimeSpan.FromMinutes(Decimal.ToDouble(totalTime));

            TotalTimeTextBlock.Text = totalTimeSpan.Minutes.ToString();

            decimal totalDistance = (decimal)lastRoute.Attributes["Shape_Length"];
            // convert meters into miles
            double totalDistanceMiles = Decimal.ToDouble(totalDistance) * 0.0006213700922;

            TotalDistanceTextBlock.Text = totalDistanceMiles.ToString("#0.0");

            routeGraphicsLayer.Graphics.Add(lastRoute);
        }
        private void routeTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
            RouteResult routeResult = e.RouteResults[0];
            _directionsFeatureSet = routeResult.Directions;

            graphicsLayer.Graphics.Add(new Graphic() { Geometry = _directionsFeatureSet.MergedGeometry, Symbol = LayoutRoot.Resources["RouteSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol });
            TotalDistanceTextBlock.Text = string.Format("Total Distance: {0}", FormatDistance(_directionsFeatureSet.TotalLength, "miles"));
            TotalTimeTextBlock.Text = string.Format("Total Time: {0}", FormatTime(_directionsFeatureSet.TotalTime));
            TitleTextBlock.Text = _directionsFeatureSet.RouteName;

            int i = 1;
            foreach (Graphic graphic in _directionsFeatureSet.Features)
            {
                System.Text.StringBuilder text = new System.Text.StringBuilder();
                text.AppendFormat("{0}. {1}", i, graphic.Attributes["text"]);
                if (i > 1 && i < _directionsFeatureSet.Features.Count)
                {
                    string distance = FormatDistance(Convert.ToDouble(graphic.Attributes["length"]), "miles");
                    string time = null;
                    if (graphic.Attributes.ContainsKey("time"))
                    {
                        time = FormatTime(Convert.ToDouble(graphic.Attributes["time"]));
                    }
                    if (!string.IsNullOrEmpty(distance) || !string.IsNullOrEmpty(time))
                        text.Append(" (");
                    text.Append(distance);
                    if (!string.IsNullOrEmpty(distance) && !string.IsNullOrEmpty(time))
                        text.Append(", ");
                    text.Append(time);
                    if (!string.IsNullOrEmpty(distance) || !string.IsNullOrEmpty(time))
                        text.Append(")");
                }
                TextBlock textBlock = new TextBlock() { Text = text.ToString(), Tag = graphic, Margin = new Thickness(4), Cursor = Cursors.Hand };
                textBlock.MouseLeftButtonDown += new MouseButtonEventHandler(directionsSegment_MouseLeftButtonDown);
                DirectionsStackPanel.Children.Add(textBlock);
                i++;
            }
            MyMap.ZoomTo(Expand(_directionsFeatureSet.Extent));
        }
        private void SolveServiceArea_Completed(object sender, RouteEventArgs e)
        {
            GraphicsLayer routeLayer = MyMap.Layers["MyServiceAreasGraphicsLayer"] as GraphicsLayer;
            routeLayer.Graphics.Clear();
            if (e.ServiceAreaPolygons != null)
            {
                foreach (Graphic g in e.ServiceAreaPolygons)
                {
                    SimpleFillSymbol symbol = new SimpleFillSymbol()
                    {
                        Fill = new SolidColorBrush(Color.FromArgb(100, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))),
                        BorderBrush = new SolidColorBrush(Colors.Transparent),
                        BorderThickness = 1
                    };

                    g.Symbol = symbol;
                    routeLayer.Graphics.Add(g);
                }
            }
            if (e.ServiceAreaPolylines != null)
            {
                foreach (Graphic g in e.ServiceAreaPolylines)
                {
                    SimpleLineSymbol symbol = new SimpleLineSymbol()
                    {
                        Color = new SolidColorBrush(Color.FromArgb(100, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))),
                        Width = 1,
                    };

                    g.Symbol = symbol;
                    routeLayer.Graphics.Add(g);
                }
            }
        }
        void SolveClosestFacility_Completed(object sender, RouteEventArgs e)
        {
            routeGraphicsLayer.Graphics.Clear();

            if (e.RouteResults != null)
            {
                foreach (RouteResult route in e.RouteResults)
                {
                    Graphic g = route.Route;
                    routeGraphicsLayer.Graphics.Add(g);
                }
            }
        }
        // ***********************************************************************************
        // * Add a from location point on the map... closest facility will be found for this location
        // ***********************************************************************************
        void SolveClosestFacility_Completed(object sender, RouteEventArgs e)
        {
            _routesGraphicsLayer.Graphics.Clear();
            _routeLabelsGraphicsLayer.Graphics.Clear();
            if (e.RouteResults != null)
            {
                int i = 0;
                Random randomGen = new Random();
                foreach (RouteResult route in e.RouteResults)
                {
                    Graphic routeGraphic = route.Route;

                    Color color = createRandomColor(randomGen);
                    randomGen.Next(255);
                   
                    routeGraphic.Symbol = new SimpleLineSymbol() { Width = 5, Color = new SolidColorBrush(color) };
                    _routesGraphicsLayer.Graphics.Add(routeGraphic);

                    //Route rank identification symbols...
                    client.Geometry.Polyline pl = (client.Geometry.Polyline)routeGraphic.Geometry;
                    int index = pl.Paths[0].Count / 4;
             
                    Graphic squareGraphic = new Graphic();
                    client.Geometry.PointCollection ptColl = pl.Paths[pl.Paths.Count/2];
                    squareGraphic.Geometry = ptColl[ptColl.Count / 2];

                    //this is the white outline... 
                    SimpleMarkerSymbol sms = new SimpleMarkerSymbol()
                    {
                        Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square,
                        Size = 24,
                        Color = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                    };
                    squareGraphic.Symbol = sms;
                    _routeLabelsGraphicsLayer.Graphics.Add(squareGraphic);

                    //purple rectangle behind the rank number
                    Graphic squareGraphic2 = new Graphic();
                    SimpleMarkerSymbol sms2 = new SimpleMarkerSymbol()
                    {
                        Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square,
                        Size = 20,
                        Color = new SolidColorBrush(Color.FromRgb(0,0,139))
                    };
                    squareGraphic2.Symbol = sms2;
                    squareGraphic2.Geometry = ptColl[ptColl.Count / 2];
                    _routeLabelsGraphicsLayer.Graphics.Add(squareGraphic2);

                    //rank number text symbol
                    Graphic routeRankGraphic = new Graphic();
                    routeRankGraphic.Geometry = ptColl[ptColl.Count / 2];

                    TextSymbol routeRankSymbol = new TextSymbol(); 
                    routeRankSymbol.FontFamily = new FontFamily("Arial Black");
                    //Modified offsetx from -4 to 5
                    routeRankSymbol.OffsetX = 5;
                    routeRankSymbol.OffsetY = 10;

                    routeRankSymbol.Text = e.RouteResults[i].Directions.RouteID.ToString();
                    routeRankSymbol.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));

                    routeRankSymbol.FontSize = 16;
                    routeRankGraphic.Symbol = routeRankSymbol;

                    _routeLabelsGraphicsLayer.Graphics.Add(routeRankGraphic);

                    i++;
                }

                //zoom to the map 
                if (chkZoomToMap.IsChecked ?? false)
                    _mapWidget.Map.Extent = _routesGraphicsLayer.FullExtent; 

                //Create and Display Closest Facilities List window...
                _result = new FindCloseFacilityResultView(this, e.RouteResults, _mapWidget);
                _mapWidget.SetToolbar(_result); 
            }
        }
Ejemplo n.º 18
0
 public void RouteAdded(RouteEventArgs e)
 {
     name      = e.Route.Name;
     Available = true;
 }
        // ***********************************************************************************
        // * Add a from location point on the map... closest facility will be found for this location
        // ***********************************************************************************
        void SolveClosestFacility_Completed(object sender, RouteEventArgs e)
        {
            _routesGraphicsLayer.Graphics.Clear();
            _routeLabelsGraphicsLayer.Graphics.Clear();
            if (e.RouteResults != null)
            {
                int    i         = 0;
                Random randomGen = new Random();
                foreach (RouteResult route in e.RouteResults)
                {
                    Graphic routeGraphic = route.Route;

                    Color color = createRandomColor(randomGen);
                    randomGen.Next(255);

                    routeGraphic.Symbol = new SimpleLineSymbol()
                    {
                        Width = 5, Color = new SolidColorBrush(color)
                    };
                    _routesGraphicsLayer.Graphics.Add(routeGraphic);

                    //Route rank identification symbols...
                    client.Geometry.Polyline pl = (client.Geometry.Polyline)routeGraphic.Geometry;
                    int index = pl.Paths[0].Count / 4;

                    Graphic squareGraphic = new Graphic();
                    client.Geometry.PointCollection ptColl = pl.Paths[pl.Paths.Count / 2];
                    squareGraphic.Geometry = ptColl[ptColl.Count / 2];

                    //this is the white outline...
                    SimpleMarkerSymbol sms = new SimpleMarkerSymbol()
                    {
                        Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square,
                        Size  = 24,
                        Color = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                    };
                    squareGraphic.Symbol = sms;
                    _routeLabelsGraphicsLayer.Graphics.Add(squareGraphic);

                    //purple rectangle behind the rank number
                    Graphic            squareGraphic2 = new Graphic();
                    SimpleMarkerSymbol sms2           = new SimpleMarkerSymbol()
                    {
                        Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square,
                        Size  = 20,
                        Color = new SolidColorBrush(Color.FromRgb(0, 0, 139))
                    };
                    squareGraphic2.Symbol   = sms2;
                    squareGraphic2.Geometry = ptColl[ptColl.Count / 2];
                    _routeLabelsGraphicsLayer.Graphics.Add(squareGraphic2);

                    //rank number text symbol
                    Graphic routeRankGraphic = new Graphic();
                    routeRankGraphic.Geometry = ptColl[ptColl.Count / 2];

                    TextSymbol routeRankSymbol = new TextSymbol();
                    routeRankSymbol.FontFamily = new FontFamily("Arial Black");
                    //Modified offsetx from -4 to 5
                    routeRankSymbol.OffsetX = 5;
                    routeRankSymbol.OffsetY = 10;

                    routeRankSymbol.Text       = e.RouteResults[i].Directions.RouteID.ToString();
                    routeRankSymbol.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));

                    routeRankSymbol.FontSize = 16;
                    routeRankGraphic.Symbol  = routeRankSymbol;

                    _routeLabelsGraphicsLayer.Graphics.Add(routeRankGraphic);

                    i++;
                }

                //zoom to the map
                if (chkZoomToMap.IsChecked ?? false)
                {
                    _mapWidget.Map.Extent = _routesGraphicsLayer.FullExtent;
                }

                //Create and Display Closest Facilities List window...
                _result = new FindCloseFacilityResultView(this, e.RouteResults, _mapWidget);
                _mapWidget.SetToolbar(_result);
            }
        }
Ejemplo n.º 20
0
 public void RouteAdded(RouteEventArgs e)
 {
 }
Ejemplo n.º 21
0
        private static void Router_GetPublic(Client Sender, RouteEventArgs E)
        {
            string FilePath     = Path.Combine(WebDirectory, E.Request.Path.TrimStart('/'));
            string RelativePath = Path.GetFullPath(FilePath).Replace(WebDirectory, "").Replace("\\", "/");

            string DefaultHTML = @"
                <!DOCTYPE html>
                <html lang='en'>
                <head>
                    <title>{title}</title>
                    <style>{style}</style>
                </head>
                <body>{body}</body>
            </html>";
            string StyleHTML   = "body {font-family: sans-serif;}";

            Boolean Exists    = File.Exists(FilePath);
            Boolean WithinDir = Path.GetFullPath(FilePath).Contains(WebDirectory);
            Boolean IsDir     = Directory.Exists(FilePath);

            // If request for a file and within a servable folder
            if (Exists && WithinDir && !IsDir)
            {
                Sender.Send(Response.SendFile(FilePath, false));
            }
            else if (!Exists && WithinDir && IsDir)
            {
                // If request for a directory, try finding index files
                string IndexPath = Path.GetFullPath(Path.Combine(FilePath, "index.html"));
                if (File.Exists(IndexPath))
                {
                    Sender.Send(Response.SendFile(IndexPath, false));
                }

                string Title    = $"Directory Listing for {RelativePath}";
                string BodyHTML = $"<h1>{Title}</h1><ul>";

                List <string> Listing = Directory.EnumerateDirectories(FilePath).ToList();
                Listing.AddRange(Directory.EnumerateFiles(FilePath));
                Listing.Sort();

                foreach (string Item in Listing)
                {
                    char   Seperator = Path.DirectorySeparatorChar;
                    string LocalPath = Path.GetFullPath(Item);
                    string Ref       = LocalPath.Replace(WebDirectory, "");
                    if (Seperator.ToString() != "/")
                    {
                        Ref = Ref.Replace(Seperator.ToString(), "/");
                    }
                    string Name = LocalPath.Replace(FilePath, "");

                    if (Directory.Exists(Item))
                    {
                        Name += Seperator.ToString();
                    }
                    Name      = Name.TrimStart(Seperator.ToString().ToCharArray());
                    BodyHTML += $"<li><a href=\"{Ref}\">{Name}</a></li>";
                }

                if (Listing.Count == 0)
                {
                    BodyHTML += "<p>This is an empty directory.</p>";
                }

                BodyHTML += "</ul>";

                Sender.Send(Response.SendHtml(DefaultHTML
                                              .Replace("{title}", Title)
                                              .Replace("{style}", StyleHTML)
                                              .Replace("{body}", BodyHTML)
                                              ));
            }
            // If the file exists or doesn't, we should always forbid any access
            // when not within the servable directory
            else if (!WithinDir)
            {
                string   Title       = "403 - Forbidden";
                Response ResponseObj = Response.SendStatus(403);
                ResponseObj.SetHtml(
                    DefaultHTML
                    .Replace("{title}", Title)
                    .Replace("{style}", StyleHTML)
                    .Replace("{body}", $"<h1>{Title}</h1>")
                    );

                Sender.Send(ResponseObj);
            }
            // If the file, or directory doesn't exist inside the servable directory
            else
            {
                // !Exists && !WithinDir, or !Exists && WithinDir (and !IsDir?)
                string   Title       = "404 - Not Found";
                Response ResponseObj = Response.SendStatus(404);
                ResponseObj.SetHtml(
                    DefaultHTML
                    .Replace("{title}", Title)
                    .Replace("{style}", StyleHTML)
                    .Replace("{body}", $"<h1>{Title}</h1>")
                    );

                Sender.Send(ResponseObj);
            }
        }
        private void SolveServiceArea_Completed(object sender, RouteEventArgs e)
        {
            if (e.ServiceAreaPolygons != null)
              {
            foreach (Graphic g in e.ServiceAreaPolygons)
            {
              g.Symbol = _saFillSymbol;
              if (_graphicsLayer != null)
            _graphicsLayer.Graphics.Add(g);
            }
              }

              if (e.ServiceAreaPolylines != null)
              {
            foreach (Graphic g in e.ServiceAreaPolylines)
            {
              g.Symbol = _saLineSymbol;
              if (_graphicsLayer != null)
            _graphicsLayer.Graphics.Add(g);
            }
              }
        }
Ejemplo n.º 23
0
 public void RouteDeleted(RouteEventArgs e)
 {
 }
Ejemplo n.º 24
0
 private void RouteSolvedComplete(object sender, RouteEventArgs a)
 {
     try
     {
         routeTask.SolveCompleted -= RouteSolvedComplete;
         WebMercator webMercator = new WebMercator();
         RoutingEventArgs routingEvent = new RoutingEventArgs();
         ESRI.ArcGIS.Client.Tasks.RouteResult routeResult = a.RouteResults[0];
         routeResult.Route.Symbol = lineRouteSymbol;
         routingEvent.RoutingResult.RouteGraphic = routeResult.Route;
         SpatialReference initialSpatialReference =
         routingEvent.RoutingResult.RouteGraphic.Geometry.SpatialReference;
         routingEvent.RoutingResult.RouteGraphic.Geometry =
         webMercator.FromGeographic(routeResult.Route.Geometry);
         routingEvent.RoutingResult.RouteName = a.UserState as string;
         routingEvent.RoutingResult.RouteDirections = routeResult.Directions;
         foreach (var item in routingEvent.RoutingResult.RouteDirections)
         {
             item.Geometry.SpatialReference = initialSpatialReference;
             item.Geometry = webMercator.FromGeographic(item.Geometry);
         }
         OnRoutingCalcComplete(routingEvent);
     }
     catch (Exception ex)
     {
         messageBoxCustom.Show(String.Format("RouteSolvedComplete /{0}", ex.Message),
             GisTexts.SevereError,
             MessageBoxCustomEnum.MessageBoxButtonCustom.Ok);
     }
 }
        private void routeTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            GraphicsLayer routeLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
            RouteResult routeResult = e.RouteResults[0];
            routeResult.Route.Symbol = LayoutRoot.Resources["RouteSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;

            routeLayer.Graphics.Clear();
            Graphic lastRoute = routeResult.Route;

            routeLayer.Graphics.Add(lastRoute);
        }