public void UpdateSeriesColors() { for (int i = 0; i < SensorsCheckBoxes.Count; i++) { CheckBoxTag tag = SensorsCheckBoxes[i].Tag as CheckBoxTag; if (tag != null) { tag.Series.Color = tag.CheckBox.ForeColor; } } for (int i = 0; i < ActorsCheckBoxes.Count; i++) { CheckBoxTag tag = ActorsCheckBoxes[i].Tag as CheckBoxTag; if (tag != null) { tag.Series.Color = tag.CheckBox.ForeColor; } } for (int i = 0; i < OptionsCheckBoxes.Count; i++) { CheckBoxTag tag = OptionsCheckBoxes[i].Tag as CheckBoxTag; if (tag != null) { tag.Series.Color = tag.CheckBox.ForeColor; } } }
public void MakeTips() { int i; if (tips == null) { tips = new ToolTip[sensors.Count + actors.Count + options.Count]; for (i = 0; i < tips.Length; i++) { tips[i] = new ToolTip(); } } ConfigManager manager = AppManager.ConfigManager; IDictionary <string, ConfigData> datas = null; i = 0; int j = 0; int limit1 = sensors.Count; int limit2 = sensors.Count + actors.Count; while (i < tips.Length) { string toolTipText = null; CheckBox control; if (i < limit1) { control = sensors[j++]; datas = manager.SensorConfigValues; } else if (i < limit2) { control = actors[j++ - limit1]; datas = manager.ActorConfigValues; } else { control = options[j++ - limit2]; datas = manager.OptionConfigValues; } String namePlusUnit = String.Empty; if (RowValues.Infos != null && i < RowValues.Infos.NamesAndUnits.Length) { string tmp = RowValues.Infos.NamesAndUnits[i]; if (tmp != null) { namePlusUnit = "[" + tmp + "] "; } } CheckBoxTag tag = control.Tag as CheckBoxTag; if (tag != null) { toolTipText = namePlusUnit + datas[tag.ConfigKey].ToolTipText; } else { toolTipText = namePlusUnit + control.Text; } tips[i++].SetToolTip(control, toolTipText); } }
private void CheckBoxCheckedChanged(object sender, EventArgs e) { CheckBox checkBox = sender as CheckBox; if (checkBox != null) { if (checkBox.Tag != null) { CheckBoxTag tag = checkBox.Tag as CheckBoxTag; if (tag != null) { AppManager.ConfigManager.SetConfigData(tag); if (checkBox.Checked) { FillSeriesWithNewData(tag, fromDateTime, toDateTime); } else { Chart chartMain = AppManager.MainForm.ChartControl.ChartMain; chartMain.BeginInit(); DataPointCollection points = tag.Series.Points; points.ClearFast(); //MsChartExtension if (chartMain.Series.Contains(tag.Series)) { chartMain.Series.Remove(tag.Series); } chartMain.EndInit(); } } } } }
private void FillSeriesWithNewData(CheckBoxTag tag, DateTime from, DateTime to) { if (tag != null) { Chart chartMain = AppManager.MainForm.ChartControl.ChartMain; int fromIndex = GetSolvisListIndex(from); int toIndex = GetSolvisListIndex(to); chartMain.BeginInit(); DataPointCollection points = tag.Series.Points; points.ClearFast(); //MsChartExtension if (fromIndex < 0 || fromIndex >= toIndex) { return; } points.SuspendUpdates(); for (int i = fromIndex; i <= toIndex; i++) { RowValues values = SolvisList[i]; if (tag.Ident == GroupIdent.Sensor) { points.AddXY(values.DateAndTime, values.GetSensorValue(tag.Index)); } else if (tag.Ident == GroupIdent.Actor) { points.AddXY(values.DateAndTime, values.GetActorValue(tag.Index)); } else //GroupIdent.Option { SeriesState state = SeriesState.Inner; if (i == fromIndex) { state = SeriesState.First; } else if (i == toIndex) { state = SeriesState.Last; } SetOptionsPoints(tag.Index, values, points, state); } } points.ResumeUpdates(); if (!chartMain.Series.Contains(tag.Series)) { chartMain.Series.Add(tag.Series); } chartMain.EndInit(); } }
public void InitOptionsSeries(IList <CheckBox> list) { for (int i = 0; i < list.Count; i++) { string key = "P" + (i + 1).ToString("00", CultureInfo.InvariantCulture); CheckBox checkBox = list[i]; Series series = new Series(key); series.ChartType = SeriesChartType.FastLine; series.ChartArea = "ChartArea1"; series.Legend = "Legend1"; series.Color = checkBox.ForeColor; series.LegendText = key; CheckBoxTag tag = new CheckBoxTag(series, GroupIdent.Option, i, checkBox, key); checkBox.Tag = tag; checkBox.CheckedChanged += CheckBoxCheckedChanged; } }
public void SetConfigData(CheckBoxTag tag) { if (SensorConfigValues.ContainsKey(tag.ConfigKey)) { ConfigData data = SensorConfigValues[tag.ConfigKey]; data.Checked = tag.CheckBox.Checked; } else if (ActorConfigValues.ContainsKey(tag.ConfigKey)) { ConfigData data = ActorConfigValues[tag.ConfigKey]; data.Checked = tag.CheckBox.Checked; } else if (OptionConfigValues.ContainsKey(tag.ConfigKey)) { ConfigData data = OptionConfigValues[tag.ConfigKey]; data.Checked = tag.CheckBox.Checked; } }
private void FillAllCheckedSeriesWithNewData(DateTime from, DateTime to) { Chart chartMain = AppManager.MainForm.ChartControl.ChartMain; int fromIndex = GetSolvisListIndex(from); int toIndex = GetSolvisListIndex(to); chartMain.BeginInit(); AppManager.MainForm.ChartControl.SetIntervals(new TimeSpan(to.Ticks - from.Ticks)); MainForm mainForm = AppManager.MainForm; for (int seriesIndex = 0; seriesIndex < mainForm.SensorsCheckBoxes.Count; seriesIndex++) { CheckBox checkBox = mainForm.SensorsCheckBoxes[seriesIndex]; if (checkBox.Checked) { CheckBoxTag tag = checkBox.Tag as CheckBoxTag; if (tag != null) { Series series = tag.Series; DataPointCollection points = series.Points; points.ClearFast(); //MsChartExtension if (fromIndex < 0 || fromIndex >= toIndex) { continue; } points.SuspendUpdates(); for (int i = fromIndex; i <= toIndex; i++) { RowValues values = SolvisList[i]; points.AddXY(values.DateAndTime, values.GetSensorValue(seriesIndex)); } points.ResumeUpdates(); if (!chartMain.Series.Contains(series)) { chartMain.Series.Add(series); } } } } for (int seriesIndex = 0; seriesIndex < mainForm.ActorsCheckBoxes.Count; seriesIndex++) { CheckBox checkBox = mainForm.ActorsCheckBoxes[seriesIndex]; if (checkBox.Checked) { CheckBoxTag tag = checkBox.Tag as CheckBoxTag; if (tag != null) { Series series = tag.Series; DataPointCollection points = series.Points; points.ClearFast(); //MsChartExtension if (fromIndex < 0 || fromIndex >= toIndex) { continue; } points.SuspendUpdates(); for (int i = fromIndex; i <= toIndex; i++) { RowValues values = SolvisList[i]; points.AddXY(values.DateAndTime, values.GetActorValue(seriesIndex)); } points.ResumeUpdates(); if (!chartMain.Series.Contains(series)) { chartMain.Series.Add(series); } } } } for (int seriesIndex = 0; seriesIndex < mainForm.OptionsCheckBoxes.Count; seriesIndex++) { CheckBox checkBox = mainForm.OptionsCheckBoxes[seriesIndex]; if (checkBox.Checked) { CheckBoxTag tag = checkBox.Tag as CheckBoxTag; if (tag != null) { Series series = tag.Series; DataPointCollection points = series.Points; points.ClearFast(); //MsChartExtension if (fromIndex < 0 || fromIndex >= toIndex) { continue; } points.SuspendUpdates(); for (int i = fromIndex; i <= toIndex; i++) { RowValues values = SolvisList[i]; SeriesState state = SeriesState.Inner; if (i == fromIndex) { state = SeriesState.First; } else if (i == toIndex) { state = SeriesState.Last; } SetOptionsPoints(seriesIndex, values, points, state); } points.ResumeUpdates(); if (!chartMain.Series.Contains(series)) { chartMain.Series.Add(series); } } } } chartMain.EndInit(); }