Ejemplo n.º 1
0
 public void addFactor(ResearchFactor factor)
 {
     if (!_model.FactorSet.Rows.Contains(factor.Name))
     {
         _model.addFactor(factor);
     }
 }
Ejemplo n.º 2
0
        public void LoadFactorSet(string FilePath)
        {
            //TODO: Implement error handling in the event a garbage file is selected.
            if (HasData)
            {
                FactorSet.Clear();
                ResearchFactors.Clear();
            }

            XmlTextReader reader = new XmlTextReader(FilePath);

            FactorSet.ReadXml(reader);

            reader.Close();

            foreach (var row in FactorSet.AsEnumerable())
            {
                ResearchFactor factor = new ResearchFactor
                {
                    Name             = row.Field <string>("Name"),
                    Labels           = row.Field <ObservableCollection <string> >("Labels"),
                    Levels           = row.Field <int>("Levels"),
                    IsWithinSubjects = row.Field <bool>("IsWithinSubjects"),
                    IsRandomized     = row.Field <bool>("IsRandomized")
                };

                ResearchFactors.Add(factor);
            }
        }
Ejemplo n.º 3
0
        public void addFactor(ResearchFactor newFactor)
        {
            Type entityType = typeof(ResearchFactor);
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(entityType);

            //now we need to add the data to the table.

            DataRow row = factorSet.NewRow();

            foreach (PropertyDescriptor prop in properties)
            {
                row[prop.Name] = prop.GetValue(newFactor);
            }

            factorSet.Rows.Add(row);
        }
Ejemplo n.º 4
0
 public void removeFactor(ResearchFactor factor)
 {
     _model.removeFactor(factor);
 }
Ejemplo n.º 5
0
 public void removeFactor(ResearchFactor newFactor)
 {
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds a row and associated bindings for each UIElement to the grid.
        /// </summary>
        /// <param name="rowNum"></param>
        private void AddRow(int rowNum)
        {
            ResearchFactor rf = new ResearchFactor();

            //Create a new research factor if there isn't one already, otherwise select that research factor
            if(_efViewModel.ResearchFactors.Count <= rowNum)
                _efViewModel.ResearchFactors.Add(rf);
            else
                rf = _efViewModel.ResearchFactors[rowNum];

            //box for label
            var tb = new TextBox
            {
                Height = 20,
                Width = 170,
                Name = "factorName",

            };

            Binding binding = new Binding("Name") { Source = rf };
            binding.Mode = BindingMode.TwoWay;
            tb.SetBinding(TextBox.TextProperty, binding);

            Grid.SetRow(tb, rowNum + 1);
            Grid.SetColumn(tb, 0);

            //Button for creating levels
            var createlevels = new Button
            {
                Content = "Create levels",
                Width = 80,
                Height = 20,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            createlevels.Click += createlevels_OnClick;
            StackPanel sp = new StackPanel();
            sp.Margin = new Thickness(10);
            Grid.SetRow(sp, rowNum + 1);
            Grid.SetColumn(sp, 1);

            //Listbox for the labels to be displayed in
            var labelList = new ListBox { MinHeight = 45, MaxHeight = 45 };

            binding = new Binding("Labels") { Source = rf };
            binding.Mode = BindingMode.TwoWay;
            labelList.SetBinding(ListBox.ItemsSourceProperty, binding);

            sp.Children.Add(labelList);
            sp.Children.Add(createlevels);

            //checkbox for isRandomized
            var checkbox = new CheckBox
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };

            binding = new Binding("IsRandomized") { Source = rf };
            binding.Mode = BindingMode.TwoWay;
            checkbox.SetBinding(CheckBox.IsCheckedProperty, binding);

            Grid.SetRow(checkbox, rowNum + 1);
            Grid.SetColumn(checkbox, 2);

            //combobox for within/between subjects selection
            var cb = new ComboBox
            {
                Width = 150,
                Height = 20
            };

            string ComboBoxTrueValue = _efViewModel.DesignTypes[0]; //"Within Subjects Factor";
            string ComboBoxFalseValue = _efViewModel.DesignTypes[1]; //"Between Subjects Factor";

            Binding binding2 = new Binding("DesignTypes") { Source = _efViewModel };
            binding2.Mode = BindingMode.TwoWay;
            cb.SetBinding(ComboBox.ItemsSourceProperty, binding2);

            binding = new Binding("IsWithinSubjects") { Source = rf, Converter = new StringToBoolConverter { TrueValue = ComboBoxTrueValue, FalseValue = ComboBoxFalseValue } };
            binding.Mode = BindingMode.TwoWay;
            cb.SetBinding(ComboBox.SelectedValueProperty, binding);

            Grid.SetRow(cb, rowNum + 1); // I guess this means that "whatever grid you put me in, I'll be in this row and this column.
            Grid.SetColumn(cb, 3);

            factorGrid.Children.Add(tb);
            factorGrid.Children.Add(sp);
            factorGrid.Children.Add(checkbox);
            factorGrid.Children.Add(cb);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds a row and associated bindings for each UIElement to the grid.
        /// </summary>
        /// <param name="rowNum"></param>
        private void AddRow(int rowNum)
        {
            ResearchFactor rf = new ResearchFactor();

            //Create a new research factor if there isn't one already, otherwise select that research factor
            if (_efViewModel.ResearchFactors.Count <= rowNum)
            {
                _efViewModel.ResearchFactors.Add(rf);
            }
            else
            {
                rf = _efViewModel.ResearchFactors[rowNum];
            }


            //box for label
            var tb = new TextBox
            {
                Height = 20,
                Width  = 170,
                Name   = "factorName",
            };

            Binding binding = new Binding("Name")
            {
                Source = rf
            };

            binding.Mode = BindingMode.TwoWay;
            tb.SetBinding(TextBox.TextProperty, binding);

            Grid.SetRow(tb, rowNum + 1);
            Grid.SetColumn(tb, 0);

            //Button for creating levels
            var createlevels = new Button
            {
                Content             = "Create levels",
                Width               = 80,
                Height              = 20,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            createlevels.Click += createlevels_OnClick;
            StackPanel sp = new StackPanel();

            sp.Margin = new Thickness(10);
            Grid.SetRow(sp, rowNum + 1);
            Grid.SetColumn(sp, 1);


            //Listbox for the labels to be displayed in
            var labelList = new ListBox {
                MinHeight = 45, MaxHeight = 45
            };

            binding = new Binding("Labels")
            {
                Source = rf
            };
            binding.Mode = BindingMode.TwoWay;
            labelList.SetBinding(ListBox.ItemsSourceProperty, binding);

            sp.Children.Add(labelList);
            sp.Children.Add(createlevels);


            //checkbox for isRandomized
            var checkbox = new CheckBox
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };


            binding = new Binding("IsRandomized")
            {
                Source = rf
            };
            binding.Mode = BindingMode.TwoWay;
            checkbox.SetBinding(CheckBox.IsCheckedProperty, binding);

            Grid.SetRow(checkbox, rowNum + 1);
            Grid.SetColumn(checkbox, 2);


            //combobox for within/between subjects selection
            var cb = new ComboBox
            {
                Width  = 150,
                Height = 20
            };

            string ComboBoxTrueValue  = _efViewModel.DesignTypes[0]; //"Within Subjects Factor";
            string ComboBoxFalseValue = _efViewModel.DesignTypes[1]; //"Between Subjects Factor";


            Binding binding2 = new Binding("DesignTypes")
            {
                Source = _efViewModel
            };

            binding2.Mode = BindingMode.TwoWay;
            cb.SetBinding(ComboBox.ItemsSourceProperty, binding2);

            binding = new Binding("IsWithinSubjects")
            {
                Source = rf, Converter = new StringToBoolConverter {
                    TrueValue = ComboBoxTrueValue, FalseValue = ComboBoxFalseValue
                }
            };
            binding.Mode = BindingMode.TwoWay;
            cb.SetBinding(ComboBox.SelectedValueProperty, binding);


            Grid.SetRow(cb, rowNum + 1); // I guess this means that "whatever grid you put me in, I'll be in this row and this column.
            Grid.SetColumn(cb, 3);

            factorGrid.Children.Add(tb);
            factorGrid.Children.Add(sp);
            factorGrid.Children.Add(checkbox);
            factorGrid.Children.Add(cb);
        }