private void editNumericIndicator(Control c) { try { int idObject = Convert.ToInt32(c.AccessibleName); Dundas.Gauges.WinControl.GaugeContainer ind = (Dundas.Gauges.WinControl.GaugeContainer)c; using (EditObjectForm f = new EditObjectForm(idObject)) { f.ShowDialog(); if (f.Submitted) { // Update object var obj = PictureViewBLL.Current.GetObjectByID(idObject); obj.Parameters = f.IDVar.ToString(); obj.Width = f.IndWidth; obj.Height = f.IndHeight; obj.X = f.IndLeft; obj.Y = f.IndTop; PictureViewBLL.Current.UpdateObject(obj); // Update gauge on-screen ind.Location = new System.Drawing.Point(f.IndLeft, f.IndTop); ind.Size = new Size(f.IndWidth, f.IndHeight); // Reset properties ind.Labels["Default"].Text = ""; ind.NumericIndicators["Default"].DigitColor = Color.Black; ind.NumericIndicators["Default"].DecimalColor = Color.Black; ind.NumericIndicators["Default"].SeparatorColor = Color.Black; ind.NumericIndicators["Default"].Value = 0; // Associate with new sensor var sensor = SensorBLL.Current.GetByID(f.IDVar); if (sensor != null) { ind.Labels["Default"].Text = sensor.Name + "\n" + sensor.Unit; if (sensor.MaxValue != null) ind.NumericIndicators["Default"].Digits = System.Convert.ToInt32(System.Math.Log10(System.Convert.ToInt32(sensor.MaxValue) + 1)) + 1 + 2 + 1; // Find value if (entityConntext.SensorValues. Where(ent => ent.SensorID == sensor.SensorID).OrderByDescending(ent => ent.MeaTime).Count() > 0) { SensorValue sensorValue = entityConntext.SensorValues. Where(ent => ent.SensorID == sensor.SensorID).OrderByDescending(ent => ent.MeaTime).First(); if (sensor.MaxValue == null) ind.NumericIndicators["Default"].Digits = System.Convert.ToInt32(System.Math.Log10(System.Convert.ToInt32(getSensorValue(sensorValue)) + 1)) + 1 + 2 + 1; ind.NumericIndicators["Default"].Value = System.Convert.ToDouble(getSensorValue(sensorValue)); ind.Labels["Default"].Text = sensor.Name + "\n" + getSensorValue(sensorValue).ToString() + " " + sensor.Unit; // Check if value is in alarm level if (PictureViewBLL.Current.CheckAlarmRunning(obj)) { ind.NumericIndicators["Default"].DigitColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); ind.NumericIndicators["Default"].DecimalColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); ind.NumericIndicators["Default"].SeparatorColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); } } } } } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }
private void editIndicator(Control c) { try { int idObject = Convert.ToInt32(c.AccessibleName); indicator ind = (indicator)c; using (EditObjectForm f = new EditObjectForm(idObject)) { f.ShowDialog(); if (f.Submitted) { // Update object var obj = PictureViewBLL.Current.GetObjectByID(idObject); obj.Parameters = f.IDVar.ToString(); obj.Width = f.IndWidth; obj.Height = f.IndHeight; obj.X = f.IndLeft; obj.Y = f.IndTop; PictureViewBLL.Current.UpdateObject(obj); // Update indicator on-screen ind.Location = new System.Drawing.Point(f.IndLeft, f.IndTop); ind.Size = new Size(f.IndWidth, f.IndHeight); // Reset properties ind.FillColor = System.Drawing.Color.Lime; ind.VarName = "Name"; ind.UnitName = "Unit"; ind.Value = "Value"; // Associate with new sensor var sensor = SensorBLL.Current.GetByID(f.IDVar); if (sensor != null) { ind.VarName = sensor.Name; ind.UnitName = sensor.Unit; // Find value if (entityConntext.SensorValues. Where(ent => ent.SensorID == sensor.SensorID).OrderByDescending(ent => ent.MeaTime).Count() > 0) { SensorValue sensorValue = entityConntext.SensorValues. Where(ent => ent.SensorID == sensor.SensorID).OrderByDescending(ent => ent.MeaTime).First(); ind.Value = getDisplayValue(sensorValue); // Check if value is in alarm level if (PictureViewBLL.Current.CheckAlarmRunning(obj)) ind.FillColor = Color.Red; } } } } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }