Ejemplo n.º 1
0
        /// <summary>
        /// Initializes this point size range control
        /// </summary>
        /// <param name="args"></param>
        public void Initialize(SizeRangeEventArgs args)
        {
            if (_sizeRange == null)
            {
                return;
            }
            _sizeRange.Start        = args.StartSize;
            _sizeRange.End          = args.EndSize;
            _sizeRange.Symbolizer   = args.Template;
            _sizeRange.UseSizeRange = args.UseSizeRange;
            IPointSymbolizer ps = args.Template as IPointSymbolizer;

            if (ps != null)
            {
                psvStart.Visible = true;
                psvEnd.Visible   = true;
                lsvStart.Visible = false;
                lsvEnd.Visible   = false;
            }
            ILineSymbolizer ls = args.Template as ILineSymbolizer;

            if (ls != null)
            {
                lsvStart.Visible = true;
                lsvEnd.Visible   = true;
                psvStart.Visible = false;
                psvEnd.Visible   = false;
            }
        }
Ejemplo n.º 2
0
        // This draws the individual point features
        private void DrawFeatures(MapArgs e, IEnumerable <IFeature> features, bool selected)
        {
            IDictionary <IFeature, IDrawnState> states = DrawingFilter.DrawnStates;

            if (states == null)
            {
                return;
            }
            if (selected && !states.Any(_ => _.Value.IsSelected))
            {
                return;
            }

            Graphics g             = e.Device ?? Graphics.FromImage(BackBuffer);
            Matrix   origTransform = g.Transform;

            foreach (IFeature feature in features)
            {
                if (!states.ContainsKey(feature))
                {
                    continue;
                }
                IDrawnState ds = states[feature];
                if (ds == null || !ds.IsVisible || ds.SchemeCategory == null)
                {
                    continue;
                }

                if (selected && !ds.IsSelected)
                {
                    continue;
                }

                IPointCategory pc = ds.SchemeCategory as IPointCategory;
                if (pc == null)
                {
                    continue;
                }

                IPointSymbolizer ps = selected ? pc.SelectionSymbolizer : pc.Symbolizer;
                if (ps == null)
                {
                    continue;
                }

                foreach (Coordinate c in feature.Geometry.Coordinates)
                {
                    DrawPoint(c.X, c.Y, e, ps, g, origTransform);
                }
            }

            if (e.Device == null)
            {
                g.Dispose();
            }
            else
            {
                g.Transform = origTransform;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Given a size, this will return the native symbolizer that has been adjusted to the specified size.
        /// </summary>
        /// <param name="size">The size of the symbol</param>
        /// <param name="color">The color of the symbol</param>
        /// <returns>The adjusted symbolizer.</returns>
        public IFeatureSymbolizer GetSymbolizer(double size, Color color)
        {
            IFeatureSymbolizer copy = Symbolizer.Copy();

            // preserve aspect ratio, larger dimension specified
            IPointSymbolizer ps = copy as IPointSymbolizer;

            if (ps != null)
            {
                Size2D s     = ps.GetSize();
                double ratio = size / Math.Max(s.Width, s.Height);
                s.Width  *= ratio;
                s.Height *= ratio;
                ps.SetSize(s);
                ps.SetFillColor(color);
            }

            ILineSymbolizer ls = copy as ILineSymbolizer;

            if (ls != null)
            {
                ls.SetWidth(size);
                ls.SetFillColor(color);
            }

            return(copy);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of LineDecoration
 /// </summary>
 public LineDecoration()
 {
     _symbol = new PointSymbolizer(SymbologyGlobal.RandomColor(), PointShape.Triangle, 10);
     _flipAll = false;
     _flipFirst = true;
     _rotateWithLine = true;
     _numSymbols = 2;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineDecoration"/> class.
 /// </summary>
 public LineDecoration()
 {
     _symbol         = new PointSymbolizer(SymbologyGlobal.RandomColor(), PointShape.Triangle, 10);
     _flipAll        = false;
     _flipFirst      = true;
     _rotateWithLine = true;
     _numSymbols     = 2;
 }
Ejemplo n.º 6
0
        public static void DrawPoint(IPointSymbolizer symbolizer, Graphics g, IPoint point, MapViewport map)
        {
            if (point == null)
            {
                return;
            }

            symbolizer.Render(map, point, g);
        }
Ejemplo n.º 7
0
        public static RectangleF DrawPointEx(IPointSymbolizer symbolizer, Graphics g, IPoint point, MapViewport map)
        {
            if (point == null)
            {
                return(RectangleF.Empty);
            }

            symbolizer.Render(map, point, g);
            return(((IPointSymbolizerEx)symbolizer).CanvasArea);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Draws a point at the given location.
        /// </summary>
        /// <param name="ptX">X-Coordinate of the point, that should be drawn.</param>
        /// <param name="ptY">Y-Coordinate of the point, that should be drawn.</param>
        /// <param name="e">MapArgs for calculating the scaleSize.</param>
        /// <param name="ps">PointSymbolizer with which the point gets drawn.</param>
        /// <param name="g">Graphics-Object that should be used by the PointSymbolizer.</param>
        /// <param name="origTransform">The original transformation that is used to position the point.</param>
        private void DrawPoint(double ptX, double ptY, MapArgs e, IPointSymbolizer ps, Graphics g, Matrix origTransform)
        {
            var    x         = Convert.ToInt32((ptX - e.MinX) * e.Dx);
            var    y         = Convert.ToInt32((e.MaxY - ptY) * e.Dy);
            double scaleSize = ps.GetScale(e);
            Matrix shift     = origTransform.Clone();

            shift.Translate(x, y);
            g.Transform = shift;
            ps.Draw(g, scaleSize);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates the category using a random fill color.
        /// </summary>
        /// <param name="fillColor">The base color to use for creating the category.</param>
        /// <param name="size">The double size of the larger dimension of the point.</param>
        /// <returns>A new polygon category.</returns>
        public override ICategory CreateNewCategory(Color fillColor, double size)
        {
            IPointSymbolizer ps = EditorSettings.TemplateSymbolizer.Copy() as IPointSymbolizer ?? new PointSymbolizer(fillColor, PointShape.Ellipse, size);

            ps.SetFillColor(fillColor);
            Size2D oSize = ps.GetSize();
            double rat   = size / Math.Max(oSize.Width, oSize.Height);

            ps.SetSize(new Size2D(rat * oSize.Width, rat * oSize.Height));
            return(new PointCategory(ps));
        }
 /// <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(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     _original = value as IPointSymbolizer;
     if (_original == null) return value;
     _copy = _original.Copy();
     IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
     DetailedPointSymbolDialog dialog = new DetailedPointSymbolDialog(_copy);
     dialog.ChangesApplied += new EventHandler(dialog_ChangesApplied);
     if (dialogProvider.ShowDialog(dialog) != DialogResult.OK) return value;
     _original.CopyProperties(_copy);
     return value;
 }
Ejemplo n.º 11
0
        private float GetAngleFromExpression(int fid, IPointSymbolizer ps)
        {
            float angle = 0;

            if (_expression == null || fid >= DataSet.DataTable.Rows.Count)
            {
                return(angle);
            }
            var    row        = DataSet.DataTable.Rows[fid];
            string value      = _expression.CalculateRowValue(row, fid);
            bool   convertRet = float.TryParse(value, out angle);

            return(angle);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Resets the existing control with the new symbolizer.
        /// </summary>
        /// <param name="original">The original symbolizer.</param>
        public void Initialize(IPointSymbolizer original)
        {
            _original         = original;
            _symbolizer       = original.Copy();
            ccSymbols.Symbols = _symbolizer.Symbols;
            ccSymbols.RefreshList();
            if (_symbolizer.Symbols.Count > 0)
            {
                ccSymbols.SelectedSymbol = _symbolizer.Symbols[0];
            }

            UpdatePreview();
            UpdateSymbolControls();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Draws a point at the given location.
        /// </summary>
        /// <param name="ptX">X-Coordinate of the point, that should be drawn.</param>
        /// <param name="ptY">Y-Coordinate of the point, that should be drawn.</param>
        /// <param name="e">MapArgs for calculating the scaleSize.</param>
        /// <param name="ps">PointSymbolizer with which the point gets drawn.</param>
        /// <param name="g">Graphics-Object that should be used by the PointSymbolizer.</param>
        /// <param name="origTransform">The original transformation that is used to position the point.</param>
        private void DrawPoint(double ptX, double ptY, MapArgs e, IPointSymbolizer ps, Graphics g, Matrix origTransform)
        {
            var pt = new Point
            {
                X = Convert.ToInt32((ptX - e.MinX) * e.Dx),
                Y = Convert.ToInt32((e.MaxY - ptY) * e.Dy)
            };
            double scaleSize = ps.ScaleMode == ScaleMode.Geographic ? e.ImageRectangle.Width / e.GeographicExtents.Width : 1;
            Matrix shift     = origTransform.Clone();

            shift.Translate(pt.X, pt.Y);
            g.Transform = shift;
            ps.Draw(g, scaleSize);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Draws a point at the given location.
        /// </summary>
        /// <param name="ptX">X-Coordinate of the point, that should be drawn.</param>
        /// <param name="ptY">Y-Coordinate of the point, that should be drawn.</param>
        /// <param name="e">MapArgs for calculating the scaleSize.</param>
        /// <param name="ps">PointSymbolizer with which the point gets drawn.</param>
        /// <param name="g">Graphics-Object that should be used by the PointSymbolizer.</param>
        /// <param name="origTransform">The original transformation that is used to position the point.</param>
        /// <param name="clockwiseAngle">clockwiseAngle.</param>
        private void DrawPoint(double ptX, double ptY, MapArgs e, IPointSymbolizer ps, Graphics g, Matrix origTransform, float clockwiseAngle)
        {
            var pt = new PointF
            {
                X = Convert.ToSingle((ptX - e.MinX) * e.Dx),
                Y = Convert.ToSingle((e.MaxY - ptY) * e.Dy)
            };
            double scaleSize = ps.GetScale(e);
            Matrix shift     = origTransform.Clone();

            shift.Translate(pt.X, pt.Y);
            shift.Rotate(clockwiseAngle);
            g.Transform = shift;
            ps.Draw(g, scaleSize);
        }
Ejemplo n.º 15
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)
        {
            IPointSymbolizer ps = EditorSettings?.TemplateSymbolizer as IPointSymbolizer;

            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));
        }
Ejemplo n.º 16
0
        private static void AssertAreEqual(IPointSymbolizer expectedSymbolizer, IPointSymbolizer actualSymbolizer)
        {
            IList <ISymbol> firstSymbols  = expectedSymbolizer.Symbols;
            IList <ISymbol> secondSymbols = actualSymbolizer.Symbols;

            Assert.AreEqual(firstSymbols.Count, secondSymbols.Count, "Unequal amount of symbols defined.");
            for (var i = 0; i < firstSymbols.Count; i++)
            {
                var firstSymbol  = (SimpleSymbol)firstSymbols[i];
                var secondSymbol = (SimpleSymbol)secondSymbols[i];

                Assert.AreEqual(firstSymbol.Color, secondSymbol.Color);
                Assert.AreEqual(firstSymbol.PointShape, secondSymbol.PointShape);
                Assert.AreEqual(firstSymbol.Size, secondSymbol.Size);
                Assert.AreEqual(firstSymbol.OutlineColor, secondSymbol.OutlineColor);
                Assert.AreEqual(firstSymbol.OutlineWidth, secondSymbol.OutlineWidth);
            }
        }
Ejemplo n.º 17
0
        /// <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 IPointSymbolizer;
            if (_original == null)
            {
                return(value);
            }
            _copy = _original.Copy();
            IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            DetailedPointSymbolDialog  dialog         = new DetailedPointSymbolDialog(_copy);

            dialog.ChangesApplied += DialogChangesApplied;
            if (dialogProvider.ShowDialog(dialog) != DialogResult.OK)
            {
                return(value);
            }
            _original.CopyProperties(_copy);
            return(value);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// This replaces the constant size calculation with a size
        /// calculation that is appropriate for features.
        /// </summary>
        /// <param name="count">The integer count of the number of sizes to create.</param>
        /// <returns>A list of double valued sizes.</returns>
        protected override List <double> GetSizeSet(int count)
        {
            List <double> result = new List <double>();

            if (EditorSettings.UseSizeRange)
            {
                double start = EditorSettings.StartSize;
                double dr    = EditorSettings.EndSize - start;
                double dx    = dr / count;
                if (!EditorSettings.RampColors)
                {
                    Random rnd = new Random(DateTime.Now.Millisecond);
                    for (int i = 0; i < count; i++)
                    {
                        result.Add(start + (rnd.NextDouble() * dr));
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        result.Add(start + (i * dx));
                    }
                }
            }
            else
            {
                Size2D           sizes = new Size2D(2, 2);
                IPointSymbolizer ps    = EditorSettings.TemplateSymbolizer as IPointSymbolizer;
                if (ps != null)
                {
                    sizes = ps.GetSize();
                }
                double size = Math.Max(sizes.Width, sizes.Height);
                for (int i = 0; i < count; i++)
                {
                    result.Add(size);
                }
            }

            return(result);
        }
Ejemplo n.º 19
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (_sizeRange == null)
            {
                return;
            }
            IPointSymbolizer ps = _sizeRange.Symbolizer as IPointSymbolizer;

            if (ps != null)
            {
                _pointDialog.Symbolizer = _sizeRange.Symbolizer as IPointSymbolizer;
                _pointDialog.ShowDialog(this);
            }
            ILineSymbolizer ls = _sizeRange.Symbolizer as ILineSymbolizer;

            if (ls != null)
            {
                _lineDialog.Symbolizer = _sizeRange.Symbolizer as ILineSymbolizer;
                _lineDialog.ShowDialog(this);
            }
        }
Ejemplo n.º 20
0
        private void BtnImportSymbolClick(object sender, EventArgs e)
        {
            IPointSymbolizer ps = SerializeHelper.OpenFeatureSymbolizer() as IPointSymbolizer;

            if (ps != null)
            {
                _symbolizer       = ps;
                ccSymbols.Symbols = _symbolizer.Symbols;
                ccSymbols.RefreshList();
                if (_symbolizer.Symbols.Count > 0)
                {
                    ccSymbols.SelectedSymbol = _symbolizer.Symbols[0];
                }

                UpdatePreview();
                UpdateSymbolControls();
            }
            else
            {
                MessageBox.Show("Failed to open file");
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Draws a point at the given location.
        /// </summary>
        /// <param name="ptX">X-Coordinate of the point, that should be drawn.</param>
        /// <param name="ptY">Y-Coordinate of the point, that should be drawn.</param>
        /// <param name="e">MapArgs for calculating the scaleSize.</param>
        /// <param name="ps">PointSymbolizer with which the point gets drawn.</param>
        /// <param name="g">Graphics-Object that should be used by the PointSymbolizer.</param>
        /// <param name="origTransform">The original transformation that is used to position the point.</param>
        private void DrawPoint(double ptX, double ptY, MapArgs e, IPointSymbolizer ps, Graphics g, Matrix origTransform)
        {
            var pt = new Point
            {
                X = Convert.ToInt32((ptX - e.MinX) * e.Dx),
                Y = Convert.ToInt32((e.MaxY - ptY) * e.Dy)
            };
            double scaleSize = ps.GetScale(e);

            // CGX
            if (MapFrame != null && (MapFrame as IMapFrame).ReferenceScale > 1.0 && (MapFrame as IMapFrame).CurrentScale > 0.0)
            {
                double dReferenceScale = (MapFrame as IMapFrame).ReferenceScale;
                double dCurrentScale   = (MapFrame as IMapFrame).CurrentScale;
                scaleSize = dReferenceScale / dCurrentScale;
            } // Fin CGX

            Matrix shift = origTransform.Clone();

            shift.Translate(pt.X, pt.Y);
            g.Transform = shift;
            ps.Draw(g, scaleSize);
        }
 /// <summary>
 /// Creates a new instance of PointSymbolizerEventArgs
 /// </summary>
 public PointSymbolizerEventArgs(IPointSymbolizer symbolizer)
     : base(symbolizer)
 {
 }
Ejemplo n.º 23
0
        // This draws the individual point features
        private void DrawFeatures(MapArgs e, IEnumerable <int> indices)
        {
            Graphics    g             = e.Device ?? Graphics.FromImage(BackBuffer);
            Matrix      origTransform = g.Transform;
            FeatureType featureType   = DataSet.FeatureType;

            if (!DrawnStatesNeeded)
            {
                if (Symbology == null || Symbology.Categories.Count == 0)
                {
                    return;
                }
                FastDrawnState   state = new FastDrawnState(false, Symbology.Categories[0]);
                IPointCategory   pc    = state.Category as IPointCategory;
                IPointSymbolizer ps    = pc?.Symbolizer;
                if (ps == null)
                {
                    return;
                }
                double[] vertices = DataSet.Vertex;

                foreach (int index in indices)
                {
                    if (DrawnStates != null && DrawnStates.Length > index && !DrawnStates[index].Visible)
                    {
                        continue;
                    }
                    if (featureType == FeatureType.Point)
                    {
                        DrawPoint(vertices[index * 2], vertices[(index * 2) + 1], e, ps, g, origTransform);
                    }
                    else
                    {
                        // multi-point
                        ShapeRange range = DataSet.ShapeIndices[index];
                        for (int i = range.StartIndex; i <= range.EndIndex(); i++)
                        {
                            DrawPoint(vertices[i * 2], vertices[(i * 2) + 1], e, ps, g, origTransform);
                        }
                    }
                }
            }
            else
            {
                FastDrawnState[] states   = DrawnStates;
                double[]         vertices = DataSet.Vertex;

                foreach (int index in indices)
                {
                    if (index >= states.Length)
                    {
                        break;
                    }
                    FastDrawnState state = states[index];
                    if (!state.Visible || state.Category == null)
                    {
                        continue;
                    }
                    IPointCategory pc = state.Category as IPointCategory;
                    if (pc == null)
                    {
                        continue;
                    }

                    IPointSymbolizer ps = state.Selected ? pc.SelectionSymbolizer : pc.Symbolizer;
                    if (ps == null)
                    {
                        continue;
                    }

                    if (featureType == FeatureType.Point)
                    {
                        DrawPoint(vertices[index * 2], vertices[(index * 2) + 1], e, ps, g, origTransform);
                    }
                    else
                    {
                        ShapeRange range = DataSet.ShapeIndices[index];
                        for (int i = range.StartIndex; i <= range.EndIndex(); i++)
                        {
                            DrawPoint(vertices[i * 2], vertices[(i * 2) + 1], e, ps, g, origTransform);
                        }
                    }
                }
            }

            if (e.Device == null)
            {
                g.Dispose();
            }
            else
            {
                g.Transform = origTransform;
            }
        }
Ejemplo n.º 24
0
        /// <inheritdoc />
        protected override void OnMouseDown(GeoMouseArgs e)
        {
            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                _mousePosition = e.Location;
                if (_dragging)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        _dragging = false;
                        Map.Invalidate();
                        Map.IsBusy = false;
                    }
                }
                else
                {
                    if (_selectedFeature != null)
                    {
                        Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);

                        Envelope env = Map.PixelToProj(mouseRect).ToEnvelope();

                        if (CheckForVertexDrag(e))
                        {
                            return;
                        }

                        // No vertex selection has occured.
                        if (!_selectedFeature.Geometry.Intersects(env.ToPolygon()))
                        {
                            // We are clicking down outside of the given polygon, so clear our selected feature
                            DeselectFeature();
                            return;
                        }
                    }

                    if (_activeFeature != null)
                    {
                        // Don't start dragging a vertices right away for polygons and lines.
                        // First you select the polygon, which displays the vertices, then they can be moved.
                        if (_featureSet.FeatureType == FeatureType.Polygon)
                        {
                            _selectedFeature = _activeFeature;
                            _activeFeature   = null;
                            IPolygonCategory sc = _selectedCategory as IPolygonCategory;
                            if (sc == null)
                            {
                                _selectedCategory = new PolygonCategory(Color.FromArgb(55, 0, 255, 255), Color.Blue, 1)
                                {
                                    LegendItemVisible = false
                                };
                            }

                            _layer.SetCategory(_selectedFeature, _selectedCategory);
                        }
                        else if (_featureSet.FeatureType == FeatureType.Line)
                        {
                            _selectedFeature = _activeFeature;
                            _activeFeature   = null;
                            ILineCategory sc = _selectedCategory as ILineCategory;
                            if (sc == null)
                            {
                                _selectedCategory = new LineCategory(Color.Cyan, 1)
                                {
                                    LegendItemVisible = false
                                };
                            }
                            _layer.SetCategory(_selectedFeature, _selectedCategory);
                        }
                        else
                        {
                            _dragging  = true;
                            Map.IsBusy = true;
                            _dragCoord = _activeFeature.Geometry.Coordinates[0];
                            MapPointLayer mpl = _layer as MapPointLayer;
                            if (mpl != null)
                            {
                                mpl.SetVisible(_activeFeature, false);
                            }
                            IPointCategory sc = _selectedCategory as IPointCategory;
                            if (sc == null)
                            {
                                IPointSymbolizer ps =
                                    _layer.GetCategory(_activeFeature).Symbolizer.Copy() as IPointSymbolizer;
                                if (ps != null)
                                {
                                    ps.SetFillColor(Color.Cyan);
                                    _selectedCategory = new PointCategory(ps);
                                }
                            }
                        }
                    }
                    Map.MapFrame.Initialize();
                    Map.Invalidate();
                }
            }
            base.OnMouseDown(e);
        }
Ejemplo n.º 25
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="pointSymbolizer">The symbolizer to use in order to create a category</param>
 public PointCategory(IPointSymbolizer pointSymbolizer)
 {
     Symbolizer = pointSymbolizer;
     SelectionSymbolizer = pointSymbolizer.Copy();
     SelectionSymbolizer.SetFillColor(Color.Cyan);
 }
 /// <summary>
 /// Resets the existing control with the new symbolizer
 /// </summary>
 /// <param name="original"></param>
 public void Initialize(IPointSymbolizer original)
 {
     _original = original;
     _symbolizer = original.Copy();
     ccSymbols.Symbols = _symbolizer.Symbols;
     ccSymbols.RefreshList();
     if (_symbolizer.Symbols.Count > 0)
     {
         ccSymbols.SelectedSymbol = _symbolizer.Symbols[0];
     }
     UpdatePreview();
     UpdateSymbolControls();
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Handles the inter-connectivity of the various controls and updates
        /// them all to match the latest value.
        /// </summary>
        public void UpdateControls()
        {
            if (_ignore)
            {
                return;
            }
            _ignore = true;

            if (_sizeRange == null)
            {
                _ignore = false;
                return;
            }
            chkSizeRange.Checked = _sizeRange.UseSizeRange;
            trkStart.Value       = (int)_sizeRange.Start;
            trkEnd.Value         = (int)_sizeRange.End;
            IPointSymbolizer ps = _sizeRange.Symbolizer as IPointSymbolizer;

            if (ps != null)
            {
                Color color = ps.GetFillColor();
                if (_scheme != null && _scheme.EditorSettings.UseColorRange)
                {
                    color = _scheme.EditorSettings.StartColor;
                }
                if (chkSizeRange.Checked)
                {
                    psvStart.Symbolizer = _sizeRange.GetSymbolizer(_sizeRange.Start, color) as IPointSymbolizer;
                }
                else
                {
                    IPointSymbolizer sm = ps.Copy();
                    sm.SetFillColor(color);
                    psvStart.Symbolizer = sm;
                }
                if (_scheme != null && _scheme.EditorSettings.UseColorRange)
                {
                    color = _scheme.EditorSettings.EndColor;
                }
                if (chkSizeRange.Checked)
                {
                    psvEnd.Symbolizer = _sizeRange.GetSymbolizer(_sizeRange.End, color) as IPointSymbolizer;
                }
                else
                {
                    IPointSymbolizer sm = ps.Copy();
                    sm.SetFillColor(color);
                    psvEnd.Symbolizer = sm;
                }
            }

            ILineSymbolizer ls = _sizeRange.Symbolizer as ILineSymbolizer;

            if (ls != null)
            {
                Color color = ls.GetFillColor();
                if (_scheme != null && _scheme.EditorSettings.UseColorRange)
                {
                    color = _scheme.EditorSettings.StartColor;
                }
                if (chkSizeRange.Checked)
                {
                    lsvStart.Symbolizer = _sizeRange.GetSymbolizer(_sizeRange.Start, color) as ILineSymbolizer;
                }
                else
                {
                    ILineSymbolizer sm = ls.Copy();
                    sm.SetFillColor(color);
                    lsvStart.Symbolizer = sm;
                }
                if (_scheme != null && _scheme.EditorSettings.UseColorRange)
                {
                    color = _scheme.EditorSettings.EndColor;
                }
                if (chkSizeRange.Checked)
                {
                    lsvEnd.Symbolizer = _sizeRange.GetSymbolizer(_sizeRange.End, color) as ILineSymbolizer;
                }
                else
                {
                    ILineSymbolizer sm = ls.Copy();
                    sm.SetFillColor(color);
                    lsvEnd.Symbolizer = sm;
                }
            }

            nudStart.Value = (decimal)_sizeRange.Start;
            nudEnd.Value   = (decimal)_sizeRange.End;

            _ignore = false;

            OnSizeRangeChanged();
        }
Ejemplo n.º 28
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="pointSymbolizer">The symbolizer to use in order to create a category</param>
 public PointCategory(IPointSymbolizer pointSymbolizer)
 {
     Symbolizer          = pointSymbolizer;
     SelectionSymbolizer = pointSymbolizer.Copy();
     SelectionSymbolizer.SetFillColor(Color.Cyan);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PointSymbolizerEventArgs"/> class.
 /// </summary>
 /// <param name="symbolizer">The symbolizer of the event.</param>
 public PointSymbolizerEventArgs(IPointSymbolizer symbolizer)
     : base(symbolizer)
 {
 }
Ejemplo n.º 30
0
 public static void DrawMultiPoint(IPointSymbolizer symbolizer, Graphics g, MultiPoint points, Map map)
 {
     symbolizer.Render(map, points, g);
 }
Ejemplo n.º 31
0
        public static void DrawPoint(IPointSymbolizer symbolizer, Graphics g, Point point, Map map)
        {
            if (point == null)
                return; 

            symbolizer.Render(map, point, g);
        }
Ejemplo n.º 32
0
 public static void DrawMultiPoint(IPointSymbolizer symbolizer, Graphics g, IMultiPoint points, MapViewport map)
 {
     symbolizer.Render(map, points, g);
 }
 /// <summary>
 /// Creates a new DetailedPointSymbolDialog that will update the specified original symbol
 /// by copying the new aspects to it only if the Apply Changes, or Ok buttons are used.
 /// </summary>
 /// <param name="original">The original IPointSymbolizer to modify.</param>
 public DetailedPointSymbolControl(IPointSymbolizer original)
 {
     Configure();
     Initialize(original);
 }
Ejemplo n.º 34
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);
        }
Ejemplo n.º 35
0
        // This draws the individual point features
        private void DrawFeatures(MapArgs e, IEnumerable <int> indices, bool selected)
        {
            if (selected && (!DrawnStatesNeeded || !DrawnStates.Any(_ => _.Selected)))
            {
                return;                                                                        // there are no selected features
            }
            Graphics    g             = e.Device ?? Graphics.FromImage(BackBuffer);
            Matrix      origTransform = g.Transform;
            FeatureType featureType   = DataSet.FeatureType;

            double minX = e.MinX;
            double maxY = e.MaxY;
            double dx   = e.Dx;
            double dy   = e.Dy;

            // CGX
            if (dx < 2000000000 && dx > -2000000000 && dy < 2000000000 && dy > -2000000000)
            {
                if (!DrawnStatesNeeded)
                {
                    if (Symbology == null || Symbology.Categories.Count == 0)
                    {
                        return;
                    }
                    FastDrawnState   state = new FastDrawnState(false, Symbology.Categories[0]);
                    IPointSymbolizer ps    = (state.Category as IPointCategory)?.Symbolizer;
                    if (ps == null)
                    {
                        return;
                    }
                    double[] vertices = DataSet.Vertex;

                    foreach (int index in indices)
                    {
                        // CGX
                        if (Visibility != null)
                        {
                            bool visi = Visibility[index].Visible;
                            if (!visi)
                            {
                                continue;
                            }
                        }
                        if (featureType == FeatureType.Point)
                        {
                            DrawPoint(vertices[index * 2], vertices[(index * 2) + 1], e, ps, g, origTransform);
                        }
                        else
                        {
                            // multi-point
                            ShapeRange range = DataSet.ShapeIndices[index];
                            for (int i = range.StartIndex; i <= range.EndIndex(); i++)
                            {
                                DrawPoint(vertices[i * 2], vertices[(i * 2) + 1], e, ps, g, origTransform);
                            }
                        }
                    }
                }
                else
                {
                    FastDrawnState[] states = DrawnStates;

                    var indexList = indices as IList <int> ?? indices.ToList();
                    if (indexList.Max() >= states.Length)
                    {
                        AssignFastDrawnStates();
                        states = DrawnStates;
                    }

                    double[] vertices = DataSet.Vertex;

                    foreach (int index in indexList)
                    {
                        if (index >= states.Length)
                        {
                            break;
                        }
                        FastDrawnState state = states[index];
                        if (!state.Visible || state.Category == null)
                        {
                            continue;
                        }
                        if (selected && !state.Selected)
                        {
                            continue;
                        }

                        IPointCategory pc = state.Category as IPointCategory;
                        if (pc == null)
                        {
                            continue;
                        }

                        IPointSymbolizer ps = selected ? pc.SelectionSymbolizer : pc.Symbolizer;
                        if (ps == null)
                        {
                            continue;
                        }

                        if (featureType == FeatureType.Point)
                        {
                            DrawPoint(vertices[index * 2], vertices[(index * 2) + 1], e, ps, g, origTransform);
                        }
                        else
                        {
                            ShapeRange range = DataSet.ShapeIndices[index];
                            for (int i = range.StartIndex; i <= range.EndIndex(); i++)
                            {
                                DrawPoint(vertices[i * 2], vertices[(i * 2) + 1], e, ps, g, origTransform);
                            }
                        }
                    }
                }
            }



            if (e.Device == null)
            {
                g.Dispose();
            }
            else
            {
                g.Transform = origTransform;
            }
        }
Ejemplo n.º 36
0
 /// <summary>
 /// Draws a point at the given location.
 /// </summary>
 /// <param name="ptX">X-Coordinate of the point, that should be drawn.</param>
 /// <param name="ptY">Y-Coordinate of the point, that should be drawn.</param>
 /// <param name="e">MapArgs for calculating the scaleSize.</param>
 /// <param name="ps">PointSymbolizer with which the point gets drawn.</param>
 /// <param name="g">Graphics-Object that should be used by the PointSymbolizer.</param>
 /// <param name="origTransform">The original transformation that is used to position the point.</param>
 private void DrawPoint(double ptX, double ptY, MapArgs e, IPointSymbolizer ps, Graphics g, Matrix origTransform)
 {
     var pt = new Point
     {
         X = Convert.ToInt32((ptX - e.MinX) * e.Dx),
         Y = Convert.ToInt32((e.MaxY - ptY) * e.Dy)
     };
     double scaleSize = ps.ScaleMode == ScaleMode.Geographic ? e.ImageRectangle.Width / e.GeographicExtents.Width : 1;
     Matrix shift = origTransform.Clone();
     shift.Translate(pt.X, pt.Y);
     g.Transform = shift;
     ps.Draw(g, scaleSize);
 }
Ejemplo n.º 37
0
        private static Bitmap GetSymbolizerBitmap(IPointSymbolizer symbolizer, IProj e)
        {
            if (symbolizer == null) return null;

            var scaleSize = symbolizer.GetScale(e);
            var size = symbolizer.GetSize();
            if (size.Width * scaleSize < 1 || size.Height * scaleSize < 1) return null;

            var bitmap = new Bitmap((int)(size.Width * scaleSize) + 1, (int)(size.Height * scaleSize) + 1);
            var bg = Graphics.FromImage(bitmap);
            bg.SmoothingMode = symbolizer.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None;
            var trans = bg.Transform;

            // keenedge:
            // added ' * scaleSize ' to fix a problme when ploted using ScaleMode=Geographic.   however, it still
            // appeared to be shifted up and left by 1 pixel so I also added the one pixel shift to the NW.
            trans.Translate(((float)(size.Width * scaleSize) / 2 - 1), (float)(size.Height * scaleSize) / 2 - 1);
            bg.Transform = trans;
            symbolizer.Draw(bg, 1);

            return bitmap;
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DetailedPointSymbolControl"/> class that will update the specified original symbol
 /// by copying the new aspects to it only if the Apply Changes, or Ok buttons are used.
 /// </summary>
 /// <param name="original">The original IPointSymbolizer to modify.</param>
 public DetailedPointSymbolControl(IPointSymbolizer original)
 {
     Configure();
     Initialize(original);
 }
Ejemplo n.º 39
0
 public GeometrySymbolizer()
 {
     _pointSymbolizer   = new RasterPointSymbolizer();
     _lineSymbolizer    = new BasicLineSymbolizer();
     _polygonSymbolizer = new BasicPolygonSymbolizer();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="original"></param>
 public DetailedPointSymbolDialog(IPointSymbolizer original)
 {
     InitializeComponent();
     detailedPointSymbolControl1.Initialize(original);
     Configure();
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DetailedPointSymbolDialog"/> class.
 /// </summary>
 /// <param name="original">The original point symbolizer.</param>
 public DetailedPointSymbolDialog(IPointSymbolizer original)
 {
     InitializeComponent();
     detailedPointSymbolControl1.Initialize(original);
     Configure();
 }