private void domainNameForAddSelected(object sender, SelectionChangedEventArgs e)
        {
            var domainName = domainsForAdd.SelectedItem.ToString();

            if (domainName != "")
            {
                _domains = new ObservableCollection <string>();
                _domains.Add("Список значений");

                var domain = FrameContainer.GetDomains();

                foreach (var d in domain)
                {
                    if (domainName == d.name)
                    {
                        foreach (var v in d.values)
                        {
                            _domains.Add(v);
                        }
                        break;
                    }
                }
                domainList.ItemsSource = _domains;
            }
            else
            {
                _domains = new ObservableCollection <string>();
                domainList.ItemsSource = _domains;
            }
        }
        private void isANameLoaded(object sender, RoutedEventArgs e)
        {
            var domains = FrameContainer.GetDomains();

            var frame = FrameContainer.GetAllFrames();

            List <string> isA = new List <string>();

            foreach (var f in frame)
            {
                foreach (var d in domains)
                {
                    foreach (var v in d.values)
                    {
                        if (v == f.name && !isA.Contains(f.name))
                        {
                            isA.Add(f.name);
                        }

                        if (f.isA != "null" && !isA.Contains(f.isA))
                        {
                            isA.Add(f.isA);
                        }
                    }
                }
            }

            isA.Add("");

            IsANames.ItemsSource = isA;
        }
        private void isASelected(object sender, SelectionChangedEventArgs e)
        {
            var isA = IsANames.SelectedItem.ToString();

            if (isA != "")
            {
                _frame = new ObservableCollection <string>();
                _frame.Add("Список слотов");

                var fr = FrameContainer.GetAllFrames();

                foreach (var f in fr)
                {
                    if (isA == f.name)
                    {
                        foreach (var slot in f.slots)
                        {
                            _frame.Add(slot.name + ":" + slot.value);
                        }
                        break;
                    }
                }
                frameList.ItemsSource = _frame;
            }
        }
Пример #4
0
 public QuestionWindow(FrameContainer fContainer, Frame fTAnswer)
 {
     InitializeComponent();
     frameContainer = fContainer;
     frameToAnswer  = fTAnswer;
     count          = fTAnswer.slots.Count;
     Load();
 }
Пример #5
0
        private void SaveKb_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog sf = new SaveFileDialog();

            sf.Filter           = "Json files (*.json)|*.json";
            sf.FilterIndex      = 2;
            sf.RestoreDirectory = true;
            sf.ShowDialog();

            if (sf.FileName != "")
            {
                string kBasePath = sf.FileName;

                FrameContainer frameContainerToSave = viewModel.Events.viewModelFramesHierarchy.GetFrameContainer();
                kBLoader.SaveInFile(kBasePath, frameContainerToSave);
                MessageBox.Show("Ну Сохранил и сохранил");
            }
        }
Пример #6
0
        public void SaveInFile(string name, FrameContainer frameContainer)
        {
            List <List <string> > domainsInFile = new List <List <string> >();
            List <List <string> > framesInFile  = new List <List <string> >();

            foreach (var domain in frameContainer.GetDomains())
            {
                List <string> str = new List <string>();

                str.Add("name:" + domain.name);

                foreach (var v in domain.values)
                {
                    str.Add(v);
                }

                domainsInFile.Add(str);
            }

            foreach (var frame in frameContainer.GetAllFrames())
            {
                List <string> str = new List <string>();

                str.Add("name:" + frame.name);
                str.Add("is_a:" + frame.isA);
                str.Add("ID:" + frame.Id);

                foreach (var slot in frame.slots)
                {
                    str.Add(slot.name + ":" + slot.value);
                }

                framesInFile.Add(str);
            }

            SerializeData serialize = new SerializeData {
                Frames = framesInFile, Domains = domainsInFile
            };

            string jsonString = JsonConvert.SerializeObject(serialize, Formatting.Indented);

            File.WriteAllText(name, jsonString);
        }
        private void domainNameLoaded(object sender, RoutedEventArgs e)
        {
            var           domains = FrameContainer.GetDomains();
            List <object> data    = new List <object>();

            foreach (var d in domains)
            {
                data.Add(d.name);
            }

            var comboBox = sender as ComboBox;

            TextBox textBox = new TextBox();

            domainValues.ItemsSource = new List <object>()
            {
                new TextBox()
            };
            data.Add(textBox);

            comboBox.ItemsSource   = data;
            comboBox.SelectedIndex = 0;
        }
        private void domainNameSelected(object sender, SelectionChangedEventArgs e)
        {
            var           name    = domainNames.SelectedItem.ToString();
            var           domains = FrameContainer.GetDomains();
            List <object> data    = new List <object>();

            foreach (var d in domains)
            {
                if (d.name == name)
                {
                    foreach (var v in d.values)
                    {
                        data.Add(v);
                    }

                    TextBox textBox = new TextBox();
                    data.Add(textBox);

                    domainValues.ItemsSource   = data;
                    domainValues.SelectedIndex = 0;
                }
            }
        }
Пример #9
0
        private void MenuItem_Change(object sender, RoutedEventArgs e)
        {
            try
            {
                ViewModelFramesHierarchy selectedNode = (ViewModelFramesHierarchy)existingSituationsTreeView.SelectedItem;

                FrameContainer  frameContainer  = selectedNode.GetFrameContainer();
                InputMessageBox inputMessageBox = new InputMessageBox();

                switch (selectedNode.kbEntity)
                {
                case ViewModelFramesHierarchy.KBEntity.FRAME:
                    foreach (var frame in frameContainer.GetAllFrames())
                    {
                        inputMessageBox.comboBox.Items.Add(frame.name);
                    }
                    inputMessageBox.comboBox.Items.Remove(selectedNode.Name);
                    break;

                case ViewModelFramesHierarchy.KBEntity.SLOT_VALUE:
                    foreach (var domain in frameContainer.GetDomains())
                    {
                        if (domain.name == selectedNode.ParentalNode.Name)
                        {
                            foreach (var domainValue in domain.values)
                            {
                                inputMessageBox.comboBox.Items.Add(domainValue);
                            }
                        }
                    }
                    break;

                case ViewModelFramesHierarchy.KBEntity.SLOT_NAME:
                    foreach (var domain in frameContainer.GetDomains())
                    {
                        inputMessageBox.comboBox.Items.Add(domain.name);
                    }
                    break;

                case ViewModelFramesHierarchy.KBEntity.IS_A:
                    foreach (var frame in frameContainer.GetAllFrames())
                    {
                        inputMessageBox.comboBox.Items.Add(frame.name);
                    }
                    inputMessageBox.comboBox.Items.Remove(selectedNode.ParentalNode.Name);
                    break;

                default:
                    break;
                }

                inputMessageBox.Owner = this;

                inputMessageBox.Title          = "Поменять имя";
                inputMessageBox.textBlock.Text = "Изменить имя " + selectedNode.Name + " на:";
                System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
                objBlur.Radius = 5;
                this.Effect    = objBlur;

                if (inputMessageBox.ShowDialog() == true)
                {
                }
                this.Effect = null;

                if (inputMessageBox.NewFrameOrSlotName != null && inputMessageBox.NewFrameOrSlotName != "")
                {
                    selectedNode.ChangeSelectedNodeName = inputMessageBox.NewFrameOrSlotName;
                }
            }
            catch (Exception E)
            {
                MessageBox.Show("Неверныe аргументы");
            }
        }