/// <summary> /// Takes any object, but attempts to compare it with values as an IDrawnState. If it can satisfy /// the IDrawnState interface and all the values are the same then this returns true. /// </summary> /// <param name="obj">IDrawnState to compare to this.</param> /// <returns>True, if this and obj are equal.</returns> public override bool Equals(object obj) { IDrawnState ds = obj as IDrawnState; if (ds == null) { return(false); } return(this == ds); }
// This draws the individual point features private void DrawFeatures(MapArgs e, IEnumerable <IFeature> features) { Graphics g = e.Device ?? Graphics.FromImage(BackBuffer); Matrix origTransform = g.Transform; IDictionary <IFeature, IDrawnState> states = DrawingFilter.DrawnStates; if (states == null) { return; } foreach (IFeature feature in features) { if (!states.ContainsKey(feature)) { continue; } IDrawnState ds = states[feature]; if (ds == null || !ds.IsVisible || ds.SchemeCategory == null) { continue; } IPointCategory pc = ds.SchemeCategory as IPointCategory; if (pc == null) { continue; } IPointSymbolizer ps = ds.IsSelected ? 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; } }
/// <summary> /// Removes the specified item from the subset of this classification if that category is used. /// Selected -> !Selected /// Category[>0] -> Category[0] /// Category[0] -> Null /// Visible -> !Visible /// Chunk -> -1 or basically a chunk index that is never drawn. /// </summary> /// <param name="item">The item to change the drawing state of.</param> /// <returns>Boolean, false if the item does not match the current grouping.</returns> /// <exception cref="ReadOnlyException">Occurs if this list is set to read-only in the constructor.</exception> public bool Remove(IFeature item) { if (IsReadOnly) { throw new ReadOnlyException(); } if (Contains(item) == false) { return(false); } IDrawnState previousState = Filter[item]; IFeatureCategory cat = previousState.SchemeCategory; int chunk = previousState.Chunk; bool sel = previousState.IsSelected; bool vis = previousState.IsVisible; if (ActiveType == FilterType.Category) { cat = Category != Filter.DefaultCategory ? Filter.DefaultCategory : null; } if (ActiveType == FilterType.Chunk) { // removing from a chunk effectively means setting to -1 so that it will not get drawn // until it is added to a chunk again. chunk = -1; } if (ActiveType == FilterType.Selection) { sel = !Selected; } if (ActiveType == FilterType.Visible) { vis = !Visible; } Filter[item] = new DrawnState(cat, sel, chunk, vis); _envelope = null; //reset the envelope so it will be calculated from the selected features the next time the property is accessed OnChanged(); return(true); }
/// <summary> /// Removes the specified item from the subset of this classification if that category is used. /// Selected -> !Selected /// Category[>0] -> Category[0] /// Category[0] -> Null /// Visible -> !Visible /// Chunk -> -1 or basically a chunk index that is never drawn. /// </summary> /// <param name="item">The item to change the drawing state of</param> /// <returns>Boolean, false if the item does not match the current grouping</returns> /// <exception cref="ReadOnlyException">Occurs if this list is set to read-only in the constructor</exception> public bool Remove(IFeature item) { if (_isReadOnly) { throw new ReadOnlyException(); } if (Contains(item) == false) { return(false); } IDrawnState previousState = _filter[item]; IFeatureCategory cat = previousState.SchemeCategory; int chunk = previousState.Chunk; bool sel = previousState.IsSelected; bool vis = previousState.IsVisible; if (_activeType == FilterType.Category) { cat = _category != _filter.DefaultCategory ? _filter.DefaultCategory : null; } if (_activeType == FilterType.Chunk) { // removing from a chunk effectively means setting to -1 so that it will not get drawn // until it is added to a chunk again. chunk = -1; } if (_activeType == FilterType.Selection) { sel = !_selected; } if (_activeType == FilterType.Visible) { vis = !_visible; } _filter[item] = new DrawnState(cat, sel, chunk, vis); OnChanged(); return(true); }
/// <summary> /// Adding a feature state sets the drawing state of the item to be. /// </summary> /// <param name="item">The item to add to this category.</param> /// <exception cref="Serialization.ReadOnlyException">Occurs if this list is set to read-only in the constructor.</exception> public void Add(IFeature item) { if (IsReadOnly) { throw new ReadOnlyException(); } IDrawnState previousState = Filter[item]; IFeatureCategory cat = previousState.SchemeCategory; if (UseCategory) { cat = Category; } bool sel = previousState.IsSelected; if (UseSelection) { sel = Selected; } int chunk = previousState.Chunk; if (UseChunks) { chunk = Chunk; } bool vis = previousState.IsVisible; if (UseVisibility) { vis = Visible; } Filter[item] = new DrawnState(cat, sel, chunk, vis); _envelope = null; //reset the envelope so it will be calculated from the selected features the next time the property is accessed OnChanged(); }
/// <summary> /// Tests to see if the item is contained in this collection. /// </summary> /// <param name="item">Item that should be contained.</param> /// <returns>True, if the item is contained.</returns> public bool Contains(IFeature item) { IDrawnState previousState = Filter[item]; if (UseSelection && previousState.IsSelected != Selected) { return(false); } if (UseVisibility && previousState.IsVisible != Visible) { return(false); } if (UseChunks && previousState.Chunk != Chunk) { return(false); } if (UseCategory && previousState.SchemeCategory != Category) { return(false); } // Contains is defined as "matching" all the criteria that we care about. return(true); }
/// <summary> /// Adding a feature state sets the drawing state of the item to be. /// </summary> /// <param name="item">The item to add to this category.</param> /// <exception cref="Serialization.ReadOnlyException">Occurs if this list is set to read-only in the constructor.</exception> public void Add(IFeature item) { if (IsReadOnly) { throw new ReadOnlyException(); } IDrawnState previousState = Filter[item]; IFeatureCategory cat = previousState.SchemeCategory; if (UseCategory) { cat = Category; } bool sel = previousState.IsSelected; if (UseSelection) { sel = Selected; } int chunk = previousState.Chunk; if (UseChunks) { chunk = Chunk; } bool vis = previousState.IsVisible; if (UseVisibility) { vis = Visible; } Filter[item] = new DrawnState(cat, sel, chunk, vis); OnChanged(); }
// This draws the individual point features private void DrawFeatures(MapArgs e, IEnumerable <IFeature> features) { Graphics g = e.Device ?? Graphics.FromImage(_backBuffer); Matrix origTransform = g.Transform; double minX = e.MinX; double maxY = e.MaxY; double dx = e.Dx; double dy = e.Dy; IDictionary <IFeature, IDrawnState> states = DrawingFilter.DrawnStates; if (states == null) { return; } foreach (IPointCategory category in Symbology.Categories) { foreach (IFeature feature in features) { if (states.ContainsKey(feature) == false) { continue; } IDrawnState ds = states[feature]; if (ds == null) { continue; } if (!ds.IsVisible) { continue; } if (ds.SchemeCategory == null) { continue; } IPointCategory pc = ds.SchemeCategory as IPointCategory; if (pc == null) { continue; } if (pc != category) { continue; } IPointSymbolizer ps = pc.Symbolizer; if (ds.IsSelected) { ps = pc.SelectionSymbolizer; } if (ps == null) { continue; } g.SmoothingMode = ps.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None; foreach (Coordinate c in feature.Coordinates) { Point pt = new Point { X = Convert.ToInt32((c.X - minX) * dx), Y = Convert.ToInt32((maxY - c.Y) * dy) }; double scaleSize = 1; if (ps.ScaleMode == ScaleMode.Geographic) { scaleSize = e.ImageRectangle.Width / e.GeographicExtents.Width; } Matrix shift = origTransform.Clone(); shift.Translate(pt.X, pt.Y); g.Transform = shift; ps.Draw(g, scaleSize); } } } if (e.Device == null) { g.Dispose(); } else { g.Transform = origTransform; } }