private UniqueValueConfigControl createNewUniqueValueConfigControl(UniqueValueInfo uniqueValueInfo)
        {
            UniqueValueConfigControl uniqueValueConfigControl = new UniqueValueConfigControl()
            {
                UniqueValue          = uniqueValueInfo,
                SymbolConfigProvider = SymbolConfigProvider,
                GeometryType         = GeometryType,
            };

            uniqueValueConfigControl.UniqueValueModified += uniqueValueConfigControl_UniqueValueModified;
            return(uniqueValueConfigControl);
        }
        void symbolsConfigControl_CurrentUniqueValueChanged(object sender, CurrentUniqueValueChangedEventArgs e)
        {
            _uniqueValueInfo = e.UniqueValue;

            if (e.UniqueValue == null)
            {
                return;
            }

            if (SymbolConfigControl != null)
            {
                SymbolConfigControl.Symbol = e.UniqueValue.Symbol;
            }
        }
Esempio n. 3
0
        private void SymbolIDLB_OnSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            UniqueValueInfo uvi = e.AddedItems[0] as UniqueValueInfo;

            if (uvi == null)
            {
                return;
            }


            Graphic g = FeatureInfoPage.DataContext as Graphic;

            if (g != null)
            {
                g.Attributes["symbolid"] = (Int16)uvi.Value;
            }
        }
Esempio n. 4
0
        public void AddUniqueValues(List <PointDTO> pointDTOList, List <UniqueValueInfoDTO> uniqueValueInfoDTOList)
        {
            Queue <SimpleMarkerSymbol> markerSymbolQueue = this.CreateSimpleMarkerSymbolQueue();

            markerSymbolQueue.Reverse <SimpleMarkerSymbol>();

            try
            {
                List <Graphic> graphicsList = new List <Graphic>();

                // First create a list of graphics from the DTO
                foreach (PointDTO pointDTO in pointDTOList)
                {
                    Graphic graphic = this.createStratifiedGraphic(pointDTO);

                    this.graphicsLayer.Graphics.Add(graphic);
                }

                UniqueValueRenderer r = new UniqueValueRenderer();
                r.Field = "StrataValue";

                foreach (UniqueValueInfoDTO dto in uniqueValueInfoDTOList)
                {
                    UniqueValueInfo x = new UniqueValueInfo();

                    SimpleMarkerSymbol simpleMarkerySymbol = markerSymbolQueue.Dequeue();

                    //  x.Symbol = 7777

                    x.Symbol = simpleMarkerySymbol;
                    x.Value  = dto.Value;

                    r.Infos.Add(x);
                }

                this.graphicsLayer.Renderer = r;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Problem with EwavMap.AddPoints \n{0}\n{1}", ex.Message, ex.StackTrace));
            }
        }
        void AddUniqueValueButton_Click(object sender, RoutedEventArgs e)
        {
            if (UniqueValueRenderer == null)
            {
                return;
            }

            UniqueValueConfigControl uniqueValueConfigControl;
            UniqueValueInfo          newUniqueValue = new UniqueValueInfo()
            {
                Value  = "",        // TODO:- set the default value based on selected attribute
                Symbol = UniqueValueRenderer.DefaultSymbol != null?UniqueValueRenderer.DefaultSymbol.CloneSymbol() : SymbolUtils.CreateDefaultSymbol(GeometryType),
            };

            uniqueValueConfigControl = createNewUniqueValueConfigControl(newUniqueValue);
            UniqueValueRenderer.Infos.Add(newUniqueValue);

            if (UniqueValueConfigItems != null)
            {
                UniqueValueConfigItems.Items.Add(uniqueValueConfigControl);
                UniqueValueConfigItems.SelectedItem = uniqueValueConfigControl;
            }
        }
Esempio n. 6
0
        private void WriteUniqueValueInfo(UniqueValueInfo uniqueValueInfo)
        {
            if (uniqueValueInfo == null)
            {
                return;
            }

            UniqueValueInfoObj uniqueValueInfoObj = uniqueValueInfo as UniqueValueInfoObj;

            if (uniqueValueInfoObj != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj", Namespaces[Constants.esriMappingPrefix]);
                if (uniqueValueInfoObj.Value != null)
                {
                    writer.WriteAttributeString("FieldType", uniqueValueInfoObj.FieldType.ToString());
                    WriteRendererInfoAttributes(uniqueValueInfo);
                    writeUniqueValueObj(uniqueValueInfoObj.SerializedValue);
                }
            }
            else
            {
                writer.WriteStartElement("UniqueValueInfo", Namespaces[Constants.esriPrefix]);
                WriteRendererInfoAttributes(uniqueValueInfo);
                if (uniqueValueInfo.Value != null)
                {
                    writeUniqueValue(uniqueValueInfo.Value);
                }
            }

            if (uniqueValueInfo.Symbol != null)
            {
                writer.WriteStartElement("UniqueValueInfo.Symbol", Namespaces[Constants.esriPrefix]);
                (new SymbolXamlWriter(writer, Namespaces)).WriteSymbol(uniqueValueInfo.Symbol);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
        void queryTaskPolygon_ExecuteCompleted(object sender, QueryEventArgs args)
        {
            FeatureSet featureSet = args.FeatureSet;

            if (featureSet == null || featureSet.Features.Count < 1)
            {
                MessageBox.Show("No features returned from query");
                return;
            }

            GraphicsLayer graphicsLayer = MyMap.Layers["MyPolygonGraphicsLayer"] as GraphicsLayer;

            Random random = new Random();

            // Random switch between class breaks and unique value renderers
            if (random.Next(0, 2) == 0)
            {
                ClassBreaksRenderer classBreakRenderer = new ClassBreaksRenderer();
                classBreakRenderer.Field = "POP2000";
                int classCount = 6;

                List <double> valueList = new List <double>();
                foreach (Graphic graphic in args.FeatureSet.Features)
                {
                    graphicsLayer.Graphics.Add(graphic);
                    valueList.Add((int)graphic.Attributes[classBreakRenderer.Field]);
                }

                // LINQ
                IEnumerable <double> valueEnumerator =
                    from aValue in valueList
                    orderby aValue
                    select aValue;

                int increment = Convert.ToInt32(Math.Ceiling(args.FeatureSet.Features.Count / classCount));
                int rgbFactor = 255 / classCount;
                int j         = 255;

                for (int i = increment; i < valueList.Count; i += increment)
                {
                    ClassBreakInfo classBreakInfo = new ClassBreakInfo();

                    if (i == increment)
                    {
                        classBreakInfo.MinimumValue = 0;
                    }
                    else
                    {
                        classBreakInfo.MinimumValue = valueEnumerator.ElementAt(i - increment);
                    }

                    classBreakInfo.MaximumValue = valueEnumerator.ElementAt(i);

                    SimpleFillSymbol symbol = new SimpleFillSymbol()
                    {
                        Fill            = new SolidColorBrush(Color.FromArgb(192, (byte)j, (byte)j, (byte)j)),
                        BorderBrush     = new SolidColorBrush(Colors.Transparent),
                        BorderThickness = 1
                    };

                    classBreakInfo.Symbol = symbol;
                    classBreakRenderer.Classes.Add(classBreakInfo);

                    j = j - rgbFactor;
                }

                // Set maximum value for largest class break
                classBreakRenderer.Classes[classBreakRenderer.Classes.Count - 1].MaximumValue = valueEnumerator.ElementAt(valueList.Count - 1) + 1;

                graphicsLayer.Renderer = classBreakRenderer;
            }
            else
            {
                UniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer();
                uniqueValueRenderer.DefaultSymbol = LayoutRoot.Resources["RedFillSymbol"] as Symbol;
                uniqueValueRenderer.Field         = "STATE_NAME";

                foreach (Graphic graphic in args.FeatureSet.Features)
                {
                    graphicsLayer.Graphics.Add(graphic);
                    UniqueValueInfo uniqueValueInfo = new UniqueValueInfo();

                    SimpleFillSymbol symbol = new SimpleFillSymbol()
                    {
                        Fill            = new SolidColorBrush(Color.FromArgb(192, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))),
                        BorderBrush     = new SolidColorBrush(Colors.Transparent),
                        BorderThickness = 1
                    };

                    uniqueValueInfo.Symbol = symbol;
                    uniqueValueInfo.Value  = graphic.Attributes["STATE_NAME"];
                    uniqueValueRenderer.Infos.Add(uniqueValueInfo);
                }

                graphicsLayer.Renderer = uniqueValueRenderer;
            }
        }
        void symbolsConfigControl_CurrentUniqueValueChanged(object sender, CurrentUniqueValueChangedEventArgs e)
        {
            _uniqueValueInfo = e.UniqueValue;

            if (e.UniqueValue == null)
                return;            

            if (SymbolConfigControl != null)
                SymbolConfigControl.Symbol = e.UniqueValue.Symbol;
        }
        private void WriteUniqueValueInfo(UniqueValueInfo uniqueValueInfo)
        {
            if (uniqueValueInfo == null)
                return;

            UniqueValueInfoObj uniqueValueInfoObj = uniqueValueInfo as UniqueValueInfoObj;
            if (uniqueValueInfoObj != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj", Namespaces[Constants.esriMappingPrefix]);
                if (uniqueValueInfoObj.Value != null)
                {
                    writer.WriteAttributeString("FieldType", uniqueValueInfoObj.FieldType.ToString());
                    WriteRendererInfoAttributes(uniqueValueInfo);
                    writeUniqueValueObj(uniqueValueInfoObj.SerializedValue);
                }
            }
            else
            {
                writer.WriteStartElement("UniqueValueInfo", Namespaces[Constants.esriPrefix]);
                WriteRendererInfoAttributes(uniqueValueInfo);
                if (uniqueValueInfo.Value != null)
                {
                    writeUniqueValue(uniqueValueInfo.Value);
                }
            }

            if (uniqueValueInfo.Symbol != null)
            {
                writer.WriteStartElement("UniqueValueInfo.Symbol", Namespaces[Constants.esriPrefix]);
                (new SymbolXamlWriter(writer, Namespaces)).WriteSymbol(uniqueValueInfo.Symbol);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
        void queryTaskPolygon_ExecuteCompleted(object sender, QueryEventArgs args)
        {
            FeatureSet featureSet = args.FeatureSet;

            if (featureSet == null || featureSet.Features.Count < 1)
            {
                MessageBox.Show("No features returned from query");
                return;
            }

            GraphicsLayer graphicsLayer = MyMap.Layers["MyPolygonGraphicsLayer"] as GraphicsLayer;

            Random random = new Random();

            // Random switch between class breaks and unique value renderers
            if (random.Next(0, 2) == 0)
            {
                ClassBreaksRenderer classBreakRenderer = new ClassBreaksRenderer();
                classBreakRenderer.Field = "POP2000";
                int classCount = 6;

                List<double> valueList = new List<double>();
                foreach (Graphic graphic in args.FeatureSet.Features)
                {
                    graphicsLayer.Graphics.Add(graphic);
                    valueList.Add((int)graphic.Attributes[classBreakRenderer.Field]);
                }

                // LINQ
                IEnumerable<double> valueEnumerator =
                   from aValue in valueList
                   orderby aValue
                   select aValue;

                int increment = Convert.ToInt32(Math.Ceiling(args.FeatureSet.Features.Count / classCount));
                int rgbFactor = 255 / classCount;
                int j = 255;

                for (int i = increment; i < valueList.Count; i += increment)
                {
                    ClassBreakInfo classBreakInfo = new ClassBreakInfo();

                    if (i == increment)
                        classBreakInfo.MinimumValue = 0;
                    else
                        classBreakInfo.MinimumValue = valueEnumerator.ElementAt(i - increment);

                    classBreakInfo.MaximumValue = valueEnumerator.ElementAt(i);

                    SimpleFillSymbol symbol = new SimpleFillSymbol()
                    {
                        Fill = new SolidColorBrush(Color.FromArgb(192, (byte)j, (byte)j, (byte)j)),
                        BorderBrush = new SolidColorBrush(Colors.Transparent),
                        BorderThickness = 1
                    };

                    classBreakInfo.Symbol = symbol;
                    classBreakRenderer.Classes.Add(classBreakInfo);

                    j = j - rgbFactor;
                }

                // Set maximum value for largest class break
                classBreakRenderer.Classes[classBreakRenderer.Classes.Count - 1].MaximumValue = valueEnumerator.ElementAt(valueList.Count - 1) + 1;

                graphicsLayer.Renderer = classBreakRenderer;

            }
            else
            {
                UniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer();
                uniqueValueRenderer.DefaultSymbol = LayoutRoot.Resources["RedFillSymbol"] as Symbol;
                uniqueValueRenderer.Field = "STATE_NAME";

                foreach (Graphic graphic in args.FeatureSet.Features)
                {
                    graphicsLayer.Graphics.Add(graphic);
                    UniqueValueInfo uniqueValueInfo = new UniqueValueInfo();

                    SimpleFillSymbol symbol = new SimpleFillSymbol()
                    {
                        Fill = new SolidColorBrush(Color.FromArgb(192, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))),
                        BorderBrush = new SolidColorBrush(Colors.Transparent),
                        BorderThickness = 1
                    };

                    uniqueValueInfo.Symbol = symbol;
                    uniqueValueInfo.Value = graphic.Attributes["STATE_NAME"];
                    uniqueValueRenderer.Infos.Add(uniqueValueInfo);
                }

                graphicsLayer.Renderer = uniqueValueRenderer;
            }
        }
 private UniqueValueConfigControl createNewUniqueValueConfigControl(UniqueValueInfo uniqueValueInfo)
 {
     UniqueValueConfigControl uniqueValueConfigControl = new UniqueValueConfigControl()
     {
         UniqueValue = uniqueValueInfo,
         SymbolConfigProvider = SymbolConfigProvider,
         GeometryType = GeometryType,
     };
     uniqueValueConfigControl.UniqueValueModified += uniqueValueConfigControl_UniqueValueModified;
     return uniqueValueConfigControl;
 }
        void AddUniqueValueButton_Click(object sender, RoutedEventArgs e)
        {
            if (UniqueValueRenderer == null)
                return;

            UniqueValueConfigControl uniqueValueConfigControl;
            UniqueValueInfo newUniqueValue = new UniqueValueInfo()
                {
                    Value = "",     // TODO:- set the default value based on selected attribute
                    Symbol = UniqueValueRenderer.DefaultSymbol != null ? UniqueValueRenderer.DefaultSymbol.CloneSymbol() : SymbolUtils.CreateDefaultSymbol(GeometryType),
                };
            uniqueValueConfigControl = createNewUniqueValueConfigControl(newUniqueValue);
            UniqueValueRenderer.Infos.Add(newUniqueValue);            

            if (UniqueValueConfigItems != null)
            {
                UniqueValueConfigItems.Items.Add(uniqueValueConfigControl);
                UniqueValueConfigItems.SelectedItem = uniqueValueConfigControl;
            }       
        }