Ejemplo n.º 1
0
        private void LoadFile()
        {
            var dialog = new OpenFileDialog {
                Filter = "Views (*.csv)|*.csv"
            };

            if (dialog.ShowDialog() == true)
            {
                var lines     = FileWorker.ReadFile(dialog.FileName).Replace("\r\n", "\n").Split('\n');
                var variables = "";
                var domains   = "";
                var strings   = new List <string>();
                foreach (var line in lines.Where(x => !string.IsNullOrEmpty(x)))
                {
                    var items = line.Split(';');
                    if (!string.IsNullOrEmpty(items[0]))
                    {
                        variables += items[0] + ",";
                    }
                    if (!string.IsNullOrEmpty(items[1]))
                    {
                        domains += items[1] + ",";
                    }
                    if (items.Length > 3)
                    {
                        strings.Add(items[2] + ";" + items[3] + ";" + items[4]);
                    }
                }

                VariableString = variables.Substring(0, variables.Length - 1);
                DomainString   = domains.Substring(0, domains.Length - 1);
                Apply();
                ConstraintItems.RemoveAt(0);

                IsPairwiseDisjunct = bool.Parse(lines.First().Split(';')[5]);
                foreach (var s in strings.Where(x => x != ";;"))
                {
                    var items      = s.Split(';');
                    var constraint = new ConstraintViewModel(_allVariables)
                    {
                        SelectedVariable1  = _allVariables.FirstOrDefault(x => x.Name == items[0]),
                        SelectedComparator = (CompareEnum)Enum.Parse(typeof(CompareEnum), items[1]),
                        SelectedVariable2  = _allVariables.FirstOrDefault(x => x.Name == items[2])
                    };
                    AddConstraintViewModel(constraint);
                }
            }
        }
Ejemplo n.º 2
0
 private void ViewModel_RemoveConstraint(ConstraintViewModel constraint)
 {
     ConstraintItems.Remove(constraint);
 }
Ejemplo n.º 3
0
 private void AddConstraintViewModel(ConstraintViewModel viewModel)
 {
     viewModel.RemoveConstraint += ViewModel_RemoveConstraint;
     ConstraintItems.Add(viewModel);
 }