private void c1Chart1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button.Equals(MouseButtons.None)) { C1Chart chart = (C1Chart)sender; ChartRegionEnum region = chart.ChartRegionFromCoord(e.X, e.Y); int g = -1, s = -1, p = -1, d = -1; if (region.Equals(ChartRegionEnum.Legend)) { if (chart.Legend.SeriesFromCoord(e.X, e.Y, ref g, ref s)) { if (g >= 0 && s >= 0) { chart.Footer.Text = "Series #" + s.ToString(); } } } else { ChartGroup grp = chart.ChartGroups[0]; if (grp.CoordToDataIndex(e.X, e.Y, CoordinateFocusEnum.XandYCoord, ref s, ref p, ref d)) { if (d == 0 && s >= 0 && p >= 0) { chart.Footer.Text = "Slice #" + s.ToString(); } else if (!chart.Footer.Text.Equals("Nowhere")) { chart.Footer.Text = "Nowhere"; } } } } }
private void c1Chart1_MouseMove(object sender, MouseEventArgs e) { X = e.X; Y = e.X; Invalidate(true); if (inMouseMove) { return; } inMouseMove = true; ChartRegionEnum region = c1Chart1.ChartRegionFromCoord(e.X, e.Y); switch (region) { case ChartRegionEnum.ChartArea: case ChartRegionEnum.ChartLabel: case ChartRegionEnum.PlotArea: txtCurSeriesValue.Text = ""; txtCurFrqValue.Text = ""; AddBarValueLabel(e.X, e.Y); break; default: AddBarValueLabel(-1, -1); break; } inMouseMove = false; }
private void c1Chart1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { C1Chart chart = (C1Chart)sender; int g = 0, s = -1; ChartRegionEnum region = chart.ChartRegionFromCoord(e.X, e.Y); if (region.Equals(ChartRegionEnum.Legend)) { Legend leg = chart.Legend; if (leg.SeriesFromCoord(e.X, e.Y, ref g, ref s)) { if (s >= 0) { if (e.Button.Equals(MouseButtons.Left)) { CycleSeries(s); } else if (e.Button.Equals(MouseButtons.Right)) { ResetSeries(s); } else if (e.Button.Equals(MouseButtons.Middle)) { ToggleSeriesDisplay(s); } } } } }
private void c1Chart1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { C1Chart chart = (C1Chart)sender; int g = 0, s = -1, p = -1, d = -1; ChartGroup grp = chart.ChartGroups[g]; ChartRegionEnum region = chart.ChartRegionFromCoord(e.X, e.Y); string footerText = "Nowhere"; if (region.Equals(ChartRegionEnum.Legend)) { // if in the legend, check for the series and update // the footerText as appropriate Legend leg = chart.Legend; if (leg.SeriesFromCoord(e.X, e.Y, ref g, ref s)) { if (s >= 0) { footerText = string.Format("Series {0}", s); } } } else { // if it's close enough check for the series and update // the footerText as appropriate CoordinateFocusEnum focus = CoordinateFocusEnum.XandYCoord; bool stacked = grp.Stacked; int minDist = 5; if (radioBar.Checked && !stacked) { // special case where X focus is more appropriate focus = CoordinateFocusEnum.XCoord; minDist = 0; } else if (radioPie.Checked || (radioBar.Checked && stacked)) { // special case where minimum distance of 0 is more // appropriate. minDist = 0; } if (grp.CoordToDataIndex(e.X, e.Y, focus, ref s, ref p, ref d)) { if (s >= 0 && p >= 0 && d <= minDist) { footerText = string.Format("Index({0},{1})", s, p); } } } chart.Footer.Text = footerText; }
private void c1Chart1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { C1Chart chart = (C1Chart)sender; if (e.Button.Equals(MouseButtons.Left)) { int g = -1, s = -1, p = -1, d = -1; ChartGroup grp = chart.ChartGroups[0]; ChartDataSeries ser = null; ChartRegionEnum region = chart.ChartRegionFromCoord(e.X, e.Y); if (region.Equals(ChartRegionEnum.Legend)) { if (chart.Legend.SeriesFromCoord(e.X, e.Y, ref g, ref s)) { ser = grp.ChartData.SeriesList[s]; if (ser.Display.Equals(SeriesDisplayEnum.Show)) { ser.Display = SeriesDisplayEnum.Hide; } else { ser.Display = SeriesDisplayEnum.Show; } } return; } if (grp.CoordToDataIndex(e.X, e.Y, CoordinateFocusEnum.XandYCoord, ref s, ref p, ref d)) { if (d == 0 && s >= 0 && p >= 0) { ser = grp.ChartData.SeriesList[s]; int offset = ser.Offset; if (offset == 0) { offset = 40; } else { offset = 0; } ser.Offset = offset; SetTextBoxSliceOffsetValue(s, offset); } } } }
private void c1Chart1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { // eliminate recursive calls. if (inMouseMove) { return; } inMouseMove = true; ChartRegionEnum region = c1Chart1.ChartRegionFromCoord(e.X, e.Y); switch (region) { case ChartRegionEnum.Legend: AddBarValueLabel(-1, -1, false); HighlightObject(c1Chart1.Legend); break; case ChartRegionEnum.Header: AddBarValueLabel(-1, -1, false); HighlightObject(c1Chart1.Header); break; case ChartRegionEnum.Footer: AddBarValueLabel(-1, -1, false); HighlightObject(c1Chart1.Footer); break; case ChartRegionEnum.ChartArea: case ChartRegionEnum.ChartLabel: case ChartRegionEnum.PlotArea: HighlightObject(null); AddBarValueLabel(e.X, e.Y, e.Button.Equals(MouseButtons.Left)); break; default: AddBarValueLabel(-1, -1, false); HighlightObject(null); break; } inMouseMove = false; }
/// <summary> /// Handles the chart MouseDown event. Based on the location of the click /// different chart dialogs are displayed. If a property grid is desired, /// use the right mouse button for the click. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Clicking on the individual series entries in the Legend toggles the /// display of the series in the PlotArea. When hidden, the legend display /// is grayed to show it is hidden in the PlotArea. /// </remarks> private void c1Chart1_MouseDown(object sender, MouseEventArgs e) { ChartRegionEnum cre = c1Chart1.ChartRegionFromCoord(e.X, e.Y); if (cre == ChartRegionEnum.Legend) { Legend leg = c1Chart1.Legend; int groupIndex = -1, seriesIndex = -1; if (leg.SeriesFromCoord(e.X, e.Y, ref groupIndex, ref seriesIndex)) { // Toggle chart series display by clicking on the series in the legend ChartDataSeries cds = c1Chart1.ChartGroups[groupIndex].ChartData.SeriesList[seriesIndex]; if (cds.Display == SeriesDisplayEnum.Show) { cds.Display = SeriesDisplayEnum.Hide; cds.Tag = new Color[] { cds.LineStyle.Color, cds.SymbolStyle.Color, cds.SymbolStyle.OutlineColor }; cds.LineStyle.Color = Color.Gray; cds.SymbolStyle.Color = Color.Gray; cds.SymbolStyle.OutlineColor = Color.DarkSlateGray; } else { Color[] clrs = cds.Tag as Color[]; cds.LineStyle.Color = clrs[0]; cds.SymbolStyle.Color = clrs[1]; cds.SymbolStyle.OutlineColor = clrs[2]; cds.Display = SeriesDisplayEnum.Show; } } else { // Show property dialog for the chart Legend, in this case when a specific series is not clicked. if (e.Button == System.Windows.Forms.MouseButtons.Left) { c1Chart1.ShowProperties(PropertyPageFlags.AppearanceLegend); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { showPropertyGridForm(c1Chart1.Legend, "Legend properties"); } } } else if (cre == ChartRegionEnum.XAxis) { // Show property dialog for the chart X Axis, including Scaling, Fonts, Colors, and annotations etc. if (e.Button == System.Windows.Forms.MouseButtons.Left) { c1Chart1.ShowProperties(PropertyPageFlags.AxisXScale | PropertyPageFlags.AxisX | PropertyPageFlags.AxisXAnno); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { showPropertyGridForm(c1Chart1.ChartArea.AxisX, "X axis properties"); } } else if (cre == ChartRegionEnum.YAxis) { // Show property dialog for the chart Y Axis, including Scaling, Fonts, Colors, and annotations etc. if (e.Button == System.Windows.Forms.MouseButtons.Left) { c1Chart1.ShowProperties(PropertyPageFlags.AxisYScale | PropertyPageFlags.AxisY | PropertyPageFlags.AxisYAnno); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { showPropertyGridForm(c1Chart1.ChartArea.AxisY, "Y axis properties"); } } else if (cre == ChartRegionEnum.Footer) { // Show property dialog for the chart Footer if (e.Button == System.Windows.Forms.MouseButtons.Left) { c1Chart1.ShowProperties(PropertyPageFlags.AppearanceFooter); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { showPropertyGridForm(c1Chart1.Footer.Style, "Footer Style properties"); } } else if (cre == ChartRegionEnum.Header) { // Show property dialog for the chart Header if (e.Button == System.Windows.Forms.MouseButtons.Left) { c1Chart1.ShowProperties(PropertyPageFlags.AppearanceHeader); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { showPropertyGridForm(c1Chart1.Header.Style, "Header Style properties"); } } else if (cre == ChartRegionEnum.PlotArea) { // Show property dialog for the chart PlotArea if (e.Button == System.Windows.Forms.MouseButtons.Left) { c1Chart1.ShowProperties(PropertyPageFlags.AppearancePlotArea | PropertyPageFlags.Group0Data); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { if ((Control.ModifierKeys | Keys.Shift) == 0) { showPropertyGridForm(c1Chart1.ChartArea.PlotArea, "PlotArea properties"); } else { showPropertyGridForm(c1Chart1.ChartGroups.Group0, "Group 0 properties"); } } } else if (cre == ChartRegionEnum.ChartLabel) { // Toggle the forecolor of the clicked label, or for right clicks, // show a modal form with a property page. int labIndex = -1; if (c1Chart1.ChartLabels.LabelFromCoord(e.X, e.Y, ref labIndex)) { C1.Win.C1Chart.Label lab = c1Chart1.ChartLabels[labIndex]; if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (lab.Style.ForeColor != Color.Red) { lab.Style.ForeColor = Color.Red; } else { lab.Style.ForeColor = Color.Black; } } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { showPropertyGridForm(lab.Style, "Style properties for " + lab.Name); } } } else { if (e.Button == System.Windows.Forms.MouseButtons.Left) { c1Chart1.ShowProperties(PropertyPageFlags.All); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { showPropertyGridForm(c1Chart1, "Chart Properties"); } } }