private void CmbGradientTypeSelectedIndexChanged(object sender, EventArgs e) { if (_ignoreChanges) { return; } IGradientPattern gp = ccPatterns.SelectedPattern as IGradientPattern; if (gp != null) { gp.GradientType = Global.ParseEnum <GradientType>((string)cmbGradientType.SelectedItem); if (gp.GradientType == GradientType.Linear) { lblStartColor.Text = SymbologyFormsMessageStrings.DetailedPolygonSymbolControl_StartColor; lblEndColor.Text = SymbologyFormsMessageStrings.DetailedPolygonSymbolControl_EndColor; } else { lblStartColor.Text = SymbologyFormsMessageStrings.DetailedPolygonSymbolControl_SurroundColor; lblEndColor.Text = SymbologyFormsMessageStrings.DetailedPolygonSymbolControl_CenterColor; } } UpdatePreview(); }
private void UpdateGradientPatternControls(IGradientPattern pattern) { cmbPatternType.SelectedItem = "Gradient"; cmbGradientType.SelectedItem = pattern.GradientType.ToString(); sliderGradient.MinimumColor = pattern.Colors[0]; sliderGradient.MaximumColor = pattern.Colors[pattern.Colors.Length - 1]; angGradientAngle.Angle = (int)pattern.Angle; }
/// <summary> /// Draws the GraphicsPaths. Before we were effectively "re-creating" the same geometric. /// </summary> /// <param name="e">The map arguments.</param> /// <param name="paths">The graphics path.</param> /// <param name="selected">Indicates whether to draw the normal colored features or the selection colored features.</param> private void DrawPaths(MapArgs e, Dictionary <FastDrawnState, GraphicsPath> paths, bool selected) { Graphics g = e.Device ?? Graphics.FromImage(BackBuffer); foreach (var kvp in paths) { var category = kvp.Key.Category; if (category == null) { continue; } Extent catBounds = (CategoryExtents.Keys.Contains(category) ? CategoryExtents[category] : CalculateCategoryExtent(category)) ?? Extent; var bounds = new RectangleF { X = Convert.ToSingle((catBounds.MinX - e.MinX) * e.Dx), 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; var ps = (selected && kvp.Key.Selected ? category.SelectionSymbolizer : category.Symbolizer) as PolygonSymbolizer; if (ps == null) { continue; } g.SmoothingMode = ps.GetSmoothingMode(); foreach (IPattern pattern in ps.Patterns) { IGradientPattern gp = pattern as IGradientPattern; if (gp != null) { gp.Bounds = bounds; } pattern.FillPath(g, kvp.Value); } double scale = ps.GetScale(e); foreach (IPattern pattern in ps.Patterns) { if (pattern.UseOutline) { pattern.DrawPath(g, kvp.Value, scale); } } } if (e.Device == null) { g.Dispose(); } }
private void angGradientAngle_AngleChanged(object sender, EventArgs e) { if (_ignoreChanges) { return; } IGradientPattern gp = ccPatterns.SelectedPattern as IGradientPattern; if (gp != null) { gp.Angle = angGradientAngle.Angle; } UpdatePreview(); }
private void sliderGradient_GradientChanging(object sender, EventArgs e) { if (_ignoreChanges) { return; } IGradientPattern gp = ccPatterns.SelectedPattern as IGradientPattern; if (gp != null) { gp.Colors = new[] { sliderGradient.MinimumColor, sliderGradient.MinimumColor, sliderGradient.MaximumColor, sliderGradient.MaximumColor }; gp.Positions = new[] { 0F, sliderGradient.StartValue, sliderGradient.EndValue, 1F }; } UpdatePreview(); }
private void UpdatePatternControls() { _ignoreChanges = true; cmbScaleMode.SelectedItem = _symbolizer.ScaleMode.ToString(); chkSmoothing.Checked = _symbolizer.Smoothing; _disableUnitWarning = true; cmbUnits.SelectedItem = _symbolizer.Units.ToString(); _disableUnitWarning = false; ocOutline.Pattern = ccPatterns.SelectedPattern; ISimplePattern sp = ccPatterns.SelectedPattern as ISimplePattern; if (sp != null) { UpdateSimplePatternControls(sp); } IPicturePattern pp = ccPatterns.SelectedPattern as IPicturePattern; if (pp != null) { UpdatePicturePatternControls(pp); } IGradientPattern gp = ccPatterns.SelectedPattern as IGradientPattern; if (gp != null) { UpdateGradientPatternControls(gp); } IHatchPattern hp = ccPatterns.SelectedPattern as IHatchPattern; if (hp != null) { UpdateHatchPatternControls(hp); } _ignoreChanges = false; UpdatePreview(); }
/// <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(); } }