Exemple #1
0
        private void openProjectDialog_FileOk(object sender, CancelEventArgs e)
        {
            Stream fstream = openProjectDialog.OpenFile();
            var    path    = System.IO.Path.GetDirectoryName(openProjectDialog.FileName) +
                             System.IO.Path.DirectorySeparatorChar;

            CurrentProject = new EditorProject(fstream, path);
            fstream.Close();

            buildOntologyTree(CurrentProject.Ontology);
            buildDictionaryTree(CurrentProject.Dictionary);

            XElement xmarkup = CurrentProject.Markup;

            if (xmarkup != null)
            {
                foreach (var xscheme in xmarkup.Elements())
                {
                    var                 scheme = CurrentProject.Bank.Schemes.First(x => x.Name == xscheme.Attribute("name").Value);
                    ElementHost         host   = initNVHost(scheme);
                    network.NetworkView nv     = host.Child as network.NetworkView;
                    foreach (XElement xel in xscheme.Elements())
                    {
                        network.Node             node   = null;
                        System.Windows.Thickness margin = new System.Windows.Thickness();
                        if (xel.Attribute("type").Value == typeof(Argument).ToString())
                        {
                            Argument arg = scheme.Arguments.First(x => x.Order == int.Parse(xel.Attribute("id").Value));
                            node = nv.AddNode(Medium.Convert(arg, CurrentProject.Dictionary));
                        }
                        else if (xel.Attribute("type").Value == typeof(Result).ToString())
                        {
                            Result res = scheme.Results.First(x => x.Name == xel.Attribute("id").Value);
                            node = nv.AddNode(Medium.Convert(res));
                        }
                        else if (xel.Attribute("type").Value == typeof(Functor).ToString())
                        {
                            Functor f = scheme.Functors.First(x => x.CID == uint.Parse(xel.Attribute("id").Value));
                            node = nv.AddNode(Medium.Convert(f));
                        }
                        else if (xel.Attribute("type").Value == typeof(Condition).ToString())
                        {
                            Condition cond = scheme.Conditions.Find(x => x.ID == uint.Parse(xel.Attribute("id").Value));
                            node = nv.AddNode(Medium.Convert(cond, CurrentProject.Gramtab, CurrentProject.Segments));
                        }
                        else
                        {
                            continue;
                        }
                        int left = int.Parse(xel.Attribute("left").Value);
                        int top  = int.Parse(xel.Attribute("top").Value);
                        margin.Left = left;
                        margin.Top  = top;
                        node.Margin = margin;
                    }
                    Medium.LoadViewFromScheme(nv, scheme);
                }
            }
            if (!CurrentProject.Bank.Schemes.Any())
            {
                createScheme();
            }
            //updateBankListView();

            CurrentScheme = CurrentProject.Bank.Schemes[0];
            bankListDataGrid.DataSource   = CurrentProject.Bank.Schemes;
            schemeSegmentCombo.DataSource = CurrentProject.Segments;

            statusLabel.Text = Locale.STATUS_PROJECT_LOADED;
        }
Exemple #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     CurrentProject = new EditorProject();
 }
Exemple #3
0
 private void newProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     dictionaryTreeView.Nodes.Clear();
     ontologyTreeView.Nodes.Clear();
     CurrentProject = new EditorProject();
 }