示例#1
0
        //Botoes
        private void btNovo_Click(object sender, EventArgs e)
        {
            //Resgata Personagem
            Personagem pers = getPersonagem();

            //Cria novo ID
            pers.ID = Guid.NewGuid();

            //Serializa JSON
            var jsonPersonagem = JsonConvert.SerializeObject(pers);

            //Grava em diretorio
            Arquivo.CriaArquivo(CAMINHO, pers.ID.ToString(), EXTENSAO, jsonPersonagem);

            //Limpa Tela
            LimpaTela();

            //Limpa Lista
            listCadastrados.Items.Clear();

            //Atualiza Lista
            CarregarPersonagens(CAMINHO);
        }
示例#2
0
        private void btnAbrirArquivo_Click(object sender, EventArgs e)
        {
            List <FilhoArvore> lista = Arquivo.CriaArquivo();
            int filaLista            = arquivos.Count();

            arquivos.Add(lista);
            count++;

            DataGridView dataGridView = new System.Windows.Forms.DataGridView();

            dataGridView.AllowUserToOrderColumns     = true;
            dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            dataGridView.Location = new System.Drawing.Point(181, -1);
            dataGridView.Name     = "dataGridViewN" + count;
            dataGridView.Size     = new System.Drawing.Size(604, 352);
            dataGridView.TabIndex = 1;

            //Cria aba com o arquivo
            TabPage tabPage = new System.Windows.Forms.TabPage();

            tabPage.Name = "tabPageN" + count;
            tabPage.Text = "Arquivo_Teste" + count;
            tabPage.Controls.Add(dataGridView1);
            tabPage.Tag = filaLista;

            TreeView treeView = new System.Windows.Forms.TreeView();

            treeView.Size            = new System.Drawing.Size(181, 351);
            treeView.TabIndex        = 0;
            treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);

            List <TreeNode> nodes = new List <TreeNode>();

            for (int i = 0; i < lista.Count; i++)
            {
                TreeNode tree = new System.Windows.Forms.TreeNode();
                tree.Name = "no" + i;
                tree.Text = lista[i].descricao;
                tree.Tag  = lista[i].id;
                nodes.Add(tree);
            }

            for (int i = 0; i < nodes.Count; i++)
            {
                for (int i2 = 0; i2 < lista.Count; i2++)
                {
                    if (int.Parse(nodes[i].Tag.ToString()) == lista[i2].id)
                    {
                        if (lista[i2].idpai != 0)
                        {
                            for (int i3 = 0; i3 < nodes.Count; i3++)
                            {
                                if (int.Parse(nodes[i3].Tag.ToString()) == lista[i2].idpai)
                                {
                                    nodes[i3].Nodes.Add(nodes[i]);
                                }
                            }
                        }
                        i2 = lista.Count;
                    }
                }
            }

            for (int i = 0; i < nodes.Count; i++)
            {
                for (int i2 = 0; i2 < lista.Count; i2++)
                {
                    if (int.Parse(nodes[i].Tag.ToString()) == lista[i2].id)
                    {
                        if (lista[i2].idpai == 0)
                        {
                            treeView.Nodes.Add(nodes[i]);
                        }
                        else
                        {
                            nodes.Remove(nodes[i]);
                        }
                    }
                }
            }



            tabPage.Controls.Add(treeView);
            tabMain.TabPages.Add(tabPage);
            this.tabMain.SelectedIndex = tabMain.TabPages.Count - 1;
        }