Interaction logic for AddFactorLevelsDialog.xaml
Наследование: System.Windows.Window
        private void _addfactorlevel_Click(object sender, RoutedEventArgs e)
        {
            int rowindex = variableGrid.SelectedIndex;
            string colname = (this.Variables[rowindex] as DataSourceVariable).RName;
            DataColumnMeasureEnum measure = (this.Variables[rowindex] as DataSourceVariable).Measure;

            if (measure == DataColumnMeasureEnum.Scale)//dont let user run "add factor " on scale col.
            {
                MessageBox.Show("Cannot add factors to Measure=Scale(Numeric) type.", "Add/Remove Level Warning:", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            List<string> oldlvls = new List<string>();
            List<string> newlvls = new List<string>();
            List<string> levels = new List<string>();
            foreach (var v in ds.Variables[rowindex].Values)
            {
                levels.Add(v);
                oldlvls.Add(v);
            }
            AddFactorLevelsDialog fld = new AddFactorLevelsDialog();
            fld.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            fld.FactorLevels = levels;
            fld.ShowDialog();

            foreach (string s in fld.FactorLevels)
            {
                if (s != "<NA>" && !oldlvls.Contains(s))
                {
                    newlvls.Add(s);
                }
            }


            //Pass new levels only
            IAnalyticsService analyticServ = LifetimeService.Instance.Container.Resolve<IAnalyticsService>();
            analyticServ.AddFactorLevels(colname, newlvls, ds.Name);
            refreshDataGrid();
        }