Beispiel #1
0
        /// <summary>
        /// Creates a new category based on a symbolizer, and uses the same symbolizer, but with a fill and border color of light cyan
        /// for the selection symbolizer
        /// </summary>
        /// <param name="polygonSymbolizer">The symbolizer to use in order to create a category</param>
        public PolygonCategory(IPolygonSymbolizer polygonSymbolizer)
        {
            Symbolizer = polygonSymbolizer;
            IPolygonSymbolizer select = polygonSymbolizer.Copy();

            select.OutlineSymbolizer.ScaleMode = ScaleMode.Symbolic;
        }
 /// <summary>
 /// Launches a form for editing the line symbolizer
 /// </summary>
 /// <param name="context"></param>
 /// <param name="provider"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     _original = value as IPolygonSymbolizer;
     if (_original == null) return value;
     _copy = _original.Copy();
     IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
     DetailedPolygonSymbolDialog dialog = new DetailedPolygonSymbolDialog(_copy);
     dialog.ChangesApplied += DialogChangesApplied;
     if (dialogProvider.ShowDialog(dialog) != DialogResult.OK) return _original;
     _original.CopyProperties(_copy);
     return value;
 }
Beispiel #3
0
 /// <summary>
 /// Assigns the original symbolizer to this control
 /// </summary>
 /// <param name="original">The polygon symbolizer to modify.</param>
 public void Initialize(IPolygonSymbolizer original)
 {
     _symbolizer         = original.Copy();
     _original           = original;
     ccPatterns.Patterns = _symbolizer.Patterns;
     ccPatterns.RefreshList();
     if (_symbolizer.Patterns.Count > 0)
     {
         ccPatterns.SelectedPattern = _symbolizer.Patterns[0];
     }
     ocOutline.Pattern = ccPatterns.SelectedPattern;
     UpdatePreview();
     UpdatePatternControls();
 }
Beispiel #4
0
        public void ConvertLayerProperties_MapPolygonDataWithThemeAndMetaDataNameNotInFeatures_OnlyAddsDefaultCategory()
        {
            // Setup
            const string metadataAttribute = "Meta";
            var          random            = new Random(21);
            var          theme             = new MapTheme <PolygonCategoryTheme>("Other Meta", new[]
            {
                new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                         new PolygonStyle
                {
                    FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });

            var polygonStyle = new PolygonStyle
            {
                FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var mapPolygonData = new MapPolygonData("test", polygonStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            var mapPolygonLayer = new MapPolygonLayer();

            var converter = new MapPolygonDataConverter();

            // Call
            converter.ConvertLayerProperties(mapPolygonData, mapPolygonLayer);

            // Assert
            IPolygonSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(polygonStyle);

            IPolygonScheme appliedScheme = mapPolygonLayer.Symbology;

            Assert.AreEqual(1, appliedScheme.Categories.Count);

            IPolygonCategory baseCategory = appliedScheme.Categories[0];

            AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer);
            Assert.IsNull(baseCategory.FilterExpression);
        }
Beispiel #5
0
        private static void AssertAreEqual(IPolygonSymbolizer firstSymbolizer, IPolygonSymbolizer secondSymbolizer)
        {
            IList <IPattern> firstPatterns  = firstSymbolizer.Patterns;
            IList <IPattern> secondPatterns = secondSymbolizer.Patterns;

            Assert.AreEqual(firstPatterns.Count, secondPatterns.Count, "Unequal amount of patterns defined.");
            for (var i = 0; i < firstPatterns.Count; i++)
            {
                var firstPattern  = (SimplePattern)firstPatterns[i];
                var secondPattern = (SimplePattern)secondPatterns[i];

                Assert.AreEqual(firstPattern.FillColor, secondPattern.FillColor);
                Assert.AreEqual(firstPattern.Outline.GetFillColor(), secondPattern.Outline.GetFillColor());
                Assert.AreEqual(firstPattern.Outline.GetWidth(), secondPattern.Outline.GetWidth());
            }
        }
Beispiel #6
0
 /// <summary>
 /// If possible, use the template to control the colors.  Otherwise, just use the default
 /// settings for creating "unbounded" colors.
 /// </summary>
 /// <param name="count">The integer count.</param>
 /// <returns>The List of colors</returns>
 protected override List <Color> GetDefaultColors(int count)
 {
     if (EditorSettings != null)
     {
         IPolygonSymbolizer ps = EditorSettings.TemplateSymbolizer as IPolygonSymbolizer;
         if (ps != null)
         {
             List <Color> result = new List <Color>();
             Color        c      = ps.GetFillColor();
             for (int i = 0; i < count; i++)
             {
                 result.Add(c);
             }
             return(result);
         }
     }
     return(base.GetDefaultColors(count));
 }
        /// <summary>
        /// Launches a form for editing the line symbolizer
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _original = value as IPolygonSymbolizer;
            if (_original == null)
            {
                return(value);
            }
            _copy = _original.Copy();
            IWindowsFormsEditorService  dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            DetailedPolygonSymbolDialog dialog         = new DetailedPolygonSymbolDialog(_copy);

            dialog.ChangesApplied += DialogChangesApplied;
            if (dialogProvider.ShowDialog(dialog) != DialogResult.OK)
            {
                return(_original);
            }
            _original.CopyProperties(_copy);
            return(value);
        }
Beispiel #8
0
        private void BtnImportSymbolClick(object sender, EventArgs e)
        {
            IPolygonSymbolizer ps = SerializeHelper.OpenFeatureSymbolizer() as IPolygonSymbolizer;

            if (ps != null)
            {
                _symbolizer         = ps;
                ccPatterns.Patterns = _symbolizer.Patterns;
                ccPatterns.RefreshList();
                if (_symbolizer.Patterns.Count > 0)
                {
                    ccPatterns.SelectedPattern = _symbolizer.Patterns[0];
                }

                UpdatePreview();
                UpdatePatternControls();
            }
            else
            {
                MessageBox.Show("Failed to open file");
            }
        }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DetailedPolygonSymbolControl"/> class
 /// where the properties displayed on the form are a duplicate of the original properties,
 /// and those properties will be copied back to the original on an apply changes or an ok click.
 /// </summary>
 /// <param name="original">The original polygon symbolizer.</param>
 public DetailedPolygonSymbolControl(IPolygonSymbolizer original)
     : this()
 {
     Initialize(original);
 }
Beispiel #10
0
 public PolygonSymbolCollection(IPolygonSymbolizer parent) : base(parent)
 {
 }
 public GeometrySymbolizer()
 {
     _pointSymbolizer   = new RasterPointSymbolizer();
     _lineSymbolizer    = new BasicLineSymbolizer();
     _polygonSymbolizer = new BasicPolygonSymbolizer();
 }
 /// <summary>
 /// Creates a new DetailedPolygonSymbolControl using the specified
 /// </summary>
 /// <param name="original"></param>
 public DetailedPolygonSymbolDialog(IPolygonSymbolizer original)
 {
     InitializeComponent();
     _detailedPolygonSymbolControl1.Initialize(original);
     Configure();
 }
        /// <summary>
        /// Draws the GraphicsPaths.  Before we were effectively "re-creating" the same geometric
        /// </summary>
        /// <param name="e"></param>
        /// <param name="paths"></param>
        private void DrawPaths(MapArgs e, IList <GraphicsPath> paths)
        {
            Graphics g             = e.Device ?? Graphics.FromImage(_backBuffer);
            int      numCategories = Symbology.Categories.Count;

            if (!DrawnStatesNeeded && !EditMode)
            {
                IPolygonSymbolizer ps = Symbolizer;
                g.SmoothingMode = ps.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None;
                Extent     catBounds = DataSet.Extent;
                RectangleF bounds    = new RectangleF();
                bounds.X = Convert.ToSingle((catBounds.MinX - e.MinX) * e.Dx);
                bounds.Y = Convert.ToSingle((e.MaxY - catBounds.MaxY) * e.Dy);
                float r = Convert.ToSingle((catBounds.MaxX - e.MinX) * e.Dx);
                bounds.Width = r - bounds.X;
                float b = Convert.ToSingle((e.MaxY - catBounds.MinY) * e.Dy);
                bounds.Height = b - bounds.Y;

                foreach (IPattern pattern in ps.Patterns)
                {
                    IGradientPattern gp = pattern as IGradientPattern;
                    if (gp != null)
                    {
                        gp.Bounds = bounds;
                    }

                    pattern.FillPath(g, paths[0]);
                }

                double scale = 1;
                if (ps.ScaleMode == ScaleMode.Geographic)
                {
                    scale = e.ImageRectangle.Width / e.GeographicExtents.Width;
                }
                foreach (IPattern pattern in ps.Patterns)
                {
                    if (pattern.UseOutline)
                    {
                        pattern.DrawPath(g, paths[0], scale);
                    }
                }
            }
            else
            {
                for (int selectState = 0; selectState < 2; selectState++)
                {
                    int iCategory = 0;
                    foreach (IPolygonCategory category in Symbology.Categories)
                    {
                        Extent catBounds;
                        if (CategoryExtents.Keys.Contains(category))
                        {
                            catBounds = CategoryExtents[category];
                        }
                        else
                        {
                            catBounds = CalculateCategoryExtent(category);
                        }
                        if (catBounds == null)
                        {
                            catBounds = Extent;
                        }
                        RectangleF bounds = new RectangleF();
                        bounds.X = Convert.ToSingle((catBounds.MinX - e.MinX) * e.Dx);
                        bounds.Y = Convert.ToSingle((e.MaxY - catBounds.MaxY) * e.Dy);
                        float r = Convert.ToSingle((catBounds.MaxX - e.MinX) * e.Dx);
                        bounds.Width = r - bounds.X;
                        float b = Convert.ToSingle((e.MaxY - catBounds.MinY) * e.Dy);
                        bounds.Height = b - bounds.Y;

                        int index = selectState * numCategories + iCategory;
                        // Define the symbology based on the category and selection state
                        IPolygonSymbolizer ps = category.Symbolizer;
                        if (selectState == SELECTED)
                        {
                            ps = category.SelectionSymbolizer;
                        }

                        g.SmoothingMode = ps.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None;

                        foreach (IPattern pattern in ps.Patterns)
                        {
                            IGradientPattern gp = pattern as IGradientPattern;
                            if (gp != null)
                            {
                                gp.Bounds = bounds;
                            }
                            if (paths[index] != null)
                            {
                                paths[index].FillMode = FillMode.Winding;
                                pattern.FillPath(g, paths[index]);
                            }
                        }

                        double scale = 1;
                        if (ps.ScaleMode == ScaleMode.Geographic)
                        {
                            scale = e.ImageRectangle.Width / e.GeographicExtents.Width;
                        }
                        foreach (IPattern pattern in ps.Patterns)
                        {
                            if (pattern.UseOutline)
                            {
                                pattern.DrawPath(g, paths[index], scale);
                            }
                        }
                        iCategory++;
                    } // category
                }     // selectState
            }

            for (int i = 0; i < Symbology.Categories.Count; i++)
            {
                paths[i].Dispose();
            }
            if (e.Device == null)
            {
                g.Dispose();
            }
        }
Beispiel #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            _wasDoubleClick = true;
            Point loc = new Point(e.X + ControlRectangle.X, e.Location.Y + ControlRectangle.Top);

            foreach (LegendBox lb in _legendBoxes)
            {
                if (!lb.Bounds.Contains(loc) || lb.CheckBox.Contains(loc))
                {
                    continue;
                }
                ILineCategory lc = lb.Item as ILineCategory;
                if (lc != null)
                {
                    DetailedLineSymbolDialog lsDialog = new DetailedLineSymbolDialog(lc.Symbolizer);
                    lsDialog.ShowDialog();
                    ILineSymbolizer sel = lc.Symbolizer.Copy();
                    sel.SetFillColor(Color.Cyan);
                    lc.SelectionSymbolizer = sel;
                }
                IPointCategory pc = lb.Item as IPointCategory;
                if (pc != null)
                {
                    DetailedPointSymbolDialog dlg = new DetailedPointSymbolDialog(pc.Symbolizer);
                    dlg.ShowDialog();
                    IPointSymbolizer ps = pc.Symbolizer.Copy();
                    ps.SetFillColor(Color.Cyan);
                    pc.SelectionSymbolizer = ps;
                }
                IPolygonCategory polyCat = lb.Item as IPolygonCategory;
                if (polyCat != null)
                {
                    DetailedPolygonSymbolDialog dlg = new DetailedPolygonSymbolDialog(polyCat.Symbolizer);
                    dlg.ShowDialog();
                    IPolygonSymbolizer ps = polyCat.Symbolizer.Copy();
                    ps.SetFillColor(Color.Cyan);
                    ps.OutlineSymbolizer.SetFillColor(Color.DarkCyan);
                    polyCat.SelectionSymbolizer = ps;
                }
                IFeatureLayer fl = lb.Item as IFeatureLayer;
                if (fl != null)
                {
                    LayerDialog layDialog = new LayerDialog(fl, new FeatureCategoryControl());
                    layDialog.ShowDialog();
                }
                IRasterLayer rl = lb.Item as IRasterLayer;
                if (rl != null)
                {
                    LayerDialog dlg = new LayerDialog(rl, new RasterCategoryControl());
                    dlg.ShowDialog();
                }
                IColorCategory cb = lb.Item as IColorCategory;
                if (cb != null)
                {
                    _tabColorDialog = new TabColorDialog();
                    _tabColorDialog.ChangesApplied += TabColorDialogChangesApplied;
                    _tabColorDialog.StartColor      = cb.LowColor;
                    _tabColorDialog.EndColor        = cb.HighColor;
                    _editCategory = cb;
                    _tabColorDialog.ShowDialog(this);
                }
            }
            base.OnMouseDoubleClick(e);
        }
 /// <summary>
 /// Creates a new category based on a symbolizer, and uses the same symbolizer, but with a fill and border color of light cyan
 /// for the selection symbolizer
 /// </summary>
 /// <param name="polygonSymbolizer">The symbolizer to use in order to create a category</param>
 public PolygonCategory(IPolygonSymbolizer polygonSymbolizer)
 {
     Symbolizer = polygonSymbolizer;
     IPolygonSymbolizer select = polygonSymbolizer.Copy();
     select.OutlineSymbolizer.ScaleMode = ScaleMode.Symbolic;
 }
Beispiel #16
0
 /// <summary>
 /// Creates a new instance of PolygonSymbolizerEventArgs
 /// </summary>
 public PolygonSymbolizerEventArgs(IPolygonSymbolizer symbolizer)
     : base(symbolizer)
 {
 }
 /// <summary>
 /// Assigns the original symbolizer to this control
 /// </summary>
 /// <param name="original">The polygon symbolizer to modify.</param>
 public void Initialize(IPolygonSymbolizer original)
 {
     _symbolizer = original.Copy();
     _original = original;
     ccPatterns.Patterns = _symbolizer.Patterns;
     ccPatterns.RefreshList();
     if (_symbolizer.Patterns.Count > 0)
     {
         ccPatterns.SelectedPattern = _symbolizer.Patterns[0];
     }
     ocOutline.Pattern = ccPatterns.SelectedPattern;
     UpdatePreview();
     UpdatePatternControls();
 }
 /// <summary>
 /// Creates a new instance of PolygonSymbolizerEventArgs
 /// </summary>
 public PolygonSymbolizerEventArgs(IPolygonSymbolizer symbolizer)
     : base(symbolizer)
 {
 }
 /// <summary>
 /// Creates a new DetailedPolygonSymbolControl using the specified
 /// </summary>
 /// <param name="original"></param>
 public DetailedPolygonSymbolDialog(IPolygonSymbolizer original)
 {
     InitializeComponent();
     _detailedPolygonSymbolControl1.Initialize(original);
     Configure();
 }