Beispiel #1
0
        private async void buttonApply_Click(object sender, EventArgs e)
        {
            if (neuralTree.SelectedNode != null)
            {
                var node = (NeuralLinkModel)neuralTree.SelectedNode.Tag;
                neuralTree.SelectedNode.Text = node.Name = tbName.Text;
                node.Title         = tbTitle.Text;
                node.QuestionTitle = tbQuestionTitle.Text;
                node.Description   = tbDescription.Text;
                bool showNeuralExpEditor = false;
                var  type    = (string)cbxExpressionTypes.SelectedItem;
                var  curType = node.NeuralExp?.GetType().Name ?? ExpressionNone;
                if (curType != type && supportedTypes.ContainsKey(type))
                {
                    if (type == ExpressionNone)
                    {
                        node.NeuralExp = null;
                    }
                    else
                    {
                        node.NeuralExp      = type == null ? null : (INeuralExpression)Activator.CreateInstance(supportedTypes[type]);
                        showNeuralExpEditor = true;
                    }
                }

                await DbLinkCollection.ReplaceOneById(node._id, node);

                if (showNeuralExpEditor)
                {
                    await ShowNeuralExpressionEditor();
                }

                ReloadTree();
            }
        }
Beispiel #2
0
        private async Task ShowNeuralExpressionEditor()
        {
            var type = (string)cbxExpressionTypes.SelectedItem;
            var node = (NeuralLinkModel)neuralTree.SelectedNode.Tag;

            if (neuralTree.SelectedNode != null && type != ExpressionNone && supportedTypes.ContainsKey(type) && node.NeuralExp?.GetType() == supportedTypes[type])
            {
                if (supportedTypes[type] == typeof(LinkExpression))
                {
                    var exp    = node.NeuralExp as LinkExpression;
                    var picker = new LinkExpressionEditor(exp);
                    var res    = picker.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        await DbLinkCollection.ReplaceOneById(node._id, node);
                    }
                }
                else if (supportedTypes[type] == typeof(DecisionExpression))
                {
                    var exp    = node.NeuralExp as DecisionExpression;
                    var picker = new DecisionExpressionEditor(exp);
                    var res    = picker.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        await DbLinkCollection.ReplaceOneById(node._id, node);
                    }
                }
            }
        }
Beispiel #3
0
        private async void lnkLabels_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (neuralTree.SelectedNode != null)
            {
                var node   = (NeuralLinkModel)neuralTree.SelectedNode.Tag;
                var editor = new ListEditor("Neural node labels editor", node.Labels);
                var res    = editor.ShowDialog();
                if (res == DialogResult.OK)
                {
                    node.Labels = editor.Result;
                    await DbLinkCollection.ReplaceOneById(node._id, node);

                    ReloadTree();
                }
            }
        }