Esempio n. 1
0
        void LoadConfig(Object sender)
        {
            DependencyObject item = VisualTreeHelper.GetParent((DependencyObject)sender);

            while (item.GetType() != typeof(TreeViewItem))
            {
                if (item == null)
                {
                    return;
                }
                item = VisualTreeHelper.GetParent(item);
            }

            ItemsControl itemParent = ItemsControl.ItemsControlFromItemContainer(item);
            object       SourceItem;

            if (itemParent == null)
            {
                TreeViewItem tv = (TreeViewItem)item;
                SourceItem = tv.DataContext;
            }
            else
            {
                SourceItem = itemParent.ItemContainerGenerator.ItemFromContainer(item);
            }
            if (SourceItem is SessionColumn)
            {
                //if the user has selected wsavg as the column type then create a windspeed sensor config
                //other wise create a regular sensor config

                SessionColumn col = (SessionColumn)SourceItem;
                if (col.ColumnType == SessionColumnType.WSAvg)
                {
                    WindSpeedConfig config = new WindSpeedConfig();
                    config.StartDate = DataSetStartDate;
                    config.EndDate   = DataSetEndDate;
                    _sessionColumnCollection [col.ColName].ColumnType = col.ColumnType;
                    _sessionColumnCollection [col.ColName].addConfig(config);
                }
                else
                {
                    SensorConfig config = new SensorConfig();
                    config.StartDate = DataSetStartDate;
                    config.EndDate   = DataSetEndDate;
                    _sessionColumnCollection [col.ColName].ColumnType = col.ColumnType;
                    _sessionColumnCollection [col.ColName].addConfig(config);
                }
            }
            else
            {
                throw new ApplicationException("Type passed in must be a SessionColumn. ViewModel1.LoadConfig");
            }
        }
Esempio n. 2
0
        void BulkEditColType(Object sender)
        {
            DependencyObject    o   = (DependencyObject)sender;
            ComboBox            cbo = VisualTreeExtensions.GetVisualDescendent <ComboBox>(o);
            List <TreeViewItem> tvi = VisualTreeExtensions.GetVisualDescendents <TreeViewItem>(o).ToList();

            foreach (TreeViewItem item in tvi)
            {
                CheckBox chk = VisualTreeExtensions.GetVisualDescendent <CheckBox>(item);
                if (chk.IsChecked == true)
                {
                    SessionColumn col = (SessionColumn)item.DataContext;
                    col.ColumnType = (SessionColumnType)cbo.SelectedValue;
                    chk.IsChecked  = false;
                }
            }
        }
Esempio n. 3
0
 public CheckableSessionColumn(SessionColumn col)
 {
     SessCol = col;
 }