Example #1
0
        private static void DeserializeLabels(dynamic labels, IMap map, IFeatureLayer featureLayer)
        {
            int fieldIndex = Convert.ToInt32(labels["Field"]) - 1;
            var fieldName  = featureLayer.DataSet.DataTable.Columns[fieldIndex].ColumnName;

            var symbolizer = new LabelSymbolizer();

            symbolizer.FontFamily = labels["Font"];

            try
            {
                if (Convert.ToBoolean(labels["Bold"]))
                {
                    symbolizer.FontStyle = FontStyle.Bold;
                }
                else if (Convert.ToBoolean(labels["Italic"]))
                {
                    symbolizer.FontStyle = FontStyle.Italic;
                }
                else if (Convert.ToBoolean(labels["Underline"]))
                {
                    symbolizer.FontStyle = FontStyle.Underline;
                }
            }
            catch (RuntimeBinderException)
            {
                // ignore and continue.
                // some versions of the files don't have these properties.
            }

            symbolizer.FontColor = LegacyDeserializer.GetColor(labels["Color"]);

            LegacyHJustification typeOfJustification = (LegacyHJustification)Enum.ToObject(typeof(LegacyHJustification), Convert.ToInt32(labels["Justification"]));

            switch (typeOfJustification)
            {
            case LegacyHJustification.Center:
                symbolizer.Orientation = ContentAlignment.MiddleCenter;
                break;

            case LegacyHJustification.Left:
                symbolizer.Orientation = ContentAlignment.MiddleLeft;
                break;

            case LegacyHJustification.Right:
                symbolizer.Orientation = ContentAlignment.MiddleRight;
                break;

            case LegacyHJustification.None:
            case LegacyHJustification.Raw:
            default:
                break;
            }

            try
            {
                symbolizer.DropShadowEnabled = Convert.ToBoolean(labels["UseShadows"]);
                symbolizer.DropShadowColor   = LegacyDeserializer.GetColor(labels["Color"]);
            }
            catch (RuntimeBinderException) { }

            // not entirely sure if Offset from MW4 translates to OffsetX.
            try { symbolizer.OffsetX = Convert.ToInt32(labels["Offset"]); }
            catch (RuntimeBinderException) { }

            string expression = String.Format("[{0}]", fieldName);

            featureLayer.AddLabels(expression, null, symbolizer, expression);
            featureLayer.LabelLayer.UseDynamicVisibility = Convert.ToBoolean(labels["UseMinZoomLevel"]);

            try { featureLayer.LabelLayer.DynamicVisibilityWidth = Convert.ToDouble(labels["Scale"]); }
            catch (RuntimeBinderException) { }
        }
Example #2
0
 [Obsolete("Use featureLayer.AddLabels() instead")] // Marked in 1.7
 public void AddLabels(IFeatureLayer featureLayer, string expression, Font font, Color fontColor)
 {
     featureLayer.AddLabels(expression, font, fontColor);
 }
Example #3
0
 [Obsolete("Use featureLayer.AddLabels() instead")] // Marked in 1.7
 public void AddLabels(IFeatureLayer featureLayer, string expression, string filterExpression,
                       ILabelSymbolizer symbolizer, double width)
 {
     featureLayer.AddLabels(expression, filterExpression, symbolizer, width);
 }
Example #4
0
 [Obsolete("Use featureLayer.AddLabels() instead")] // Marked in 1.7
 public void AddLabels(IFeatureLayer featureLayer, string expression, string filterExpression,
                       ILabelSymbolizer symbolizer, string name)
 {
     featureLayer.AddLabels(expression, filterExpression, symbolizer, name);
 }
        private static void DeserializeLabels(dynamic labels, IMap map, IFeatureLayer featureLayer)
        {
            int fieldIndex = Convert.ToInt32(labels["Field"]) - 1;
            var fieldName = featureLayer.DataSet.DataTable.Columns[fieldIndex].ColumnName;

            var symbolizer = new LabelSymbolizer();
            symbolizer.FontFamily = labels["Font"];

            try
            {
                if (Convert.ToBoolean(labels["Bold"]))
                    symbolizer.FontStyle = FontStyle.Bold;
                else if (Convert.ToBoolean(labels["Italic"]))
                    symbolizer.FontStyle = FontStyle.Italic;
                else if (Convert.ToBoolean(labels["Underline"]))
                    symbolizer.FontStyle = FontStyle.Underline;
            }
            catch (RuntimeBinderException)
            {
                // ignore and continue.
                // some versions of the files don't have these properties.
            }

            symbolizer.FontColor = LegacyDeserializer.GetColor(labels["Color"]);

            LegacyHJustification typeOfJustification = (LegacyHJustification)Enum.ToObject(typeof(LegacyHJustification), Convert.ToInt32(labels["Justification"]));

            switch (typeOfJustification)
            {
                case LegacyHJustification.Center:
                    symbolizer.Orientation = ContentAlignment.MiddleCenter;
                    break;
                case LegacyHJustification.Left:
                    symbolizer.Orientation = ContentAlignment.MiddleLeft;
                    break;
                case LegacyHJustification.Right:
                    symbolizer.Orientation = ContentAlignment.MiddleRight;
                    break;
                case LegacyHJustification.None:
                case LegacyHJustification.Raw:
                default:
                    break;
            }

            try
            {
                symbolizer.DropShadowEnabled = Convert.ToBoolean(labels["UseShadows"]);
                symbolizer.DropShadowColor = LegacyDeserializer.GetColor(labels["Color"]);
            }
            catch (RuntimeBinderException) { }

            // not entirely sure if Offset from MW4 translates to OffsetX.
            try { symbolizer.OffsetX = Convert.ToInt32(labels["Offset"]); }
            catch (RuntimeBinderException) { }

            string expression = String.Format("[{0}]", fieldName);

            featureLayer.AddLabels(expression, null, symbolizer, expression);
            featureLayer.LabelLayer.UseDynamicVisibility = Convert.ToBoolean(labels["UseMinZoomLevel"]);

            try { featureLayer.LabelLayer.DynamicVisibilityWidth = Convert.ToDouble(labels["Scale"]); }
            catch (RuntimeBinderException) { }
        }
Example #6
0
 [Obsolete("Use featureLayer.AddLabels() instead")] // Marked in 1.7
 public static void AddLabels(this IMap map, IFeatureLayer featureLayer, string expression, Font font, Color fontColor)
 {
     featureLayer.AddLabels(expression, font, fontColor);
 }