Example #1
0
        private static SimpleRenderer createNewDefaultSimpleRenderer(GraphicsLayer graphicsLayer)
        {
            Symbol         defaultSymbol    = graphicsLayer.GetDefaultSymbolClone();
            SimpleRenderer rendererRenderer = new SimpleRenderer()
            {
                Symbol = defaultSymbol,
            };

            return(rendererRenderer);
        }
Example #2
0
        private static UniqueValueRenderer createNewDefaultUniqueValueRenderer(GraphicsLayer graphicsLayer, IEnumerable <object> uniqueValues, FieldInfo attributeField, LinearGradientBrush defaultColorRampGradientBrush, IEnumerable <Symbol> existingSymbolSet)
        {
            Symbol defaultSymbol = graphicsLayer.GetDefaultSymbol();
            UniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer()
            {
                Field         = attributeField != null ? attributeField.Name : null,
                DefaultSymbol = defaultSymbol,
            };

            if (uniqueValues != null)
            {
                List <Symbol> symbols = new List <Symbol>();
                int           i       = 0;
                foreach (object uniqueValue in uniqueValues)
                {
                    Symbol symbol = null;
                    if (existingSymbolSet != null)
                    {
                        symbol = existingSymbolSet.ElementAtOrDefault(i);
                    }
                    if (symbol == null)
                    {
                        symbol = graphicsLayer.GetDefaultSymbolClone();
                    }
                    uniqueValueRenderer.Infos.Add(new UniqueValueInfoObj()
                    {
                        Symbol          = symbol,
                        SerializedValue = uniqueValue,
                        FieldType       = attributeField.FieldType,
                    });
                    symbols.Add(symbol);
                    i++;
                }
                if (defaultColorRampGradientBrush != null)
                {
                    if (existingSymbolSet == null) // apply the gradient brush, only if symbols have not been pre-defined
                    {
                        applyLinearGradientBrushToSymbolSet(symbols, defaultColorRampGradientBrush, defaultSymbol);
                    }
                }
            }
            return(uniqueValueRenderer);
        }
Example #3
0
        private static IRenderer createNewDefaultClassBreaksRenderer(GraphicsLayer graphicsLayer, FieldInfo attributeField, double min, double max, int numOfClassBreaks, LinearGradientBrush defaultColorRampGradientBrush, IEnumerable <Symbol> existingSymbolSet)
        {
            Symbol defaultSymbol         = graphicsLayer.GetDefaultSymbolClone();
            ClassBreaksRenderer renderer = new ClassBreaksRenderer()
            {
                Field         = attributeField != null ? attributeField.Name : null,
                DefaultSymbol = defaultSymbol,
            };
            List <Symbol> symbols = new List <Symbol>();

            if (numOfClassBreaks < 2) // classbreaks renderer must have atleast 2 classbreaks
            {
                numOfClassBreaks = 2;
            }
            double rangeSize           = Math.Round((max - min) / numOfClassBreaks, 2);
            double rangeDelta          = 1.0; // delta between 2 class ranges // we choose an integral size
            double lastRangeDeltaIncr  = 1.0; // SL core api requires the last classbreak to be greater than max value of dataset
            bool   fractionalIncrement = false;

            if (Math.Round(max, 0) != max)// we are dealing with a non-integeral values, so our delta's are in fractional increments
            {
                fractionalIncrement = true;
                rangeDelta          = 0.01;
                lastRangeDeltaIncr  = 0.01;
            }

            double startValue = min;

            for (int i = 0; i < numOfClassBreaks; i++)
            {
                Symbol symbol = null;
                if (existingSymbolSet != null)
                {
                    symbol = existingSymbolSet.ElementAtOrDefault(i);
                }
                if (symbol == null)
                {
                    symbol = graphicsLayer.GetDefaultSymbolClone();
                }
                double         endValue   = (startValue + rangeSize) - rangeDelta;
                ClassBreakInfo classBreak = new ClassBreakInfo()
                {
                    MinimumValue = fractionalIncrement ? startValue : Math.Floor(startValue),
                    MaximumValue = fractionalIncrement ? endValue : Math.Floor(endValue),
                    Symbol       = symbol,
                };
                if (i == numOfClassBreaks - 1) // last class break
                {
                    classBreak.MaximumValue = max + lastRangeDeltaIncr;
                    if (max > 1000000)                  // SL has a limitation on values greater than a million http://msdn.microsoft.com/en-us/library/bb412393.aspx
                    {
                        classBreak.MaximumValue += 2.0; // the +2 is to workaround Silverlights limitation of single precision values
                    }
                }
                symbols.Add(symbol);
                renderer.Classes.Add(classBreak);
                startValue += rangeSize;
            }
            if (defaultColorRampGradientBrush != null)
            {
                if (existingSymbolSet == null) // apply the gradient brush, only if symbols have not been pre-defined
                {
                    applyLinearGradientBrushToSymbolSet(symbols, defaultColorRampGradientBrush, defaultSymbol);
                }
            }
            return(renderer);
        }
 private static SimpleRenderer createNewDefaultSimpleRenderer(GraphicsLayer graphicsLayer)
 {
     Symbol defaultSymbol = graphicsLayer.GetDefaultSymbolClone();
     SimpleRenderer rendererRenderer = new SimpleRenderer()
     {
         Symbol = defaultSymbol,
     };
     return rendererRenderer;
 }
 private static UniqueValueRenderer createNewDefaultUniqueValueRenderer(GraphicsLayer graphicsLayer, IEnumerable<object> uniqueValues, FieldInfo attributeField, LinearGradientBrush defaultColorRampGradientBrush, IEnumerable<Symbol> existingSymbolSet)
 {
     Symbol defaultSymbol = graphicsLayer.GetDefaultSymbol();
     UniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer()
     {
         Field = attributeField != null ? attributeField.Name : null,
         DefaultSymbol = defaultSymbol,
     };
     if (uniqueValues != null)
     {
         List<Symbol> symbols = new List<Symbol>();
         int i = 0;
         foreach (object uniqueValue in uniqueValues)
         {
             Symbol symbol = null;
             if (existingSymbolSet != null)
                 symbol = existingSymbolSet.ElementAtOrDefault(i);
             if (symbol == null)
                 symbol = graphicsLayer.GetDefaultSymbolClone();
             uniqueValueRenderer.Infos.Add(new UniqueValueInfoObj()
             {
                 Symbol = symbol,
                 SerializedValue = uniqueValue,
                 FieldType = attributeField.FieldType,
             });
             symbols.Add(symbol);
             i++;
         }
         if (defaultColorRampGradientBrush != null)
         {
             if (existingSymbolSet == null) // apply the gradient brush, only if symbols have not been pre-defined
             {
                 applyLinearGradientBrushToSymbolSet(symbols, defaultColorRampGradientBrush, defaultSymbol);
             }
         }
     }
     return uniqueValueRenderer;
 }
        private static IRenderer createNewDefaultClassBreaksRenderer(GraphicsLayer graphicsLayer, FieldInfo attributeField, double min, double max, int numOfClassBreaks, LinearGradientBrush defaultColorRampGradientBrush, IEnumerable<Symbol> existingSymbolSet)
        {
            Symbol defaultSymbol = graphicsLayer.GetDefaultSymbolClone();
            ClassBreaksRenderer renderer = new ClassBreaksRenderer()
            {
                Field = attributeField != null ? attributeField.Name : null,
                DefaultSymbol = defaultSymbol,
            };
            List<Symbol> symbols = new List<Symbol>();
            if (numOfClassBreaks < 2) // classbreaks renderer must have atleast 2 classbreaks
                numOfClassBreaks = 2;
            double rangeSize = Math.Round((max - min) / numOfClassBreaks, 2);
            double rangeDelta = 1.0; // delta between 2 class ranges // we choose an integral size
            double lastRangeDeltaIncr = 1.0; // SL core api requires the last classbreak to be greater than max value of dataset
            bool fractionalIncrement = false;
            if (Math.Round(max, 0) != max)// we are dealing with a non-integeral values, so our delta's are in fractional increments
            {
                fractionalIncrement = true;
                rangeDelta = 0.01;
                lastRangeDeltaIncr = 0.01;
            }

            double startValue = min;
            for (int i = 0; i < numOfClassBreaks; i++)
            {
                Symbol symbol = null;
                if (existingSymbolSet != null)
                    symbol = existingSymbolSet.ElementAtOrDefault(i);
                if (symbol == null)
                    symbol = graphicsLayer.GetDefaultSymbolClone();
                double endValue = (startValue + rangeSize) - rangeDelta;
                ClassBreakInfo classBreak = new ClassBreakInfo()
                {
                    MinimumValue = fractionalIncrement ? startValue : Math.Floor(startValue),
                    MaximumValue = fractionalIncrement ? endValue : Math.Floor(endValue),
                    Symbol = symbol,
                };
                if (i == numOfClassBreaks - 1) // last class break
                {
                    classBreak.MaximumValue = max + lastRangeDeltaIncr;
                    if (max > 1000000) // SL has a limitation on values greater than a million http://msdn.microsoft.com/en-us/library/bb412393.aspx
                        classBreak.MaximumValue += 2.0;// the +2 is to workaround Silverlights limitation of single precision values
                }
                symbols.Add(symbol);
                renderer.Classes.Add(classBreak);
                startValue += rangeSize;
            }
            if (defaultColorRampGradientBrush != null)
            {
                if (existingSymbolSet == null) // apply the gradient brush, only if symbols have not been pre-defined
                {
                    applyLinearGradientBrushToSymbolSet(symbols, defaultColorRampGradientBrush, defaultSymbol);
                }
            }
            return renderer;
        }