Esempio n. 1
0
        private void LbEditBtn_Click(object sender, RoutedEventArgs e)
        {
            //a button on list view has been clicked
            Button button = sender as Button;
            //walk up the tree to find the ListboxItem
            DependencyObject tvi = Helpers.ListUtility.FindParentTreeItem(button, typeof(ListBoxItem));

            //if not null cast the Dependancy object to type of Listbox item.
            if (tvi != null)
            {
                ListBoxItem lbi = tvi as ListBoxItem;
                IDashboardTimeSeriesPoint timeSeriesPoint = (IDashboardTimeSeriesPoint)lbi.DataContext;
                // Open edit window for this point
                if (timeSeriesPoint is DashboardScadaTimeSeriesPoint scadaTimeSeriesPoint)
                {
                    ScadaTimeSeriesPointEditWindow scadaTimeSeriesPointEditWindow = new ScadaTimeSeriesPointEditWindow(new DashboardScadaTimeSeriesPoint(scadaTimeSeriesPoint));
                    scadaTimeSeriesPointEditWindow.ShowDialog();
                    if (scadaTimeSeriesPointEditWindow.DialogResult == true)
                    {
                        // update the point
                        int pointIndex = dataPointsVM.dashboardTimeSeriesPoints.IndexOf(timeSeriesPoint);
                        if (pointIndex >= 0)
                        {
                            dataPointsVM.dashboardTimeSeriesPoints[pointIndex] = scadaTimeSeriesPointEditWindow.scadaTimeSeriesPointVM.ScadaTimeSeriesPoint;
                            ICollectionView view = CollectionViewSource.GetDefaultView(dataPointsVM.dashboardTimeSeriesPoints);
                            view.Refresh();
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 private void AddBtn_Click(object sender, RoutedEventArgs e)
 {
     // show relavent edit window
     if (TimeSeriesPointTypesComboBox.SelectedIndex > -1 && TimeSeriesPointTypesComboBox.SelectedIndex <= dataPointsVM.PointTypes.Count && dataPointsVM.PointTypes[TimeSeriesPointTypesComboBox.SelectedIndex] == DashboardScadaTimeSeriesPoint.timeSeriesType)
     {
         // show scada point edit window with relavent initialisation
         DateTime       startTime = DateTime.Now;
         DateTime       endTime   = startTime;
         ScadaDataPoint pnt       = new ScadaDataPoint("");
         if (dataPointsVM.dashboardTimeSeriesPoints.Count > 0)
         {
             startTime = dataPointsVM.dashboardTimeSeriesPoints.ElementAt(0).StartTime;
             endTime   = dataPointsVM.dashboardTimeSeriesPoints.ElementAt(0).EndTime;
         }
         DashboardScadaTimeSeriesPoint  scadaTimeSeriesPoint           = new DashboardScadaTimeSeriesPoint(pnt, startTime, endTime);
         ScadaTimeSeriesPointEditWindow scadaTimeSeriesPointEditWindow = new ScadaTimeSeriesPointEditWindow(scadaTimeSeriesPoint);
         scadaTimeSeriesPointEditWindow.ShowDialog();
         if (scadaTimeSeriesPointEditWindow.DialogResult == true)
         {
             // update the point
             dataPointsVM.dashboardTimeSeriesPoints.Add(scadaTimeSeriesPointEditWindow.scadaTimeSeriesPointVM.ScadaTimeSeriesPoint);
         }
     }
 }