Exemplo n.º 1
0
        private void CmbStrokeTypeSelectedIndexChanged(object sender, EventArgs e)
        {
            if (_ignoreChanges)
            {
                return;
            }
            int index = ccStrokes.Strokes.IndexOf(ccStrokes.SelectedStroke);

            if (index == -1)
            {
                return;
            }
            string strokeType = cmbStrokeType.SelectedItem.ToString();

            if (strokeType == "Cartographic")
            {
                ICartographicStroke cs = new CartographicStroke();
                ccStrokes.Strokes[index] = cs;
                ccStrokes.RefreshList();
                ccStrokes.SelectedStroke = cs;

                // UpdateStrokeControls();
            }
            else if (strokeType == "Simple")
            {
                ISimpleStroke ss = new SimpleStroke();
                ccStrokes.Strokes[index] = ss;
                ccStrokes.RefreshList();
                ccStrokes.SelectedStroke = ss;

                // UpdateStrokeControls();
            }

            // UpdatePreview();
        }
Exemplo n.º 2
0
        private void CmbStrokeTypeSelectedIndexChanged(object sender, EventArgs e)
        {
            if (_ignoreChanges)
            {
                return;
            }
            var oldStroke      = ccStrokes.SelectedStroke;
            var oldStrokeStyle = oldStroke.StrokeStyle;
            int index          = ccStrokes.Strokes.IndexOf(ccStrokes.SelectedStroke);

            if (index == -1)
            {
                return;
            }
            StrokeStyle strokeStyle = Global.ParseEnum <StrokeStyle>(cmbStrokeType.SelectedIndex);
            IStroke     newStroke   = null;

            switch (strokeStyle)
            {
            case StrokeStyle.Cartographic:
                newStroke = new CartographicStroke();
                break;

            case StrokeStyle.Simple:
                newStroke = new SimpleStroke();
                break;

            case StrokeStyle.Marker:
                newStroke = new MarkerStroke();
                break;

            default:
                cmbStrokeType.SelectedIndex = Global.GetEnumIndex(oldStrokeStyle);
                MessageBox.Show("暂未实现");
                return;
            }
            StrokeStyle newStrokeStyle = newStroke.StrokeStyle;

            newStroke.CopyProperties(oldStroke);
            ccStrokes.Strokes[index] = newStroke;
            ccStrokes.RefreshList();
            ccStrokes.SelectedStroke = newStroke;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Translates the given style as line style and adds it to the given line scheme.
        /// </summary>
        /// <param name="scheme">The scheme the style gets added to.</param>
        /// <param name="style">The style that gets translated.</param>
        private static void TranslateLineStyle(LineScheme scheme, string style)
        {
            if (string.IsNullOrWhiteSpace(style))
            {
                return;
            }

            var mystyle = style;
            int index   = mystyle.IndexOf("(", StringComparison.Ordinal);

            if (index < 1)
            {
                return;
            }

            var toolname = mystyle.Substring(0, index);

            mystyle = mystyle.Substring(index + 1);

            Color     col       = Color.Black;
            double    width     = 1;
            DashStyle dashStyle = DashStyle.Solid;

            float[] pattern   = null;
            bool    invisible = true;

            switch (toolname)
            {
            case "PEN":
                col       = GetColor(ref mystyle, Parameters.Color);
                width     = GetWidth(ref mystyle);
                pattern   = GetPattern(ref mystyle);
                dashStyle = GetDashStyle(ref mystyle, out invisible);
                break;
            }

            if (pattern != null)
            {
                dashStyle = DashStyle.Custom;
            }
            if (invisible)
            {
                col = Color.Transparent;
            }

            var stroke = new CartographicStroke(col)
            {
                Width     = width,
                DashStyle = dashStyle
            };

            if (pattern != null)
            {
                stroke.DashPattern = pattern;
            }

            var symb = new LineSymbolizer
            {
                ScaleMode = ScaleMode.Simple,
                Smoothing = false,
                Strokes   =
                {
                    [0] = stroke
                }
            };

            var cat = new LineCategory
            {
                FilterExpression = $"[style] = '{style}'",
                LegendText       = style,
                Symbolizer       = symb
            };

            scheme.AddCategory(cat);
        }
 private void cmbStrokeType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_ignoreChanges) return;
     int index = ccStrokes.Strokes.IndexOf(ccStrokes.SelectedStroke);
     if (index == -1) return;
     string strokeType = cmbStrokeType.SelectedItem.ToString();
     if (strokeType == "Cartographic")
     {
         ICartographicStroke cs = new CartographicStroke();
         ccStrokes.Strokes[index] = cs;
         ccStrokes.RefreshList();
         ccStrokes.SelectedStroke = cs;
         //UpdateStrokeControls();
     }
     else if (strokeType == "Simple")
     {
         ISimpleStroke ss = new SimpleStroke();
         ccStrokes.Strokes[index] = ss;
         ccStrokes.RefreshList();
         ccStrokes.SelectedStroke = ss;
         // UpdateStrokeControls();
     }
     //UpdatePreview();
 }
Exemplo n.º 5
0
        private void SymbolizerLines(IMapFeatureLayer aLayer)
        {
            //Method 1. simple symbolizer
            aLayer.Symbolizer = new LineSymbolizer(Color.Brown, 1);

            //Method 2. Combined symbolizer
            LineSymbolizer road = new LineSymbolizer(Color.Yellow, 5);

            road.SetOutline(Color.Black, 1);
            aLayer.Symbolizer = road;

            /* Method 3. Symbology by unique values:
             * HueSatLight = true, then the ramp is created by adjusting the
             * hue, saturation and lightness between the start and end colors.
             * HueSatLight = false, then the red, blue and green values are ramped instead.
             *
             * In both cases, alpha (transparency) is ramped the same way.
             */
            LineScheme lScheme = new LineScheme();

            lScheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues;
            lScheme.EditorSettings.FieldName          = "CARTO";
            lScheme.CreateCategories(aLayer.DataSet.DataTable);
            aLayer.Symbology = lScheme;

            //Method 4. Collapsible field name in legend via 'AppearsInLegend'
            LineScheme lScheme1 = new LineScheme();

            lScheme1.Categories.Clear(); //redundant???
            LineCategory lowCat = new LineCategory(Color.Blue, 2);

            lowCat.FilterExpression = "[CARTO] = 3";
            lowCat.LegendText       = "Low";
            LineCategory highCat = new LineCategory(
                Color.Red,
                Color.Black,
                6,
                DashStyle.Solid,
                LineCap.Triangle);;

            highCat.FilterExpression = "[CARTO] = 2";
            highCat.LegendText       = "High";
            lScheme1.AppearsInLegend = true;
            lScheme1.LegendText      = "CARTO";
            lScheme1.Categories.Add(lowCat);
            aLayer.Symbology = lScheme1;
            lScheme1.Categories.Add(highCat);

            /*Method 5. Lines with multiple strokes
             * Each individual LineSymbolizer is made up of at least one,
             * but potentially several strokes overlapping each other
             */
            LineSymbolizer multiStrokeSym = new LineSymbolizer();

            multiStrokeSym.Strokes.Clear(); //redundant???
            CartographicStroke ties = new CartographicStroke(Color.Brown);

            ties.DashPattern = new float[] { 1 / 6f, 2 / 6f };
            ties.Width       = 6;
            ties.EndCap      = LineCap.Flat;
            ties.StartCap    = LineCap.Flat;
            CartographicStroke rails = new CartographicStroke(Color.DarkGray);

            rails.CompoundArray = new float[] { .15f, .3f, .6f, .75f };
            rails.Width         = 6;
            rails.EndCap        = LineCap.Flat;
            rails.StartCap      = LineCap.Flat;
            multiStrokeSym.Strokes.Add(ties);
            multiStrokeSym.Strokes.Add(rails);
            aLayer.Symbolizer = multiStrokeSym;
        }