Ejemplo n.º 1
0
        public void Ctor_ValidProperties()
        {
            var target = new LabelSymbolizer();

            Assert.IsTrue(ValidEnumValue(target.Alignment));
            Assert.IsTrue(ValidEnumValue(target.FontStyle));
            Assert.IsTrue(ValidEnumValue(target.LabelPlacementMethod));
            Assert.IsTrue(ValidEnumValue(target.Orientation));
            Assert.IsTrue(ValidEnumValue(target.PartsLabelingMethod));
            Assert.IsTrue(ValidEnumValue(target.ScaleMode));
        }
 public static LabelCategory GetLabelCategory(
     string pTitle,
     string pLabelExpression,
     LabelSymbolizer pLabelSymbolizer)
 {
     return(new LabelCategory()
     {
         Expression = pLabelExpression,
         Symbolizer = pLabelSymbolizer,
         Name = pTitle
     });
 }
        private void UpdateLabeling(IFeatureLayer mapLayer, string columnName)
        {
            var symbolizer = new LabelSymbolizer
            {
                FontColor         = Color.Black,
                FontSize          = 8,
                FontFamily        = "Arial Unicode MS",
                PreventCollisions = true,
                HaloEnabled       = true,
                HaloColor         = Color.White,
                Orientation       = ContentAlignment.MiddleRight,
            };

            ((Map)((IMapFrame)_layer.MapFrame).Parent).AddLabels(mapLayer, string.Format("[{0}]", columnName), string.Empty, symbolizer, "Category Default");
        }
Ejemplo n.º 4
0
        public void UpdateLabeling()
        {
            const string attributeName = "SiteName";

            var symb = new LabelSymbolizer
            {
                FontColor         = Color.Black,
                FontSize          = 8,
                FontFamily        = "Arial Unicode MS",
                PreventCollisions = true,
                HaloEnabled       = true,
                HaloColor         = Color.White,
                Orientation       = ContentAlignment.MiddleRight,
                OffsetX           = 0.0f,
                OffsetY           = 0.0f,
            };

            _map.AddLabels(_layer, string.Format("[{0}]", attributeName),
                           string.Format("[ValueCount] > {0}", 10),
                           symb, "Category Default");
        }
Ejemplo n.º 5
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) { }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Run the tool.
        /// </summary>
        private void OK_Click(object sender, EventArgs e)
        {
            if (PolygonLayerList.SelectedValue != null &&
                SiteList.SelectedValue != null &&
                VariableList.SelectedValue != null &&
                !String.IsNullOrEmpty(OutputResultName.Text))
            {
                // Validate site name
                string nameCheckResult = resultNameIsValid(OutputResultName.Text);
                if (nameCheckResult != string.Empty)
                {
                    MessageBox.Show("Invalid site name. " + nameCheckResult, "CRWR Aggregation");
                    return;
                }

                List <string> LegendElements = new List <string>();

                for (int i = 0; i < PolygonLayerList.Items.Count; i++)
                {
                    LegendElements.Add(PolygonLayerList.Items[i].ToString().Split(',')[1].Substring(1));
                }
                for (int i = 0; i < SiteList.Items.Count; i++)
                {
                    LegendElements.Add(SiteList.Items[i].ToString().Split(',')[1].Substring(1));
                }

                if (!LegendElements.Contains(PolygonLayerList.Text + "_agg]"))
                {
                    sitesPoints.Name = PolygonLayerList.Text + "_agg";
                }
                else
                {
                    int counter = 1;
                    do
                    {
                        if (!LegendElements.Contains(PolygonLayerList.Text + "_agg (" + counter.ToString("D") + ")]"))
                        {
                            sitesPoints.Name = PolygonLayerList.Text + "_agg (" + counter.ToString("D") + ")";
                        }
                        else
                        {
                            counter = counter + 1;
                        }
                    } while (String.IsNullOrEmpty(sitesPoints.Name));
                }

                sitesPoints.Projection = App.Map.Projection;
                sitesPoints.DataTable.Columns.Add(new DataColumn("SiteCode", typeof(string)));

                var symb = new LabelSymbolizer
                {
                    FontColor         = Color.Black,
                    FontSize          = 10,
                    FontFamily        = "Arial",
                    PreventCollisions = true,
                    HaloEnabled       = true,
                    HaloColor         = Color.White,
                    Orientation       = ContentAlignment.MiddleRight,
                    OffsetX           = 0.0f,
                    OffsetY           = 0.0f,
                };

                AggregateData();

                IFeatureLayer flayer = App.Map.Layers.Add(sitesPoints);

                App.Map.AddLabels(flayer, string.Format("[{0}]", "SiteCode"),
                                  "", symb, "");
                flayer.ShowLabels = true;

                MessageBox.Show("The time series aggregation is completed.", "CRWR Aggregation",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                Parameters_form.ActiveForm.Close();
            }
            else
            {
                MessageBox.Show("Please complete the missing parts of the form.", "CRWR Aggregation");
            }
        }