public ChartSeriesStyle(ChartHatchStyle hatchStyle, string backgroundColor, string foregroundColor) : this() { HatchStyle = hatchStyle; BackgroundColor = backgroundColor; ForegroundColor = foregroundColor; }
public static void SetChartArea(ChartArea chartArea , Color backColor , Color backGradientEndColor , Color borderColor , ChartDashStyle borderStyle , int borderWidth , ChartHatchStyle chartHatchStyle , GradientType gradientType , int shadowOffset , Color shadowColor , bool enable3D) { SetChartArea(chartArea , backColor , backGradientEndColor , borderColor , borderStyle , borderWidth , chartHatchStyle , gradientType , shadowOffset , shadowColor , enable3D , null , ChartImageAlign.TopRight , ChartImageWrapMode.Unscaled , Color.Empty); }
protected void HatchStyle_SelectedIndexChanged(object sender, System.EventArgs e) { Gradient.SelectedIndex = 0; // Set Hatch Style Chart1.BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.SelectedItem.Text); Chart1.BackGradientStyle = GradientStyle.None; }
private void ControlChanged(object sender, System.EventArgs e) { if (this.StripEndColor.SelectedIndex >= 0) { this.Chart1.ChartAreas[0].AxisX.StripLines[0].BackSecondaryColor = Color.FromName(this.StripEndColor.SelectedItem.ToString()); } if (this.StripColor.SelectedIndex >= 0) { this.Chart1.ChartAreas[0].AxisX.StripLines[0].BackColor = Color.FromName(this.StripColor.SelectedItem.ToString()); } if (this.LineColor.SelectedIndex >= 0) { this.Chart1.ChartAreas[0].AxisX.StripLines[0].BorderColor = Color.FromName(this.LineColor.SelectedItem.ToString()); } if (this.LineWidth.SelectedIndex >= 0) { this.Chart1.ChartAreas[0].AxisX.StripLines[0].BorderWidth = int.Parse(this.LineWidth.SelectedItem.ToString()); } if (this.Interval.SelectedIndex >= 0) { this.Chart1.ChartAreas[0].AxisX.StripLines[0].Interval = int.Parse(this.Interval.SelectedItem.ToString()); } if (this.HatchStyle.SelectedIndex >= 0) { // Set Hatch Style this.Chart1.ChartAreas[0].AxisX.StripLines[0].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), this.HatchStyle.SelectedItem.ToString()); } if (this.Gradient.SelectedIndex >= 0) { // Set Gradient Type this.Chart1.ChartAreas[0].AxisX.StripLines[0].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), this.Gradient.SelectedItem.ToString()); } if (this.StripLinesStyle.SelectedIndex >= 0) { this.Chart1.ChartAreas[0].AxisX.StripLines[0].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), this.StripLinesStyle.SelectedItem.ToString()); } // Enable/disable attribute contros StripEndColor.Enabled = (Gradient.SelectedIndex != 0 || HatchStyle.SelectedIndex != 0); LineColor.Enabled = (StripLinesStyle.SelectedIndex != 0); LineWidth.Enabled = (StripLinesStyle.SelectedIndex != 0); }
private void btnOK_Click(object sender, EventArgs e) { BorderColor = ccboBorderColor.SelectedItem; BorderDashStyle = (ChartDashStyle)cboBorderDashStyle.SelectedItem; BorderWidth = (int)nudBorderWidth.Value; BackColor = ccboBackColor.SelectedItem; BackSecondColor = ccboBackSecondColor.SelectedItem; BackHatchStyle = (ChartHatchStyle)cboBackHatchStyle.SelectedItem; BackGradientStyle = (GradientStyle)cboBackGradientStyle.SelectedItem; this.DialogResult = DialogResult.OK; }
/// <summary> /// updateTimeSeries /// </summary> private void updateCompareChart(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wasteType) { CurrentWasteType = wasteType; // view everything, user may select other years to compare dataFound(true); // init year combo boxes int year1 = this.ucYearCompare.Year1; int year2 = this.ucYearCompare.Year2; // get compare result compare char TimeSeriesClasses.ComparisonWasteTransfer result = WasteTransferTrend.GetComparisonTimeSeries(filter, year1, year2, wasteType); bool foundData = (result.TotalFrom != null || result.TotalTo != null); if (foundData) { dataFound(true); Color[] colors = new Color[] { Global.ColorWasteTotal, Global.ColorWasteTotal }; ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { Global.HatchStyleBothYears, Global.HatchStyleTotal }; string[] legendTexts = new string[] { Resources.GetGlobal("Common", "FacilitiesBothYears"), Resources.GetGlobal("Common", "AllFacilities") }; this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, CODE_TNE, colors, hatchStyles, legendTexts); // from and to bar TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData { Year = result.YearFrom, Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothTotalFrom), TimeSeriesUtils.RangeValue(result.TotalFrom) - TimeSeriesUtils.RangeValue(result.BothTotalFrom) }, }; TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData { Year = result.YearTo, Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothTotalTo), TimeSeriesUtils.RangeValue(result.TotalTo) - TimeSeriesUtils.RangeValue(result.BothTotalTo) }, }; // from and to bar this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>() { dataFrom, dataTo }); // update sinle table updateTable(result); } else { dataFound(false); } }
private void AppearanceChange(object sender) { // Set Back Color Chart1.ChartAreas["Default"].BackColor = Color.FromName(BackColorCom.GetItemText(BackColorCom.SelectedItem)); // Set Back Gradient End Color Chart1.ChartAreas["Default"].BackSecondaryColor = Color.FromName(ForeColorCom.GetItemText(ForeColorCom.SelectedItem)); // Set Border Color Chart1.ChartAreas["Default"].BorderColor = Color.FromName(BorderColor.GetItemText(BorderColor.SelectedItem)); // Set Gradient Type if (Gradient.SelectedItem != null) { Chart1.ChartAreas["Default"].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.GetItemText(Gradient.SelectedItem)); } // Set Gradient Type if (HatchStyle.SelectedItem != null) { Chart1.ChartAreas["Default"].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.GetItemText(HatchStyle.SelectedItem)); } if (sender == Gradient && Chart1.ChartAreas["Default"].BackGradientStyle != GradientStyle.None) { HatchStyle.SelectedIndex = 0; } if (sender == HatchStyle && Chart1.ChartAreas["Default"].BackHatchStyle != ChartHatchStyle.None) { Gradient.SelectedIndex = 0; } // Set Border Width if (BorderSizeCom.SelectedItem != null) { Chart1.ChartAreas["Default"].BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem)); } // Set Border Style if (BorderDashStyle.SelectedItem != null) { Chart1.ChartAreas["Default"].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.GetItemText(BorderDashStyle.SelectedItem)); } // Set Shadow Offset if (ShadowOffset.SelectedItem != null) { Chart1.ChartAreas["Default"].ShadowOffset = int.Parse(ShadowOffset.GetItemText(ShadowOffset.SelectedItem)); } }
public static Legend CreateLegend(Chart chart, string legendName , Color backColor, Color backGradientEndColor, Color borderColor , Font font , GradientType gradientType, ChartHatchStyle chartHatchStyle , bool positionAuto, float positionX, float positionY, float positionWidth, float positionHeight) { return(CreateLegend(chart, legendName , backColor, backGradientEndColor, borderColor , font , gradientType, chartHatchStyle , -1, ChartDashStyle.NotSet , -1, Color.Empty , positionAuto, positionX, positionX, positionWidth, positionHeight)); }
/// <summary> /// updateTimeSeries /// </summary> private void updateCompareChart(PollutantTransferTimeSeriesFilter filter) { dataFound(true); // init year combo boxes int year1 = this.ucYearCompare.Year1; int year2 = this.ucYearCompare.Year2; Color[] colors = new Color[] { Global.ColorWasteWater, Global.ColorWasteWater }; string[] legendTexts = new string[] { Resources.GetGlobal("Common", "FacilitiesBothYears"), Resources.GetGlobal("Common", "AllFacilities") }; ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { Global.HatchStyleBothYears, Global.HatchStyleTotal }; // same unit for all data this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantTransferTrend.CODE_KG, colors, hatchStyles, legendTexts); // from and to bar // get compare result compare char TimeSeriesClasses.ComparisonPollutant result = PollutantTransferTrend.GetComparisonTimeSeries(filter, year1, year2); bool foundData = (result.QuantityFrom != null || result.QuantityTo != null); if (foundData) { TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData { Year = result.YearFrom, Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothQuantityFrom), TimeSeriesUtils.RangeValue(result.QuantityFrom) - TimeSeriesUtils.RangeValue(result.BothQuantityFrom) }, }; TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData { Year = result.YearTo, Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothQuantityTo), TimeSeriesUtils.RangeValue(result.QuantityTo) - TimeSeriesUtils.RangeValue(result.BothQuantityTo) }, }; // from and to bar this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>() { dataFrom, dataTo }); // update sinle table updateTable(result); } else { dataFound(false); } }
public void UpdateColor() { if (!ApplyToPoint.Checked) { // Set Series["Default"] visual attributes Chart1.Series["Default"].Color = Color.FromName(ColorList.SelectedItem.Text); Chart1.Series["Default"].BackSecondaryColor = Color.FromName(EndColorList.SelectedItem.Text); Chart1.Series["Default"].BorderColor = Color.FromName(BorderColorList.SelectedItem.Text); Chart1.Series["Default"].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), GradientList.SelectedItem.Text); Chart1.Series["Default"].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchingList.SelectedItem.Text); Chart1.Series["Default"].BorderWidth = int.Parse(BorderSizeList.SelectedItem.Text); Chart1.Series["Default"].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyleList.SelectedItem.Text); Chart1.Series["Default"].ShadowOffset = int.Parse(ShadowOffsetList.SelectedItem.Text); // Disable fore color control if gradient or hatching are not used if (HatchingList.SelectedItem.Text == "None" && GradientList.SelectedItem.Text == "None") { EndColorList.Enabled = false; } else { EndColorList.Enabled = true; } } else { // Set Series["Default"] visual attributes Chart1.Series["Default"].Points[2].Color = Color.FromName(ColorList.SelectedItem.Text); Chart1.Series["Default"].Points[2].BackSecondaryColor = Color.FromName(EndColorList.SelectedItem.Text); Chart1.Series["Default"].Points[2].BorderColor = Color.FromName(BorderColorList.SelectedItem.Text); Chart1.Series["Default"].Points[2].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), GradientList.SelectedItem.Text); Chart1.Series["Default"].Points[2].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchingList.SelectedItem.Text); Chart1.Series["Default"].Points[2].BorderWidth = int.Parse(BorderSizeList.SelectedItem.Text); Chart1.Series["Default"].Points[2].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyleList.SelectedItem.Text); Chart1.Series["Default"].ShadowOffset = int.Parse(ShadowOffsetList.SelectedItem.Text); // Disable fore color control if gradient or hatching are not used if (HatchingList.SelectedItem.Text == "None" && GradientList.SelectedItem.Text == "None") { EndColorList.Enabled = false; } else { EndColorList.Enabled = true; } } }
public void SetAttributes(DataPointAttributes attrib, bool area3D) { this.borderColor = attrib.BorderColor; this.borderWidth = attrib.BorderWidth; this.borderStyle = attrib.BorderStyle; this.markerStyle = attrib.MarkerStyle; this.markerSize = attrib.MarkerSize; this.markerImage = attrib.MarkerImage; this.markerImageTranspColor = attrib.MarkerImageTransparentColor; this.markerColor = attrib.MarkerColor; this.markerBorderColor = attrib.MarkerBorderColor; this.markerBorderWidth = attrib.MarkerBorderWidth; float num = 96f; if (this.common != null) { num = this.common.graph.Graphics.DpiX; } int num2 = (int)Math.Round(2.0 * num / 96.0); if (this.markerBorderWidth > num2) { this.markerBorderWidth = num2; } if (attrib.MarkerBorderWidth <= 0) { this.markerBorderColor = Color.Transparent; } if (this.style == LegendImageStyle.Line && this.borderWidth <= (int)Math.Round(num / 96.0)) { this.borderWidth = num2; } if (!area3D) { this.backGradientType = attrib.BackGradientType; this.backGradientEndColor = attrib.BackGradientEndColor; this.backImageTranspColor = attrib.BackImageTransparentColor; this.backImage = attrib.BackImage; this.backImageMode = attrib.BackImageMode; this.backImageAlign = attrib.BackImageAlign; this.backHatchStyle = attrib.BackHatchStyle; } }
internal void SetAttributes(DataPointAttributes attrib, bool area3D) { borderColor = attrib.BorderColor; borderWidth = attrib.BorderWidth; borderStyle = attrib.BorderStyle; markerStyle = attrib.MarkerStyle; markerSize = attrib.MarkerSize; markerImage = attrib.MarkerImage; markerImageTranspColor = attrib.MarkerImageTransparentColor; markerColor = attrib.MarkerColor; markerBorderColor = attrib.MarkerBorderColor; markerBorderWidth = attrib.MarkerBorderWidth; float num = 96f; if (common != null) { num = common.graph.Graphics.DpiX; } int num2 = (int)Math.Round(2f * num / 96f); if (markerBorderWidth > num2) { markerBorderWidth = num2; } if (attrib.MarkerBorderWidth <= 0) { markerBorderColor = Color.Transparent; } if (style == LegendImageStyle.Line && borderWidth <= (int)Math.Round(num / 96f)) { borderWidth = num2; } if (!area3D) { backGradientType = attrib.BackGradientType; backGradientEndColor = attrib.BackGradientEndColor; backImageTranspColor = attrib.BackImageTransparentColor; backImage = attrib.BackImage; backImageMode = attrib.BackImageMode; backImageAlign = attrib.BackImageAlign; backHatchStyle = attrib.BackHatchStyle; } }
/// <summary> /// populate /// </summary> public void Populate(PollutantTransferTimeSeriesFilter filter) { // result from qyerylayer List <TimeSeriesClasses.PollutantTransfers> data = PollutantTransferTrend.GetTimeSeries(filter); // set data to table. this.lvTimeSeriesTable.DataSource = data; this.lvTimeSeriesTable.DataBind(); // init time series. Must be done after table databinding, because missing years are added. this.ucStackColumnTime.Visible = (data != null && data.Count > 0); if (this.ucStackColumnTime.Visible) { Color[] colors = new Color[] { Global.ColorWasteWater }; ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None }; // init time series this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_KG, colors, hatchStyles, null); //this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_TNE, colors, null); this.ucStackColumnTime.Width = 700; List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>(); // loop through data and create tooltip foreach (var v in data) { string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year), String.Format("{0}: {1}", Resources.GetGlobal("Common", "Quantity"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)), String.Format("{0}: {1}", Resources.GetGlobal("Common", "Facilities"), v.Facilities) }; TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData { Year = v.Year, Values = new double?[] { TimeSeriesUtils.RangeValue(v.Quantity) }, ToolTip = ToolTipFormatter.FormatLines(tip) }; bars.Add(cd); } this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bars, false)); } }
public static void DundasChartBase(Chart chart , ChartImageType chartImageType , int width , int height , BorderSkinStyle borderSkinStyle , Color borderLineColor , int borderLineWidth , Color backColor , Color backGradientEndColor , Color borderColor , ChartDashStyle chartDashStyle , int borderWidth , ChartHatchStyle chartHatchStyle , GradientType gradientType , AntiAliasing antiAliasing ) { DundasChartBase(chart , chartImageType , width, height , borderSkinStyle , borderLineColor , borderLineWidth , backColor , backGradientEndColor , borderColor , chartDashStyle , borderWidth , chartHatchStyle , gradientType , antiAliasing , null , ChartImageWrapMode.Unscaled , ChartImageAlign.TopRight , Color.Empty); }
/// <summary> /// Draws 3D border. /// </summary> /// <param name="graph">Graphics to draw the border on.</param> /// <param name="borderSkin">Border skin object.</param> /// <param name="rect">Rectangle of the border.</param> /// <param name="backColor">Color of rectangle</param> /// <param name="backHatchStyle">Hatch style</param> /// <param name="backImage">Back Image</param> /// <param name="backImageWrapMode">Image mode</param> /// <param name="backImageTransparentColor">Image transparent color.</param> /// <param name="backImageAlign">Image alignment</param> /// <param name="backGradientStyle">Gradient type</param> /// <param name="backSecondaryColor">Gradient End Color</param> /// <param name="borderColor">Border Color</param> /// <param name="borderWidth">Border Width</param> /// <param name="borderDashStyle">Border Style</param> public virtual void DrawBorder( ChartGraphics graph, BorderSkin borderSkin, SKRect rect, SKColor backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageWrapMode, SKColor backImageTransparentColor, ChartImageAlignmentStyle backImageAlign, GradientStyle backGradientStyle, SKColor backSecondaryColor, SKColor borderColor, int borderWidth, ChartDashStyle borderDashStyle) { SKRect absolute = ChartGraphics.Round(rect); // Calculate shadow colors (0.2 - 0.6) float colorDarkeningIndex = 0.2f + (0.4f * (borderSkin.PageColor.Red + borderSkin.PageColor.Green + borderSkin.PageColor.Blue) / 765f); SKColor shadowColor = new( (byte)(borderSkin.PageColor.Red * colorDarkeningIndex), (byte)(borderSkin.PageColor.Green * colorDarkeningIndex), (byte)(borderSkin.PageColor.Blue * colorDarkeningIndex)); if (borderSkin.PageColor == SKColors.Transparent) { shadowColor = new(0, 0, 0, 60); } colorDarkeningIndex += 0.2f; SKColor shadowLightColor = new( (byte)(borderSkin.PageColor.Red * colorDarkeningIndex), (byte)(borderSkin.PageColor.Green * colorDarkeningIndex), (byte)(borderSkin.PageColor.Blue * colorDarkeningIndex)); // Calculate rounded rect radius float radius = defaultRadiusSize; radius = Math.Max(radius, 2f * resolution / 96.0f); radius = Math.Min(radius, rect.Width / 2f); radius = Math.Min(radius, rect.Height / 2f); radius = (float)Math.Ceiling(radius); // Fill page background color using (SKPaint brush = new() { Style = SKPaintStyle.Fill, Color = borderSkin.PageColor }) { graph.FillRectangle(brush, rect); } // Top/Left shadow SKRect shadowRect = absolute; shadowRect.Right -= radius * .3f; shadowRect.Bottom -= radius * .3f; graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius + 1 * resolution / 96.0f, shadowLightColor, borderSkin.PageColor, 1.4f); // Bottom/Right shadow shadowRect = absolute; shadowRect.Left = absolute.Left + radius / 3f; shadowRect.Top = absolute.Top + radius / 3f; shadowRect.Right -= radius / 3.5f; shadowRect.Bottom -= radius / 3.5f; graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, shadowColor, borderSkin.PageColor, 1.3f); // Draw Background shadowRect = absolute; shadowRect.Left = absolute.Left + 3f * resolution / 96.0f; shadowRect.Top = absolute.Top + 3f * resolution / 96.0f; shadowRect.Right -= radius * .75f; shadowRect.Bottom -= radius * .75f; SKPath path = ChartGraphics.CreateRoundedRectPath(shadowRect, cornerRadius); graph.DrawPathAbs( path, backColor, backHatchStyle, backImage, backImageWrapMode, backImageTransparentColor, backImageAlign, backGradientStyle, backSecondaryColor, borderColor, borderWidth, borderDashStyle, PenAlignment.Inset); // Dispose Graphic path if (path != null) { path.Dispose(); } // Bottom/Right inner shadow SKRegion innerShadowRegion = new( ChartGraphics.CreateRoundedRectPath( new SKRect( shadowRect.Left - radius, shadowRect.Top - radius, shadowRect.Width + radius - radius * 0.25f, shadowRect.Height + radius - radius * 0.25f), cornerRadius)); innerShadowRegion.Op(ChartGraphics.CreateRoundedRectPath(shadowRect, cornerRadius), SKRegionOperation.Difference); graph.Clip = innerShadowRegion; graph.DrawRoundedRectShadowAbs( shadowRect, cornerRadius, radius, SKColors.Transparent, new(SKColors.Gray.Red, SKColors.Gray.Green, SKColors.Gray.Blue, 128), .5f); graph.Clip = new(); }
/// <summary> /// Create trend sheet /// </summary> private void createTrendSheet(TrendTransferContent type, int facilityid, string pollutantCode) { this.ucStackColumnTime.Visible = false; this.ucStackColumnCompare.Visible = false; this.ucYearCompareSeries.Visible = false; this.compareTable.Visible = false; // Get time series data, used by all sub sheets List <TimeSeriesClasses.PollutantTransfers> data = getTimeSeriesData(facilityid, pollutantCode); // Time series sheet if (type == TrendTransferContent.TimeSeries) { ViewState[CONTENT_TYPE] = TrendTransferContent.TimeSeries; if (data != null && data.Count > 0) { this.ucStackColumnTime.Visible = true; Color[] colors = new Color[] { Global.ColorWasteWater }; ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None }; this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_KG, colors, hatchStyles, null); //this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_TNE, colors, null); List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>(); foreach (var v in data) { string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year), String.Format("{0}: {1}", Resources.GetGlobal("Common", "Quantity"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)) }; TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData { Year = v.Year, Values = new double?[] { v.Quantity }, ToolTip = ToolTipFormatter.FormatLines(tip) }; bars.Add(cd); } this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYears(bars, showEPER)); } } // comparison if (type == TrendTransferContent.Comparison) { ViewState[CONTENT_TYPE] = TrendTransferContent.Comparison; if (data != null && data.Count > 0) { this.compareTable.Visible = true; // Create chart this.ucStackColumnCompare.Visible = true; Color[] colors = new Color[] { Global.ColorWasteWater }; ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None }; this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantTransferTrend.CODE_KG, colors, hatchStyles, null); //this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantTransferTrend.CODE_TNE, colors, null); // init year combo boxes this.ucYearCompareSeries.Visible = true; int year1 = this.ucYearCompareSeries.Year1; int year2 = this.ucYearCompareSeries.Year2; // reset resetLabels(); TimeSeriesClasses.PollutantTransfers data1 = data.Where(d => d.Year == year1).DefaultIfEmpty(new TimeSeriesClasses.PollutantTransfers(year1)).Single(); TimeSeriesClasses.PollutantTransfers data2 = data.Where(d => d.Year == year2).DefaultIfEmpty(new TimeSeriesClasses.PollutantTransfers(year2)).Single(); bool dataFound = data1 != null || data2 != null; if (dataFound) { TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData { Year = year1 }; TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData { Year = year2 }; if (data1 != null) { dataFrom.Values = new double?[] { data1.Quantity }; } if (data2 != null) { dataTo.Values = new double?[] { data2.Quantity }; } // from and to bar this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>() { dataFrom, dataTo }); updateTableLabels(data1, data2); } // display that no data found for the selected years this.lbNoDataForSelectedYears.Visible = !dataFound; } } }
protected void Page_Load(object sender, System.EventArgs e) { if (!this.IsPostBack) { // Add Hatch styles to control. foreach (string colorName in Enum.GetNames(typeof(ChartHatchStyle))) { HatchStyle.Items.Add(colorName); } HatchStyle.Items[0].Selected = true; // Add Chart Gradient types to control. foreach (string colorName in Enum.GetNames(typeof(GradientStyle))) { Gradient.Items.Add(colorName); } // Add Chart Line styles to control. foreach (string colorName in Enum.GetNames(typeof(ChartDashStyle))) { BorderDashStyle.Items.Add(colorName); } BorderDashStyle.Items.FindByValue("Solid").Selected = true; // Add Image Mode foreach (string item in Enum.GetNames(typeof(ChartImageWrapMode))) { ImageMode.Items.Add(item); } ImageMode.SelectedIndex = 5; // Add Image Aligne foreach (string item in Enum.GetNames(typeof(ChartImageAlignmentStyle))) { ImageAlign1.Items.Add(item); } ImageAlign1.SelectedIndex = 2; } // Set Back Color Chart1.BackColor = Color.FromName(BackColor.SelectedItem.Value); // Set Back Gradient End Color Chart1.BackSecondaryColor = Color.FromName(ForeColor.SelectedItem.Value); // Set Hatch Style Chart1.BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.SelectedItem.Text); // Set Gradient Type Chart1.BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.SelectedItem.Text); // Set Border Color Chart1.BorderColor = Color.FromName(BorderColor.SelectedItem.Value); // Set Border Style Chart1.BorderlineDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.SelectedItem.Text); // Set Border Width Chart1.BorderWidth = int.Parse(BorderSize.SelectedItem.Value); // Chart Image Mode Chart1.BackImageWrapMode = (ChartImageWrapMode)ChartImageWrapMode.Parse(typeof(ChartImageWrapMode), ImageMode.SelectedItem.Text); // Chart Image Align Chart1.BackImageAlignment = (ChartImageAlignmentStyle)ChartImageAlignmentStyle.Parse(typeof(ChartImageAlignmentStyle), ImageAlign1.SelectedItem.Text); // Disable secondary back color if gradient and hatching are not used ForeColor.Enabled = (HatchStyle.SelectedIndex != 0 || Gradient.SelectedIndex != 0); // Set Image ImageAlign1.Enabled = false; ImageMode.Enabled = Image1.Checked; if (Image1.Checked) { Chart1.BackImage = "Flag.gif"; Chart1.BackImageTransparentColor = Color.White; if (ImageMode.SelectedItem.Value == "Unscaled") { ImageAlign1.Enabled = true; } } else { Chart1.BackImage = ""; } // Enable/disable border attributes BorderColor.Enabled = (BorderDashStyle.SelectedIndex != 0); BorderSize.Enabled = (BorderDashStyle.SelectedIndex != 0); }
/// <summary> /// updateTimeSeries /// </summary> private void updateCompareChart(PollutantReleasesTimeSeriesFilter filter, MediumFilter.Medium medium) { CurrentMedium = medium; // view everything, user may select other years to compare dataFound(true); // init year combo boxes int year1 = this.ucYearCompare.Year1; int year2 = this.ucYearCompare.Year2; // get compare result compare char TimeSeriesClasses.ComparisonPollutant result = PollutantReleaseTrend.GetComparisonTimeSeries(filter, year1, year2, medium); bool foundData = (result.QuantityFrom != null || result.QuantityTo != null); if (foundData) { Color[] colors = new Color[] { }; // create compare chart and table if (medium.Equals(MediumFilter.Medium.Air)) { colors = new Color[] { Global.ColorAirTotal, Global.ColorAirTotal }; } else if (medium.Equals(MediumFilter.Medium.Water)) { // get report data colors = new Color[] { Global.ColorWaterTotal, Global.ColorWaterTotal }; } else if (medium.Equals(MediumFilter.Medium.Soil)) { colors = new Color[] { Global.ColorSoilTotal, Global.ColorSoilTotal }; } ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { Global.HatchStyleBothYears, Global.HatchStyleTotal }; string[] legendTexts = new string[] { Resources.GetGlobal("Common", "FacilitiesBothYears"), Resources.GetGlobal("Common", "AllFacilities") }; this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantReleaseTrend.CODE_KG, colors, hatchStyles, legendTexts); TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData { Year = result.YearFrom, Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothQuantityFrom), TimeSeriesUtils.RangeValue(result.QuantityFrom) - TimeSeriesUtils.RangeValue(result.BothQuantityFrom) }, }; TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData { Year = result.YearTo, Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothQuantityTo), TimeSeriesUtils.RangeValue(result.QuantityTo) - TimeSeriesUtils.RangeValue(result.BothQuantityTo) }, }; // from and to bar this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>() { dataFrom, dataTo }); // update sinle table updateTable(result); } else { dataFound(false); } }
private void ChartAppearanceChange() { // Enable/disable appearance controls ForeColorCom.Enabled = (HatchStyle.SelectedIndex != 0 || Gradient.SelectedIndex != 0); BorderColor.Enabled = (BorderDashStyle.SelectedIndex != 0); BorderSizeCom.Enabled = (BorderDashStyle.SelectedIndex != 0); // Set Back Color Chart1.BackColor = Color.FromName(BackColorCom.GetItemText(BackColorCom.SelectedItem)); // Set Back Gradient End Color Chart1.BackSecondaryColor = Color.FromName(ForeColorCom.GetItemText(ForeColorCom.SelectedItem)); // Set Gradient Type if (Gradient.SelectedItem != null) { Chart1.BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.GetItemText(Gradient.SelectedItem)); } // Set Gradient Type if (HatchStyle.SelectedItem != null) { Chart1.BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.GetItemText(HatchStyle.SelectedItem)); } // Set background image if (!ShowImageCheck.Checked) { Chart1.BackImage = ""; ImageAlign.Enabled = false; ImageMode.Enabled = false; } else { ImageMode.Enabled = true; ImageAlign.Enabled = (ImageMode.SelectedIndex == 5); // Set chart image MainForm mainForm = (MainForm)this.ParentForm; string imageFileName = mainForm.CurrentSamplePath; imageFileName += "\\Flag.gif"; Chart1.BackImage = imageFileName; Chart1.BackImageTransparentColor = Color.Red; // Set Image Mode if (ImageMode.SelectedItem != null) { Chart1.BackImageWrapMode = (ChartImageWrapMode)ChartImageWrapMode.Parse(typeof(ChartImageWrapMode), ImageMode.SelectedItem.ToString()); } // Set Image Alignment if (ImageAlign.SelectedItem != null) { Chart1.BackImageAlignment = (ChartImageAlignmentStyle)ChartImageAlignmentStyle.Parse(typeof(ChartImageAlignmentStyle), ImageAlign.SelectedItem.ToString()); } } // Set Border Width if (BorderSizeCom.SelectedItem != null) { Chart1.BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem)); } // Set Border Style if (BorderDashStyle.SelectedItem != null) { Chart1.BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.GetItemText(BorderDashStyle.SelectedItem)); } // Set Border Color Chart1.BorderColor = Color.FromName(BorderColor.GetItemText(BorderColor.SelectedItem)); }
public static Legend CreateLegend(Chart chart, string legendName , Color backColor, Color backGradientEndColor, Color borderColor , Font font , GradientType gradientType, ChartHatchStyle chartHatchStyle , int borderWidth, ChartDashStyle boaderStyle , int shadowOffset, Color shadowColor , bool positionAuto, float positionX, float positionY, float positionWidth, float positionHeight) { chart.Legends.Add(legendName); Legend legend = chart.Legends[legendName]; // Set Legend visual attributes if (!backColor.Equals(Color.Empty)) { legend.BackColor = backColor; } if (!backGradientEndColor.Equals(Color.Empty)) { legend.BackGradientEndColor = backGradientEndColor; } if (!borderColor.Equals(Color.Empty)) { legend.BorderColor = borderColor; } if (font != null) { legend.Font = font; } if (gradientType != GradientType.None) { legend.BackGradientType = gradientType; } if (chartHatchStyle != ChartHatchStyle.None) { legend.BackHatchStyle = chartHatchStyle; } if (borderWidth != -1) { legend.BorderWidth = borderWidth; } if (boaderStyle != ChartDashStyle.NotSet) { legend.BorderStyle = boaderStyle; } if (shadowOffset != -1) { legend.ShadowOffset = shadowOffset; } if (!shadowColor.Equals(Color.Empty)) { legend.ShadowColor = shadowColor; } legend.Position.Auto = positionAuto; if (!positionAuto) { if (positionX != -1) { legend.Position.X = positionX; } if (positionY != -1) { legend.Position.Y = positionY; } if (positionWidth != -1) { legend.Position.Width = positionWidth; } if (positionHeight != -1) { legend.Position.Height = positionHeight; } } return(legend); }
private void CreateAndAddStripLine(string title, int start, int end, Color color, Color secondColor, ChartHatchStyle hatchStyle = ChartHatchStyle.None) { StripLine stripLine = new StripLine(); stripLine.BackColor = color; stripLine.BackSecondaryColor = secondColor; stripLine.BackHatchStyle = hatchStyle; stripLine.Text = title; stripLine.Font = new Font("Times New Roman", 12, FontStyle.Bold); // strip range is [start .. end] inclusive, but we evaluate [start..end[ (end is exclusive) // the strip should be by one longer (starting at start - 0.5 and ending at end + 0.5) stripLine.StripWidth = end - start; stripLine.IntervalOffset = start - 0.5; // start slightly to the left of the first point to clearly indicate the first point in the partition this.chart.ChartAreas[0].AxisX.StripLines.Add(stripLine); }
/// <summary> /// Draws 3D border. /// </summary> /// <param name="graph">Graphics to draw the border on.</param> /// <param name="borderSkin">Border skin object.</param> /// <param name="rect">Rectangle of the border.</param> /// <param name="backColor">Color of rectangle</param> /// <param name="backHatchStyle">Hatch style</param> /// <param name="backImage">Back Image</param> /// <param name="backImageWrapMode">Image mode</param> /// <param name="backImageTransparentColor">Image transparent color.</param> /// <param name="backImageAlign">Image alignment</param> /// <param name="backGradientStyle">Gradient type</param> /// <param name="backSecondaryColor">Gradient End Color</param> /// <param name="borderColor">Border Color</param> /// <param name="borderWidth">Border Width</param> /// <param name="borderDashStyle">Border Style</param> public override void DrawBorder( ChartGraphics graph, BorderSkin borderSkin, RectangleF rect, Color backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageWrapMode, Color backImageTransparentColor, ChartImageAlignmentStyle backImageAlign, GradientStyle backGradientStyle, Color backSecondaryColor, Color borderColor, int borderWidth, ChartDashStyle borderDashStyle) { drawBottomShadow = true; sunken = false; outsideShadowRate = .9f; drawOutsideTopLeftShadow = false; bool oldScrewsFlag = this.drawScrews; this.drawScrews = false; base.DrawBorder( graph, borderSkin, rect, borderSkin.BackColor, borderSkin.BackHatchStyle, borderSkin.BackImage, borderSkin.BackImageWrapMode, borderSkin.BackImageTransparentColor, borderSkin.BackImageAlignment, borderSkin.BackGradientStyle, borderSkin.BackSecondaryColor, borderSkin.BorderColor, borderSkin.BorderWidth, borderSkin.BorderDashStyle); this.drawScrews = oldScrewsFlag; rect.X += sizeLeftTop.Width; rect.Y += sizeLeftTop.Height; rect.Width -= sizeRightBottom.Width + sizeLeftTop.Width; rect.Height -= sizeRightBottom.Height + sizeLeftTop.Height; if (rect.Width > 0 && rect.Height > 0) { float[] oldCorners = new float[8]; oldCorners = (float[])cornerRadius.Clone(); cornerRadius = innerCorners; drawBottomShadow = false; sunken = true; drawOutsideTopLeftShadow = true; outsideShadowRate = 1.4f; Color oldPageColor = borderSkin.PageColor; borderSkin.PageColor = Color.Transparent; base.DrawBorder( graph, borderSkin, rect, backColor, backHatchStyle, backImage, backImageWrapMode, backImageTransparentColor, backImageAlign, backGradientStyle, backSecondaryColor, borderColor, borderWidth, borderDashStyle); borderSkin.PageColor = oldPageColor; cornerRadius = oldCorners; } }
protected void Page_Load(object sender, System.EventArgs e) { if (!this.IsPostBack) { // Add Hatch styles to control. foreach (string colorName in Enum.GetNames(typeof(ChartHatchStyle))) { HatchStyle.Items.Add(colorName); } // Add Chart Gradient types to control. foreach (string colorName in Enum.GetNames(typeof(GradientStyle))) { Gradient.Items.Add(colorName); } // Add Chart Line styles to control. foreach (string colorName in Enum.GetNames(typeof(ChartDashStyle))) { BorderDashStyle.Items.Add(colorName); } BorderDashStyle.SelectedIndex = 5; } // Set Back Color Chart1.ChartAreas["ChartArea1"].BackColor = Color.FromName(BackColor.SelectedItem.Value); // Set Back Gradient End Color Chart1.ChartAreas["ChartArea1"].BackSecondaryColor = Color.FromName(ForeColor.SelectedItem.Value); // Set Hatch Style Chart1.ChartAreas["ChartArea1"].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.SelectedItem.Text); // Set Gradient Type Chart1.ChartAreas["ChartArea1"].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.SelectedItem.Text); // Set Border Color Chart1.ChartAreas["ChartArea1"].BorderColor = Color.FromName(BorderColor.SelectedItem.Value); // Set Border Style Chart1.ChartAreas["ChartArea1"].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.SelectedItem.Text); // Set Border Width Chart1.ChartAreas["ChartArea1"].BorderWidth = int.Parse(BorderSize.SelectedItem.Value); // Disable hatch if gradient is active if (Chart1.ChartAreas["ChartArea1"].BackGradientStyle != GradientStyle.None) { HatchStyle.Enabled = false; } else { HatchStyle.Enabled = true; } // Disable gradient if hatch style is active if (Chart1.ChartAreas["ChartArea1"].BackHatchStyle != ChartHatchStyle.None) { Gradient.Enabled = false; } else { Gradient.Enabled = true; } }
public static void SetChartArea(ChartArea chartArea , Color backColor , Color backGradientEndColor , Color borderColor , ChartDashStyle borderStyle , int borderWidth , ChartHatchStyle chartHatchStyle , GradientType gradientType , int shadowOffset , Color shadowColor , bool enable3D , string backImage , ChartImageAlign chartImageAlign , ChartImageWrapMode chartImageWrapMode , Color backImageTranspColor) { if (!backColor.Equals(Color.Empty)) { chartArea.BackColor = backColor; } if (!backGradientEndColor.Equals(Color.Empty)) { chartArea.BackGradientEndColor = backGradientEndColor; } if (!borderColor.Equals(Color.Empty)) { chartArea.BorderColor = borderColor; } chartArea.BorderStyle = borderStyle; if (borderWidth != -1) { chartArea.BorderWidth = borderWidth; } if (chartHatchStyle != ChartHatchStyle.None) { chartArea.BackHatchStyle = chartHatchStyle; } if (gradientType != GradientType.None) { chartArea.BackGradientType = gradientType; } if (shadowOffset != -1) { chartArea.ShadowOffset = shadowOffset; } if (!shadowColor.Equals(Color.Empty)) { chartArea.ShadowColor = shadowColor; } chartArea.Area3DStyle.Enable3D = enable3D; if (backImage != null) { chartArea.BackImage = backImage; chartArea.BackImageAlign = chartImageAlign; chartArea.BackImageMode = chartImageWrapMode; if (!backImageTranspColor.Equals(Color.Empty)) { chartArea.BackImageTranspColor = backImageTranspColor; } } }
/// <summary> /// updateTimeSeries /// </summary> private void updateTimeSeries(PollutantReleasesTimeSeriesFilter filter, MediumFilter.Medium medium) { CurrentMedium = medium; // assume data is found dataFound(true); // result from qyerylayer List <TimeSeriesClasses.PollutantReleases> data = PollutantReleaseTrend.GetTimeSeries(filter, medium);; if (data == null || data.Count == 0) { dataFound(false); return; } // set report data to table this.lvTimeSeriesTable.DataSource = data; this.lvTimeSeriesTable.DataBind(); Color[] colors = new Color[] {}; string[] legendTexts = new string[] { Resources.GetGlobal("Common", "Accidental"), Resources.GetGlobal("Common", "Controlled") }; // init chart. Must be done after table databinding, because missing years are added. if (medium.Equals(MediumFilter.Medium.Air)) { colors = new Color[] { Global.ColorAirAccidental, Global.ColorAirTotal }; } else if (medium.Equals(MediumFilter.Medium.Water)) { colors = new Color[] { Global.ColorWaterAccidental, Global.ColorWaterTotal }; } else if (medium.Equals(MediumFilter.Medium.Soil)) { colors = new Color[] { Global.ColorSoilAccidental, Global.ColorSoilTotal }; } ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None, ChartHatchStyle.None }; this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantReleaseTrend.CODE_KG, colors, hatchStyles, legendTexts); //this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantReleaseTrend.CODE_TNE, colors, legendTexts); List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>(); foreach (var v in data) { string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year), String.Format("{0}: {1}", Resources.GetGlobal("Common", "Facilities"), v.Facilities), String.Format("{0}: {1}", Resources.GetGlobal("Pollutant", "ReleasesTotal"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)), String.Format("{0}: {1}", Resources.GetGlobal("Pollutant", "ReleasesAccidentalReleases"), QuantityFormat.Format(v.QuantityAccidental, v.QuantityAccidentalUnit)), (v.AccidentalPercent > 0.0) ? String.Format("{0}: {1:F5}%", Resources.GetGlobal("Pollutant", "ReleasesAccidentalPercentValue"), v.AccidentalPercent) : String.Format("{0}: 0%", Resources.GetGlobal("Pollutant", "ReleasesAccidentalPercentValue")) }; TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData { Year = v.Year, Values = new double?[] { TimeSeriesUtils.RangeValue(v.QuantityAccidental), TimeSeriesUtils.RangeValue(v.Quantity) - TimeSeriesUtils.RangeValue(v.QuantityAccidental) }, ToolTip = ToolTipFormatter.FormatLines(tip) }; bars.Add(cd); } this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bars, false)); }
protected void Page_Load(object sender, System.EventArgs e) { if (!this.IsPostBack) { // Add Hatch styles to control. foreach (string colorName in Enum.GetNames(typeof(ChartHatchStyle))) { HatchStyle.Items.Add(colorName); } // Add Chart Gradient types to control. foreach (string colorName in Enum.GetNames(typeof(GradientStyle))) { Gradient.Items.Add(colorName); } Gradient.Items.FindByValue("None").Selected = true; // Add Chart Line styles to control. foreach (string skinStyle in Enum.GetNames(typeof(BorderSkinStyle))) { SkinStyle.Items.Add(skinStyle); } SkinStyle.Items.FindByValue("Emboss").Selected = true; // Add Border styles to control. foreach (string colorName in Enum.GetNames(typeof(ChartDashStyle))) { BorderDashStyle.Items.Add(colorName); } BorderDashStyle.Items.FindByValue("Solid").Selected = true; // Add Colors to controls. foreach (String colorName in KnownColor.GetNames(typeof(KnownColor))) { BackColor.Items.Add(colorName); ForeColor.Items.Add(colorName); BorderColor.Items.Add(colorName); } BackColor.Items.FindByValue("PeachPuff").Selected = true; ForeColor.Items.FindByValue("White").Selected = true; BorderColor.Items.FindByValue("Maroon").Selected = true; } // Set Border Skin Chart1.BorderSkin.SkinStyle = (BorderSkinStyle)ChartHatchStyle.Parse(typeof(BorderSkinStyle), SkinStyle.SelectedItem.Text); // disable controls this.ForeColor.Enabled = this.IsFrameStyle(); this.BackColor.Enabled = this.IsFrameStyle(); // set default appearance Chart1.BorderSkin.BorderDashStyle = ChartDashStyle.NotSet; Chart1.BorderSkin.BorderColor = Color.Empty; Chart1.BorderSkin.BorderWidth = 1; Chart1.BorderlineDashStyle = ChartDashStyle.NotSet; Chart1.BorderColor = Color.Empty; Chart1.BorderWidth = 1; if (this.IsFrameStyle()) { // Set Back Color Chart1.BorderSkin.BackColor = Color.FromName(BackColor.SelectedItem.Value); // Set Back Gradient End Color Chart1.BorderSkin.BackSecondaryColor = Color.FromName(ForeColor.SelectedItem.Value); // Set Hatch Style Chart1.BorderSkin.BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.SelectedItem.Text); // Set Gradient Type Chart1.BorderSkin.BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.SelectedItem.Text); // Set Border Color Chart1.BorderSkin.BorderColor = Color.FromName(BorderColor.SelectedItem.Value); // Set Border Style Chart1.BorderSkin.BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.SelectedItem.Text); // Set Border Width Chart1.BorderSkin.BorderWidth = int.Parse(BorderSize.SelectedItem.Value); } else { // Set Border Line Color Chart1.BorderColor = Color.FromName(BorderColor.SelectedItem.Value); // Set Border Line Style Chart1.BorderlineDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.SelectedItem.Text); // Set Border Line Width Chart1.BorderWidth = int.Parse(BorderSize.SelectedItem.Value); } // Disable hatch if gradient is active if (this.IsFrameStyle() && Chart1.BorderSkin.BackGradientStyle == GradientStyle.None) { HatchStyle.Enabled = true; } else { HatchStyle.Enabled = false; } // Disable gradient if hatch style is active if (this.IsFrameStyle() && Chart1.BorderSkin.BackHatchStyle == ChartHatchStyle.None) { Gradient.Enabled = true; } else { Gradient.Enabled = false; } }
/// <summary> /// Draws 3D border /// </summary> /// <param name="graph">Graphics to draw the border on.</param> /// <param name="borderSkin">Border skin object.</param> /// <param name="rect">Rectangle of the border.</param> /// <param name="backColor">Color of rectangle</param> /// <param name="backHatchStyle">Hatch style</param> /// <param name="backImage">Back Image</param> /// <param name="backImageWrapMode">Image mode</param> /// <param name="backImageTransparentColor">Image transparent color.</param> /// <param name="backImageAlign">Image alignment</param> /// <param name="backGradientStyle">Gradient type</param> /// <param name="backSecondaryColor">Gradient End Color</param> /// <param name="borderColor">Border Color</param> /// <param name="borderWidth">Border Width</param> /// <param name="borderDashStyle">Border Style</param> public virtual void DrawBorder( ChartGraphics graph, BorderSkin borderSkin, RectangleF rect, Color backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageWrapMode, Color backImageTransparentColor, ChartImageAlignmentStyle backImageAlign, GradientStyle backGradientStyle, Color backSecondaryColor, Color borderColor, int borderWidth, ChartDashStyle borderDashStyle) { RectangleF absolute = graph.Round(rect); RectangleF shadowRect = absolute; // Calculate shadow colors (0.2 - 0.6) float colorDarkeningIndex = 0.3f + (0.4f * (borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f); Color shadowColor = Color.FromArgb( (int)(backColor.R * colorDarkeningIndex), (int)(backColor.G * colorDarkeningIndex), (int)(backColor.B * colorDarkeningIndex)); colorDarkeningIndex += 0.2f; Color shadowLightColor = Color.FromArgb( (int)(borderSkin.PageColor.R * colorDarkeningIndex), (int)(borderSkin.PageColor.G * colorDarkeningIndex), (int)(borderSkin.PageColor.B * colorDarkeningIndex)); if (borderSkin.PageColor == Color.Transparent) { shadowLightColor = Color.FromArgb(60, 0, 0, 0); } // Calculate rounded rect radius float radius = defaultRadiusSize; radius = (float)Math.Max(radius, 2f * resolution / 96.0f); radius = (float)Math.Min(radius, rect.Width / 2f); radius = (float)Math.Min(radius, rect.Height / 2f); radius = (float)Math.Ceiling(radius); // Fill page background color using (Brush brush = new SolidBrush(borderSkin.PageColor)) { graph.FillRectangle(brush, rect); } if (drawOutsideTopLeftShadow) { // Top/Left outside shadow shadowRect = absolute; shadowRect.X -= radius * 0.3f; shadowRect.Y -= radius * 0.3f; shadowRect.Width -= radius * .3f; shadowRect.Height -= radius * .3f; graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, Color.FromArgb(128, Color.Black), borderSkin.PageColor, outsideShadowRate); } // Bottom/Right outside shadow shadowRect = absolute; shadowRect.X += radius * 0.3f; shadowRect.Y += radius * 0.3f; shadowRect.Width -= radius * .3f; shadowRect.Height -= radius * .3f; graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, shadowLightColor, borderSkin.PageColor, outsideShadowRate); // Background shadowRect = absolute; shadowRect.Width -= radius * .3f; shadowRect.Height -= radius * .3f; GraphicsPath path = graph.CreateRoundedRectPath(shadowRect, cornerRadius); graph.DrawPathAbs( path, backColor, backHatchStyle, backImage, backImageWrapMode, backImageTransparentColor, backImageAlign, backGradientStyle, backSecondaryColor, borderColor, borderWidth, borderDashStyle, PenAlignment.Inset); // Dispose Graphic path if (path != null) { path.Dispose(); } // Draw ----s imitation in the corners of the farame if (drawScrews) { // Left/Top ---- RectangleF screwRect = RectangleF.Empty; float offset = radius * 0.4f; screwRect.X = shadowRect.X + offset; screwRect.Y = shadowRect.Y + offset; screwRect.Width = radius * 0.55f; screwRect.Height = screwRect.Width; DrawScrew(graph, screwRect); // Right/Top ---- screwRect.X = shadowRect.Right - offset - screwRect.Width; DrawScrew(graph, screwRect); // Right/Bottom ---- screwRect.X = shadowRect.Right - offset - screwRect.Width; screwRect.Y = shadowRect.Bottom - offset - screwRect.Height; DrawScrew(graph, screwRect); // Left/Bottom ---- screwRect.X = shadowRect.X + offset; screwRect.Y = shadowRect.Bottom - offset - screwRect.Height; DrawScrew(graph, screwRect); } // Bottom/Right inner shadow Region innerShadowRegion = null; if (drawBottomShadow) { shadowRect = absolute; shadowRect.Width -= radius * .3f; shadowRect.Height -= radius * .3f; innerShadowRegion = new Region( graph.CreateRoundedRectPath( new RectangleF( shadowRect.X - radius, shadowRect.Y - radius, shadowRect.Width + 0.5f * radius, shadowRect.Height + 0.5f * radius), cornerRadius)); innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowRect, cornerRadius)); graph.Clip = innerShadowRegion; shadowRect.X -= 0.5f * radius; shadowRect.Width += 0.5f * radius; shadowRect.Y -= 0.5f * radius; shadowRect.Height += 0.5f * radius; graph.DrawRoundedRectShadowAbs( shadowRect, cornerRadius, radius, Color.Transparent, Color.FromArgb(175, (sunken) ? Color.White : shadowColor), 1.0f); graph.Clip = new Region(); } // Top/Left inner shadow shadowRect = absolute; shadowRect.Width -= radius * .3f; shadowRect.Height -= radius * .3f; innerShadowRegion = new Region( graph.CreateRoundedRectPath( new RectangleF( shadowRect.X + radius * .5f, shadowRect.Y + radius * .5f, shadowRect.Width - .2f * radius, shadowRect.Height - .2f * radius), cornerRadius)); RectangleF shadowWithOffset = shadowRect; shadowWithOffset.Width += radius; shadowWithOffset.Height += radius; innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowWithOffset, cornerRadius)); innerShadowRegion.Intersect(graph.CreateRoundedRectPath(shadowRect, cornerRadius)); graph.Clip = innerShadowRegion; graph.DrawRoundedRectShadowAbs( shadowWithOffset, cornerRadius, radius, Color.Transparent, Color.FromArgb(175, (sunken) ? shadowColor : Color.White), 1.0f); graph.Clip = new Region(); }
/// <inheritdoc/> public override void Draw(FRPaintEventArgs e) { base.Draw(e); Rectangle chartRect = new Rectangle((int)Math.Round(AbsLeft), (int)Math.Round(AbsTop), (int)Math.Round(Width), (int)Math.Round(Height)); GraphicsState state = e.Graphics.Save(); try { if (IsPrinting) { chartRect = new Rectangle((int)Math.Round(AbsLeft * e.ScaleX), (int)Math.Round(AbsTop * e.ScaleY), (int)Math.Round(Width * e.ScaleX), (int)Math.Round(Height * e.ScaleY)); // workaround the MS Chart bug - series border is not scaled properly int[] borderWidths = new int[Series.Count]; for (int i = 0; i < Series.Count; i++) { int borderWidth = Series[i].SeriesSettings.BorderWidth; borderWidths[i] = borderWidth; Series[i].SeriesSettings.BorderWidth = (int)Math.Round(borderWidth * e.ScaleX); } FChart.Printing.PrintPaint(e.Graphics, chartRect); for (int i = 0; i < Series.Count; i++) { Series[i].SeriesSettings.BorderWidth = borderWidths[i]; } } else { e.Graphics.ScaleTransform(e.ScaleX, e.ScaleY); Color saveBackSecondaryColor = Color.Empty; ChartHatchStyle saveBackHatchStyle = ChartHatchStyle.None; Color saveBorderColor = Color.Empty; ChartDashStyle saveBorderStyle = ChartDashStyle.NotSet; int saveBorderWidth = 0; if (HotPoint != null) { saveBackSecondaryColor = HotPoint.BackSecondaryColor; saveBackHatchStyle = HotPoint.BackHatchStyle; saveBorderColor = HotPoint.BorderColor; saveBorderStyle = HotPoint.BorderDashStyle; saveBorderWidth = HotPoint.BorderWidth; HotPoint.BackHatchStyle = ChartHatchStyle.LightUpwardDiagonal; HotPoint.BackSecondaryColor = Color.White; HotPoint.BorderColor = Color.Orange; HotPoint.BorderDashStyle = ChartDashStyle.Solid; HotPoint.BorderWidth = 2; } FChart.Printing.PrintPaint(e.Graphics, chartRect); if (HotPoint != null) { HotPoint.BackSecondaryColor = saveBackSecondaryColor; HotPoint.BackHatchStyle = saveBackHatchStyle; HotPoint.BorderColor = saveBorderColor; HotPoint.BorderDashStyle = saveBorderStyle; HotPoint.BorderWidth = saveBorderWidth; } } } catch (Exception ex) { using (Font font = new Font("Tahoma", 8)) using (StringFormat sf = new StringFormat()) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; e.Graphics.DrawString(ex.Message, font, Brushes.Red, chartRect, sf); } } finally { e.Graphics.Restore(state); } }
public virtual void DrawBorder(ChartGraphics graph, BorderSkinAttributes borderSkin, RectangleF rect, Color backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageMode, Color backImageTranspColor, ChartImageAlign backImageAlign, GradientType backGradientType, Color backGradientEndColor, Color borderColor, int borderWidth, ChartDashStyle borderStyle) { RectangleF rectangleF = graph.Round(rect); RectangleF rectangleF2 = rectangleF; float num = (float)(0.30000001192092896 + 0.40000000596046448 * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765.0); Color color = Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num)); num = (float)(num + 0.20000000298023224); Color centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num)); if (borderSkin.PageColor == Color.Transparent) { centerColor = Color.FromArgb(60, 0, 0, 0); } Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num)); float val = this.defaultRadiusSize; val = Math.Max(val, (float)(2.0 * this.resolution / 96.0)); val = Math.Min(val, (float)(rect.Width / 2.0)); val = Math.Min(val, (float)(rect.Height / 2.0)); val = (float)Math.Ceiling((double)val); graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect); if (this.drawOutsideTopLeftShadow) { rectangleF2 = rectangleF; rectangleF2.X -= (float)(val * 0.30000001192092896); rectangleF2.Y -= (float)(val * 0.30000001192092896); rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, Color.FromArgb(128, Color.Black), borderSkin.PageColor, this.outsideShadowRate); } rectangleF2 = rectangleF; rectangleF2.X += (float)(val * 0.30000001192092896); rectangleF2.Y += (float)(val * 0.30000001192092896); rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, centerColor, borderSkin.PageColor, this.outsideShadowRate); rectangleF2 = rectangleF; rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius); graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backGradientEndColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset); if (graphicsPath != null) { graphicsPath.Dispose(); } if (this.drawScrews) { RectangleF empty = RectangleF.Empty; float num2 = (float)(val * 0.40000000596046448); empty.X = rectangleF2.X + num2; empty.Y = rectangleF2.Y + num2; empty.Width = (float)(val * 0.550000011920929); empty.Height = empty.Width; this.DrawScrew(graph, empty); empty.X = rectangleF2.Right - num2 - empty.Width; this.DrawScrew(graph, empty); empty.X = rectangleF2.Right - num2 - empty.Width; empty.Y = rectangleF2.Bottom - num2 - empty.Height; this.DrawScrew(graph, empty); empty.X = rectangleF2.X + num2; empty.Y = rectangleF2.Bottom - num2 - empty.Height; this.DrawScrew(graph, empty); } Region region = null; if (this.drawBottomShadow) { rectangleF2 = rectangleF; rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); region = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X - val, rectangleF2.Y - val, (float)(rectangleF2.Width + 0.5 * val), (float)(rectangleF2.Height + 0.5 * val)), this.cornerRadius)); region.Complement(graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius)); graph.Clip = region; rectangleF2.X -= (float)(0.5 * val); rectangleF2.Width += (float)(0.5 * val); rectangleF2.Y -= (float)(0.5 * val); rectangleF2.Height += (float)(0.5 * val); graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, Color.Transparent, Color.FromArgb(175, this.sunken ? Color.White : color), 1f); graph.Clip = new Region(); } rectangleF2 = rectangleF; rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); region = new Region(graph.CreateRoundedRectPath(new RectangleF((float)(rectangleF2.X + val * 0.5), (float)(rectangleF2.Y + val * 0.5), (float)(rectangleF2.Width - 0.20000000298023224 * val), (float)(rectangleF2.Height - 0.20000000298023224 * val)), this.cornerRadius)); RectangleF rect2 = rectangleF2; rect2.Width += val; rect2.Height += val; region.Complement(graph.CreateRoundedRectPath(rect2, this.cornerRadius)); region.Intersect(graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius)); graph.Clip = region; graph.DrawRoundedRectShadowAbs(rect2, this.cornerRadius, val, Color.Transparent, Color.FromArgb(175, this.sunken ? color : Color.White), 1f); graph.Clip = new Region(); }
public static void DundasChartBase(Chart chart , ChartImageType chartImageType , int width , int height , BorderSkinStyle borderSkinStyle , Color borderLineColor , int borderLineWidth , Color backColor , Color backGradientEndColor , Color borderColor , ChartDashStyle borderStyle , int borderWidth , ChartHatchStyle chartHatchStyle , GradientType gradientType , AntiAliasing antiAliasing , string backImage , ChartImageWrapMode backImageMode , ChartImageAlign backImageAlign , Color backImageTranspColor) { chart.ImageType = chartImageType; if (width != -1) { chart.Width = width; } if (height != -1) { chart.Height = height; } if (borderSkinStyle != BorderSkinStyle.None) { chart.BorderSkin.SkinStyle = borderSkinStyle; } if (!borderLineColor.Equals(Color.Empty)) { chart.BorderLineColor = borderLineColor; } if (borderLineWidth != -1) { chart.BorderLineWidth = borderLineWidth; } if (!backColor.Equals(Color.Empty)) { chart.BackColor = backColor; } // Set Back Gradient End Color if (!backGradientEndColor.Equals(Color.Empty)) { chart.BackGradientEndColor = backGradientEndColor; } // Set Hatch Style // Set Border Color if (!borderColor.Equals(Color.Empty)) { chart.BorderColor = borderColor; } // Set Border Style if (borderStyle != ChartDashStyle.NotSet) { chart.BorderStyle = borderStyle; } // Set Border Width if (borderWidth != -1) { chart.BorderWidth = borderWidth; } if (chartHatchStyle != ChartHatchStyle.None) { chart.BackHatchStyle = chartHatchStyle; } if (gradientType != GradientType.None) { chart.BackGradientType = gradientType; } if (antiAliasing != AntiAliasing.None) { chart.AntiAliasing = antiAliasing; } if (backImage != null) { chart.BackImage = backImage; chart.BackImageMode = backImageMode; chart.BackImageAlign = backImageAlign; if (!backImageTranspColor.Equals(Color.Empty)) { chart.BackImageTranspColor = backImageTranspColor; } } }
private void AppearanceChange() { // suppress appearance settings during loading if (this.initializing) { return; } // load default chart settings if (defaultChartView.Length > 0) { defaultChartView.Position = 0; Chart1.Serializer.Load(defaultChartView); } // Set Back Color Chart1.Series[0].Points[2].Color = Color.FromName(ColorCom.GetItemText(ColorCom.SelectedItem)); // Set Back Gradient End Color Chart1.Series[0].Points[2].BackSecondaryColor = Color.FromName(EndColorCom.GetItemText(EndColorCom.SelectedItem)); // Set Border Color Chart1.Series[0].Points[2].BorderColor = Color.FromName(BorderColorCom.GetItemText(BorderColorCom.SelectedItem)); // Set Gradient Type if (GradientCom.SelectedItem != null) { Chart1.Series[0].Points[2].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), GradientCom.GetItemText(GradientCom.SelectedItem)); } // Set Gradient Type if (HatchingCom.SelectedItem != null) { Chart1.Series[0].Points[2].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchingCom.GetItemText(HatchingCom.SelectedItem)); } // Set Border Width if (BorderSizeCom.SelectedItem != null) { Chart1.Series[0].Points[2].BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem)); } // Set Border Style if (BorderDashStyleCom.SelectedItem != null) { Chart1.Series[0].Points[2].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyleCom.GetItemText(BorderDashStyleCom.SelectedItem)); } if (!this.ThirdPoint.Checked) { // Set Back Color Chart1.Series[0].Color = Color.FromName(ColorCom.GetItemText(ColorCom.SelectedItem)); // Set Back Gradient End Color Chart1.Series[0].BackSecondaryColor = Color.FromName(EndColorCom.GetItemText(EndColorCom.SelectedItem)); // Set Border Color Chart1.Series[0].BorderColor = Color.FromName(BorderColorCom.GetItemText(BorderColorCom.SelectedItem)); // Set Gradient Type if (GradientCom.SelectedItem != null) { Chart1.Series[0].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), GradientCom.GetItemText(GradientCom.SelectedItem)); } // Set Gradient Type if (HatchingCom.SelectedItem != null) { Chart1.Series[0].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchingCom.GetItemText(HatchingCom.SelectedItem)); } // Set Border Width if (BorderSizeCom.SelectedItem != null) { Chart1.Series[0].BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem)); } // Set Border Style if (BorderDashStyleCom.SelectedItem != null) { Chart1.Series[0].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyleCom.GetItemText(BorderDashStyleCom.SelectedItem)); } // Set Shadow Offset if (ShadowOffset.SelectedItem != null) { Chart1.Series[0].ShadowOffset = int.Parse(ShadowOffset.GetItemText(ShadowOffset.SelectedItem)); } } }