private void c1Chart1_Click(object sender, System.EventArgs e) { if (onPoint) { // add point to the second series int len = ds2.PointData.Length; ds2.PointData.Length = len + 1; ds2.PointData[len] = ds1.PointData[pi]; ds2.Label = string.Format("Blue series - {0} points", ds2.Length); C1.Win.C1Chart.Label lbl = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel(); lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex; lbl.AttachMethodData.GroupIndex = 0; lbl.AttachMethodData.SeriesIndex = 1; lbl.AttachMethodData.PointIndex = len; lbl.Text = string.Format("{0}", len + 1); lbl.Visible = menuOptionsShowLabels.Checked; // remove point from the first series if (pi != ds1.Length - 1) { ds1.PointData[pi] = ds1.PointData[ds1.Length - 1]; } ds1.PointData.Length -= 1; ds1.Label = string.Format("Red series - {0} points", ds1.Length); if (ds1.Length == 0) { c1Chart1.Header.Text = "Game Over!\nDouble click on the chart to restart"; } } }
/// <summary> /// Pulse of the game /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void stepTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { this.stepTimer.Stop(); nTime--; if (nTime < 0) { StopGame(); return; } // A candy goes out of the region int i = 0; for (int index = 5; index < c1Chart1.ChartGroups[0].ChartData.SeriesList.Count; index++) { C1.Win.C1Chart.ChartDataSeries series = c1Chart1.ChartGroups[0].ChartData.SeriesList[index]; series.Y[0] = (int)series.Y[0] + 10; if ((int)series.Y[0] > 100) { c1Chart1.ChartGroups[0].ChartData.SeriesList.Remove(series); c1Chart1.ChartLabels.LabelsCollection.RemoveAt(i); foreach (C1.Win.C1Chart.Label lbl in c1Chart1.ChartLabels.LabelsCollection) { lbl.AttachMethodData.SeriesIndex--; } nLosts++; break; } series.Y1[0] = (int)series.Y[0] / 20; i++; } // It is time to give a new candy if (count >= 10 / this.numCandies) { count = 0; C1.Win.C1Chart.ChartDataSeries series = this.c1Chart1.ChartGroups[0].ChartData.SeriesList.AddNewSeries(); series.SymbolStyle.Shape = GetShape(); series.SymbolStyle.Color = Color.FromArgb(xPosRandom.Next(0, 255), xPosRandom.Next(0, 255), xPosRandom.Next(0, 255)); series.Display = C1.Win.C1Chart.SeriesDisplayEnum.Show; series.X.Length = 1; series.Y.Length = 1; series.Y1.Length = 1; series.X[0] = xPosRandom.Next(10, 90); series.Y[0] = 10; series.Y1[0] = (int)series.Y[0] / 20; C1.Win.C1Chart.Label lbl = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel(); lbl.Text = GetWord(); lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex; lbl.AttachMethodData.GroupIndex = 0; lbl.AttachMethodData.SeriesIndex = c1Chart1.ChartGroups[0].ChartData.SeriesList.Count - 1; lbl.AttachMethodData.PointIndex = 0; lbl.Compass = C1.Win.C1Chart.LabelCompassEnum.South; lbl.Visible = true; } else { count++; } SetStatusLabel(); this.stepTimer.Start(); }
void setupChart() { // setup chart style chart.Style.BackColor = Color.Firebrick; chart.Style.ForeColor = Color.Navy; // setup header chart.Header.Style.BackColor = Color.Tan; chart.Header.Style.Border.BorderStyle = C1.Win.C1Chart.BorderStyleEnum.InsetBevel; chart.Header.Style.Border.Thickness = 5; chart.Header.Style.Font = new Font("Arial", 10, FontStyle.Italic); chart.Header.Location = new Point(10, 20); chart.Header.Text = "Average length of stay for patients\n" + "with the same type of illness\n" + "at three different hospitals"; // setup footer chart.Footer.Style.BackColor = Color.Tan; chart.Footer.Style.Border.BorderStyle = C1.Win.C1Chart.BorderStyleEnum.InsetBevel; chart.Footer.Style.Border.Thickness = 5; chart.Footer.Style.Font = new Font("Arial", 10); chart.Footer.Text = "Nowhere"; chart.Footer.Style.HorizontalAlignment = C1.Win.C1Chart.AlignHorzEnum.Center; // setup label C1.Win.C1Chart.Label lbl = chart.ChartLabels.LabelsCollection.AddNewLabel(); lbl.Style.BackColor = Color.Tan; lbl.Style.Border.BorderStyle = C1.Win.C1Chart.BorderStyleEnum.InsetBevel; lbl.Style.Border.Thickness = 5; lbl.Style.ForeColor = Color.DarkViolet; lbl.Style.Font = new Font("Arial", 10); lbl.Text = "Move the mouse over a Bubble\n to see length of stay in days"; lbl.Compass = C1.Win.C1Chart.LabelCompassEnum.SouthEast; lbl.AttachMethodData.X = 250; lbl.AttachMethodData.Y = 20; lbl.Style.HorizontalAlignment = C1.Win.C1Chart.AlignHorzEnum.Center; lbl.Visible = true; // setup chart area chart.ChartArea.Style.BackColor = Color.Tan; chart.ChartArea.Style.Border.BorderStyle = C1.Win.C1Chart.BorderStyleEnum.InsetBevel; chart.ChartArea.Style.Border.Thickness = 5; // setup axis X C1.Win.C1Chart.ValueLabel vlbl = chart.ChartArea.AxisX.ValueLabels.AddNewLabel(); vlbl.NumericValue = 1; vlbl.Text = "General"; vlbl = chart.ChartArea.AxisX.ValueLabels.AddNewLabel(); vlbl.NumericValue = 2; vlbl.Text = "Western"; vlbl = chart.ChartArea.AxisX.ValueLabels.AddNewLabel(); vlbl.NumericValue = 3; vlbl.Text = "Eastern"; chart.ChartArea.AxisX.Min = 0.5f; chart.ChartArea.AxisX.Max = 3.5f; chart.ChartArea.AxisX.AnnoMethod = C1.Win.C1Chart.AnnotationMethodEnum.ValueLabels; // setup axis Y vlbl = chart.ChartArea.AxisY.ValueLabels.AddNewLabel(); vlbl.NumericValue = 1; vlbl.Text = "Men"; vlbl = chart.ChartArea.AxisY.ValueLabels.AddNewLabel(); vlbl.NumericValue = 2; vlbl.Text = "Women"; chart.ChartArea.AxisY.Min = 0; chart.ChartArea.AxisY.Max = 3; chart.ChartArea.AxisY.AnnoMethod = C1.Win.C1Chart.AnnotationMethodEnum.ValueLabels; chart.ChartGroups[0].ChartType = C1.Win.C1Chart.Chart2DTypeEnum.Bubble; }