コード例 #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 addArgumentMenuItem_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.Argument arg = scheme.AddArgument(ontologyClass);

            network.Node node = nv.AddNode(Medium.Convert(arg), true);
        }
コード例 #4
0
ファイル: Medium.cs プロジェクト: KostblLb/FatonSchemeEditor
        ///convert factscheme argument into nv node
        ///
        public static NodeInfo Convert(FactScheme.Argument argument, Vocabularies.Vocabulary vocabulary = null)
        {
            NodeInfo info = new NodeInfo();

            info.Tag = argument;

            info.NodeNameProperty     = string.Format("arg{0} {1}", argument.Order, argument.Name);
            argument.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Order")
                {
                    info.NodeNameProperty = string.Format("arg{0} {1}", argument.Order, argument.Name);
                }
                //if (e.PropertyName == "")
            };

            if (argument.ArgType == ArgumentType.IOBJECT)
            {
                foreach (var attr in argument.Attributes)
                {
                    NodeInfo.SectionInfo attrInfo = new NodeInfo.SectionInfo();
                    attrInfo.Data     = attr;
                    attrInfo.IsInput  = false;
                    attrInfo.IsOutput = true;
                    var attrName = new Label();
                    attrName.Content = attr.Name;
                    attrName.ToolTip = (attr.AttrType == OntologyNode.Attribute.AttributeType.DOMAIN || attr.AttrType == OntologyNode.Attribute.AttributeType.OBJECT) ? attr.Opt : attr.AttrType;

                    attrInfo.UIPanel = attrName;
                    info.Sections.Add(attrInfo);
                }

                info.FillColor = System.Windows.Media.Colors.LightSkyBlue;
            }
            else
            {
                for (int i = 0; i < 2; i++) // $Class and $Value are 2 mandatory attributes
                {
                    var attr = argument.Attributes[i];
                    NodeInfo.SectionInfo attrInfo = new NodeInfo.SectionInfo();
                    attrInfo.Data     = attr;
                    attrInfo.IsInput  = false;
                    attrInfo.IsOutput = true;
                    var attrName = new Label();
                    attrName.Content = attr.Name;
                    attrName.ToolTip = (attr.AttrType == OntologyNode.Attribute.AttributeType.DOMAIN || attr.AttrType == OntologyNode.Attribute.AttributeType.OBJECT) ? attr.Opt : attr.AttrType;

                    attrInfo.UIPanel = attrName;
                    info.Sections.Add(attrInfo);
                }
                var plusInfo = new NodeInfo.SectionInfo();
                var plusBtn  = new Button();
                plusBtn.Content = "+";
                plusBtn.Click  += (s, e) =>
                {
                    var newAttr = new OntologyNode.Attribute(OntologyNode.Attribute.AttributeType.STRING, vocabulary.First().Name, true);
                    argument.Attributes.Add(newAttr);
                    info.Sections.Add(TerminVarAttrInfo(argument, newAttr, vocabulary, info));
                };
                plusInfo.UIPanel = plusBtn;
                info.Sections.Add(plusInfo);
                for (int i = 2; i < argument.Attributes.Count; i++)
                {
                    info.Sections.Add(TerminVarAttrInfo(argument, argument.Attributes[i], vocabulary, info));
                }
                info.FillColor = System.Windows.Media.Colors.DeepSkyBlue;
            }

            return(info);
        }