コード例 #1
0
        public List <int> BiggestTableWidthAndHeight(string projectPath, string projectName)
        {
            int biggestHeight = 0;
            int biggestWidth  = 0;

            List <int>   listOfAtributes = new List <int>();
            LoadProjects loadProjects    = new LoadProjects();

            foreach (var table in loadProjects.LoadTables(projectName))
            {
                string tablePath = projectPath + "\\" + table;
                int    height    = (NumberOfLinesInFile(tablePath) * 15 + 17);
                int    width     = (LengthOfNameAndType(tablePath, table) * 8) + 46;
                if (height > biggestHeight)
                {
                    biggestHeight = height;
                }
                if (width > biggestWidth)
                {
                    biggestWidth = width;
                }
            }
            listOfAtributes.Add(biggestWidth);
            listOfAtributes.Add(biggestHeight);
            return(listOfAtributes);
        }
コード例 #2
0
        public Dictionary <string, string> TypeOfConnection(string childTable, string parentTable, string projectPath)
        {
            LoadProjects  loadProjects                   = new LoadProjects();
            List <string> contentOfChildTable            = loadProjects.ListOfTableContent(projectPath + "\\" + childTable);
            Dictionary <string, string> listOFConnection = new Dictionary <string, string>();

            foreach (var attribute in contentOfChildTable)
            {
                string[] parts = attribute.Split(',');

                if (LastAttribute(contentOfChildTable, j))
                {
                    attributeName.Clear();
                }

                if (!attributeName.Contains(parts[2]))
                {
                    j = contentOfChildTable.IndexOf(attribute);

                    if (parts[8].Contains(parentTable) && parentTable + ".dat" == childTable)
                    {
                        if (parts[6].ToString() == "True" && parts[4].ToString() == "True")
                        {
                            listOFConnection.Add("1", "1");
                            attributeName.Add(parts[2].ToString());
                            break;
                        }
                        else
                        {
                            listOFConnection.Add("1", "M");
                            attributeName.Add(parts[2].ToString());
                            break;
                        }
                    }
                    else
                    {
                        //Ako atribut sadrzi ime primarne tablice onda provjeravamo taj atribut
                        if (parts[8].Contains(parentTable))
                        {
                            //Ako je unique onda je veza 1:1
                            if (parts[6].ToString() == "True")
                            {
                                listOFConnection.Add("1", "1");
                                attributeName.Add(parts[2].ToString());
                                break;
                            }
                            //Inace je veza 1:M
                            else
                            {
                                listOFConnection.Add("1", "M");
                                attributeName.Add(parts[2].ToString());
                                break;
                            }
                        }
                    }
                }
            }
            return(listOFConnection);
        }
コード例 #3
0
        private void formERADijagram_Load(object sender, EventArgs e)
        {
            LoadProjects loadProjects = new LoadProjects();

            loadProjects.CreateProjectDirectory();
            newProjectList = loadProjects.ProjectList();
            formERADijagram_Activated(sender, e);
        }
コード例 #4
0
        public void btnSaveProjectName_Click(object sender, EventArgs e)
        {
            NewTableController controller   = new NewTableController();
            LoadProjects       loadProjects = new LoadProjects();
            bool exists = false;

            foreach (var project in loadProjects.ProjectList())
            {
                if (project == projectName1 && rename1)
                {
                    string folderName  = loadProjects.CreateProjectDirectory();
                    string pathString  = System.IO.Path.Combine(folderName, projectName1.Replace(" ", "_"));
                    string pathString1 = System.IO.Path.Combine(folderName, txtProjectName.Text.Replace(" ", "_"));
                    if (!loadProjects.ProjectList().Contains(txtProjectName.Text.Replace(" ", "_")))
                    {
                        if (controller.CheckTextInput(txtProjectName.Text.Replace(" ", "_")))
                        {
                            System.IO.Directory.Move(pathString, pathString1);
                            f1.oldName          = projectName1.Replace(" ", "_");
                            f1.newProject       = txtProjectName.Text.Replace(" ", "_");
                            f1.projectIsRenamed = true;
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Invalid input!");
                        }
                    }
                }
                else if (project == txtProjectName.Text.Replace(" ", "_"))
                {
                    exists = true;
                }
            }

            if (!exists)
            {
                if (controller.CheckTextInput(txtProjectName.Text))
                {
                    string folderName = loadProjects.CreateProjectDirectory();
                    string pathString = System.IO.Path.Combine(folderName, txtProjectName.Text.Replace(" ", "_"));
                    System.IO.Directory.CreateDirectory(pathString);
                    f1.newProject = txtProjectName.Text.Replace(" ", "_");
                    this.Hide();
                }
                else if (!rename1)
                {
                    txtProjectName.Text = "";
                    MessageBox.Show("Invalid input");
                }
            }
            else
            {
                MessageBox.Show("Project already exists!");
            }
        }
コード例 #5
0
ファイル: sqlCode.cs プロジェクト: mlehpamer/Zavrsni_Rad
        private void sqlCode_Load(object sender, EventArgs e)
        {
            LoadProjects loadProjects = new LoadProjects();

            foreach (var item in loadProjects.TableContentToSQL(projectName))
            {
                txtCode.AppendText(item.ToString());
                txtCode.AppendText("\n");
                content.Add(item);
            }
        }
コード例 #6
0
        private void lblRenameTable_Click(object sender, EventArgs e)
        {
            LoadProjects    loadProjects = new LoadProjects();
            string          tableName    = treeProject.SelectedNode.Text;
            string          projectName  = treeProject.SelectedNode.Parent.Text;
            frmNewTableName newTableName = new frmNewTableName(tableName, true, projectName);

            newTableName.Show();

            panelTableOptions.Height = 0;
            isTableMenuOpen          = false;
        }
コード例 #7
0
        private void btnOdustani_Click(object sender, EventArgs e)
        {
            NewTableController controller   = new NewTableController();
            LoadProjects       loadProjects = new LoadProjects();

            if (brojAtributa < 1 || !controller.CheckPrimaryKey(dirPath1))
            {
                controller.DeleteTable(dirPath1);
                loadProjects.DeleteTableDependece(projectName1, tableName1 + ".dat");
            }
            this.Close();
        }
コード例 #8
0
        public void ChangeFKNameInDatAfterRenaming(string oldName, string newName, string projectName, string projectPath)
        {
            LoadProjects  loadProjects      = new LoadProjects();
            List <String> listOfFileContent = new List <string>();



            foreach (var table in loadProjects.LoadTables(projectName))
            {
                listOfFileContent.Clear();
                string tablePath = projectPath + "\\" + table;

                using (StreamReader sr = new StreamReader(tablePath))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] parts = line.Split(',');
                        if (parts[8].Contains(oldName))
                        {
                            string newLine = null;
                            for (int i = 0; i < parts.Length; i++)
                            {
                                if (i == 8)
                                {
                                    string [] secondPart = parts[8].Split(':');
                                    newLine += "[" + newName + ":" + secondPart[1];
                                }
                                else if (parts[i] == "};")
                                {
                                    newLine += "};";
                                    break;
                                }
                                else
                                {
                                    newLine += parts[i] + ",";
                                }
                            }
                            listOfFileContent.Add(newLine);
                        }
                        else
                        {
                            listOfFileContent.Add(line);
                        }
                    }
                    sr.Close();
                }
                File.WriteAllLines(tablePath, listOfFileContent.ToArray());
            }
        }
コード例 #9
0
        private void btnSaveTableName_Click(object sender, EventArgs e)
        {
            NewTableController controller   = new NewTableController();
            LoadProjects       loadProjects = new LoadProjects();
            bool exists = false;

            foreach (var table in loadProjects.LoadTables(projectName))
            {
                if ((table) == (tableName1 + ".dat") && rename1)
                {
                    string projectPath            = loadProjects.CreateProjectDirectory() + "\\" + projectName + "\\" + tableName1.Replace(" ", "_") + ".dat";
                    string projectPath1           = loadProjects.CreateProjectDirectory() + "\\" + projectName + "\\" + txtTableName.Text.Replace(" ", "_") + ".dat";
                    string projectPathForChangeFK = loadProjects.CreateProjectDirectory() + "\\" + projectName;

                    controller.ChangeFKNameInDatAfterRenaming(tableName1.Replace(" ", "_"), txtTableName.Text.Replace(" ", "_"), projectName, projectPathForChangeFK);
                    if (!loadProjects.LoadTables(projectName).Contains(txtTableName.Text + ".dat"))
                    {
                        if (controller.CheckTextInput(txtTableName.Text.Replace(" ", "_")))
                        {
                            System.IO.File.Move(projectPath, projectPath1);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Invalid input");
                        }
                    }
                }
                if (table == txtTableName.Text + ".dat")
                {
                    MessageBox.Show("Table already exists!");
                    exists = true;
                }
            }

            if (controller.CheckTextInput(txtTableName.Text) && !rename1 && !exists)
            {
                string     projectPath = loadProjects.CreateProjectDirectory() + "\\" + projectName + "\\" + txtTableName.Text.Replace(" ", "_") + ".dat";
                FileStream fs          = File.Create(projectPath);
                fs.Close();
                formNovaTablica frmNewTable = new formNovaTablica(txtTableName.Text, projectPath, projectName);
                frmNewTable.Show();
                this.Close();
            }
            else if (!controller.CheckTextInput(txtTableName.Text) && !rename1)
            {
                MessageBox.Show("Invalid input!");
            }
        }
コード例 #10
0
        private void lblDeleteProjectRightClick_Click(object sender, EventArgs e)
        {
            string       selectedNode = treeProject.SelectedNode.Text;
            LoadProjects loadProjects = new LoadProjects();
            string       projectPath  = loadProjects.CreateProjectDirectory() + "\\" + selectedNode;
            DialogResult dialogResult = MessageBox.Show("Are you sure", "Delete project: " + selectedNode, MessageBoxButtons.YesNo);

            if (Directory.Exists(projectPath) && dialogResult == DialogResult.Yes)
            {
                Directory.Delete(projectPath, true);
                projectOptionsPanel.Height = 0;
                isProjectMenuOpen          = false;
                newProjectList.Remove(selectedNode);
                formERADijagram_Activated(sender, e);
            }
        }
コード例 #11
0
        private void lblDeleteTable_Click(object sender, EventArgs e)
        {
            LoadProjects loadProjects = new LoadProjects();
            string       projectName  = treeProject.SelectedNode.Parent.Text;
            string       tableName    = treeProject.SelectedNode.Text;
            var          dirPath      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var          dirName      = $@"{dirPath}\Projects\" + projectName + "\\" + tableName;
            DialogResult dialogResult = MessageBox.Show("Are you sure", "Delete table: " + tableName, MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                File.Delete(dirName);
                panelTableOptions.Height = 0;
                isTableMenuOpen          = false;
                loadProjects.DeleteTableDependece(projectName, tableName);
                formERADijagram_Activated(sender, e);
            }
        }
コード例 #12
0
        private void btnSpremi_Click(object sender, EventArgs e)
        {
            NewTableController controller   = new NewTableController();
            LoadProjects       loadProjects = new LoadProjects();

            if (brojAtributa < 1)
            {
                controller.DeleteTable(dirPath1);
                loadProjects.DeleteTableDependece(projectName1, tableName1 + ".dat");
                this.Close();
            }
            else
            {
                if (!controller.CheckPrimaryKey(dirPath1))
                {
                    MessageBox.Show("There is no primary key");
                }
                else
                {
                    this.Close();
                }
            }
        }
コード例 #13
0
        private void formERADijagram_Activated(object sender, EventArgs e)
        {
            treeProject.Nodes.Clear();
            treeProject.Nodes.Add("Projects");

            LoadProjects loadProjects = new LoadProjects();

            // newProjectList = loadProjects.ProjectList();
            if (newProject != "" && !projectIsRenamed)
            {
                newProjectList.Add(newProject);
                newProject = "";
            }

            if (projectIsRenamed)
            {
                newProjectList.Remove(oldName);
                newProjectList.Add(newProject);
                System.Console.WriteLine("oldname" + oldName);
                System.Console.WriteLine("new name" + newProject);
                projectIsRenamed = false;
                newProject       = "";
            }
            foreach (var item in newProjectList)
            {
                TreeNode node;
                node = treeProject.Nodes[0].Nodes.Add(item.ToString());
                foreach (var table in loadProjects.LoadTables(item.ToString()))
                {
                    node.Nodes.Add(table.ToString());
                }
            }
            filePanel.Height    = 0;
            isFileMenuPanelOpen = false;
            treeProject.ExpandAll();
        }
コード例 #14
0
        public int NumberOfTables(string projectName)
        {
            LoadProjects loadProjects = new LoadProjects();

            return(loadProjects.LoadTables(projectName).Count());
        }
コード例 #15
0
        private void lblGenerateERA_Click(object sender, EventArgs e)
        {
            Graphics gr = panelERADijagrama.CreateGraphics();

            gr.Clear(Color.White);
            panelERADijagrama.Controls.Clear();

            LoadProjects  loadProjects  = new LoadProjects();
            GeneratingERA generatingERA = new GeneratingERA();
            List <string> listOfTablePositionAndArea = new List <string>();

            listOfEndTableTypePoints.Clear();
            listOfEndPointsTable.Clear();
            listOfDockingLinesPoints.Clear();
            listOfStartTablePoints.Clear();
            listOfStartTableTypePoints.Clear();
            listOfRandomColor.Clear();

            //Initilize drawing area
            int eraPanelWidth      = panelERADijagrama.Width - (panel4.Width + panel1.Width);
            int eraPanelHeight     = panelERADijagrama.Height - panel3.Height;
            int realEraPanelHeight = panelERADijagrama.Height;
            int realEraPanelWidth  = panelERADijagrama.Width;

            //Initilaze starting position for drawing
            int eraStartingPositionX = panel4.Width + panel1.Width;
            int eraStartingPositionY = panel3.Height;


            Canvas canvas = new Canvas(eraPanelHeight, eraPanelWidth, eraStartingPositionX, eraStartingPositionY, realEraPanelHeight, realEraPanelWidth);

            //Making string path for selected project
            string projectName = treeProject.SelectedNode.Text;
            var    dirPath     = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var    projectPath = $@"{dirPath}\Projects\" + projectName;

            // generatingERA.TableArea(projectPath,eraPanelWidth,eraPanelHeight);
            int numberOfTables = generatingERA.NumberOfTables(projectName);

            //Creating grid for drawing surface
            int biggestWidth  = generatingERA.BiggestTableWidthAndHeight(projectPath, projectName).ElementAt(0);
            int biggestHeight = generatingERA.BiggestTableWidthAndHeight(projectPath, projectName).ElementAt(1);


            //Making empty canvas for tables
            canvas.SetMatrixToEmpty();

            //Loading every table in project
            foreach (var table in loadProjects.LoadTables(projectName))
            {
                string tablePath = projectPath + "\\" + table;

                int height = (generatingERA.NumberOfLinesInFile(tablePath) * 15 + 17);
                int width  = (generatingERA.LengthOfNameAndType(tablePath, table) * 8) + 46;

                //Giving dimenisions for every table one by one and geting back coordinates
                int[,] point = canvas.StartingTablePoints(biggestWidth, biggestHeight, width, height, numberOfTables);
                int pointX = point.GetLength(0);
                int pointY = point.GetLength(1);



                //Creating panels for every table
                Panel tablePanel = new Panel();
                tablePanel.Size        = new System.Drawing.Size(width, height);
                tablePanel.Location    = new Point(pointX, pointY);
                tablePanel.BorderStyle = BorderStyle.FixedSingle;
                tablePanel.BringToFront();
                Color myCOlor = Color.FromArgb(169, 186, 171);
                tablePanel.BackColor = myCOlor;
                panelERADijagrama.Controls.Add(tablePanel);

                //Creating list for later drawings of connections
                string positionAndName = "[(" + pointX + "," + pointY + ");(" + width + "," + height + ");:" + table + "]";
                listOfTablePositionAndArea.Add(positionAndName);

                //Creating label for table name
                Label lblTableName = new Label();
                lblTableName.Text = table.Substring(0, table.IndexOf('.'));
                lblTableName.Font = new Font("Arial", 9, FontStyle.Bold);
                int tableNameWidth = table.Substring(0, table.IndexOf('.')).Length * 8;
                lblTableName.AutoSize = true;
                lblTableName.Location = new Point((width - tableNameWidth) / 2, 0);
                tablePanel.Controls.Add(lblTableName);

                //Drawing line to seperate table name from atributtes
                tablePanel.Paint += new PaintEventHandler(tablePanelPaint);
                tablePanel.Refresh();


                int newY = 18;

                //Loop for placing labels which are PK
                foreach (var PK in generatingERA.ListOfPrimaryKeyInTable(tablePath))
                {
                    string[] parts = PK.Split(',');

                    //Creating label for primary keys
                    Label lbPK = new Label();
                    lbPK.Text     = parts[0].ToString();
                    lbPK.Font     = new Font("Arial", 8, FontStyle.Bold);
                    lbPK.Location = new System.Drawing.Point(20, newY);
                    lbPK.AutoSize = true;
                    tablePanel.Controls.Add(lbPK);

                    //Creating label for primary key type
                    Label lbTypePK = new Label();
                    lbTypePK.Text     = parts[1].ToString();
                    lbTypePK.Font     = new Font("Arial", 8, FontStyle.Bold);
                    lbTypePK.Location = new System.Drawing.Point(width - (width - (generatingERA.BiggestAttribute(tablePath)) * 8) + 26, newY);
                    lbTypePK.AutoSize = true;
                    tablePanel.Controls.Add(lbTypePK);

                    //Creating Label for PK indicator
                    Label lblPk1 = new Label();
                    lblPk1.Text     = "PK";
                    lblPk1.Font     = new Font("Arial", 8, FontStyle.Bold);
                    lblPk1.Location = new System.Drawing.Point(0, newY);
                    lblPk1.AutoSize = true;
                    tablePanel.Controls.Add(lblPk1);
                    newY += 15;
                    lbTypePK.BringToFront();
                }


                //Loop for placing labels that are normal atributes
                foreach (var attribute in generatingERA.AtributeNameAndTypeInFile(tablePath))
                {
                    string[] parts = attribute.Split(',');

                    //Creating labels for every atribute
                    Label lb = new Label();
                    lb.Text     = parts[0].ToString();
                    lb.Font     = new Font("Arial", 8, FontStyle.Regular);
                    lb.Location = new System.Drawing.Point(20, newY);
                    lb.AutoSize = true;
                    tablePanel.Controls.Add(lb);

                    //Creating label for type
                    Label lbType = new Label();
                    lbType.Text     = parts[1].ToString();
                    lbType.Font     = new Font("Arial", 8, FontStyle.Regular);
                    lbType.Location = new System.Drawing.Point(width - (width - (generatingERA.BiggestAttribute(tablePath)) * 8) + 26, newY);
                    //lbType.Location = new System.Drawing.Point(width - lb.Width-10, newY);
                    lbType.AutoSize = true;
                    tablePanel.Controls.Add(lbType);

                    newY += 15;
                    lbType.BringToFront();
                }

                //Adding foreing keys to table panel
                foreach (var PK in generatingERA.ListOfFKAtributeAndType(tablePath))
                {
                    string[] parts = PK.Split(',');

                    //Creating laber from FK keys
                    Label lbFK = new Label();
                    lbFK.Text     = parts[0].ToString();
                    lbFK.Font     = new Font("Arial", 8, FontStyle.Bold);
                    lbFK.Location = new System.Drawing.Point(20, newY);
                    lbFK.AutoSize = true;
                    tablePanel.Controls.Add(lbFK);

                    //Creating label for FK key type
                    Label lbTypeFK = new Label();
                    lbTypeFK.Text     = parts[1].ToString();
                    lbTypeFK.Font     = new Font("Arial", 8, FontStyle.Bold);
                    lbTypeFK.Location = new System.Drawing.Point(width - (width - (generatingERA.BiggestAttribute(tablePath)) * 8) + 26, newY);
                    lbTypeFK.AutoSize = true;
                    tablePanel.Controls.Add(lbTypeFK);

                    //Creating Label for FK indicator
                    Label lblFk1 = new Label();
                    lblFk1.Text     = "FK";
                    lblFk1.Font     = new Font("Arial", 8, FontStyle.Bold);
                    lblFk1.Location = new System.Drawing.Point(0, newY);
                    lblFk1.AutoSize = true;
                    tablePanel.Controls.Add(lblFk1);
                    newY += 15;
                    lbTypeFK.BringToFront();
                }
            }
            ;

            //Loop for drawing lines
            foreach (var item in listOfTablePositionAndArea)
            {
                string[] parts = item.Split(';');

                string tableName = item.Substring(item.LastIndexOf(':') + 1, item.IndexOf(']') - item.IndexOf(':') - 1);
                int    pointX    = int.Parse(parts[0].Substring(item.IndexOf('(') + 1, item.IndexOf(',') - 2));
                int    pointY    = int.Parse(parts[0].Substring(item.IndexOf(',') + 1, item.IndexOf(')') - item.IndexOf(',') - 1));
                int    width     = int.Parse(parts[1].Substring(parts[1].IndexOf('(') + 1, parts[1].IndexOf(',') - 1));
                int    height    = int.Parse(parts[1].Substring(parts[1].IndexOf(',') + 1, parts[1].IndexOf(')') - parts[1].IndexOf(',') - 1));

                //Checks if table has a FK-that would be child table
                if (generatingERA.TableHasFK(projectPath + "\\" + tableName))
                {
                    //Checks list of FK for that table(how many of FK child table has )
                    foreach (var FK in generatingERA.ListOfTableFK(projectPath + "\\" + tableName))
                    {
                        //Finding again coordinates for table that is the parent
                        foreach (var tableFK in listOfTablePositionAndArea)
                        {
                            string[] newParts    = tableFK.Split(';');
                            string   parentTable = newParts[2].Substring(newParts[2].IndexOf(':') + 1, newParts[2].IndexOf('.') - newParts[2].IndexOf(':') - 1);


                            //FK== item from list where child table has FK that FK is acctualy nake of primary table
                            if (FK == parentTable)
                            {
                                //Primary table coordinates and dimension
                                int newPointX = int.Parse(newParts[0].Substring(newParts[0].IndexOf('(') + 1, newParts[0].IndexOf(',') - 2));
                                int newPointY = int.Parse(newParts[0].Substring(newParts[0].IndexOf(',') + 1, newParts[0].IndexOf(')') - newParts[0].IndexOf(',') - 1));
                                int newWidth  = int.Parse(newParts[1].Substring(newParts[1].IndexOf('(') + 1, newParts[1].IndexOf(',') - 1));
                                int newHeight = int.Parse(newParts[1].Substring(newParts[1].IndexOf(',') + 1, newParts[1].IndexOf(')') - newParts[1].IndexOf(',') - 1));

                                //Sada ovdje treba provijeriti na koji nacin su povezane te dvije tablice
                                //Provijeriti tablica u kojoj se nalazi FK kojeg je tipa atribut
                                //Onda na koordinate od child tablice staviti vezu
                                //I na koordinate od parent tablice staviti takoker tip veze
                                // tableName- ime tablice sa FK
                                // parentTable- ime tablice sa PK

                                Dictionary <string, string> typeOfConnection = generatingERA.TypeOfConnection(tableName, parentTable, projectPath);
                                string childTableConnectionType  = "";
                                string parentTableConnectionType = "";
                                try
                                {
                                    foreach (var type in typeOfConnection)
                                    {
                                        childTableConnectionType  = type.Key;
                                        parentTableConnectionType = type.Value;
                                    }
                                }
                                catch { }

                                canvas.NewStartingCoordinates(newPointX, newPointY, pointX, pointY, newWidth, newHeight, width, height);

                                Point[] pointsEndTable       = canvas.MyDrawingPathEndTable(pointX, pointY, width, height);
                                Point[] pointsStartTable     = canvas.MyDrawingPathStartTable(newPointX, newPointY, newWidth, newHeight);
                                Point[] startTabletypePoints = canvas.TableConnectionStartTable(parentTableConnectionType);
                                Point[] endTableTypePoints   = canvas.TableConnectionsEndTable(childTableConnectionType, parentTableConnectionType);
                                Point[] dokcingPoints        = canvas.AgainMyTry();



                                try
                                {
                                    listOfEndPointsTable.Add(pointsEndTable);
                                    listOfStartTablePoints.Add(pointsStartTable);
                                    listOfStartTableTypePoints.Add(startTabletypePoints);
                                    listOfEndTableTypePoints.Add(endTableTypePoints);
                                    listOfDockingLinesPoints.Add(dokcingPoints);

                                    Random rnd         = new Random();
                                    Color  randomColor = Color.FromArgb(rnd.Next(150), rnd.Next(150), rnd.Next(150));
                                    try
                                    {
                                        while (listOfRandomColor.Contains(randomColor))
                                        {
                                            randomColor = Color.FromArgb(rnd.Next(150), rnd.Next(150), rnd.Next(150));
                                        }
                                        listOfRandomColor.Add(randomColor);
                                    }
                                    catch {
                                        listOfRandomColor.Add(randomColor);
                                    }
                                }
                                catch
                                {
                                    System.Console.WriteLine("Not work");
                                }
                            }
                        }
                    }
                }
            }
            //canvas.PrintMatrix();
            panelERADijagrama.Invalidate();
            projectOptionsPanel.Height = 0;
            isProjectMenuOpen          = false;
        }
コード例 #16
0
        private void formNovaTablica_Load(object sender, EventArgs e)
        {
            brojAtributa         = 0;
            rowIndex             = 0;
            rowIndexForFK        = 0;
            txtTableName.Text    = tableName1.Replace(" ", "_");
            txtKeyNameTable.Text = tableName1.Replace(" ", "_");
            NewTableController controller   = new NewTableController();
            LoadProjects       loadProjects = new LoadProjects();



            if (reload1)
            {
                foreach (var item in loadProjects.OpenSpecificTable(dirPath1))
                {
                    string[] parts = item.Split(',');
                    dgvStupci.Rows.Add(1);
                    dgvStupci.Rows[brojAtributa].Cells[0].Value = parts[0].ToString();
                    dgvStupci.Rows[brojAtributa].Cells[1].Value = parts[1].ToString();
                    if (parts[3].ToString() == "True")
                    {
                        dgvStupci.Rows[brojAtributa].Cells[2].Value = true;
                    }
                    else
                    {
                        dgvStupci.Rows[brojAtributa].Cells[2].Value = false;
                    }
                    if (parts[2].ToString() == "True")
                    {
                        dgvStupci.Rows[brojAtributa].Cells[3].Value = true;
                    }
                    else
                    {
                        dgvStupci.Rows[brojAtributa].Cells[3].Value = false;
                    }
                    if (parts[4].ToString() == "True")
                    {
                        dgvKeys.Rows.Add(1);
                        dgvStupci.Rows[brojAtributa].Cells[4].Value = true;
                        dgvKeys.Rows[rowIndex].Cells[0].Value       = parts[0].ToString();
                        dgvKeys.Rows[rowIndex].Cells[1].Value       = parts[1].ToString();
                        dgvKeys.Rows[rowIndex].Cells[2].Value       = true;
                        rowIndex++;
                    }
                    else
                    {
                        dgvStupci.Rows[brojAtributa].Cells[4].Value = false;
                    }

                    if (parts[5].ToString() != "")
                    {
                        string[] line = parts[5].Split(':');
                        dgvForeignKeys.Rows.Add(1);
                        dgvForeignKeys.Rows[rowIndexForFK].Cells[0].Value = line[0].Substring(line[0].IndexOf("[") + 1, line[0].Length - 1);
                        dgvForeignKeys.Rows[rowIndexForFK].Cells[1].Value = parts[0];
                        dgvForeignKeys.Rows[rowIndexForFK].Cells[2].Value = line[1].Substring(0, line[1].IndexOf("]"));
                        rowIndexForFK++;
                    }

                    brojAtributa++;
                }
            }
            cmbFKTableName.DataSource           = loadProjects.LoadTablesWithoutExtension(projectName1);
            cmbColumnAtribut.DataSource         = controller.ListOfTableAtributesForPrimaryKey(dirPath1);
            cmbCurrentTableAtributes.DataSource = controller.ListOfAtributesInCurrentTable(dirPath1);
        }