public void UpdateInterface(ChartableControl target, DataPoint value) { target.LastValue = value; Program.mainWindow.BigChart.ResetAutoValues(); }
public BaseNodeGroupBox(EventHandler setAddressEvent, EventHandler isPresentEvent, string name) : base() { List <Label> horizontalSeparators = new List <Label> { new Label { AutoSize = false, Height = 2, BorderStyle = BorderStyle.Fixed3D, Dock = DockStyle.Fill, }, new Label { AutoSize = false, Height = 2, BorderStyle = BorderStyle.Fixed3D, Dock = DockStyle.Fill, } }; List <Label> verticalSeparators = new List <Label> { new Label { AutoSize = false, Width = 2, BorderStyle = BorderStyle.Fixed3D, Dock = DockStyle.Fill, }, new Label { AutoSize = false, Width = 2, BorderStyle = BorderStyle.Fixed3D, Dock = DockStyle.Fill, } }; activeEnergy = new Series { Color = Color.Green, YAxisType = AxisType.Primary, Legend = "LeftLegend", LegendText = "Active energy (kWh)", }; reactiveEnergy = new Series { Color = Color.Blue, YAxisType = AxisType.Secondary, Legend = "RightLegend", LegendText = "Reactive energy (kVARh)", }; activePower = new Series { Color = Color.Green, YAxisType = AxisType.Primary, Legend = "LeftLegend", LegendText = "Active power (kW)", }; reactivePower = new Series { Color = Color.Blue, YAxisType = AxisType.Secondary, Legend = "RightLegend", LegendText = "Reactive power (kVAR)", }; apparentPower = new Series { Color = Color.Red, YAxisType = AxisType.Primary, Legend = "LeftLegend", LegendText = "Apparent power (kVA)", }; List <Series> energyChartSeries = new List <Series> { activeEnergy, reactiveEnergy }; List <Series> powerChartSeries = new List <Series> { activePower, reactivePower, apparentPower }; foreach (Series series in energyChartSeries) { series.ChartType = SeriesChartType.Line; series.XValueType = ChartValueType.DateTime; } foreach (Series series in powerChartSeries) { series.ChartType = SeriesChartType.Line; series.XValueType = ChartValueType.DateTime; } EnergyChart = new ChartControl(energyChartSeries, "Energy") { Size = new Size(ChartWidth, ChartHeight), }; PowerChart = new ChartControl(powerChartSeries, "Power") { Size = new Size(ChartWidth, ChartHeight), }; LastReadingTime = new TextBoxControl(this, "LastReading", TextBoxControl.Type.Output); ActiveEnergy = new ChartableControl(this, EnergyChart, activeEnergy, "ActiveEnergy", "kWh"); ReactiveEnergy = new ChartableControl(this, EnergyChart, reactiveEnergy, "ReactiveEnergy", "kVArh"); ActivePower = new ChartableControl(this, PowerChart, activePower, "ActivePower", "kW"); ReactivePower = new ChartableControl(this, PowerChart, reactivePower, "ReactivePower", "kVAr"); ApparentPower = new ChartableControl(this, PowerChart, apparentPower, "ApparentPower", "kVA"); PowerFactor = new TextBoxControl(this, "PowerFactor", TextBoxControl.Type.Output); Outputs = new List <ParameterCheckBox>(); resetButton = new ButtonControl(this, "Reset"); configureButton = new ButtonControl(this, "Configure"); mainLayout = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, ColumnCount = 3, Name = name + "MainLayout", Location = new Point(InterfaceConstants.ItemPadding, InterfaceConstants.GroupBoxFirstItemY), }; chartsLayout = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, ColumnCount = 2, Name = name + "ChartsLayout", }; regulatorLayout = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, ColumnCount = 2, Name = name + "RegulatorLayout", }; readingsLayout = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, ColumnCount = 2, Name = name + "ReadingsLayout", }; regulatorLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50)); regulatorLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50)); readingsLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50)); readingsLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50)); chartsLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50)); chartsLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50)); Controls.Add(mainLayout); mainLayout.Controls.Add(readingsLayout); mainLayout.Controls.Add(regulatorLayout); mainLayout.Controls.Add(chartsLayout); chartsLayout.Controls.Add(EnergyChart); chartsLayout.Controls.Add(PowerChart); regulatorLayout.Controls.Add(LastReadingTime.Label); regulatorLayout.Controls.Add(LastReadingTime.Field); readingsLayout.Controls.Add(PowerFactor.Label); readingsLayout.Controls.Add(PowerFactor.Field); readingsLayout.Controls.Add(ActivePower.Text.Label); readingsLayout.Controls.Add(ActivePower.Text.Field); readingsLayout.Controls.Add(ReactivePower.Text.Label); readingsLayout.Controls.Add(ReactivePower.Text.Field); chartsLayout.Controls.Add(resetButton.Field); chartsLayout.Controls.Add(configureButton.Field); AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; Name = name.Replace(" ", "") + "GroupBox"; Text = name; TabStop = false; EnergyChart.Click += new EventHandler(ShowAsBigChart); PowerChart.Click += new EventHandler(ShowAsBigChart); resetButton.Field.Click += new EventHandler(ResetClicked); configureButton.Field.Click += new EventHandler(ConfigureClicked); }