Example #1
0
        /// <summary>
        /// 利用常用简单要素样式枚举常量,创建简单要素渲染器
        /// </summary>
        /// <param name="symbol">常用简单要素样式</param>
        /// <param name="width">渲染样式大小(点大小、线宽度、面外框宽度)</param>
        /// <returns>简单要素渲染器</returns>
        public IFeatureRenderer CreateSimpleFeatureRenderer(EnumSimpleSymbol symbol, int width = 5)
        {
            ISimpleRenderer renderer = new SimpleRenderer();

            renderer.Symbol = new SimpleSymbolFactory().CreateSimpleSymbol(symbol, width);
            return(renderer as IFeatureRenderer);
        }
        private void DrawModel()
        {
            ModelMarkerSymbol mms = new ModelMarkerSymbol();

            mms.SourceUri = "Data/M-14/M-14.obj";
            mms.Scale     = 1000;

            SimpleRenderer sr = new SimpleRenderer();

            sr.Symbol = mms;

            GraphicsOverlay graphicsOverlay = new GraphicsOverlay()
            {
                RenderingMode   = GraphicsRenderingMode.Dynamic,
                Renderer        = sr,
                SceneProperties = new LayerSceneProperties()
                {
                    SurfacePlacement = SurfacePlacement.Relative
                }
            };

            MapPoint mp = new MapPoint(-122.4167, 37.7833, 55000);

            Graphic gm = new Graphic(mp);

            graphicsOverlay.Graphics.Add(gm);

            this.sceneView.GraphicsOverlays.Add(graphicsOverlay);
        }
Example #3
0
        public LaneMarker(SimpleRenderer renderer)
        {
            if (Game.GameState != GameState.Init)
            {
                return;
            }

            this.renderer = renderer;
            var ratio = (float)Drawing.Width / Drawing.Height;

            if (Math.Abs(ratio - (16f / 9)) < 0.1)
            {
                this.ratioAdjustment = 0;
            }
            else if (Math.Abs(ratio - (16f / 10)) < 0.1)
            {
                this.ratioAdjustment = 1;
            }
            else
            {
                this.ratioAdjustment = 2;
            }

            Game.OnUpdate      += this.OnUpdate;
            Game.OnWndProc     += this.OnWndProc;
            this.renderer.Draw += this.OnDraw;
        }
Example #4
0
        private static void MapUsingSimpleMarkerRenderer()
        {
            string layerName = CboLayers.GetSelectedLayer();
            ILayer layer     = GetLayerByName(layerName);

            string     colorName   = CboColors.GetSelectedColor();
            ICmykColor markerColor = ColorbrewerExtension.GetSingleCMYKColor();

            ISimpleMarkerSymbol marker = new SimpleMarkerSymbol();

            marker.Style = esriSimpleMarkerStyle.esriSMSCircle;
            marker.Color = markerColor;
            marker.Size  = 5;

            ISimpleRenderer renderer = new SimpleRenderer();

            renderer.Symbol = marker as ISymbol;
            renderer.Label  = layer.Name;

            IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer;

            gFLayer.Renderer = renderer as IFeatureRenderer;
            IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;
            IMap        map   = mxDoc.FocusMap;

            mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,
                                            gFLayer, mxDoc.ActiveView.Extent);
            mxDoc.UpdateContents();
        }
Example #5
0
        public void TestUsingConsole()
        {
            var             sr  = new SimpleRenderer();
            var             con = new ConsoleLoggerProvider((x, y) => true, false, true);
            ILoggerProvider alp = new AugmentingLoggerProvider(con, sr, null)
            {
                IncludeScopes = true
            };
            var augged = alp.CreateLogger("tests");

            augged.LogInformation("Hello world.");
            using (augged.BeginScope("tagscope"))
            {
                augged.LogInformation("Hello world from within.");
            }

            using (augged.BeginScope(new Dictionary <string, object>()
            {
                ["CustomerId"] = 4444,
                ["OrderId"] = 777
            }))
            {
                augged.LogInformation("Searching for order status");
            }
        }
 public static Symbol GetDefaultSymbol(this IRenderer renderer)
 {
     if (renderer != null)
     {
         SimpleRenderer simpleRenderer = renderer as SimpleRenderer;
         if (simpleRenderer != null)
         {
             return(simpleRenderer.Symbol);
         }
         else
         {
             ClassBreaksRenderer classBreaksRenderer = renderer as ClassBreaksRenderer;
             if (classBreaksRenderer != null)
             {
                 return(classBreaksRenderer.DefaultSymbol);
             }
             else
             {
                 UniqueValueRenderer uniqueValueRenderer = renderer as UniqueValueRenderer;
                 if (uniqueValueRenderer != null)
                 {
                     return(uniqueValueRenderer.DefaultSymbol);
                 }
             }
         }
     }
     return(null);
 }
        private static IRenderer CreateDefaultRenderer(GeometryType geomType)
        {
            SimpleRenderer renderer = new SimpleRenderer();

            renderer.Symbol = CreateDefaultSymbol(geomType);
            return(renderer);
        }
Example #8
0
        public static ISimpleRenderer GetDirectionalMaskRenderer(GCDCore.Project.Masks.DirectionalMask mask)
        {
            RgbColor rgb = new RgbColor();

            rgb.Red   = 0;
            rgb.Blue  = 0;
            rgb.Green = 0;

            ISimpleFillSymbol symbol = new SimpleFillSymbol();

            symbol.Style         = esriSimpleFillStyle.esriSFSHollow;
            symbol.Outline.Width = 1.0;
            ILineSymbol pLineSymbol = symbol.Outline;

            pLineSymbol.Color = rgb;
            pLineSymbol.Width = 1;
            symbol.Outline    = pLineSymbol;

            // These properties should be set prior to adding values
            ISimpleRenderer pRender = new SimpleRenderer();

            pRender.Label  = "Directional Mask";
            pRender.Symbol = symbol as ISymbol;

            return(pRender);
        }
        /// <summary>
        /// Handle FeatureLayer Initialization Event
        /// </summary>
        private void FeatureLayer_Initialized(object sender, EventArgs e)
        {
            FeatureLayer     fLayer    = sender as FeatureLayer;
            EditFeatureLayer editLayer = widgetConfig.EditableLayers.FirstOrDefault(layer => fLayer.ID.Equals(string.Format("edit_{0}", layer.ID.ToString())));

            if (string.IsNullOrEmpty(editLayer.OutFields) || editLayer.OutFields == "*")
            {
                foreach (Field f in fLayer.LayerInfo.Fields)
                {
                    fLayer.OutFields.Add(f.Name);
                }
            }
            else
            {
                string[] fields = editLayer.OutFields.Split(',');
                foreach (string field in fields)
                {
                    fLayer.OutFields.Add(field);
                }
            }

            if (editLayer != null)
            {
                SymbolTypeGroup typeGroup = new SymbolTypeGroup();
                typeGroup.LayerID         = fLayer.ID;
                typeGroup.LayerName       = editLayer.Title;
                typeGroup.LayerVisibility = editLayer.VisibleInitial;
                symbolTypeGroups.Add(typeGroup);

                if (fLayer.LayerInfo.Renderer is SimpleRenderer)
                {
                    SimpleRenderer renderer   = fLayer.LayerInfo.Renderer as SimpleRenderer;
                    SymbolType     symbolType = new SymbolType(fLayer.LayerInfo.Name, null, renderer.Symbol, "");
                    typeGroup.SymbolTypes.Add(symbolType);
                }
                if (fLayer.LayerInfo.Renderer is UniqueValueRenderer)
                {
                    UniqueValueRenderer renderer = fLayer.LayerInfo.Renderer as UniqueValueRenderer;
                    foreach (UniqueValueInfo valueInfo in renderer.Infos)
                    {
                        SymbolType symbolType = new SymbolType(valueInfo.Label, valueInfo.Value, valueInfo.Symbol, valueInfo.Description);
                        typeGroup.SymbolTypes.Add(symbolType);
                    }
                }
                else if (fLayer.LayerInfo.Renderer is ClassBreaksRenderer)
                {
                    ClassBreaksRenderer renderer = fLayer.LayerInfo.Renderer as ClassBreaksRenderer;
                    foreach (ClassBreakInfo classInfo in renderer.Classes)
                    {
                        SymbolType symbolType = new SymbolType(classInfo.Label, null, classInfo.Symbol, classInfo.Description);
                        typeGroup.SymbolTypes.Add(symbolType);
                    }
                }
            }

            if (symbolTypeGroups.Count == widgetConfig.EditableLayers.Count()) // All layers are initialized
            {
                FeatureTemplateList.ItemsSource = symbolTypeGroups;
            }
        }
Example #10
0
        internal void CreateOverlay(Dictionary <double, MyMapPoint> points)
        {
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Add points to the graphics overlay
            foreach (MyMapPoint point in points.Values)
            {
                // Create new graphic and add it to the overlay
                //MapPoint baseMapPoint1 = new MapPoint(25.905114, -80.767646, SpatialReferences.WebMercator);
                overlay.Graphics.Add(new Graphic(point.SDKMapPoint));
            }

            // Create symbol for points
            SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol()
            {
                Color = Color.Yellow,
                Size  = 20,
                Style = SimpleMarkerSymbolStyle.X
            };

            // Create simple renderer with symbol
            SimpleRenderer renderer = new SimpleRenderer(pointSymbol);

            // Set renderer to graphics overlay
            overlay.Renderer = renderer;

            // Add created overlay to the MapView
            MySceneView.GraphicsOverlays.Add(overlay);
        }
Example #11
0
 private void WriteSimpleRenderer(SimpleRenderer renderer)
 {
     if (renderer != null && renderer.Symbol != null)
     {
         WriteSymbol(renderer.Symbol);
     }
 }
Example #12
0
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            var  arg = new RenderEventArgs(RenderModes.Render, this.camera);
            mat4 projectionMatrix = camera.GetProjectionMat4();
            mat4 viewMatrix       = camera.GetViewMat4();
            //mat4 modelMatrix = glm.rotate(rotateAngle, new vec3(0, 1, 0)); //modelRotationCamera.GetViewMat4(); //mat4.identity();
            //rotateAngle += 0.03f;
            //mat4 modelMatrix = this.modelRotator.GetModelRotation();//glm.rotate(rotateAngle, new vec3(0, 1, 0)); //modelRotationCamera.GetViewMat4(); //mat4.identity();
            mat4 modelMatrix = this.modelRotator.GetRotationMatrix();

            this.renderer.projectionMatrix = projectionMatrix;
            this.renderer.viewMatrix       = viewMatrix;
            this.renderer.modelMatrix      = modelMatrix;
            this.groundRenderer.SetUniformValue("projectionMatrix", projectionMatrix);
            this.groundRenderer.SetUniformValue("viewMatrix", viewMatrix);
            this.groundRenderer.SetUniformValue("modelMatrix", mat4.identity());

            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            this.uiAxis.Render(arg);
            if (this.newRenderer != null)
            {
                this.renderer    = newRenderer;
                this.newRenderer = null;
            }
            this.renderer.Render(arg);
            this.groundRenderer.Render(arg);
        }
        private void Initialize()
        {
            var myScene = new Scene(Basemap.CreateTopographic());

            MySceneView.Scene = myScene;

            var camera = new Camera(28.4, 83, 20000, 10, 70, 300);

            MySceneView.SetViewpointCamera(camera);

            graphicsOverlay = new GraphicsOverlay();
            graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Draped;
            MySceneView.GraphicsOverlays.Add(graphicsOverlay);

            var renderer   = new SimpleRenderer();
            var lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.White, 1);

            renderer.Symbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Colors.Blue, lineSymbol);
            renderer.SceneProperties.ExtrusionMode       = ExtrusionMode.BaseHeight;
            renderer.SceneProperties.ExtrusionExpression = "[height]";
            graphicsOverlay.Renderer = renderer;

            var surface = new Surface();
            var url     = new System.Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");

            var elevationSource = new ArcGISTiledElevationSource(url);

            surface.ElevationSources.Add(elevationSource);
            myScene.BaseSurface = surface;

            addGraphics();
        }
Example #14
0
        private void CreateElement()
        {
            var element = new SimpleRenderer(factories[currentModelIndex].Create(this.radius));

            element.Initialize();
            this.newRenderer = element;
        }
Example #15
0
 protected virtual void WriteRenderer(IRenderer renderer)
 {
     if (IsSerializable(renderer))
     {
         ClassBreaksRenderer classBreaksRenderer = renderer as ClassBreaksRenderer;
         if (classBreaksRenderer != null)
         {
             writer.WriteStartElement("GraphicsLayer.Renderer", Namespaces[Constants.esriPrefix]);
             WriteClassBreaksRenderer(classBreaksRenderer);
             writer.WriteEndElement();
         }
         else
         {
             UniqueValueRenderer uniqueValueRenderer = renderer as UniqueValueRenderer;
             if (uniqueValueRenderer != null)
             {
                 writer.WriteStartElement("GraphicsLayer.Renderer", Namespaces[Constants.esriPrefix]);
                 WriteUniqueValueRenderer(uniqueValueRenderer);
                 writer.WriteEndElement();
             }
             else
             {
                 SimpleRenderer simpleRenderer = renderer as SimpleRenderer;
                 if (simpleRenderer != null)
                 {
                     writer.WriteStartElement("GraphicsLayer.Renderer", Namespaces[Constants.esriPrefix]);
                     WriteSimpleValueRenderer(simpleRenderer);
                     writer.WriteEndElement();
                 }
             }
         }
     }
 }
 private void RendererType_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (RendererType.SelectedIndex == 0)
     {
         if (!(Renderer is SimpleRenderer))
         {
             Renderer = new SimpleRenderer(new SimpleMarkerSymbol());
             return;
         }
     }
     else if (RendererType.SelectedIndex == 1)
     {
         if (!(Renderer is UniqueValueRenderer))
         {
             Renderer = new UniqueValueRenderer();
             return;
         }
     }
     else if (RendererType.SelectedIndex == 2)
     {
         if (!(Renderer is ClassBreaksRenderer))
         {
             Renderer = new ClassBreaksRenderer();
             return;
         }
     }
     else if (RendererType.SelectedIndex == 3)
     {
         if ((Renderer is null) || HeatMapRendererEditor.HeatMapRendererModel.FromRenderer(Renderer).type != "heatmap")
         {
             Renderer = new HeatMapRendererEditor.HeatMapRendererModel().AsRenderer();
             return;
         }
     }
 }
Example #17
0
        public SLDRenderer(IFeatureLayer featureLayer)
        {
            if (featureLayer == null)
            {
                return;
            }

            if (featureLayer.FeatureRenderer is SimpleRenderer)
            {
                SimpleRenderer sRenderer = (SimpleRenderer)featureLayer.FeatureRenderer;

                gView.Framework.OGC.WFS.Filter filter = null;
                Rule.FilterType filterType            = Rule.FilterType.None;
                if (featureLayer.FilterQuery != null)
                {
                    filter     = new gView.Framework.OGC.WFS.Filter(featureLayer.FeatureClass, featureLayer.FilterQuery, _gmlVersion);
                    filterType = (filter != null) ? Rule.FilterType.OgcFilter : Rule.FilterType.None;
                }
                Rule rule = new Rule(filter, sRenderer.Symbol);
                rule.filterType = filterType;
                _rules.Add(rule);
            }
            else if (featureLayer.FeatureRenderer is ValueMapRenderer)
            {
            }
            else if (featureLayer.FeatureRenderer is ScaleDependentRenderer)
            {
            }
            else if (featureLayer.FeatureRenderer is ScaleDependentLabelRenderer)
            {
            }
        }
Example #18
0
        private static void MapUsingSimpleFillRenderer()
        {
            string layerName = CboLayers.GetSelectedLayer();
            ILayer layer     = GetLayerByName(layerName);

            string     colorName = CboColors.GetSelectedColor();
            ICmykColor fillColor = ColorbrewerExtension.GetSingleCMYKColor();

            ISimpleFillSymbol fill = new SimpleFillSymbol();

            fill.Style = esriSimpleFillStyle.esriSFSSolid;
            fill.Color = fillColor;

            ISimpleRenderer simpleRenderer = new SimpleRenderer();

            simpleRenderer.Symbol = fill as ISymbol;
            simpleRenderer.Label  = layer.Name;

            IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer;

            gFLayer.Renderer = simpleRenderer as IFeatureRenderer;
            IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;
            IMap        map   = mxDoc.FocusMap;

            mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography
                                            , gFLayer, mxDoc.ActiveView.Extent);
        }
Example #19
0
        /// <summary>
        /// 根据url向地图添加一个FeatureLayer
        /// </summary>
        /// <param name="layerID"></param>
        /// <param name="url"></param>
        /// <param name="renderer"></param>
        /// <param name="filter"></param>
        /// <param name="visiable"></param>
        /// <returns></returns>
        public static FeatureLayer AddFeatureLayer(string layerID, string url, SimpleRenderer renderer, string filter, bool visiable)
        {
            try
            {
                if (!HttpHelper.CheckUrl(url))
                {
                    LogHelper.WriteLog("图层url:" + url + "-无法连接!");
                    return(null);
                }
                if (PublicParams.pubMainMap.Layers[layerID] != null)
                {
                    LogHelper.WriteLog(layerID + "图层已存在");
                    return(null);
                }
                FeatureLayer featureLayer = new FeatureLayer()
                {
                    ID = layerID, Url = url, Renderer = renderer, Where = filter, Visible = visiable
                };
                featureLayer.OutFields.Add("*");

                PublicParams.pubMainMap.Layers.Add(featureLayer);
                return(featureLayer);
            }
            catch (Exception)
            {
                LogHelper.WriteLog(layerID + ":发生了一个错误,在AddFeatureLayer");
                return(null);
            }
        }
Example #20
0
        /// <summary>
        /// 由传入的图层初始化lineSymbol
        /// </summary>
        private async void initLegendAsync()
        {
            FeatureLayer   feature        = layer as FeatureLayer;
            SimpleRenderer simpleRenderer = feature.Renderer as SimpleRenderer;

            if (simpleRenderer.Symbol is SimpleLineSymbol)
            {
                simpleLineSymbol = simpleRenderer.Symbol.Clone() as SimpleLineSymbol;
                //初始化控件
                int index = findStyle(x => simpleLineSymbol.Style.ToString().Equals(x.ToString()));
                if (index == -1)
                {
                    index = 0;
                    Debug.Print("未查到到style的索引");
                }
                StyleCombox.SelectedIndex = index;
                sizeUpDown.Value          = (decimal)simpleLineSymbol.Width;
                colorBtn.BackColor        = simpleLineSymbol.Color;
                transparencyControl.Value = simpleLineSymbol.Color.A;
                await refreshPreview();
            }
            //线样式为非简单样式的情况
            else
            {
                //暂未实现
            }
        }
        /// <summary>
        /// okBtn事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void okBtn_Click(object sender, EventArgs e)
        {
            SimpleRenderer simpleRenderer = new SimpleRenderer(simpleMarkerSymbol);
            FeatureLayer   feature        = layer as FeatureLayer;

            if (feature != null && simple_RB.Checked)
            {
                feature.Renderer = simpleRenderer;
                Close();
            }
            else if (feature != null && customPic_RB.Checked)
            {
                if (pictureMarkerSymbol == null)
                {
                    MessageBox.Show("请选择图片");
                    return;
                }
                simpleRenderer.Symbol = pictureMarkerSymbol;
                feature.Renderer      = simpleRenderer;
                Close();
            }
            //其他情况
            else
            {
                Close();
            }
        }
Example #22
0
        private async void Initialize()
        {
            try
            {
                // Define the Uri for the service feature table (US state polygons)
                Uri serviceFeatureTableUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3");

                // Create a new service feature table from the Uri
                ServiceFeatureTable censusTable = new ServiceFeatureTable(serviceFeatureTableUri);

                // Create a new feature layer from the service feature table
                FeatureLayer censusLayer = new FeatureLayer(censusTable)
                {
                    // Set the rendering mode of the feature layer to be dynamic (needed for extrusion to work)
                    RenderingMode = FeatureRenderingMode.Dynamic
                };

                // Create a new simple line symbol for the feature layer
                SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1);

                // Create a new simple fill symbol for the feature layer
                SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Blue, lineSymbol);

                // Create a new simple renderer for the feature layer
                SimpleRenderer layerRenderer = new SimpleRenderer(fillSymbol);

                // Get the scene properties from the simple renderer
                RendererSceneProperties sceneProperties = layerRenderer.SceneProperties;

                // Set the extrusion mode for the scene properties
                sceneProperties.ExtrusionMode = ExtrusionMode.AbsoluteHeight;

                // Set the initial extrusion expression
                sceneProperties.ExtrusionExpression = "[POP2007] / 10";

                // Set the feature layer's renderer to the define simple renderer
                censusLayer.Renderer = layerRenderer;

                // Create a new scene with the topographic backdrop
                Scene myScene = new Scene(BasemapType.Topographic);

                // Set the scene view's scene to the newly create one
                MySceneView.Scene = myScene;

                // Add the feature layer to the scene's operational layer collection
                myScene.OperationalLayers.Add(censusLayer);

                // Create a new map point to define where to look on the scene view
                MapPoint myMapPoint = new MapPoint(-10974490, 4814376, 0, SpatialReferences.WebMercator);

                // Set the scene view's camera controller to the orbit location camera controller
                MySceneView.CameraController = new OrbitLocationCameraController(myMapPoint, 20000000);
            }
            catch (Exception ex)
            {
                // Something went wrong, display the error
                var message = new MessageDialog(ex.ToString(), "Error");
                await message.ShowAsync();
            }
        }
Example #23
0
        /**
         * Render using the specified options and the specified display. If the
         * specified options do not exist - defaults will be used.
         *
         * @param optionsName name of the {@link RenderObject} which contains the
         *            options
         * @param display display object
         */
        public void render(string optionsName, IDisplay display)
        {
            if (string.IsNullOrEmpty(optionsName))
            {
                optionsName = "::options";
            }
            renderObjects.updateScene(scene);
            Options opt = lookupOptions(optionsName);

            if (opt == null)
            {
                opt = new Options();
            }
            scene.setCamera(lookupCamera(opt.getstring("camera", null)));

            // baking
            string bakingInstanceName = opt.getstring("baking.instance", null);

            if (bakingInstanceName != null)
            {
                Instance bakingInstance = lookupInstance(bakingInstanceName);
                if (bakingInstance == null)
                {
                    UI.printError(UI.Module.API, "Unable to bake instance \"{0}\" - not found", bakingInstanceName);
                    return;
                }
                scene.setBakingInstance(bakingInstance);
            }
            else
            {
                scene.setBakingInstance(null);
            }

            string       samplerName = opt.getstring("sampler", "bucket");
            ImageSampler sampler     = null;

            if (samplerName == "none" || samplerName == "null")
            {
                sampler = null;
            }
            else if (samplerName == "bucket")
            {
                sampler = bucketRenderer;
            }
            else if (samplerName == "ipr")
            {
                sampler = progressiveRenderer;
            }
            else if (samplerName == "fast")
            {
                sampler = new SimpleRenderer();
            }
            else
            {
                UI.printError(UI.Module.API, "Unknown sampler type: {0} - aborting", samplerName);
                return;
            }
            scene.render(opt, sampler, display);
        }
        // Setup the pin graphic and graphics layer renderer
        private async Task SetSimpleRendererSymbols()
        {
            var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 };
            await markerSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png"));
            var renderer = new SimpleRenderer() { Symbol = markerSymbol };

            addressesGraphicsLayer.Renderer = renderer;
        }
        private void OnViewpointChanged(object sender, EventArgs e)
        {
            // Unhook the event
            MyMapView.ViewpointChanged -= OnViewpointChanged;

            // Get area that is shown in a MapView
            Polygon visibleArea = MyMapView.VisibleArea;

            // Get extent of that area
            Envelope extent = visibleArea.Extent;

            // Get central point of the extent
            MapPoint centerPoint = extent.GetCenter();

            // Create values inside the visible extent for creating graphic
            var extentWidth  = extent.Width / 5;
            var extentHeight = extent.Height / 10;

            // Create point collection
            PointCollection points = new PointCollection(SpatialReferences.WebMercator)
            {
                new MapPoint(centerPoint.X - extentWidth * 2, centerPoint.Y - extentHeight * 2),
                new MapPoint(centerPoint.X - extentWidth * 2, centerPoint.Y + extentHeight * 2),
                new MapPoint(centerPoint.X + extentWidth * 2, centerPoint.Y + extentHeight * 2),
                new MapPoint(centerPoint.X + extentWidth * 2, centerPoint.Y - extentHeight * 2)
            };

            // Create overlay to where graphics are shown
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Add points to the graphics overlay
            foreach (var point in points)
            {
                // Create new graphic and add it to the overlay
                overlay.Graphics.Add(new Graphic(point));
            }

            // Create symbol for points
            SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol()
            {
                Color = System.Drawing.Color.Yellow,
                Size  = 30,
                Style = SimpleMarkerSymbolStyle.Square,
            };

            // Create simple renderer with symbol
            SimpleRenderer renderer = new SimpleRenderer(pointSymbol);

            // Set renderer to graphics overlay
            overlay.Renderer = renderer;

            // Make sure that the UI changes are done in the UI thread
            Device.BeginInvokeOnMainThread(() =>
            {
                // Add created overlay to the MapView
                MyMapView.GraphicsOverlays.Add(overlay);
            });
        }
Example #26
0
 public void ApplySimple(IGeoFeatureLayer geoLayer, ISymbol aSymbol)
 {
     ISimpleRenderer simpleRenderer;
     simpleRenderer = new SimpleRenderer();
     simpleRenderer.Symbol = aSymbol as ISymbol;
     geoLayer.Renderer = simpleRenderer as IFeatureRenderer;
     axMapControl1.ActiveView.Refresh();
     axTOCControl1.Update();
 }
        public bool ConvertLayerToKML(IFeatureClass fc, string kmzOutputPath, string tmpShapefilePath, ESRI.ArcGIS.Carto.IMap map)
        {
            try
            {
                string kmzName    = System.IO.Path.GetFileName(kmzOutputPath);
                string folderName = System.IO.Path.GetDirectoryName(kmzOutputPath);
                var    fcName     = System.IO.Path.GetFileNameWithoutExtension(kmzName);

                IFeatureLayer fLayer = new FeatureLayer();
                fLayer.FeatureClass = fc;
                var geoLayer = (fLayer as IGeoFeatureLayer);
                if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
                    pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
                    pSimpleMarkerSymbol.Size  = CoordinateConversionLibrary.Constants.SymbolSize;
                    pSimpleMarkerSymbol.Color = new RgbColorClass()
                    {
                        Red = 255
                    };
                    ISimpleRenderer pSimpleRenderer;
                    pSimpleRenderer        = new SimpleRenderer();
                    pSimpleRenderer.Symbol = (ISymbol)pSimpleMarkerSymbol;
                    geoLayer.Name          = fcName;
                    geoLayer.Renderer      = (IFeatureRenderer)pSimpleRenderer;
                }
                var featureLayer = geoLayer as FeatureLayer;

                map.AddLayer(geoLayer);

                // Initialize the geoprocessor.
                IGeoProcessor2 gp         = new GeoProcessorClass();
                IVariantArray  parameters = new VarArrayClass();
                parameters.Add(featureLayer.Name);
                parameters.Add(folderName + "\\" + kmzName);
                var result = gp.Execute(CoordinateConversionLibrary.Constants.LayerToKMLGPTool, parameters, null);

                // Remove the temporary layer from the TOC
                for (int i = 0; i < map.LayerCount; i++)
                {
                    ILayer layer = map.get_Layer(i);
                    if (layer.Name == fcName)
                    {
                        map.DeleteLayer(layer);
                        break;
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            return(false);
        }
 private void Form_Load(object sender, EventArgs e)
 {
     {
         var camera = new Camera(
             new vec3(0, 0, 5), new vec3(0, 0, 0), new vec3(0, 1, 0),
             CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
         var rotator = new SatelliteManipulater();
         rotator.Bind(camera, this.glCanvas1);
         this.scene             = new Scene(camera, this.glCanvas1);
         this.scene.ClearColor  = Color.SkyBlue;
         this.glCanvas1.Resize += this.scene.Resize;
     }
     {
         const int gridsPer2Unit = 20;
         const int scale         = 2;
         var       ground        = GroundRenderer.Create(new GroundModel(gridsPer2Unit * scale));
         ground.Scale = new vec3(scale, scale, scale);
         var obj = new SceneObject();
         obj.Renderer = ground;
         this.scene.RootObject.Children.Add(obj);
     }
     {
         SimpleRenderer movableRenderer = SimpleRenderer.Create(new Teapot());
         movableRenderer.RotationAxis = new vec3(0, 1, 0);
         movableRenderer.Scale        = new vec3(0.1f, 0.1f, 0.1f);
         this.movableRenderer         = movableRenderer;
         SceneObject obj = movableRenderer.WrapToSceneObject();
         this.scene.RootObject.Children.Add(obj);
     }
     {
         BillboardRenderer billboardRenderer = BillboardRenderer.Create(new BillboardModel());
         SceneObject       obj = billboardRenderer.WrapToSceneObject(new UpdateBillboardPosition(movableRenderer));
         this.scene.RootObject.Children.Add(obj);
     }
     {
         LabelRenderer labelRenderer = LabelRenderer.Create();
         labelRenderer.Text = "Teapot - CSharpGL";
         SceneObject obj = labelRenderer.WrapToSceneObject(new UpdateLabelPosition(movableRenderer));
         this.scene.RootObject.Children.Add(obj);
     }
     {
         var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom,
                                 new Padding(3, 3, 3, 3), new Size(128, 128));
         this.scene.RootUI.Children.Add(uiAxis);
     }
     {
         var frmPropertyGrid = new FormProperyGrid(this.scene);
         frmPropertyGrid.Show();
     }
     {
         var frmPropertyGrid = new FormProperyGrid(this.glCanvas1);
         frmPropertyGrid.Show();
     }
     {
         this.scene.Start();
     }
 }
Example #29
0
        private static bool IsSerializable(IRenderer renderer)
        {
            ClassBreaksRenderer classBreaksRenderer = renderer as ClassBreaksRenderer;

            if (classBreaksRenderer != null)
            {
                if (classBreaksRenderer.Classes != null)
                {
                    foreach (ClassBreakInfo info in classBreaksRenderer.Classes)
                    {
                        if (!SymbolXamlWriter.IsSerializable(info.Symbol))
                        {
                            return(false);
                        }
                    }

                    if (!SymbolXamlWriter.IsSerializable(classBreaksRenderer.DefaultSymbol))
                    {
                        return(false);
                    }
                }
            }
            else
            {
                UniqueValueRenderer uniqueValueRenderer = renderer as UniqueValueRenderer;
                if (uniqueValueRenderer != null)
                {
                    if (uniqueValueRenderer.Infos != null)
                    {
                        foreach (UniqueValueInfo info in uniqueValueRenderer.Infos)
                        {
                            if (!SymbolXamlWriter.IsSerializable(info.Symbol))
                            {
                                return(false);
                            }
                        }

                        if (!SymbolXamlWriter.IsSerializable(uniqueValueRenderer.DefaultSymbol))
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    SimpleRenderer simpleRenderer = renderer as SimpleRenderer;
                    if (simpleRenderer != null)
                    {
                        if (!SymbolXamlWriter.IsSerializable(simpleRenderer.Symbol))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Example #30
0
        public override void Load()
        {
            highlight = new TileHighlight(new Vector2(20, 20), Color.Blue);

            chunk       = new Chunk(new Vector2Int(0, 0));
            renderer    = new SimpleRenderer();
            chunk.State = ChunkState.NotSoReady;

            chunk.Add(new Tile(TileType.Floor, new Vector2Int(0, 0)));

            chunk.Add(new Tile(TileType.Floor, new Vector2Int(20, 20)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(21, 20)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(22, 20)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(20, 21)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(21, 21)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(22, 21)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(20, 22)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(21, 22)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(22, 22)));

            chunk.Add(new Tile(TileType.Wall, new Vector2Int(19, 20)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(19, 21)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(19, 22)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(23, 20)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(23, 22)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(23, 21)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(20, 19)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(21, 19)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(22, 19)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(20, 23)));

            //chunk.Add(new Tile(TileType.Wall, new Vector2Int(21, 23)));
            chunk.Add(new Tile(TileType.Floor, new Vector2Int(21, 23)));

            chunk.Add(new Tile(TileType.Wall, new Vector2Int(22, 23)));

            chunk.Add(new Tile(TileType.Wall, new Vector2Int(19, 19)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(19, 23)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(23, 19)));
            chunk.Add(new Tile(TileType.Wall, new Vector2Int(23, 23)));

            TileProcessor.Initialize();
            TileProcessor.Process(chunk);

            World.UpdateDayLight();

            BananaGame.GamePlayer          = new Player();
            BananaGame.GamePlayer.Position = new Vector2(20, 20);
            BananaGame.GamePlayer.Load();
            ControllerManager.AddPlayer(BananaGame.GamePlayer);

            BananaGame.GameCamera.FollowTaget = true;
            BananaGame.GameCamera.Target      = (BananaGame.GamePlayer);
            //GameCamera.TargetOffset = new Vector3(0.0f, 0f, 10f);
            BananaGame.GameCamera.TargetOffset = new Vector3(0.0f, 0f, 12f);
        }
Example #31
0
        private static SimpleRenderer createNewDefaultSimpleRenderer(GraphicsLayer graphicsLayer)
        {
            Symbol         defaultSymbol    = graphicsLayer.GetDefaultSymbolClone();
            SimpleRenderer rendererRenderer = new SimpleRenderer()
            {
                Symbol = defaultSymbol,
            };

            return(rendererRenderer);
        }
        /// <summary>
        /// Initializes a new instance of the ViewshedViewModel class.
        /// </summary>
        public ViewshedViewModel()
        {
            this.CreateViewshedRelayCommand = new RelayCommand(CreateViewshed);

            Messenger.Default.Register<Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) =>
            {
                this.mapView = mapView;



                this.sms = new SimpleMarkerSymbol();
                this.sms.Color = System.Windows.Media.Colors.Black;
                sms.Style = SimpleMarkerStyle.X;
                sms.Size = 20;

                this.simpleRenderer = new SimpleRenderer();
                this.simpleRenderer.Symbol = sms;

                this.simpleLineSymbol = new SimpleLineSymbol();
                this.simpleLineSymbol.Color = System.Windows.Media.Colors.Red;
                this.simpleLineSymbol.Width = 2;
                this.simpleLineSymbol.Style = SimpleLineStyle.Solid;

                this.simpleFillSymbol = new SimpleFillSymbol();
                this.simpleFillSymbol.Color =  (Color)ColorConverter.ConvertFromString("#44FF9999");
                this.simpleFillSymbol.Outline = simpleLineSymbol;

                this.viewshedRenderer = new SimpleRenderer();
                this.viewshedRenderer.Symbol = this.simpleFillSymbol;

                gpTask = new Geoprocessor(new Uri(viewshedServiceUrl));

                this.viewshedGraphicsLayer = new GraphicsLayer();
                this.viewshedGraphicsLayer.ID = "Viewshed";
                this.viewshedGraphicsLayer.DisplayName = "Viewshed";
                this.viewshedGraphicsLayer.Renderer = this.viewshedRenderer;
                this.viewshedGraphicsLayer.InitializeAsync();

                this.inputGraphicsLayer = new GraphicsLayer();
                this.inputGraphicsLayer.ID = "Input Point";
                this.inputGraphicsLayer.DisplayName = "Input Point";
                this.inputGraphicsLayer.Renderer = this.simpleRenderer;
                this.inputGraphicsLayer.InitializeAsync();

                this.mapView.Map.Layers.Add(this.inputGraphicsLayer);
                this.mapView.Map.Layers.Add(this.viewshedGraphicsLayer);

            });


        }
        private void SetRenderers()
        {
            SimpleRenderer simpleRenderer = new SimpleRenderer()
            {
                Description = "Rivers",
                Label = "Rivers",
                Symbol = new SimpleLineSymbol() { Color = Colors.Blue, Style = SimpleLineStyle.Dash, Width = 2 }
            };
            (mapView1.Map.Layers["MyFeatureLayerSimple"] as FeatureLayer).Renderer = simpleRenderer;

            UniqueValueRenderer uvr = new UniqueValueRenderer();
            uvr.Fields = new ObservableCollection<string>(new string [] { "STATE_NAME" });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] {"New Mexico" }), Symbol = new SimpleFillSymbol() { Color = Colors.Yellow } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "Texas" }), Symbol = new SimpleFillSymbol() { Color = Colors.PaleGreen } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "Arizona" }), Symbol = new SimpleFillSymbol() { Color = Colors.YellowGreen } });

            (mapView1.Map.Layers["MyFeatureLayerUnique"] as FeatureLayer).Renderer = uvr;


            ClassBreaksRenderer CBR = new ClassBreaksRenderer()
            {
                DefaultLabel = "All Other Values",
                DefaultSymbol = new SimpleMarkerSymbol() { Color = Colors.Black, Style = SimpleMarkerStyle.Cross, Size = 10 },
                Field = "POP1990",
                Minimum = 0
            };

            CBR.Infos.Add(new ClassBreakInfo()
            {
                Maximum = 30000,
                Label = "0-30000",
                Description = "Pop between 0 and 30000",
                Symbol = new SimpleMarkerSymbol() { Color = Colors.Yellow, Size = 8, Style = SimpleMarkerStyle.Circle }
            });
            CBR.Infos.Add(new ClassBreakInfo()
            {
                Maximum = 300000,
                Label = "30000-300000",
                Description = "Pop between 30000 and 300000",
                Symbol = new SimpleMarkerSymbol() { Color = Colors.Red, Size = 10, Style = SimpleMarkerStyle.Circle }
            });

            CBR.Infos.Add(new ClassBreakInfo()
            {
                Maximum = 5000000,
                Label = "300000-5000000",
                Description = "Pop between 300000 and 5000000",
                Symbol = new SimpleMarkerSymbol() { Color = Colors.Orange, Size = 12, Style = SimpleMarkerStyle.Circle }
            });
            (mapView1.Map.Layers["MyFeatureLayerClassBreak"] as FeatureLayer).Renderer = CBR;
        }
        /// <summary>
        /// Initializes a new instance of the ViewshedViewModel class.
        /// </summary>
        public ClipViewModel()
        {
            this.ClipRelayCommand = new RelayCommand(Clip);

            Messenger.Default.Register<Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) =>
            {
                this.mapView = mapView;

                this.simpleInputLineSymbol = new SimpleLineSymbol();
                this.simpleInputLineSymbol.Color = System.Windows.Media.Colors.Red;
                this.simpleInputLineSymbol.Width = 2;
                this.simpleInputLineSymbol.Style = SimpleLineStyle.Solid;

                this.simpleResultLineSymbol = new SimpleLineSymbol();
                this.simpleResultLineSymbol.Color = (Color)ColorConverter.ConvertFromString("#FF0000FF");
                
                this.simpleResultFillSymbol = new SimpleFillSymbol();
                this.simpleResultFillSymbol.Color = (Color)ColorConverter.ConvertFromString("#770000FF");
                this.simpleResultFillSymbol.Outline = this.simpleResultLineSymbol;

                this.simpleResultRenderer = new SimpleRenderer();
                this.simpleResultRenderer.Symbol = this.simpleResultFillSymbol;

                this.inputLineRenderer = new SimpleRenderer();
                this.inputLineRenderer.Symbol = this.simpleInputLineSymbol;


               
                this.localGPService = new LocalGeoprocessingService(this.clipGPKPath, GeoprocessingServiceType.SubmitJob);
                this.localGPService.StartAsync();
                

                this.resultGraphicsLayer = new GraphicsLayer();
                this.resultGraphicsLayer.ID = "Clip Result";
                this.resultGraphicsLayer.DisplayName = "Viewshed";
                this.resultGraphicsLayer.Renderer = this.simpleResultRenderer;
                this.resultGraphicsLayer.InitializeAsync();

                this.inputGraphicsLayer = new GraphicsLayer();
                this.inputGraphicsLayer.ID = "Input Line";
                this.inputGraphicsLayer.DisplayName = "Input Line";
                this.inputGraphicsLayer.Renderer = this.inputLineRenderer;
                this.inputGraphicsLayer.InitializeAsync();

                this.mapView.Map.Layers.Add(this.inputGraphicsLayer);
                this.mapView.Map.Layers.Add(this.resultGraphicsLayer);

            });
        }
		// Setup the pin graphic and graphics overlay renderer
        private async void SetSimpleRendererSymbols()
        {
			try
			{
				var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 };
				await markerSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png"));
				var renderer = new SimpleRenderer() { Symbol = markerSymbol };

				_addressOverlay.Renderer = renderer;
			}
			catch (Exception ex)
			{
				MessageBox.Show("Error occurred : " + ex.Message, "Find Place Sample");
			}
        }
		// Setup the pin graphic and graphics overlay renderer
		private async void SetSimpleRendererSymbols()
		{
			try
			{
				var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 };
				await markerSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickpin.png"));
				var renderer = new SimpleRenderer() { Symbol = markerSymbol };

				_addressOverlay.Renderer = renderer;
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog("Selection Error: " + ex.Message, "Find Place Sample").ShowAsync();
			}
		}
        private void OnOverrideButtonClicked(object sender, RoutedEventArgs e)
        {
            // Create a symbol to be used in the renderer
            SimpleLineSymbol symbol = new SimpleLineSymbol()
            {
                Color = Colors.Blue,
                Width = 2,
                Style = SimpleLineSymbolStyle.Solid
            };

            // Create a new renderer using the symbol just created
            SimpleRenderer renderer = new SimpleRenderer(symbol);

            // Assign the new renderer to the feature layer
            _featureLayer.Renderer = renderer;
        }
Example #38
0
 public static ESRI.ArcGIS.Client.GraphicsLayer CreateSearchLyr(ESRI.ArcGIS.Client.Geometry.Geometry mp)
 {
     ESRI.ArcGIS.Client.GraphicsLayer gl = new GraphicsLayer();
     ESRI.ArcGIS.Client.GraphicCollection listGc = new GraphicCollection();
     ESRI.ArcGIS.Client.Graphic gp = new Graphic()
     {
         Geometry = mp
     };
     listGc.Add(gp);
     gl.ID = "SearchLyr";
     gl.Graphics = listGc;
     ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol skb = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol();
     skb.Color = Brushes.Red;
     skb.Size = 15;
     var render = new SimpleRenderer();
     render.Symbol = skb;
     gl.Renderer = render as IRenderer;
     return gl;
 }
        private void Button_Load(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                FeatureSet featureSet = FeatureSet.FromJson(JsonTextBox.Text);

                GraphicsLayer graphicsLayerFromFeatureSet = new GraphicsLayer()
                {
                    Graphics = new GraphicCollection(featureSet)
                };

                if (!featureSet.SpatialReference.Equals(MyMap.SpatialReference))
                {
                    if (MyMap.SpatialReference.Equals(new SpatialReference(102100)) &&
                        featureSet.SpatialReference.Equals(new SpatialReference(4326)))
                        foreach (Graphic g in graphicsLayerFromFeatureSet.Graphics)
                            g.Geometry = _mercator.FromGeographic(g.Geometry);

                    else if (MyMap.SpatialReference.Equals(new SpatialReference(4326)) &&
                        featureSet.SpatialReference.Equals(new SpatialReference(102100)))
                        foreach (Graphic g in graphicsLayerFromFeatureSet.Graphics)
                            g.Geometry = _mercator.ToGeographic(g.Geometry);

                    else
                    {
                        GeometryService geometryService =
                            new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

                        geometryService.ProjectCompleted += (s, a) =>
                        {
                            for (int i = 0; i < a.Results.Count; i++)
                                graphicsLayerFromFeatureSet.Graphics[i].Geometry = a.Results[i].Geometry;
                        };

                        geometryService.Failed += (s, a) =>
                        {
                            MessageBox.Show("Projection error: " + a.Error.Message);
                        };

                        geometryService.ProjectAsync(graphicsLayerFromFeatureSet.Graphics, MyMap.SpatialReference);
                    }
                }

                SimpleRenderer simpleRenderer = new SimpleRenderer();
                SolidColorBrush symbolColor = new SolidColorBrush(Colors.Blue);
                graphicsLayerFromFeatureSet.Renderer = simpleRenderer;

                if (featureSet.GeometryType == GeometryType.Polygon || featureSet.GeometryType == GeometryType.Polygon)
                {
                    simpleRenderer.Symbol = new SimpleFillSymbol()
                    {
                        Fill = symbolColor
                    };
                }
                else if (featureSet.GeometryType == GeometryType.Polyline)
                {
                    simpleRenderer.Symbol = new SimpleLineSymbol()
                    {
                        Color = symbolColor
                    };
                }
                else // Point
                {
                    simpleRenderer.Symbol = new SimpleMarkerSymbol()
                    {
                        Color = symbolColor,
                        Size = 12
                    };
                }

                Border border = new Border()
                {
                    Background = new SolidColorBrush(Colors.White),
                    BorderBrush = new SolidColorBrush(Colors.Black),
                    BorderThickness = new Thickness(1),
                    CornerRadius = new CornerRadius(10),
                    Effect = new DropShadowEffect()
                };

                StackPanel stackPanelParent = new StackPanel()
                {
                    Orientation = Orientation.Vertical,
                    Margin = new Thickness(12)
                };

                foreach (KeyValuePair<string, string> keyvalue in featureSet.FieldAliases)
                {
                    StackPanel stackPanelChild = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal,
                        Margin = new Thickness(0, 0, 0, 6)
                    };
                    TextBlock textValue = new TextBlock()
                    {
                        Text = keyvalue.Value + ": "
                    };

                    TextBlock textKey = new TextBlock();
                    Binding keyBinding = new Binding(string.Format("[{0}]", keyvalue.Key));
                    textKey.SetBinding(TextBlock.TextProperty, keyBinding);

                    stackPanelChild.Children.Add(textValue);
                    stackPanelChild.Children.Add(textKey);

                    if (keyvalue.Key == featureSet.DisplayFieldName)
                    {
                        textKey.FontWeight = textValue.FontWeight = FontWeights.Bold;
                        stackPanelParent.Children.Insert(0, stackPanelChild);
                    }
                    else
                        stackPanelParent.Children.Add(stackPanelChild);

                }

                border.Child = stackPanelParent;
                graphicsLayerFromFeatureSet.MapTip = border;

                MyMap.Layers.Add(graphicsLayerFromFeatureSet);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "GraphicsLayer creation failed", MessageBoxButton.OK);
            }
        }
        private void DrawModel()
        {
            ModelMarkerSymbol mms = new ModelMarkerSymbol();
            mms.SourceUri = "Data/M-14/M-14.obj";
            mms.Scale = 1000;

            SimpleRenderer sr = new SimpleRenderer();
            sr.Symbol = mms;

            GraphicsOverlay graphicsOverlay = new GraphicsOverlay()
            {
                RenderingMode = GraphicsRenderingMode.Dynamic,
                Renderer = sr,
                SceneProperties = new LayerSceneProperties()
                {
                    SurfacePlacement = SurfacePlacement.Relative
                }
            };

            MapPoint mp = new MapPoint(-122.4167, 37.7833, 55000);

            Graphic gm = new Graphic(mp);
            graphicsOverlay.Graphics.Add(gm);

            this.sceneView.GraphicsOverlays.Add(graphicsOverlay);
        }
 private static SimpleRenderer createNewDefaultSimpleRenderer(GraphicsLayer graphicsLayer)
 {
     Symbol defaultSymbol = graphicsLayer.GetDefaultSymbolClone();
     SimpleRenderer rendererRenderer = new SimpleRenderer()
     {
         Symbol = defaultSymbol,
     };
     return rendererRenderer;
 }
        private void OnViewpointChanged(object sender, EventArgs e)
        {
            // Unhook the event
            _myMapView.ViewpointChanged -= OnViewpointChanged;

            // Get area that is shown in a MapView
            Polygon visibleArea = _myMapView.VisibleArea;

            // Get extent of that area
            Envelope extent = visibleArea.Extent;
   
            // Get central point of the extent
            MapPoint centerPoint = extent.GetCenter();

            // Create values inside the visible extent for creating graphic
            var extentWidth = extent.Width / 5;
            var extentHeight = extent.Height / 10;

            // Create point collection
            PointCollection points = new PointCollection(SpatialReferences.WebMercator)
                {
                    new MapPoint(centerPoint.X - extentWidth * 2, centerPoint.Y - extentHeight * 2),
                    new MapPoint(centerPoint.X - extentWidth * 2, centerPoint.Y + extentHeight * 2),
                    new MapPoint(centerPoint.X + extentWidth * 2, centerPoint.Y + extentHeight * 2),
                    new MapPoint(centerPoint.X + extentWidth * 2, centerPoint.Y - extentHeight * 2)
                };

            // Create overlay to where graphics are shown
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Add points to the graphics overlay
            foreach (var point in points)
            {
                // Create new graphic and add it to the overlay
                overlay.Graphics.Add(new Graphic(point));
            }

            // Create symbol for points
            SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol()
            {
                Color = System.Drawing.Color.Yellow,
                Size = 30,
                Style = SimpleMarkerSymbolStyle.Square,
            };

            // Create simple renderer with symbol
            SimpleRenderer renderer = new SimpleRenderer(pointSymbol);

            // Set renderer to graphics overlay
            overlay.Renderer = renderer;

            // Make sure that the UI changes are done in the UI thread
            RunOnUiThread(() =>
            {
                // Add created overlay to the MapView
                _myMapView.GraphicsOverlays.Add(overlay);
            });
        }
        public void SetShapeRangeValues(DashboardHelper dashboardHelper, string shapeKey, string dataKey, string valueField, Color dotColor, int dotValue)
        {
            try
            {
                this.dotValue = dotValue;
                this.dashboardHelper = dashboardHelper;
                this.shapeKey = shapeKey;
                this.dataKey = dataKey;
                this.valueField = valueField;
                this.dotColor = dotColor;

                List<string> columnNames = new List<string>();
                if (dashboardHelper.IsUsingEpiProject)
                {
                    columnNames.Add("UniqueKey");
                }
                columnNames.Add(valueField);
                columnNames.Add(dataKey);

                DataTable loadedData;

                if (valueField.Equals("{Record Count}"))
                {
                    GadgetParameters gadgetOptions = new GadgetParameters();
                    gadgetOptions.MainVariableName = dataKey;

                    Dictionary<string, string> inputVariableList = new Dictionary<string, string>();
                    inputVariableList.Add("freqvar", dataKey);
                    inputVariableList.Add("allvalues", "false");
                    inputVariableList.Add("showconflimits", "false");
                    inputVariableList.Add("showcumulativepercent", "false");
                    inputVariableList.Add("includemissing", "false");
                    inputVariableList.Add("maxrows", "500");

                    gadgetOptions.InputVariableList = inputVariableList;
                    loadedData = dashboardHelper.GenerateFrequencyTable(gadgetOptions).First().Key;
                    foreach (DataRow dr in loadedData.Rows)
                    {
                        dr[0] = dr[0].ToString().Trim();
                    }
                    valueField = "freq";
                }
                else
                {
                    loadedData = dashboardHelper.GenerateTable(columnNames);
                }

                GraphicsLayer graphicsLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer;

                List<double> valueList = new List<double>();
                List<Graphic> graphicsToBeAdded = new List<Graphic>();
                for (int i = 0; i < graphicsLayer.Graphics.Count; i++)
                {
                    Graphic graphicFeature = graphicsLayer.Graphics[i];

                    double xmin = graphicFeature.Geometry.Extent.XMin;
                    double xmax = graphicFeature.Geometry.Extent.XMax;
                    double ymin = graphicFeature.Geometry.Extent.YMin;
                    double ymax = graphicFeature.Geometry.Extent.YMax;

                    Random rnd = new Random();

                    string shapeValue = graphicFeature.Attributes[shapeKey].ToString().Replace("'", "''").Trim();

                    string filterExpression = "";
                    if (dataKey.Contains(" ") || dataKey.Contains("$") || dataKey.Contains("#"))
                        filterExpression += "[";
                    filterExpression += dataKey;
                    if (dataKey.Contains(" ") || dataKey.Contains("$") || dataKey.Contains("#"))
                        filterExpression += "]";
                    filterExpression += " = '" + shapeValue + "'";

                    double graphicValue = Double.PositiveInfinity;
                    try
                    {
                        graphicValue = Convert.ToDouble(loadedData.Select(filterExpression)[0][valueField]);

                        for (int counter = 0; counter < graphicValue; counter += dotValue)
                        {
                            bool pointInGraphic = false;

                            ExtendedGraphic graphic = new ExtendedGraphic();
                            while (!pointInGraphic)
                            {
                                double rndX = xmin + (rnd.NextDouble() * (xmax - xmin));
                                double rndY = ymin + (rnd.NextDouble() * (ymax - ymin));
                                graphic.Geometry = new MapPoint(rndX, rndY, graphicFeature.Geometry.SpatialReference);
                                graphic.Symbol = MarkerSymbol;

                                bool foundBottomLeft = false;
                                bool foundBottomRight = false;
                                bool foundTopLeft = false;
                                bool foundTopRight = false;
                                foreach (ESRI.ArcGIS.Client.Geometry.PointCollection pc in ((ESRI.ArcGIS.Client.Geometry.Polygon)graphicFeature.Geometry).Rings)
                                {
                                    foundBottomLeft = pc.Any((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                    foundBottomRight = pc.Any((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);
                                    foundTopLeft = pc.Any((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                    foundTopRight = pc.Any((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);

                                    if (foundBottomLeft && foundBottomRight && foundTopLeft && foundTopRight)
                                    {
                                        try
                                        {
                                            MapPoint firstBottomLeft = pc.First((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                            MapPoint firstBottomRight = pc.First((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);
                                            MapPoint firstTopLeft = pc.First((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                            MapPoint firstTopRight = pc.First((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);

                                            int indexBL = pc.IndexOf(firstBottomLeft);
                                            int indexBR = pc.IndexOf(firstBottomRight);
                                            int indexTL = pc.IndexOf(firstTopLeft);
                                            int indexTR = pc.IndexOf(firstTopRight);

                                            MapPoint lastBottomLeft = pc.Last((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                            MapPoint lastBottomRight = pc.Last((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);
                                            MapPoint lastTopLeft = pc.Last((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                            MapPoint lastTopRight = pc.Last((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);

                                            int indexBL2 = pc.IndexOf(lastBottomLeft);
                                            int indexBR2 = pc.IndexOf(lastBottomRight);
                                            int indexTL2 = pc.IndexOf(lastTopLeft);
                                            int indexTR2 = pc.IndexOf(lastTopRight);

                                            if ((Math.Abs(indexTL - indexTR2) == 1 && Math.Abs(indexTR - indexBR2) == 1) || (Math.Abs(indexBL - indexTL2) == 1 && Math.Abs(indexTL - indexTR2) == 1) || (Math.Abs(indexBR - indexBL2) == 1 && Math.Abs(indexTR - indexBR2) == 1))
                                            {
                                                pointInGraphic = true;
                                                break;
                                            }
                                            else if ((Math.Abs(indexBL - indexBR2) == 1 && Math.Abs(indexTL - indexBL2) == 1) || (Math.Abs(indexTL - indexBL2) == 1 && Math.Abs(indexTR - indexTL2) == 1) || (Math.Abs(indexBR - indexTR2) == 1 && Math.Abs(indexTR - indexTL2) == 1))
                                            {
                                                pointInGraphic = true;
                                                break;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            pointInGraphic = false;
                                        }

                                    }
                                }
                            }
                            graphicsToBeAdded.Add(graphic);
                        }
                    }
                    catch (Exception ex)
                    {
                        graphicValue = Double.PositiveInfinity;
                    }
                }

                SimpleRenderer renderer = new SimpleRenderer();
                renderer.Symbol = new SimpleFillSymbol()
                {
                    Fill = new SolidColorBrush(Colors.Transparent),
                    BorderBrush = new SolidColorBrush(Colors.Black),
                    BorderThickness = 1
                };

                graphicsLayer.Renderer = renderer;

                GraphicsLayer dotLayer = myMap.Layers[layerId.ToString() + "_dotLayer"] as GraphicsLayer;
                int currentDotIndex = myMap.Layers.Count;
                if (dotLayer != null)
                {
                    currentDotIndex = myMap.Layers.IndexOf(dotLayer);
                    myMap.Layers.Remove(dotLayer);
                }
                dotLayer = new GraphicsLayer();
                dotLayer.ID = layerId.ToString() + "_dotLayer";
                myMap.Layers.Insert(currentDotIndex, dotLayer);
                foreach (Graphic g in graphicsToBeAdded)
                {
                    dotLayer.Graphics.Add(g);
                }

            }
            catch (Exception ex)
            {
            }
        }
        // Creates the renderers in code
        private void initializeRenderers()
        {
            // Create simple renderer with one symbol for rivers layer
            SimpleRenderer simpleRenderer = new SimpleRenderer()
            {
                Description = "Rivers",
                Label = "Rivers",
                Symbol = new SimpleLineSymbol() { Color = Colors.Blue, Style = SimpleLineStyle.Dash, Width = 2 }
            };
            RiversRenderer = simpleRenderer;

            // Create a unique value renderer that defines different symbols for New Mexico, Texas, 
            // and Arizona
            UniqueValueRenderer uvr = new UniqueValueRenderer();
            uvr.Fields = new ObservableCollection<string>(new string[] { "STATE_NAME" });
            SimpleLineSymbol stateOutline = new SimpleLineSymbol() { Color = Colors.Black };
            uvr.Infos.Add(new UniqueValueInfo 
            { 
                Values = new ObservableCollection<object>(new object[] { "New Mexico" }), 
                Symbol = new SimpleFillSymbol() { Color = Colors.Yellow, Outline = stateOutline } 
            });
            uvr.Infos.Add(new UniqueValueInfo 
            { 
                Values = new ObservableCollection<object>(new object[] { "Texas" }),
                Symbol = new SimpleFillSymbol() { Color = Colors.Green, Outline = stateOutline }
            });
            uvr.Infos.Add(new UniqueValueInfo 
            { 
                Values = new ObservableCollection<object>(new object[] { "Arizona" }),
                Symbol = new SimpleFillSymbol() { Color = Colors.LightGray, Outline = stateOutline }
            });
            StatesRenderer = uvr;

            // Create a class breaks renderer to symbolize cities of different sizes
            ClassBreaksRenderer cbr = new ClassBreaksRenderer()
            {
                DefaultLabel = "All Other Values",
                DefaultSymbol = new SimpleMarkerSymbol() { Color = Colors.Black, 
                    Style = SimpleMarkerStyle.Cross, Size = 10 },
                Field = "POP1990",
                Minimum = 0
            };

            // Create and add symbols
            SimpleLineSymbol cityOutline = new SimpleLineSymbol() { Color = Colors.White };
            cbr.Infos.Add(new ClassBreakInfo()
            {
                Minimum = 100000,
                Maximum = 200000,
                Label = "100000 - 200000",
                Description = "Population between 100000 and 200000",
                Symbol = new SimpleMarkerSymbol() 
                { 
                    Color = Color.FromArgb(255, 0, 210, 0), 
                    Outline = cityOutline,
                    Size = 4, 
                    Style = SimpleMarkerStyle.Circle 
                }
            });
            cbr.Infos.Add(new ClassBreakInfo()
            {
                Minimum = 200001,
                Maximum = 1000000,
                Label = "200001 - 1000000",
                Description = "Population between 200001 and 1000000",
                Symbol = new SimpleMarkerSymbol() 
                { 
                    Color = Color.FromArgb(255, 0, 127, 0), 
                    Outline = cityOutline,
                    Size = 8, 
                    Style = SimpleMarkerStyle.Circle 
                }
            });

            cbr.Infos.Add(new ClassBreakInfo()
            {
                Minimum = 1000001,
                Maximum = 10000000,
                Label = "1000001 - 10000000",
                Description = "Population between 1000001 and 10000000",
                Symbol = new SimpleMarkerSymbol() 
                { 
                    Color = Color.FromArgb(255, 0, 50, 0), 
                    Outline = cityOutline,
                    Size = 12, 
                    Style = SimpleMarkerStyle.Circle 
                }
            });
            CitiesRenderer = cbr;
        }
Example #45
0
 internal static SimpleRenderer Create(IBufferable model, vec3 lengths, string positionNameInIBufferable)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("in_Position", "position");
     map.Add("in_Color", "color");
     var renderer = new SimpleRenderer(model, shaderCodes, map, positionNameInIBufferable);
     renderer.ModelSize = lengths;
     return renderer;
 }
Example #46
0
        public void Add()
        {
            IsRunning = true;

            geoRss = new GeoRssLayer() { ID = Name, Source = Location };
            gl = AppState.ViewDef.FindOrCreateGroupLayer(this.Folder);
            if (gl != null) gl.ChildLayers.Add(geoRss);
            var sr = new SimpleRenderer
            {
                Symbol = new PictureMarkerSymbol()
                {
                    Source = new BitmapImage(IconUri),
                    Width = IconSize,
                    OffsetX = IconSize / 2,
                    OffsetY = IconSize / 2
                }
            };
            geoRss.Renderer = sr; // Renderer;
            geoRss.Initialize();
        }
		private void CreateRouteLayer()
        {

            var routeLayer = new GraphicsLayer()
            {
                ID = "RouteLayer"
            };

            var renderer = new SimpleRenderer()
            {
                Symbol = new SimpleLineSymbol()
                {
                    Color = Colors.Black,
                    Width = 5,
                    Style = SimpleLineStyle.Solid
                }
            };

            routeLayer.Renderer = renderer;
            Map.Layers.Add(routeLayer);
            _routeLayer = routeLayer;
        }
 private static IRenderer CreateDefaultRenderer(GeometryType geomType)
 {
     SimpleRenderer renderer = new SimpleRenderer();
     renderer.Symbol = CreateDefaultSymbol(geomType);
     return renderer;
 }
        private async Task SetSimpleRendererSymbols()
        {

            PictureMarkerSymbol findResultMarkerSymbol = new PictureMarkerSymbol()
            {
                Width = 48,
                Height = 48,
                YOffset = 24
            };

            await findResultMarkerSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png"));
            SimpleRenderer findResultRenderer = new SimpleRenderer()
            {
                Symbol = findResultMarkerSymbol,
            };
            _candidateAddressesGraphicsLayer.Renderer = findResultRenderer;
        }
        /// <summary>
        /// 住所検索結果用のシンボル作成
        /// </summary>
        private SimpleRenderer createGeocoordingSymbol()
        {
            SimpleMarkerSymbol resultGeocoordingSymbol = new SimpleMarkerSymbol()
            {
                Style = SimpleMarkerStyle.Circle,
                Size = 12,
                Color = Colors.Blue,
            };


            SimpleRenderer resultRenderer = new SimpleRenderer() { Symbol = resultGeocoordingSymbol };

            return resultRenderer;
        }
        private void CreateOverlays()
        {
            // This function will create the overlays that show the user clicked location and the results of the 
            // viewshed analysis. Note: the overlays will not be populated with any graphics at this point

            // Create renderer for input graphic. Set the size and color properties for the simple renderer
            SimpleRenderer myInputRenderer = new SimpleRenderer()
            {
                Symbol = new SimpleMarkerSymbol()
                {
                    Size = 15,
                    Color = Colors.Red
                }
            };

            // Create overlay to where input graphic is shown
            _inputOverlay = new GraphicsOverlay()
            {
                Renderer = myInputRenderer
            };

            // Create fill renderer for output of the viewshed analysis. Set the color property of the simple renderer 
            SimpleRenderer myResultRenderer = new SimpleRenderer()
            {
                Symbol = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(100, 226, 119, 40)
                }
            };

            // Create overlay to where viewshed analysis graphic is shown
            _resultOverlay = new GraphicsOverlay()
            {
                Renderer = myResultRenderer
            };

            // Add the created overlays to the MapView
            MyMapView.GraphicsOverlays.Add(_inputOverlay);
            MyMapView.GraphicsOverlays.Add(_resultOverlay);
        }
        private void MapView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (nameof(MapView.SpatialReference).Equals(e.PropertyName) && null != MapView.SpatialReference)
            {
                Task.Run(() =>
                {
                    // Load the data
                    var inputFile = new FileInfo(Settings.Default.GeonamesFilePath);
                    var delimiter = Settings.Default.Delimiter;
                    switch (delimiter)
                    {
                        case @"\t":
                            delimiter = "\t";
                            break;
                    }
                    var clusterFile = new ClusterPointTextFile(inputFile, delimiter, Settings.Default.XTokenIndex, Settings.Default.YTokenIndex, Settings.Default.StartRowIndex);
                    var distanceCalculator = new EuclideanDistanceCalculator();
                    var clusterer = new KMeansClusterer(distanceCalculator);
                    return clusterer.CreateClusters(clusterFile, Settings.Default.ClusterCount);
                }).ContinueWith((clusterTask)=> {
                    // Create the graphics
                    var clusters = clusterTask.Result;
                    var random = new Random();
                    var wgs84 = SpatialReference.Create(4326);
                    foreach (var cluster in clusters)
                    {
                        // Create a graphic layer
                        var layer = new GraphicsLayer();
                        layer.RenderingMode = GraphicsRenderingMode.Static;
                        foreach (var element in cluster.Elements)
                        {
                            var clusterPoint = element as ClusterPoint;
                            if (null != clusterPoint)
                            {
                                var mapPoint = new MapPoint(clusterPoint.X, clusterPoint.Y, wgs84);
                                var projectedMapPoint = GeometryEngine.Project(mapPoint, MapView.SpatialReference);
                                var graphic = new Graphic(projectedMapPoint);
                                layer.Graphics.Add(graphic);
                            }
                        }

                        // Create a marker symbol
                        var markerSymbol = new SimpleMarkerSymbol();
                        markerSymbol.Style = SimpleMarkerStyle.Circle;
                        markerSymbol.Size = 6;
                        markerSymbol.Color = Color.FromRgb((byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255));

                        // Create a renderer
                        var renderer = new SimpleRenderer();
                        renderer.Symbol = markerSymbol;
                        layer.Renderer = renderer;

                        MapView.Map.Layers.Add(layer);
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
        }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                // Code runs "for real"
                ConfigService config = new ConfigService();
                this.myModel = config.LoadJSON();
                this.AddStopsRelayCommand = new RelayCommand(AddStops);

                Messenger.Default.Register<Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) =>
                {
                    this.mapView = mapView;
                    this.mapView.MaxScale = 500;

                    ArcGISLocalTiledLayer localTiledLayer = new ArcGISLocalTiledLayer(this.TilePackage);
                    localTiledLayer.ID = "SF Basemap";
                    localTiledLayer.InitializeAsync();

                    this.mapView.Map.Layers.Add(localTiledLayer);

                    this.CreateLocalServiceAndDynamicLayer();
                    this.CreateFeatureLayers();


                    //============================
                    // Create a new renderer to symbolize the routing polyline and apply it to the GraphicsLayer
                    SimpleLineSymbol polylineRouteSymbol = new SimpleLineSymbol();
                    polylineRouteSymbol.Color = System.Windows.Media.Colors.Red;
                    polylineRouteSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleLineStyle.Solid;
                    polylineRouteSymbol.Width = 4;
                    SimpleRenderer polylineRouteRenderer = new SimpleRenderer();
                    polylineRouteRenderer.Symbol = polylineRouteSymbol;

                    // Create a new renderer to symbolize the start and end points that define the route and apply it to the GraphicsLayer
                    SimpleMarkerSymbol stopSymbol = new SimpleMarkerSymbol();
                    stopSymbol.Color = System.Windows.Media.Colors.Green;
                    stopSymbol.Size = 12;
                    stopSymbol.Style = SimpleMarkerStyle.Circle;
                    SimpleRenderer stopRenderer = new SimpleRenderer();
                    stopRenderer.Symbol = stopSymbol;
                   
                    // create the route results graphics layer
                    this.routeGraphicsLayer = new GraphicsLayer();
                    this.routeGraphicsLayer.ID = "RouteResults";
                    this.routeGraphicsLayer.DisplayName = "Routes";
                    this.routeGraphicsLayer.Renderer = polylineRouteRenderer;
                    this.routeGraphicsLayer.InitializeAsync();
                    
                    this.mapView.Map.Layers.Add(this.routeGraphicsLayer);

                    // create the stops graphics layer
                    this.stopsGraphicsLayer = new GraphicsLayer();
                    this.stopsGraphicsLayer.ID = "Stops";
                    this.stopsGraphicsLayer.DisplayName = "Stops";
                    this.stopsGraphicsLayer.Renderer = stopRenderer;
                    this.stopsGraphicsLayer.InitializeAsync();
                    this.mapView.Map.Layers.Add(this.stopsGraphicsLayer);

                    // Offline routing task.
                    routeTask = new LocalRouteTask(@"C:\ArcGISRuntimeBook\Data\Networks\RuntimeSanFrancisco.geodatabase", "Streets_ND");


                });
            }
        }
 private void WriteSimpleValueRenderer(SimpleRenderer simpleRenderer)
 {
     writer.WriteStartElement("SimpleRenderer", Namespaces[Constants.esriPrefix]);
     if (simpleRenderer.Symbol != null)
     {
         writer.WriteStartElement("SimpleRenderer.Symbol", Namespaces[Constants.esriPrefix]);
         (new SymbolXamlWriter(writer, Namespaces)).WriteSymbol(simpleRenderer.Symbol);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
        private byte[] getLayerCountByType(System.Collections.Specialized.NameValueCollection boundVariables,
            ESRI.ArcGIS.SOESupport.JsonObject operationInput,
            string outputFormat,
            string requestProperties,
            out string responseProperties) 
        {
            IMapImage mapImage = null;

            bool? shouldAdd = null;
            operationInput.TryGetAsBoolean("addlayer", out shouldAdd);

            if (shouldAdd.HasValue)
            {
                if ((bool)shouldAdd)
                {
                    if (((IMapServerInfo4)mapServerInfo).SupportsDynamicLayers)
                    {
                        IRgbColor color = new RgbColor(){ Blue = 255};

                        ISimpleLineSymbol outline = new SimpleLineSymbol(){ 
                            Color = color, 
                            Width = 1, 
                            Style = esriSimpleLineStyle.esriSLSSolid
                        };

                        ISimpleFillSymbol sfs = new SimpleFillSymbol(){ 
                            Color = color, 
                            Outline = outline, 
                            Style = esriSimpleFillStyle.esriSFSSolid
                        };
                        
                        ISimpleRenderer sr = new SimpleRenderer(){ Symbol = (ISymbol)sfs };

                        IFeatureLayerDrawingDescription featureLayerDrawingDesc = new FeatureLayerDrawingDescription(){
                            FeatureRenderer = (IFeatureRenderer)sr
                        };

                        IMapServerSourceDescription mapServerSourceDesc = new TableDataSourceDescriptionClass();
                        ((IDataSourceDescription)mapServerSourceDesc).WorkspaceID = "MyFGDB";
                        ((ITableDataSourceDescription)mapServerSourceDesc).TableName = "B";

                        IDynamicLayerDescription dynamicLayerDesc = new LayerDescriptionClass(){
                            ID = 3,
                            Visible = true,
                            DrawingDescription = (ILayerDrawingDescription)featureLayerDrawingDesc,
                            Source = mapServerSourceDesc
                        };

                        mapDesc.HonorLayerReordering = true;
                        mapDesc.LayerDescriptions.Insert(0, (ILayerDescription)dynamicLayerDesc);

                        mapImage = exportMap();
                    }    
                }
                else
                {
                    mapImage = exportMap();
                }
            }
            responseProperties = null; 
  
        	JSONObject json = new JSONObject();
            json.AddString("URL", mapImage.URL);
            return Encoding.UTF8.GetBytes(json.ToJSONString(null));
        }
        // Create webmap layer out of a feature set from a query task
        private async Task<WebMapLayer> CreateFeatureCollectionLayer()
        {
            try
            {
                //Perform Query to get a featureSet and add to webmap as featurecollection
                QueryTask qt = new QueryTask(
                    new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0"));

                Esri.ArcGISRuntime.Tasks.Query.Query query = new Esri.ArcGISRuntime.Tasks.Query.Query("magnitude > 3.5");
                query.OutFields.Add("*");
                query.ReturnGeometry = true;

                var queryResult = await qt.ExecuteAsync(query);

                var simpleRenderer = new SimpleRenderer { Symbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Color = Color.FromArgb(255, 0, 0, 255), Size = 8 } };
                var drawingInfo = new DrawingInfo { Renderer = simpleRenderer };
                var layerDefinition = new LayerDefinition {DrawingInfo = drawingInfo};

                //Create FeatureCollection as webmap layer
                FeatureCollection featureCollection = null;

                if (queryResult.FeatureSet.Features.Count > 0)
                {
                    var sublayer = new WebMapSubLayer();
                    sublayer.Id = 0;
                    sublayer.FeatureSet = queryResult.FeatureSet;

                    sublayer.LayerDefinition = layerDefinition;
                    featureCollection = new FeatureCollection { 
                        SubLayers = new List<WebMapSubLayer> { sublayer } 
                    };
                }

                return new WebMapLayer { FeatureCollection = featureCollection, Title = "Earthquakes from last 7 days" };
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Sample Error");
                return null;
            }
        }
        void GeometryService_BufferCompleted(object sender, GraphicsEventArgs args)
        {
            IList<Graphic> results = args.Results;
            if (results == null || results.Count < 1)
                return;

            FindNearbyEventArgs eventArgs = args.UserState as FindNearbyEventArgs;
            if (eventArgs == null)
                return;

            GraphicsLayer targetGraphicsLayer = eventArgs.SelectedLayer;
            if(targetGraphicsLayer == null)
                return;

            #region Draw the buffer graphics layer
            GraphicsLayer bufferGraphicsLayer = new GraphicsLayer() { ID = eventArgs.EventId };            

            // Add the circle graphic
            Graphic circleGraphic = results[0];
            circleGraphic.Attributes.Add(Resources.Strings.BufferDistance, string.Format("{0} {1}", eventArgs.Distance, eventArgs.LinearUnit.ToString()));
            SimpleFillSymbol defaultBufferSymbol = new SimpleFillSymbol()
            {
                BorderBrush = new SolidColorBrush(Colors.Blue),
                BorderThickness = 1,
                Fill = new SolidColorBrush(new Color() { A =(byte)102, R = (byte)255, G = (byte)0, B = (byte)0})
            };
            SimpleRenderer simpleRenderer = new SimpleRenderer() { 
                 Symbol = defaultBufferSymbol,
            };
            bufferGraphicsLayer.Renderer = simpleRenderer;
            Collection<FieldInfo> layerFields = Core.LayerExtensions.GetFields(bufferGraphicsLayer);
            if (layerFields != null)
                layerFields.Add(new FieldInfo() { DisplayName = Resources.Strings.BufferDistance, Name = Resources.Strings.BufferDistance, FieldType = FieldType.Text });             
            bufferGraphicsLayer.Graphics.Add(circleGraphic);
            #endregion

            Graphic graphicCircle = results[0];
            if (graphicCircle != null)
            {
                ESRI.ArcGIS.Client.Geometry.Geometry graphicCircleGeometry = graphicCircle.Geometry;
                if (graphicCircleGeometry != null)
                {
                    // Ensure that atleast the first graphic of the graphics layer has a spatial reference set
                    // because ESRI.ArcGIS.Client.Tasks checks it
                    if (targetGraphicsLayer.Graphics.Count > 0)
                    {
                        if (targetGraphicsLayer.Graphics[0].Geometry != null
                            && targetGraphicsLayer.Graphics[0].Geometry.SpatialReference == null && Map != null)
                        {
                            targetGraphicsLayer.Graphics[0].Geometry.SpatialReference = Map.SpatialReference;
                        }
                    }

                    // The extent of the result layer should be the extent of the circle
                    if(Map != null)
                        Map.ZoomTo(expandExtent(graphicCircleGeometry.Extent));

                    relationAsync(GeometryServiceUrl, targetGraphicsLayer.Graphics.ToList(), results, new object[] { eventArgs, bufferGraphicsLayer });
                }
            }
        }
		/// <summary>
		/// Create layers and renderers for states and query areas.
		/// </summary>
		private void CreateGraphicsLayers()
		{
			#region States layer
			_statesLayer = new GraphicsLayer()
			{
				ID = "States"
			};

			var statesAreaSymbol = new SimpleFillSymbol()
			{
				Color = (Color)ColorConverter.ConvertFromString("#440000FF"),
				Outline = new SimpleLineSymbol
									{
										Color = Colors.Blue,
										Width = 2
									}
			};

			var renderer = new SimpleRenderer { Symbol = statesAreaSymbol };
			_statesLayer.Renderer = renderer;

			Map.Layers.Add(_statesLayer);
			#endregion

			#region QueryArea layer
			_queryAreaLayer = new GraphicsLayer()
			{
				ID = "QueryArea"
			};

			var queryAreaLayerSymbol = new SimpleFillSymbol()
			{
				Color = (Color)ColorConverter.ConvertFromString("#66BB0000"),
				Style = SimpleFillStyle.DiagonalCross,
				Outline = new SimpleLineSymbol
				{
					Color = Colors.Red,
					Width = 2
				}
			};

			var queryAreaRenderer = new SimpleRenderer { Symbol = queryAreaLayerSymbol};
			_queryAreaLayer.Renderer = queryAreaRenderer;

			Map.Layers.Add(_queryAreaLayer);
			#endregion
		}