Esempio n. 1
0
        public void RefreshAll()
        {
            if (root == null)
            {
                return;
            }
            var filename = root.Text;

            FileWriter(mapNode, filename);


            LoadTree.id = 1;
            id          = 0;
            root        = new TreeNode();
            root.Name   = id.ToString();
            id++;
            root.Text       = Path.GetFileName(dialog.FileName);
            root.ImageIndex = root.SelectedImageIndex = 3;

            mainTreeView.Nodes.Clear();

            mapNode = null;
            mapNode = new MappingNode(root.Text, 0, true);
            var yaml = FileHandler.LoadFile(mapNode, dialog.FileName);

            LoadTree.CreateTree(mapNode, yaml.Documents[0].RootNode as YamlMappingNode, root);
            mainTreeView.Nodes.Add(root);
            setTreeId(root);
            root.Expand();
        }
Esempio n. 2
0
        /// <summary>
        /// Creats a column object and initializes it to the values defined in this ColumnAttribute.
        /// </summary>
        /// <returns>A new Column object.</returns>
        public new ForeignKeyColumn CreateColum(MappingNode parent)
        {
            ForeignKeyColumn column = new ForeignKeyColumn(parent);

            SetColumnValues(column);
            return(column);
        }
Esempio n. 3
0
        /// <summary>
        /// Creats a column object and initializes it to the values defined in this ColumnAttribute.
        /// </summary>
        /// <returns>A new Column object.</returns>
        public Column CreateColum(MappingNode parent)
        {
            Column column = new Column(parent);

            SetColumnValues(column);
            return(column);
        }
Esempio n. 4
0
            public override MappingNodeHead Dump_2(Caller caller)
            {
                this.logger?.Info($"{caller} DUMP");
                lock (this.mappings)
                {
                    var mappingNodeNullable = new MappingNodeHead();

                    MappingNode currentNode = null;
                    foreach (Internal.Mapping mapping in this.mappings)
                    {
                        if (mappingNodeNullable.MappingNode == null)
                        {
                            mappingNodeNullable.MappingNode = new MappingNode {
                                Mapping = mapping
                            };
                            currentNode = mappingNodeNullable.MappingNode;
                        }
                        else if (currentNode != null)
                        {
                            var mappingNode = new MappingNode {
                                Mapping = mapping
                            };

                            currentNode.Next = mappingNode;
                            currentNode      = mappingNode;
                        }
                    }

                    return(mappingNodeNullable);
                }
            }
Esempio n. 5
0
        public static void LoadTreeNode(TreeNode treeNode, MappingNode rootNode)
        {
            var children = rootNode?.Children;

            if (children == null)
            {
                return;
            }

            foreach (var child in children)
            {
                if (child is ScalarNode)
                {
                    ScalarNode scalarChild = (ScalarNode)child;
                    var        node        = treeNode.Nodes.Add($"{scalarChild.Key}: {scalarChild.Value}");
                    node.ImageIndex = scalarChild.ImageIndex;

                    node.Tag = child.Tag;
                }
                else if (child is SequenceNode)
                {
                    var node = treeNode.Nodes.Add(child.Value);
                    node.Tag        = child.Tag;
                    node.ImageIndex = child.ImageIndex;
                    LoadTreeNode(node, child as SequenceNode);
                }
                else if (child is MappingNode)
                {
                    var node = treeNode.Nodes.Add(child.Value);
                    node.Tag        = child.Tag;
                    node.ImageIndex = child.ImageIndex;
                    LoadTreeNode(node, child as MappingNode);
                }
            }
        }
Esempio n. 6
0
        public void tableData()
        {
            MappingNode  map = new MappingNode();
            SequenceNode sec = new SequenceNode();

            ComponentName = textBox1.Text;

            //INode nodeFound = editor.mapNode.searchNodeByName(ComponentName);
            INode nodeFound = editor.nodeSelected;

            if (nodeFound != null)
            {
                if (nodeFound == editor.mapNode)
                {
                    map = new MappingNode(ComponentName, LoadTree.id++);
                    getPropertiesFromWizard(map, dataGridView1);
                    editor.mapNode.AddChild(map);
                }
                else if (nodeFound.Value != ComponentName)
                {
                    map = new MappingNode(ComponentName, null, 4, LoadTree.id++, editor.nodeSelected);
                    getPropertiesFromWizard(map, dataGridView1);
                    editor.nodeSelected.AddChild(map);
                }
                else if (nodeFound is MappingNode)
                {
                    if (ComponentName == nodeFound.Value && nodeFound.getParent() is SequenceNode)
                    {
                        MessageBox.Show("Can not add a new component with this name to this component", "Invalid operation",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    map = (MappingNode)nodeFound;
                    MappingNode tempMap = map.DeepClone();
                    map.RemoveNode(map);

                    sec = new SequenceNode(tempMap.Value, tempMap.Tag, 3, LoadTree.id++, tempMap.parent);

                    MappingNode mapAntigo = tempMap;
                    mapAntigo.id = LoadTree.id++;
                    sec.AddChild(mapAntigo);

                    MappingNode newMap = new MappingNode(ComponentName, null, 4, LoadTree.id++, sec);
                    sec.AddChild(newMap);

                    getPropertiesFromWizard(newMap, dataGridView1);
                    editor.nodeSelected.getParent().AddChild(sec);
                }
                else if (nodeFound is SequenceNode)
                {
                    map = new MappingNode(ComponentName, null, 4, LoadTree.id++, editor.nodeSelected);
                    editor.nodeSelected.AddChild(map);
                    getPropertiesFromWizard(map, dataGridView1);
                }
            }


            //editor.mapNode.SearchNode(mapping);
        }
Esempio n. 7
0
 public RemoveCommand(ref MappingNode maxRoot, INode itemNode, ref TreeNode root, TreeNode nodeToRemove, YAMLEditorForm a)
 {
     this.maxRoot      = maxRoot;
     this.nodeToRemove = nodeToRemove;
     this.itemNode     = itemNode;
     this.root         = root;
     this.editor       = a;
 }
Esempio n. 8
0
        public static void LoadChildren(MappingNode root, YamlMappingNode mapping)
        {
            var children = mapping?.Children;

            if (children == null)
            {
                return;
            }

            foreach (var child in children)
            {
                var key = child.Key as YamlScalarNode;
                System.Diagnostics.Trace.Assert(key != null);

                if (child.Value is YamlScalarNode)
                {
                    var scalar = child.Value as YamlScalarNode;

                    if (scalar.Tag == "!include")
                    {
                        MappingNode scalarToMapping = (MappingNode)root.AddChild(new MappingNode(scalar.Value, scalar.Tag, ImageLoad.GetImageIndex(scalar), id, root));
                        id++;

                        var yaml = FileHandler.LoadFile(scalarToMapping as MappingNode, scalar.Value);
                        if (yaml.Documents.Count == 0)
                        {
                            continue;
                        }

                        //scalarToMapping.AddChild(newRoot);
                        LoadChildren(scalarToMapping, yaml.Documents[0].RootNode as YamlMappingNode);
                        continue;
                    }

                    ScalarNode scalarToSave = new ScalarNode(scalar.Value, child, scalar.Tag, ImageLoad.GetImageIndex(scalar), id, root, key.Value);
                    id++;
                    if (scalar.Tag == "!secret")
                    {
                        scalarToSave.Property   = scalar.Tag;
                        scalarToSave.ImageIndex = 2;
                    }
                    var node = root.AddChild(scalarToSave);
                }
                else if (child.Value is YamlSequenceNode)
                {
                    var node = root.AddChild(new SequenceNode(key.Value, child.Value, ImageLoad.GetImageIndex(child.Value), id, root));
                    id++;

                    LoadChildren(node as SequenceNode, child.Value as YamlSequenceNode);
                }
                else if (child.Value is YamlMappingNode)
                {
                    var node = root.AddChild(new MappingNode(key.Value, child.Value, ImageLoad.GetImageIndex(child.Value), id, root));
                    id++;
                    LoadChildren(node as MappingNode, child.Value as YamlMappingNode);
                }
            }
        }
Esempio n. 9
0
        public Dictionary <object, object> FindMappingNode(string objId)
        {
            if (MappingNode == null || MappingNode.Count <= 0 || !MappingNode.ContainsKey(objId))
            {
                return(null);
            }

            return((Dictionary <object, object>)MappingNode[objId]);
        }
Esempio n. 10
0
        private INode searchForNode(INode root, int idNodeToEdit)
        {
            bool found = false;

            if (root is MappingNode)
            {
                MappingNode raiz = (MappingNode)root;

                if (raiz.Children == null)
                {
                    return(null);
                }
                if (raiz.id == idNodeToEdit)
                {
                    nodeSelected = raiz;
                }

                foreach (INode child in raiz.Children)
                {
                    if (child.getID() == idNodeToEdit)
                    {
                        nodeSelected = child;
                    }
                    else if (child is MappingNode || child is SequenceNode)
                    {
                        searchForNode(child, idNodeToEdit);
                    }
                    continue;
                }
            }

            if (root is SequenceNode)
            {
                SequenceNode raiz = (SequenceNode)root;
                if (raiz.Children == null)
                {
                    return(null);
                }
                foreach (INode child in raiz.Children)
                {
                    if (child.getID() == idNodeToEdit)
                    {
                        nodeSelected = child;
                    }
                    else if (child is MappingNode || child is SequenceNode)
                    {
                        searchForNode(child, idNodeToEdit);
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            return(nodeSelected);
        }
Esempio n. 11
0
 public ValueCommand(MappingNode maxRoot, TreeNode nodeToEdit, ScalarNode itemNode, string key, YAMLEditorForm editor, string value = null)
 {
     this.itemNode   = itemNode;
     this.key        = key;
     this.value      = value;
     this.maxRoot    = maxRoot;
     this.nodeToEdit = nodeToEdit;
     this.editor     = editor;
 }
Esempio n. 12
0
        private void doit()
        {
            MappingNode temp         = editor.mapNode.DeepClone();
            TreeNode    tempTreeNode = (TreeNode)editor.root.Clone();

            editor.mapNode = previousMaxRoot;
            editor.root    = previousTreeNode;

            previousMaxRoot  = temp;
            previousTreeNode = tempTreeNode;
        }
Esempio n. 13
0
        void AddProperty(object sender, EventArgs args)
        {
            AddPropertyDialog dlg = new AddPropertyDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                MappingNode mappingNode = (MappingNode)this.o;
                Property    prop        = new Property(mappingNode, dlg.PropName, dlg.Type, dlg.Value);
                mappingNode.AddProperty(prop);
                this.Nodes.Add(new PropertyNode(this, prop));
            }
        }
Esempio n. 14
0
        public void doit()
        {
            TreeNode    tempTreeNode = (TreeNode)editor.root.Clone();
            MappingNode tempMaxRoot  = maxRoot.DeepClone();


            editor.root    = previousTreeNode;
            editor.mapNode = previousMaxRoot;

            previousMaxRoot  = tempMaxRoot;
            previousTreeNode = tempTreeNode;
        }
        private void CreateFaultDistanceRow(double lineLength, MappingNode local, MappingNode remote)
        {
            FaultLocationData.DoubleEndedFaultDistanceRow row;

            row = m_doubleEndedFaultDistanceTable.NewDoubleEndedFaultDistanceRow();
            row.LocalFaultSummaryID  = local.Fault.ID;
            row.RemoteFaultSummaryID = remote.Fault.ID;
            row.Distance             = local.DistanceCurve[local.Fault.CalculationCycle].Value;
            row.Angle   = local.AngleCurve[local.Fault.CalculationCycle].Value;
            row.IsValid = IsValid(row.Distance, lineLength) ? 1 : 0;

            m_doubleEndedFaultDistanceTable.AddDoubleEndedFaultDistanceRow(row);
        }
Esempio n. 16
0
        public IReadOnlyList <Mapping> Dump()
        {
            var list = new List <Mapping>();

            MappingNode node = this.client.Dump_2().MappingNode;

            while (node != null)
            {
                list.Add(Convert(node.Mapping));
                node = node.Next;
            }

            return(list);
        }
Esempio n. 17
0
        /// <summary>
        /// Gets the elements from wizard, crates the new nodes and add to map node
        /// </summary>
        /// <param name="map"></param>
        /// <param name="dataGridView1"></param>
        public void getPropertiesFromWizard(MappingNode map, DataGridView dataGridView1)
        {
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                string key   = row.Cells[0].EditedFormattedValue.ToString();
                string value = row.Cells[1].EditedFormattedValue.ToString();
                if (key == "" && value == "")
                {
                    continue;
                }

                ScalarNode scalar = new ScalarNode(value, null, null, 0, LoadTree.id++, map, key);
                map.AddChild(scalar);
            }
        }
Esempio n. 18
0
        public void Execute()
        {
            TreeNode    tempTreeNode = (TreeNode)editor.root.Clone();
            int         i            = 0;
            MappingNode tempMaxRoot  = maxRoot.DeepClone();

            RemoveTreeNode(nodeToRemove);
            itemNode.RemoveNode(itemNode);

            TreeNode teste   = (TreeNode)editor.root.Clone();
            TreeNode temTest = editor.searchTreeEdit(teste, itemNode.getID());

            previousMaxRoot  = tempMaxRoot;
            previousTreeNode = tempTreeNode;
        }
Esempio n. 19
0
        void ChangeProperty(object sender, EventArgs args)
        {
            AddPropertyDialog dlg = new AddPropertyDialog();

            dlg.PropName     = Property.Name;
            dlg.Type         = Property.Type;
            dlg.Value        = Property.Value;
            dlg.EditProperty = true;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Property.Type  = dlg.Type;
                Property.Value = dlg.Value;
                MappingNode mn = (MappingNode)parent.Object;
                mn.AddProperty(Property);
            }
            this.TreeView.Refresh();
        }
Esempio n. 20
0
        public static void FileWriter2(MappingNode n, string filename) //para auto-save
        {
            n.IsRoot = true;

            YamlMappingNode rootNode = new YamlMappingNode();

            CreateNodeVisitor visitor = new CreateNodeVisitor();

            //SaveTree.saveChildrenMapping(n, rootNode);
            n.Accept(visitor, rootNode);

            YamlDocument doc  = new YamlDocument(rootNode);
            var          yaml = new YamlStream(doc);

            using (TextWriter writer = File.CreateText(@"..\\Config_Files\\bin\\" + filename))
                yaml.Save(writer, false);
        }
Esempio n. 21
0
 private void setExpanded(MappingNode node, bool expand, bool isTarget)
 {
     //don't do anything if null
     if (node == null)
     {
         return;
     }
     //set expanded property
     if (!node.showAll && isTarget)
     {
         node.setChildNodes();
     }
     node.showAll = expand;
     //do the same for the childnodes
     foreach (MappingNode subNode in node.childNodes)
     {
         setExpanded(subNode, expand, isTarget);
     }
 }
Esempio n. 22
0
        void Initialize(MappingNode mappingNode, IEnumerable <OidColumn> oidColumns, IEnumerable <ForeignKeyColumn> fkColumns, KeyValuePair <string, int>?typeCodeInfo)
        {
            IEnumerator <OidColumn> oidEnumerator = oidColumns.GetEnumerator();

            oidEnumerator.MoveNext();
            List <OqlExpression> compareExpressions = new List <OqlExpression>();

            foreach (ForeignKeyColumn fkColumn in fkColumns)
            {
                OidColumn oidColumn = oidEnumerator.Current;
                compareExpressions.Add(new OnCompareExpression(mappingNode, oidColumn, fkColumn));
                oidEnumerator.MoveNext();
            }

            if (typeCodeInfo.HasValue)
            {
                compareExpressions.Add(new OnCompareExpression(mappingNode, typeCodeInfo.Value.Key, typeCodeInfo.Value.Value));
            }

            if (compareExpressions.Count == 1)
            {
                Add(compareExpressions[0]);
            }
            else
            {
                OqlExpression andExpression = new OqlExpression(0, 0);
                int           i             = 0;
                foreach (var compareExpression in compareExpressions)
                {
                    if (i++ == 0)
                    {
                        andExpression.Add(compareExpression);
                    }
                    else
                    {
                        andExpression.Add(compareExpression, "AND");
                    }
                }

                Add(andExpression);
            }
        }
        private void ExtractDistanceVectors(MappingNode local, ComplexNumber[] curve)
        {
            List <DataPoint> vaRMS = local.CycleDataGroup.VA.RMS.DataPoints;
            int count = Math.Min(vaRMS.Count, curve.Length);

            for (int i = 0; i < count; i++)
            {
                local.DistanceCurve.Series.DataPoints.Add(new DataPoint()
                {
                    Time  = vaRMS[i].Time,
                    Value = curve[i].Magnitude
                });

                local.AngleCurve.Series.DataPoints.Add(new DataPoint()
                {
                    Time  = vaRMS[i].Time,
                    Value = curve[i].Angle
                });
            }
        }
Esempio n. 24
0
        public static string Get(Column column)
        {
            Class       cls  = null;
            MappingNode node = column.Parent;

            while (!(node is Class))
            {
                if (node.NodeParent == null)
                {
                    break;
                }
                node = node.NodeParent;
            }
            cls = (Class)node;
            IProvider     provider = cls.Provider;
            StringBuilder sb       = new StringBuilder(cls.GetQualifiedTableName());

            sb.Append('.');
            sb.Append(provider.GetQuotedName(column.Name));
            return(sb.ToString());
        }
Esempio n. 25
0
        public void setNewTreeRoot(TreeNode root, MappingNode mapingNode)
        {
            mainTreeView.Nodes.Clear();
            if (root == null)
            {
                return;
            }
            var filename = root.Text;

            FileWriter(mapNode, filename);

            root = (mainTreeView.Nodes.Add(Path.GetFileName(dialog.FileName)));

            root.ImageIndex = root.SelectedImageIndex = 3;
            this.id         = 0;
            root.Name       = id.ToString();
            id++;
            LoadTree.LoadTreeNode(root, mapingNode);
            setTreeId(root);
            root.Expand();
        }
Esempio n. 26
0
        public YamlMappingNode Visit(MappingNode node, YamlNode currentRootNode)
        {
            if (node.IsRoot)
            {
                return new YamlMappingNode()
                       {
                           Tag = "ignore"
                       }
            }
            ;

            if (currentRootNode is YamlMappingNode)
            {
                YamlMappingNode rootNode = (YamlMappingNode)currentRootNode; //downcast

                if (node.Tag != null && node.Tag.ToString() == "!include" && node.Children != null)
                {
                    YAMLEditorForm.FileWriter(node as MappingNode, node.Value);
                    rootNode.Add(node.Value, new YamlScalarNode(node.Value)
                    {
                        Tag = "!include"
                    });
                    return(null);
                }
                else
                {
                    YamlMappingNode child = new YamlMappingNode();
                    rootNode.Add(node.Value, child);
                    return(child);
                }
                // YamlMappingNode rootNode = (YamlMappingNode)currentRootNode; //downcast
            }
            else
            {
                YamlSequenceNode rootNode = (YamlSequenceNode)currentRootNode;
                YamlMappingNode  child    = new YamlMappingNode();
                rootNode.Add(child);
                return(child);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Generate compares for type codes
        /// </summary>
        /// <param name="mappingNode"></param>
        /// <param name="columnName"></param>
        /// <param name="value"></param>
        public OnCompareExpression(MappingNode mappingNode, string columnName, int value)
            : base(null, 0, 0)
        {
            Class fkParentClass = mappingNode as Class;

            if (fkParentClass != null)
            {
                Add(new RawIdentifierExpression(QualifiedColumnName.Get(fkParentClass, columnName), 0, 0));
                Add(new NumberExpression(value, 0, 0), "=");
                return;
            }
            MappingTable mappingTable = mappingNode as MappingTable;

            if (mappingTable != null)
            {
                Add(new RawIdentifierExpression(QualifiedColumnName.Get(mappingTable, columnName), 0, 0));
                Add(new NumberExpression(value, 0, 0), "=");
                return;
            }
            else
            {
                throw new ArgumentException("OnCompareExpression: Unexpected mapping node type", "mappingNode");
            }
        }
Esempio n. 28
0
        public OnCompareExpression(MappingNode mappingNode, OidColumn oidColumn, ForeignKeyColumn fkColumn)
            : base(null, 0, 0)
        {
            Class fkParentClass = mappingNode as Class;

            if (fkParentClass != null)
            {
                Add(new RawIdentifierExpression(QualifiedColumnName.Get(oidColumn), 0, 0));
                Add(new RawIdentifierExpression(QualifiedColumnName.Get(fkParentClass, fkColumn), 0, 0), "=");
                return;
            }
            MappingTable mappingTable = mappingNode as MappingTable;

            if (mappingTable != null)
            {
                Add(new RawIdentifierExpression(QualifiedColumnName.Get(oidColumn), 0, 0));
                Add(new RawIdentifierExpression(QualifiedColumnName.Get(mappingTable, fkColumn), 0, 0), "=");
                return;
            }
            else
            {
                throw new ArgumentException("OnCompareExpression: Unexpected mapping node type", "mappingNode");
            }
        }
 public Mapping(FaultLocationData.FaultSummaryRow left, FaultLocationData.FaultSummaryRow right)
 {
     Left  = new MappingNode(left);
     Right = new MappingNode(right);
 }
        private void ExecuteFaultLocationAlgorithm(double lineLength, ComplexNumber nominalImpedance, MappingNode local, MappingNode remote)
        {
            FaultLocationDataSet faultLocationDataSet;
            CycleData            remoteCycle;

            ComplexNumber[] curve;

            faultLocationDataSet              = new FaultLocationDataSet();
            faultLocationDataSet.FaultType    = local.FaultType;
            faultLocationDataSet.LineDistance = lineLength;
            faultLocationDataSet.Z1           = nominalImpedance;
            local.CycleDataGroup.PushDataTo(faultLocationDataSet.Cycles);

            remoteCycle = GetCycleAt(remote.CycleDataGroup, remote.Fault.CalculationCycle - remote.StartSample);

            curve = FaultLocationAlgorithms.DoubleEnded(faultLocationDataSet, remoteCycle, string.Empty);
            ExtractDistanceVectors(local, curve);
        }