예제 #1
0
        public void AddDoubleEdge(tNode aNode1, tNode aNode2)
        {
            IEdge savedG = AddEdge(aNode1, aNode2);

            savedG.EdgeAttr.Linewidth = 3;
            savedG.EdgeAttr.Color     = Color.Gray;
        }
예제 #2
0
        public void AddTribbleEdge(tNode aNode1, tNode aNode2)
        {
            IEdge savedG = AddEdge(aNode1, aNode2);

            savedG.EdgeAttr.Linewidth = 6;
            savedG.EdgeAttr.Color     = Color.Blue;
            g.FindNode(savedG.Source).NodeAttribute.Color = Color.Blue;
            g.FindNode(savedG.Target).NodeAttribute.Color = Color.Blue;
        }
예제 #3
0
        private static bool ProcessNodeLine(ref string mLinia, ref int NrL, ref bool KONIEC)
        {
            tNode mNode = default(tNode);
            int   tmpNR = 0;

            if (mLinia.IndexOf("-1") == 1)
            {
                try {
                    NodeLineCounter += 1;
                    tmpNR            = Convert.ToInt32(mLinia.Substring(3, 10), NFI);
                    mNode.X          = Convert.ToDouble(mLinia.Substring(13, 12), NFI);
                    mNode.Y          = Convert.ToDouble(mLinia.Substring(25, 12), NFI);
                    mNode.Z          = Convert.ToDouble(mLinia.Substring(37, 12), NFI);
                    mNode.IsFirst    = true;
                    NodeTab.Add(tmpNR, mNode);
                } catch {
                    Console.WriteLine(ERTXT0011, NrL);
                    return(false);
                }
            }
            else if (mLinia.IndexOf("-3") == 1)
            {
                //end of reading
                if (NodeTab.Count == NodeLineCounter)
                {
                    //read number is correct
                    KONIEC = true;
                    Console.WriteLine(TXT0004, NodeLineCounter);
                }
                else
                {
                    //the numbers differs
                    Console.WriteLine(ERTXT0012, NodeLineCounter, NodeTab.Count);
                    return(false);
                }
            }
            else
            {
                Console.WriteLine(ERTXT0013, NrL);
                return(false);
            }

            return(true);
        }
예제 #4
0
        public void ProcessRequest(HttpContext context)
        {
            string nod  = context.Request.Params["node"]; // IPA@123 RUBR@123 IPA@123[1]  RUBR@435653[3]
            tNode  node = new tNode(nod);

            if (node.nodeId == -1 || node.nodeId == 0)
            {
                return;
            }
            string nodeRaw = context.Request.Form["node"];

            if (context.Application[TREE_KEY] == null)
            {
                InitializeTreeStore(node.nodeId.ToString());
            }

            List <SimpleTreeItem> xDoc = (List <SimpleTreeItem>)context.Application[TREE_KEY];

            if (xDoc == null || xDoc.Count == 0)
            {
                throw new InvalidOperationException("Errore nel recupero dell'ente");
            }

            if (xDoc.SingleOrDefault(e => e.Value.Equals(node.nodeId.ToString())) == null)
            {
                InitializeTreeStore(node.nodeId.ToString());
                xDoc = (List <SimpleTreeItem>)context.Application[TREE_KEY];
            }

            IEnumerable <HierarchyNode <SimpleTreeItem> > hl = null;
            IEnumerable <SimpleTreeItem> ll = null;
            Func <List <SimpleTreeItem>, SimpleTreeItem> getRoot = l => l.FirstOrDefault(x => !l.Select(y => y.Value).Contains(x.Padre));

            try
            {
                //provo prima a prendere gli item dalla memoria
                if (node.nodeId > -1)
                {
                    ll = xDoc.Where(e => e.Padre.Equals(node.nodeId.ToString()));
                }
                else
                {
                    ll = xDoc.Where(e => String.IsNullOrEmpty(e.Padre));
                }

                if (node.virtualNode)
                {
                    ll = ll.Skip((node.virtualPager - 1) * PACK_SIZE).Take(PACK_SIZE);
                }

                JSONTreeNode[] nodes = null;
                //se non trova figli prova a caricarli dalla banca dati
                if (ll.Count() == 0)
                {
                    if (nodeRaw == ROOT_NODE)
                    {
                        hl    = xDoc.AsHierarchy(e => e.Value, e => e.Padre, e => e.Text, getRoot(xDoc).Value);
                        nodes = ConvertToJSON(hl);
                    }
                    else
                    {
                        RubricaEntitaService  rubrentitaService = new RubricaEntitaService();
                        List <SimpleTreeItem> tree = (List <SimpleTreeItem>)rubrentitaService.GetRubricaEntitaTreeByIdPadre(node.nodeId);
                        if (tree != null && tree.Count > 0)
                        {
                            AppendChildren(tree);
                        }
                        xDoc  = (List <SimpleTreeItem>)context.Application[TREE_KEY];
                        hl    = xDoc.AsHierarchy(e => e.Value, e => e.Padre, e => e.Text, node.nodeId.ToString());
                        nodes = ConvertToJSON(hl.ElementAt(0).ChildNodes);
                    }
                }
                else
                {
                    if (node.nodeId > -1)
                    {
                        ll = ll.Union(xDoc.Where(x => x.Value.Equals(node.nodeId.ToString())));
                        hl = ll.AsHierarchy(e => e.Value, e => e.Padre, e => e.Text, node.nodeId.ToString()).ToList();
                        if (nodeRaw == ROOT_NODE)
                        {
                            nodes = ConvertToJSON(hl);
                        }
                        else
                        {
                            nodes = ConvertToJSON(hl.ElementAt(0).ChildNodes);
                        }
                    }
                    else
                    {
                        nodes = ConvertToJSON(ll);
                    }
                }

                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(JSONTreeNode[]));
                System.IO.MemoryStream     ms  = new System.IO.MemoryStream();
                ser.WriteObject(ms, nodes);
                string json = Encoding.UTF8.GetString(ms.ToArray());
                ms.Close();

                context.Response.ContentType = "application/json";
                context.Response.AppendHeader("Content-type", "text/json");
                context.Response.Write(json);
            }
            catch (Exception e)
            {
                throw new Exception("Retry Please!!");
            }
        }
예제 #5
0
        public void AddPunktirEdge(tNode aNode1, tNode aNode2)
        {
            IEdge savedG = AddEdge(aNode1, aNode2);

            savedG.EdgeAttr.Color = Color.Brown;
        }
예제 #6
0
 public void AddSimpleEdge(tNode aNode1, tNode aNode2)
 {
     IEdge savedG = AddEdge(aNode1, aNode2);
 }
예제 #7
0
 public IEdge AddEdge(tNode aNode1, tNode aNode2)
 {
     return(AddEdge(aNode1.Name, aNode1.Text, aNode2.Name, aNode2.Text));
 }
예제 #8
0
        private tEdge addEdge(DerivationContext aContext, IPhrase aPhr, IPhrase aParent)
        {
            tGraph graph    = (aContext as BuildGraphContext).BuildingGraph;
            string fromName = "unk";
            string toName   = "unk";

            // determine fromName
            if (aParent == null)
            {
                fromName = aContext.Grammar.MainSymbol.CounterName;
                graph.ensureExistsNode(fromName, aContext.Grammar.MainSymbol.Text);
            }
            else
            {
                NonTerminal parentNt = aParent as NonTerminal;
                if (parentNt != null)
                {
                    fromName = parentNt.CounterName;
                    graph.ensureExistsNode(parentNt.CounterName, parentNt.Text);
                }
                else
                {
                    fromName = (aContext as BuildGraphContext).GeneratedToName;
                    Debug.Assert(!string.IsNullOrEmpty(fromName), "Не должно быть");
                }
            }
            // determine toName
            NonTerminal nonTerminal = aPhr as NonTerminal;
            Terminal    terminal    = aPhr as Terminal;

            if (nonTerminal != null)
            {
                toName = nonTerminal.CounterName;
                string text = nonTerminal.Text;
                if ((nonTerminal.CycicKind & CycicKind.SkippedAsSeen) > 0)
                {
                    text += " *";
                }
                graph.ensureExistsNode(toName, text);
            }
            else if (terminal != null)
            {
                string text = string.IsNullOrEmpty(terminal.Text) ? "e" : terminal.Text;
                tNode  n    = graph.addNonUniqueNode(text);
                toName             = n.Name;
                n.CustomAttributes = "term";
            }
            else
            {
                toName = graph.addNonUniqueNode(aPhr.ToString()).Name;
                //надо запомнить это в контексте
                (aContext as BuildGraphContext).GeneratedToName = toName;
            }
            tEdge e = graph.addEdge(fromName, toName);

            if (e == null)
            {
                Debug.WriteLine("не создалась дуга, потому что нет вершин");
            }
            return(e);
        }