protected BaseDemo()
        {
            DesignCommand = new DelegateCommand(
                execute: y =>
            {
                var definition        = ReadLabelDefinition(DefinitionFileName);
                var updatedDefinition = ListLabelManager.Design(definition, Data, ParentEntity);
                WriteLabelDefinition(DefinitionFileName, updatedDefinition);
            },
                canExecute: x => true);

            PrintCommand = new DelegateCommand(
                execute: y =>
            {
                var definition = ReadLabelDefinition(DefinitionFileName);
                ListLabelManager.Print(definition, Data, ParentEntity);
            },
                canExecute: x => true);

            ExportCommand = new DelegateCommand(
                execute: y =>
            {
                var pdfFileName = Path.ChangeExtension(DefinitionFileName, ".pdf");
                var targetPath  = Path.Combine(Directory.GetCurrentDirectory(), pdfFileName);

                var definition = ReadLabelDefinition(DefinitionFileName);
                ListLabelManager.ExportAsPdf(definition, Data, ParentEntity, targetPath);
            },
                canExecute: x => true);
        }
Beispiel #2
0
    public void updateList()
    {
        foreach (GameObject go in listLabelList)
        {
            GameObject.Destroy(go);
        }

        listLabelList.Clear();

        Vector3 offset     = new Vector3(0.0f, 0.0f, -0.01f);
        Vector3 yOffsetInc = listObject.transform.up * -0.05f;

        int numNodes    = currentActiveNodes.Count;
        int numExtNodes = exteriorNodeRefs.Count;

        int maxPage = (numNodes + maxNodesPerPage - 1) / maxNodesPerPage;

        if (currNodePage < 1)
        {
            currNodePage = 1;
        }
        else if (currNodePage > maxPage)
        {
            currNodePage = maxPage;
        }

        // update the page label and arrows
        TextMesh tMesh = pageText.GetComponent <TextMesh>();

        if (numNodes < 1)
        {
            tMesh.text = "empty";
        }
        else
        {
            tMesh.text = "Page " + currNodePage + " of " + maxPage;
        }

        MeshRenderer prevMeshRend = prevPageQuad.GetComponent <MeshRenderer>();
        MeshRenderer nextMeshRend = nextPageQuad.GetComponent <MeshRenderer>();

        if (currNodePage == 1)
        {
            prevMeshRend.material.color = Color.gray;
        }
        else
        {
            prevMeshRend.material.color = Color.white;
        }

        if (currNodePage == maxPage)
        {
            nextMeshRend.material.color = Color.gray;
        }
        else
        {
            nextMeshRend.material.color = Color.white;
        }



        int firstIdx = (currNodePage - 1) * maxNodesPerPage + 1;
        int lastIdx  = firstIdx + maxNodesPerPage;
        int currIdx  = 0;

        foreach (KeyValuePair <string, NodeStatus> entry in currentActiveNodes)
        {
            currIdx++;
            if (currIdx < firstIdx)
            {
                continue;
            }
            else if (currIdx >= lastIdx)
            {
                break;
            }

            GameObject       txtObj = (GameObject)Instantiate(labelTxtPrefab);
            ListLabelManager man    = txtObj.GetComponent <ListLabelManager>();
            man.nodeStatus = entry.Value;

            TextMesh mesh = man.labelText.GetComponent <TextMesh>();
            mesh.text = entry.Key;

            if (activeNodeIpAddress.Equals(entry.Key))
            {
                mesh.color = Color.yellow;
            }

            txtObj.transform.SetParent(listObject.transform);

            listLabelList.Add(txtObj);

            txtObj.transform.position = listObject.transform.position + offset;
            txtObj.transform.rotation = listObject.transform.rotation;

            offset += yOffsetInc;
        }



        offset = new Vector3(0.0f, 0.0f, -0.01f);

        maxPage = (numExtNodes + maxNodesPerPage - 1) / maxNodesPerPage;

        if (currExtNodePage < 1)
        {
            currExtNodePage = 1;
        }
        else if (currExtNodePage > maxPage)
        {
            currExtNodePage = maxPage;
        }

        // update the external page label and arrows
        tMesh = extPageText.GetComponent <TextMesh>();
        if (numNodes < 1)
        {
            tMesh.text = "empty";
        }
        else
        {
            tMesh.text = "Page " + currExtNodePage + " of " + maxPage;
        }

        prevMeshRend = prevPageExtQuad.GetComponent <MeshRenderer>();
        nextMeshRend = nextPageExtQuad.GetComponent <MeshRenderer>();

        if (currExtNodePage == 1)
        {
            prevMeshRend.material.color = Color.gray;
        }
        else
        {
            prevMeshRend.material.color = Color.white;
        }

        if (currExtNodePage == maxPage)
        {
            nextMeshRend.material.color = Color.gray;
        }
        else
        {
            nextMeshRend.material.color = Color.white;
        }

        firstIdx = (currExtNodePage - 1) * maxNodesPerPage + 1;
        lastIdx  = firstIdx + maxNodesPerPage;
        currIdx  = 0;

        foreach (long key in exteriorNodeRefs.Keys)
        {
            currIdx++;
            if (currIdx < firstIdx)
            {
                continue;
            }
            else if (currIdx >= lastIdx)
            {
                break;
            }

            GameObject       txtObj = (GameObject)Instantiate(labelTxtExtNodePrefab);
            ListLabelManager man    = txtObj.GetComponent <ListLabelManager>();
            man.nodeStatus = null;

            TextMesh mesh = man.labelText.GetComponent <TextMesh>();
            mesh.text = TestSQLiteConn.getIpStringFromLong(key);

            if (currActiveExteriorNodes.ContainsKey(key))
            {
                mesh.color = Color.yellow;
            }

            txtObj.transform.SetParent(extListObject.transform);

            listLabelList.Add(txtObj);

            txtObj.transform.position = extListObject.transform.position + offset;
            txtObj.transform.rotation = extListObject.transform.rotation;

            offset += yOffsetInc;
        }
    }