private void ButtonMeasurement_Click(object sender, RoutedEventArgs e) { DependencyObject obj = sender as DependencyObject; TreeViewItem item; RealTimeMeasurement realTimeMeasurement; Measurement measurement; PhasorMeasurementUserControl phasorMeasurementUserControl; while ((object)obj != null && obj.GetType() != typeof(TreeViewItem)) { obj = VisualTreeHelper.GetParent(obj); } item = (TreeViewItem)obj; realTimeMeasurement = (RealTimeMeasurement)item?.DataContext; measurement = Measurement.GetMeasurement(null, $"WHERE SignalReference = '{realTimeMeasurement?.SignalReference}'"); if ((object)measurement != null && measurement.DeviceID.HasValue) { phasorMeasurementUserControl = CommonFunctions.LoadUserControl("Manage Measurements for " + measurement.DeviceAcronym, typeof(PhasorMeasurementUserControl), (int)measurement.DeviceID) as PhasorMeasurementUserControl; if (phasorMeasurementUserControl != null) { ((PhasorMeasurements)phasorMeasurementUserControl.DataContext).CurrentItem = measurement; } } }
// Attempt to get measurement name from signal ID private string GetMeasurementName(Guid signalID) { DataModelMeasurement measurement = DataModelMeasurement.GetMeasurement(null, signalID); if ((object)measurement != null) { return(string.Format("{0} [{1}:{2}]", measurement.PointTag, measurement.HistorianAcronym, measurement.PointID)); } return(signalID.ToString()); }
private void ButtonMeasurement_Click(object sender, RoutedEventArgs e) { Measurement measurement = Measurement.GetMeasurement(null, "WHERE SignalReference = '" + ((Button)sender).Content + "'"); if (measurement.DeviceID.HasValue) { PhasorMeasurementUserControl phasorMeasurementUserControl = CommonFunctions.LoadUserControl("Manage Measurements for " + measurement.DeviceAcronym, typeof(PhasorMeasurementUserControl), (int)measurement.DeviceID) as PhasorMeasurementUserControl; if (phasorMeasurementUserControl != null) { ((PhasorMeasurements)phasorMeasurementUserControl.DataContext).CurrentItem = measurement; } } }