コード例 #1
0
        private void changeBtn_Click(object sender, EventArgs e)
        {
            if (projectList.SelectedItem == null)
            {
                MessageBox.Show("Select a project in Project List.");
                return;
            }
            string    beforeName = projectList.SelectedItem.ToString();
            InputForm inputForm  = new InputForm(fileName, 1, beforeName);

            inputForm.ShowDialog();
            resetList();
            int i    = 0;
            int flag = 0;

            while (projectList.Items.Count > i)
            {
                if (projectList.Items[i].ToString() == beforeName)
                {
                    flag = 1;
                    break;
                }
                i++;
            }
            if (flag == 0)
            {
                if (beforeName == projectName)
                {
                    projectName      = inputForm.getAfterName();
                    curProjText.Text = projectName;
                    ManageFile mf = new ManageFile();
                    mf.setCurrentProject("check.txt", projectName);
                }
            }
        }
コード例 #2
0
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            if (projectList.SelectedItem == null)
            {
                MessageBox.Show("Select a project in Project List.");
                return;
            }
            AccessSqlite sql    = new AccessSqlite();
            int          result = sql.deleteTable(projectList.SelectedItem.ToString());

            if (result == 0)
            {
                if (projectName != null && projectList.SelectedItem.ToString() == projectName)
                {
                    projectName      = null;
                    curProjText.Text = null;
                    ManageFile mf = new ManageFile();
                    mf.setCurrentProject("check.txt", null);
                }
                resetList();
                MessageBox.Show("Succeed in deleting the project.");
            }
            else
            {
                MessageBox.Show("Deleting the table failed.");
            }
        }
コード例 #3
0
        public AccessSqlite()
        {
            conn = new SQLiteConnection("Data Source = db.db");
            ManageFile mf = new ManageFile();

            check = mf.checkDBFile("db.db");
            if (check != -1)
            {
                conn.Open();
            }
        }
コード例 #4
0
        public ActionResult FindRoute()
        {
            FindRouteViewModel emptyModel = new FindRouteViewModel();

            emptyModel.GARoute = new List <Node>();
            emptyModel.CWRoute = new List <Node>();

            ManageFile  mf             = new ManageFile();
            List <Node> allAddressList = mf.GetNodes(Server.MapPath("~/Files/Rzeszow_Addresses.json"));

            TempData["AllAddresses"] = allAddressList;

            return(View(emptyModel));
        }
コード例 #5
0
        private void applyBtn_Click(object sender, EventArgs e)
        {
            if (projectList.SelectedItem == null)
            {
                MessageBox.Show("Select a project in Project List.");
                return;
            }
            projectName      = projectList.SelectedItem.ToString();
            curProjText.Text = projectName;
            ManageFile mf = new ManageFile();

            mf.setCurrentProject("check.txt", projectName);
            this.Close();
        }
コード例 #6
0
        public CheckProjectForm()
        {
            InitializeComponent();
            curProjText.Enabled = false;
            fileName            = "db.db";
            ManageFile mf    = new ManageFile();
            int        check = mf.checkDBFile(fileName);

            if (check != -1)
            {
                resetList();
                projectName = mf.getCurrentProject("check.txt");
                if (projectName != null)
                {
                    curProjText.Text = projectName;
                }
            }
        }
コード例 #7
0
        private void setDirectory()
        {
            AccessSqlite sql = new AccessSqlite();
            ManageFile   mf  = new ManageFile();

            string[] rows = sql.getRows(projectName, "name", null);
            int      i    = 0;

            try
            {
                while (rows.Length > i)
                {
                    string row = rows[i].Replace(".", @"\");
                    mf.createDirectory(projectName + @"\" + row);
                    i++;
                }
            }
            catch (Exception e)
            {
            }
        }
コード例 #8
0
        private void BtnZipFiles_Clicked(object sender, EventArgs e)
        {
            try
            {
                string zipPath = folder.Path + @"\" + zipFileName;

                // LocalStorage Path
                // Win - C:\Users\GIGABYTE\AppData\Local\Packages\a6e37ba2-4e37-4bd6-b5b6-16ae0b1e4f54_tbz3402trp7yy\LocalState
                // Android - /data/user/0/HelloXamarinFormsWorld.Android/files

                // zip directory
                //ZipFile.CreateFromDirectory(startPath, zipPath);

                string jsonpath = folder.Path + @"\" + Global.JSON_FILE_NAME;

                ManageFile.AddFilesToZip(zipPath, ManageFile.ReadJSONAndCreateFileList(jsonpath, folder.Path + @"\start"));

                Debug.WriteLine("Zip files complete!");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception occur when zip files: '{0}'", ex.Message);
            }
        }
コード例 #9
0
        public ActionResult FindRoute(FindRouteViewModel findRouteVM, string speed)
        {
            Graph basedGraph = new Graph(Server.MapPath("~/Files/Rzeszow_AdjacencyList.json"), Server.MapPath("~/Files/Rzeszow_Nodes.json"));

            Graph vrpGraph = new Graph();
            FindRouteBusinessLayer findRouteBL           = new FindRouteBusinessLayer();
            List <int>             addressArrayIndexList = new List <int>(); //indeksy adresów w grafie bazowym

            FindRouteBusinessLayer.CompleteGraphAndDijPaths completeGraphAndDijPaths = new FindRouteBusinessLayer.CompleteGraphAndDijPaths();
            List <Route>             vrpPathMemoryList = new List <Route>();
            GeneticAlgorithm         ga;
            ClarkeAndWrightAlgorithm clarkeWright;
            Chromosome  gaResult;
            List <int>  clarkeWrightResult;
            List <Node> gaResultNodeList, cwResultNodeList;
            Route       gaFullResult, cwFullResult;
            ManageFile  mf              = new ManageFile();
            List <Node> allAddressList  = mf.GetNodes(Server.MapPath("~/Files/Rzeszow_Addresses.json"));
            List <Node> destinationList = new List <Node>();

            //validation
            for (int i = 0; i < findRouteVM.AddressList.Count(); i++)
            {
                if (!findRouteBL.ValidAddress(findRouteVM.AddressList[i].StreetName, findRouteVM.AddressList[i].HouseNumber, allAddressList))
                {
                    ModelState.AddModelError(string.Empty, "Adres " + findRouteVM.AddressList[i].StreetName + " "
                                             + findRouteVM.AddressList[i].HouseNumber + " nie został odnaleziony");
                    return(View(findRouteVM));
                }
                else
                {
                    Node destination = allAddressList.Where(x => x.dict["addr:street"].Equals(findRouteVM.AddressList[i].StreetName) &&
                                                            x.dict["addr:housenumber"].Equals(findRouteVM.AddressList[i].HouseNumber)).First();
                    destinationList.Add(destination);
                }
            }
            basedGraph.ConnectAddressesToGraph(destinationList);

            for (int i = 0; i < findRouteVM.AddressList.Count(); i++)
            {
                addressArrayIndexList.Add(basedGraph.NodeList.Where(n => n.dict.ContainsKey("addr:housenumber") &&
                                                                    n.dict["addr:street"] == findRouteVM.AddressList[i].StreetName &&
                                                                    n.dict["addr:housenumber"] == findRouteVM.AddressList[i].HouseNumber).First().ArrayIndex);
            }


            completeGraphAndDijPaths = findRouteBL.CreateCompleteGraph(basedGraph, addressArrayIndexList, double.Parse(speed.Replace(".", ",")));
            vrpGraph          = completeGraphAndDijPaths.Graph;
            vrpPathMemoryList = completeGraphAndDijPaths.PathMemoryList;

            //mf.SaveAdjacencyList(completeGraphAndDijPaths.Graph.Edges);
            //mf.SaveNodes(completeGraphAndDijPaths.Graph.NodeList);
            //mf.SavePathMemory(completeGraphAndDijPaths.PathMemoryList);

            ga           = new GeneticAlgorithm(vrpGraph);
            clarkeWright = new ClarkeAndWrightAlgorithm(vrpGraph);

            gaResult = ga.Main().Last();
            gaResult.NodeIndexList.Add(gaResult.NodeIndexList[0]);
            clarkeWrightResult = clarkeWright.Main();

            gaResultNodeList = findRouteBL.ConvertSolution(gaResult.NodeIndexList, vrpGraph);
            cwResultNodeList = findRouteBL.ConvertSolution(clarkeWrightResult, vrpGraph);

            gaFullResult = findRouteBL.CreateFullRoute(gaResultNodeList, vrpPathMemoryList);
            cwFullResult = findRouteBL.CreateFullRoute(cwResultNodeList, vrpPathMemoryList);

            findRouteVM.GARouteCost = gaFullResult.Cost;
            findRouteVM.CWRouteCost = cwFullResult.Cost;
            findRouteVM.GARouteCost = Math.Round(findRouteVM.GARouteCost, 3);
            findRouteVM.CWRouteCost = Math.Round(findRouteVM.CWRouteCost, 3);

            //display full result
            findRouteVM.GARoute = gaFullResult.Path;
            findRouteVM.CWRoute = cwFullResult.Path;

            return(View(findRouteVM));
        }
コード例 #10
0
ファイル: Capturebutton.cs プロジェクト: LoisMonet/GARnie
    public void RecordButton()
    {
        if (capture.isRunning)
        {
            capture.StopCapturing();
            if (this.GetComponent <ToastExample2>() == null)
            {
                this.gameObject.AddComponent <ToastExample2>();
            }

            this.GetComponent <ToastExample2>().MethodToastExample(true, "video saved in" + ManageFile.GetDCIMPath() + folderSave);
            //te2=new ToastExample2(true,"video saved in /sdcard/DCIM");
        }
        else
        {
            capture.StartCapturing();
        }
        cameraRecord.GetComponent <Image>().color = capture.isRunning ? new Color32(50, 146, 156, 143) : new Color32(50, 204, 156, 143);
        txt.text = capture.isRunning ? "Stop Recording" : "Start Recording";
    }
コード例 #11
0
        private void setClassFile()
        {
            AccessSqlite sql = new AccessSqlite();
            ManageFile   mf  = new ManageFile();
            string       path;
            int          point;

            string[] rows = sql.getRowsDistinct(projectName, "name", null);
            int      i    = 0;
            int      j    = 0;

            try
            {
                while (rows.Length > i)
                {
                    path = rows[i].Replace(".", @"\");
                    string[] crows = sql.getRows(projectName, "class", "name = '" + rows[i] + "'");
                    j = 0;
                    try
                    {
                        while (crows.Length > j)
                        {
                            if (crows[j] == "")
                            {
                                j++;
                                continue;
                            }
                            if (mf.checkFile(path, crows[j]))
                            {
                                // field check
                                j++;
                                continue;
                            }
                            string curDir;
                            point = rows[i].LastIndexOf(".");
                            if (point != -1)
                            {
                                curDir = rows[i].Substring(point + 1);
                            }
                            else
                            {
                                curDir = rows[i];
                            }
                            int result = mf.createFile(projectName + @"\" + path, curDir, crows[j]);
                            if (result == 0)
                            {
                                try
                                {
                                    string[] frow = sql.getRows(projectName, "field", "name = '" + rows[i] + "' and class = '" + crows[j] + "'");
                                    if (frow[0] == "")
                                    {
                                        j++;
                                        continue;
                                    }
                                    mf.createField(projectName + @"\" + path, curDir, crows[j], frow[0]);
                                }
                                catch (Exception e)
                                {
                                }
                            }
                            j++;
                        }
                    }
                    catch (Exception e)
                    {
                    }
                    i++;
                }
            }
            catch (Exception e)
            {
            }
        }
コード例 #12
0
        private void doBtn_Click(object sender, EventArgs e)
        {
            AccessSqlite sql    = new AccessSqlite();
            ManageFile   mf     = new ManageFile();
            int          result = -2;
            string       path;

            if (categoryCombo.SelectedItem == null)
            {
                MessageBox.Show("Select a Category for this work.");
                return;
            }
            else if (workAtText.Text == "")
            {
                string msg = "";
                if (categoryCombo.SelectedItem.ToString() == "Class")
                {
                    msg = "Click a Namespace in View for this work.";
                }
                else if (categoryCombo.SelectedItem.ToString() == "Field")
                {
                    msg = "Click a Class in View for this work.";
                }
                MessageBox.Show(msg);
                return;
            }
            else if (nameText.Text == "")
            {
                MessageBox.Show("Input a name in Name Textbox for this work.");
                return;
            }
            else if (CheckCharacter.checkNamespace(nameText.Text) != 0)
            {
                return;
            }
            else if (workCombo.SelectedItem == null)
            {
                MessageBox.Show("Select a work in Work Combo box for this work.");
                return;
            }
            else if (categoryCombo.SelectedItem.ToString() == "Namespace" && workCombo.SelectedItem.ToString() == "Create")
            {
                result = sql.insertNamespace(projectName, nameText.Text);
                if (result == 0)
                {
                    namespaceTree = new SetNamespaceTreeView(namespaceTreeView, fileName, projectName);
                    namespaceTree.expandNode(nameText.Text);
                    path = nameText.Text.Replace(".", @"\");
                    mf.createDirectory(projectName + @"\" + path);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Namespace is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Creating new Namespace failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Class" && workCombo.SelectedItem.ToString() == "Create")
            {
                result = sql.insertClass(projectName, namespaceTree.getPath(), nameText.Text);
                if (result == 0)
                {
                    path = namespaceTree.getPath().Replace(".", @"\");
                    int    point = namespaceTree.getPath().LastIndexOf(".");
                    string curDir;
                    if (point != -1)
                    {
                        curDir = namespaceTree.getPath().Substring(point + 1);
                    }
                    else
                    {
                        curDir = namespaceTree.getPath();
                    }
                    mf.createFile(projectName + @"\" + path, curDir, nameText.Text);
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Class is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Creating new Class failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Field" && workCombo.SelectedItem.ToString() == "Create")
            {
                if (classTree.getClassName() != null)
                {
                    lastClassName = classTree.getClassName();
                }
                string type = null;
                if (typeCombo.SelectedItem == null)
                {
                    MessageBox.Show("Select a field type for this work.");
                    return;
                }
                else
                {
                    type = typeCombo.SelectedItem.ToString();
                }
                result = sql.insertField(projectName, namespaceTree.getPath(), lastClassName, nameText.Text, type);
                if (result == 0)
                {
                    path = namespaceTree.getPath().Replace(".", @"\");
                    int    point = namespaceTree.getPath().LastIndexOf(".");
                    string curDir;
                    if (point != -1)
                    {
                        curDir = namespaceTree.getPath().Substring(point + 1);
                    }
                    else
                    {
                        curDir = namespaceTree.getPath();
                    }
                    mf.addField(projectName + @"\" + path, lastClassName, nameText.Text, type);
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    classTree.expandNode(lastClassName);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Field is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Creating new Field failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Namespace" && workCombo.SelectedItem.ToString() == "Delete")
            {
                WarningForm warningForm = new WarningForm();
                warningForm.ShowDialog();
                if (!warningForm.getCheckOK())
                {
                    return;
                }
                result = sql.deleteNamespace(projectName, nameText.Text);
                if (result == 0)
                {
                    namespaceTree = new SetNamespaceTreeView(namespaceTreeView, fileName, projectName);
                    namespaceTree.expandNode(nameText.Text);
                    path = nameText.Text;
                    path = path.Replace(".", @"\");
                    mf.deleteDirectory(projectName + @"\" + path);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Namespace dose not exist.");
                    return;
                }
                else
                {
                    MessageBox.Show("Deleting the Namespace failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Class" && workCombo.SelectedItem.ToString() == "Delete")
            {
                result = sql.deleteClass(projectName, workAtText.Text, nameText.Text);
                if (result == 0)
                {
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    path      = namespaceTree.getPath().Replace(".", @"\");
                    mf.deleteFile(projectName + @"\" + path, nameText.Text);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Class dose not exist.");
                    return;
                }
                else
                {
                    MessageBox.Show("Deleting the Class failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Field" && workCombo.SelectedItem.ToString() == "Delete")
            {
                if (classTree.getClassName() != null)
                {
                    lastClassName = classTree.getClassName();
                }
                result = sql.deleteField(projectName, namespaceTree.getPath(), lastClassName, nameText.Text);
                if (result == 0)
                {
                    path = namespaceTree.getPath().Replace(".", @"\");
                    int    point = namespaceTree.getPath().LastIndexOf(".");
                    string curDir;
                    if (point != -1)
                    {
                        curDir = namespaceTree.getPath().Substring(point + 1);
                    }
                    else
                    {
                        curDir = namespaceTree.getPath();
                    }
                    mf.deleteField(projectName + @"\" + path, lastClassName, nameText.Text);
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    classTree.expandNode(lastClassName);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Field dose not exist.");
                    return;
                }
                else
                {
                    MessageBox.Show("Deleting the Field failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Namespace" && workCombo.SelectedItem.ToString() == "Modify")
            {
                if (namespaceTree.getPath() == null)
                {
                    MessageBox.Show("Click a namespace in View for this work.");
                    return;
                }
                else if (namespaceTree.getPath() == nameText.Text)
                {
                    MessageBox.Show("Input changed name in Name Textbox for this work.");
                    return;
                }
                else if (nameText.Text.LastIndexOf(".") != -1)
                {
                    int    point = nameText.Text.LastIndexOf(".");
                    string temp  = nameText.Text.Substring(0, point);
                    if (namespaceTree.getParentPath() == null || namespaceTree.getParentPath() != temp)
                    {
                        MessageBox.Show("Invalid namespace. Try again appropriately.");
                        return;
                    }
                }
                else if (namespaceTree.getPath().LastIndexOf(".") != -1)
                {
                    MessageBox.Show("Invalid namespace. Try again appropriately.");
                    return;
                }
                result = sql.changeNamespace(projectName, namespaceTree.getPath(), nameText.Text);
                if (result == 0)
                {
                    string oldPath = namespaceTree.getPath().Replace(".", @"\");
                    string newPath = nameText.Text.Replace(".", @"\");
                    mf.modifyDirectory(projectName + @"\" + oldPath, projectName + @"\" + newPath);
                    namespaceTree = new SetNamespaceTreeView(namespaceTreeView, fileName, projectName);
                    namespaceTree.expandNode(nameText.Text);
                    nameText.Text = null;
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Namespace is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Changing the Namespace failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Class" && workCombo.SelectedItem.ToString() == "Modify")
            {
                if (classTree.getClassName() == null)
                {
                    MessageBox.Show("Click a class in View for this work.");
                    return;
                }
                else if (classTree.getClassName() == nameText.Text)
                {
                    MessageBox.Show("Input changed name in Name Textbox for this work.");
                    return;
                }
                result = sql.changeClass(projectName, workAtText.Text, classTree.getClassName(), nameText.Text);
                if (result == 0)
                {
                    path = workAtText.Text.Replace(".", @"\");
                    mf.modifyFile(projectName + @"\" + path, classTree.getClassName(), nameText.Text);
                    classTree     = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    nameText.Text = null;
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Class is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Changing the Class failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Field" && workCombo.SelectedItem.ToString() == "Modify")
            {
                if (classTree.getClassName() != null)
                {
                    lastClassName = classTree.getClassName();
                }
                if (classTree.getFieldName() == null)
                {
                    MessageBox.Show("Click a Field in View for this work.");
                    return;
                }
                else if (typeCombo.SelectedItem == null)
                {
                    MessageBox.Show("Select a field type in Type for this work.");
                    return;
                }
                result = sql.changeField(projectName, namespaceTree.getPath(), classTree.getClassName(), classTree.getFieldName(), nameText.Text, typeCombo.SelectedItem.ToString());
                if (result == 0)
                {
                    path = namespaceTree.getPath().Replace(".", @"\");
                    int    point = namespaceTree.getPath().LastIndexOf(".");
                    string curDir;
                    if (point != -1)
                    {
                        curDir = namespaceTree.getPath().Substring(point + 1);
                    }
                    else
                    {
                        curDir = namespaceTree.getPath();
                    }
                    mf.modifyField(projectName + @"\" + path, classTree.getClassName(), classTree.getFieldName(), nameText.Text, typeCombo.SelectedItem.ToString());
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    classTree.expandNode(lastClassName);
                    nameText.Text = null;
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Field is duplicated.");
                    return;
                }
                else if (result == -3)
                {
                    MessageBox.Show("Input changed value.");
                    return;
                }
                else
                {
                    MessageBox.Show("Changing the Field failed.");
                    return;
                }
            }
            nameText.Focus();
        }
コード例 #13
0
 private void synchronizeDirectory()
 {
     ManageFile mf = new ManageFile();
 }