Пример #1
0
        private void Nv_Drop(object sender, System.Windows.DragEventArgs e)
        {
            TabPage tabPage = schemesTabControl.SelectedTab;

            if (tabPage.Tag == null)
            {
                return;
            }
            network.NetworkView nv = tabPage.Controls.OfType <ElementHost>().First().Child as network.NetworkView;

            // Retrieve the client coordinates of the drop location.
            System.Windows.Point p           = new System.Windows.Point(MousePosition.X, MousePosition.Y);
            System.Windows.Point targetPoint = nv.PointFromScreen(p);

            // Retrieve the node that was dragged.
            if (!e.Data.GetDataPresent(typeof(DataContainer)))
            {
                return;
            }
            DataContainer ontologyClassContainer = (DataContainer)e.Data.GetData(typeof(DataContainer));

            OntologyClass ontologyClass = ontologyClassContainer.Data as OntologyClass;

            //Layout layout;

            Scheme scheme = (Scheme)schemesTabControl.SelectedTab.Tag;

            FactScheme.Argument arg = scheme.AddArgument(ontologyClass);

            network.Node node = nv.AddNode(Medium.Convert(arg), true);
        }
Пример #2
0
        private void addDictionaryArgumentMenuItem_Click(object sender, EventArgs e)
        {
            network.NetworkView nv = getCurrentNetworkView();
            if (nv == null)
            {
                return;
            }
            var theme = menuItemToTheme(sender as ToolStripMenuItem);

            FactScheme.Argument arg = CurrentScheme.AddArgument(theme);

            network.Node node = nv.AddNode(Medium.Convert(arg, CurrentProject.Dictionary), true);
        }
Пример #3
0
        private void addResultMenuItem_Click(object sender, EventArgs e)
        {
            network.NetworkView nv = getCurrentNetworkView();
            if (nv == null)
            {
                return;
            }

            OntologyClass ontologyClass = menuItemToClass(sender as ToolStripMenuItem);
            Scheme        scheme        = (Scheme)schemesTabControl.SelectedTab.Tag;

            FactScheme.Result result = scheme.AddResult(ontologyClass);
            network.Node      node   = nv.AddNode(Medium.Convert(result), true);
        }
Пример #4
0
        private void addFnCatToolStripItem_Click(object sender, EventArgs e)
        {
            var fun = CurrentScheme.AddFunctor <FunctorCat>();

            getCurrentNetworkView().AddNode(Medium.Convert(fun));
        }
Пример #5
0
        private void addSchemeConditionButton_Click(object sender, EventArgs e)
        {
            Condition cond = CurrentScheme.AddCondition();

            getCurrentNetworkView().AddNode(Medium.Convert(cond, CurrentProject.Gramtab, CurrentProject.Segments));
        }
Пример #6
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;
        }