Example #1
0
        private static void CopyResFiles(string outputPath)
        {
            if (!File.Exists(PATH_CONFIGFILE))
            {
                return;
            }
            string content = File.ReadAllText(PATH_CONFIGFILE);

            ResFiles resFiles = JsonUtility.FromJson <ResFiles>(content);

            foreach (var item in resFiles.items)
            {
                File.Copy(item.assetPath, outputPath + Path.DirectorySeparatorChar + Path.GetFileName(item.name), true);
            }
        }
        /* public void EditEnglish(ResWord word)
         * {
         *  var data = DbContext.ResData
         *      .Where(r => r.FileId == word.ResFile.FileID)
         *      .Where(r => r.Title == word.Title)
         *      .Where(r => r.CultureTitle == "Neutral");
         *
         *  foreach (var d in data)
         *  {
         *      d.TextValue = word.ValueFrom;
         *  }
         *
         *  DbContext.SaveChanges();
         * } */

        /*  public void AddComment(ResWord word)
         * {
         *   var data = DbContext.ResData
         *       .Where(r => r.Title == word.Title)
         *       .Where(r => r.FileId == word.ResFile.FileID)
         *       .Where(r => r.CultureTitle == "Neutral");
         *
         *   foreach (var d in data)
         *   {
         *       d.Description = word.TextComment;
         *   }
         *
         *   DbContext.SaveChanges();
         * } */

        public int AddFile(string fileName, string projectName, string moduleName)
        {
            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);

            if (fileNameWithoutExtension != null && fileNameWithoutExtension.Split('.').Length > 1)
            {
                fileName = fileNameWithoutExtension.Split('.')[0] + Path.GetExtension(fileName);
            }

            var count = DbContext.ResFiles
                        .Where(r => r.ResName == fileName)
                        .Where(r => r.ProjectName == projectName)
                        .Where(r => r.ModuleName == moduleName)
                        .Count();

            if (count == 0)
            {
                var file = new ResFiles
                {
                    ResName     = fileName,
                    ProjectName = projectName,
                    ModuleName  = moduleName
                };

                DbContext.ResFiles.Add(file);
                DbContext.SaveChanges();
            }

            var files      = DbContext.ResFiles.ToList();
            var lastUpdate = DateTime.UtcNow.AddHours(4);

            foreach (var f in files)
            {
                f.LastUpdate = lastUpdate;
            }

            DbContext.SaveChanges();

            return(DbContext.ResFiles
                   .Where(r => r.ResName == fileName)
                   .Where(r => r.ProjectName == projectName)
                   .Where(r => r.ModuleName == moduleName)
                   .Select(r => r.Id)
                   .FirstOrDefault());
        }
Example #3
0
        public void getFiles()
        {
            resFiles = new ResFiles();
            int count = 1;

            try
            {
                Directory.EnumerateFiles(soundDirectory.soundDir);
            }
            catch (DirectoryNotFoundException e)
            {
                getSoundDirectory();
            }
            var soundFiles = Directory.EnumerateFiles(soundDirectory.soundDir);
            var fCount     = (from file in Directory.EnumerateFiles(@soundDirectory.soundDir, "*", SearchOption.AllDirectories) select file).Count();

            foreach (string currentFile in soundFiles)
            {
                int a = 0;
                while (currentFile.IndexOf("\\", a) != -1)
                {
                    a = currentFile.IndexOf("\\", a) + 1;
                }
                if (!countOver)
                {
                    if (count == 1 && resFiles.sound1 == "")
                    {
                        resFiles.sound1 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button1.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 2 && resFiles.sound2 == "")
                    {
                        resFiles.sound2 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button2.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 3 && resFiles.sound3 == "")
                    {
                        resFiles.sound3 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button3.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 4 && resFiles.sound4 == "")
                    {
                        resFiles.sound4 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button4.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 5 && resFiles.sound5 == "")
                    {
                        resFiles.sound5 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button5.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 6 && resFiles.sound6 == "")
                    {
                        resFiles.sound6 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button6.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 7 && resFiles.sound7 == "")
                    {
                        resFiles.sound7 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button7.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 8 && resFiles.sound8 == "")
                    {
                        resFiles.sound8 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button8.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 9 && resFiles.sound9 == "")
                    {
                        resFiles.sound9 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button9.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 10 && resFiles.sound10 == "")
                    {
                        resFiles.sound10 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button10.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 11 && resFiles.sound11 == "")
                    {
                        resFiles.sound11 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button11.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 12 && resFiles.sound12 == "")
                    {
                        resFiles.sound12 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button12.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 13 && resFiles.sound13 == "")
                    {
                        resFiles.sound13 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button13.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 14 && resFiles.sound14 == "")
                    {
                        resFiles.sound14 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button14.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 15 && resFiles.sound15 == "")
                    {
                        resFiles.sound15 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button15.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 16 && resFiles.sound16 == "")
                    {
                        resFiles.sound16 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button16.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 17 && resFiles.sound17 == "")
                    {
                        resFiles.sound17 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button17.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 18 && resFiles.sound18 == "")
                    {
                        resFiles.sound18 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button18.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 19 && resFiles.sound19 == "")
                    {
                        resFiles.sound19 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button19.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 20 && resFiles.sound20 == "")
                    {
                        resFiles.sound20 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button20.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 21 && resFiles.sound21 == "")
                    {
                        resFiles.sound21 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button21.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 22 && resFiles.sound22 == "")
                    {
                        resFiles.sound22 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button22.Text = currentFile.Remove(0, a);
                    }
                    else if (count > 22)
                    {
                        if (nextBool == true)
                        {
                            countOver     = true;
                            button25.Text = "Last Page";
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                if (countOver && fCount > 22)
                {
                    if (count == 23 && resFiles.sound23 == "")
                    {
                        resFiles.sound23 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button1.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 24 && resFiles.sound24 == "")
                    {
                        resFiles.sound24 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button2.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 25 && resFiles.sound25 == "")
                    {
                        resFiles.sound25 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button3.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 26 && resFiles.sound26 == "")
                    {
                        resFiles.sound26 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button4.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 27 && resFiles.sound27 == "")
                    {
                        resFiles.sound27 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button5.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 28 && resFiles.sound28 == "")
                    {
                        resFiles.sound28 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button6.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 29 && resFiles.sound29 == "")
                    {
                        resFiles.sound29 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button7.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 30 && resFiles.sound30 == "")
                    {
                        resFiles.sound30 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button8.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 31 && resFiles.sound31 == "")
                    {
                        resFiles.sound31 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button9.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 32 && resFiles.sound32 == "")
                    {
                        resFiles.sound32 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button10.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 33 && resFiles.sound33 == "")
                    {
                        resFiles.sound33 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button11.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 34 && resFiles.sound34 == "")
                    {
                        resFiles.sound34 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button12.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 35 && resFiles.sound35 == "")
                    {
                        resFiles.sound35 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button13.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 36 && resFiles.sound36 == "")
                    {
                        resFiles.sound36 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button14.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 37 && resFiles.sound37 == "")
                    {
                        resFiles.sound37 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button15.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 38 && resFiles.sound38 == "")
                    {
                        resFiles.sound38 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button16.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 39 && resFiles.sound39 == "")
                    {
                        resFiles.sound39 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button17.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 40 && resFiles.sound40 == "")
                    {
                        resFiles.sound40 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button18.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 41 && resFiles.sound41 == "")
                    {
                        resFiles.sound41 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button19.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 42 && resFiles.sound42 == "")
                    {
                        resFiles.sound42 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button20.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 43 && resFiles.sound43 == "")
                    {
                        resFiles.sound43 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button21.Text = currentFile.Remove(0, a);
                    }
                    else if (count == 44 && resFiles.sound44 == "")
                    {
                        resFiles.sound44 = currentFile;
                        textBox3.AppendText("Button " + count.ToString() + ": " + currentFile.Remove(0, a) + System.Environment.NewLine);
                        button22.Text = currentFile.Remove(0, a);
                    }
                    else if (count > 44)
                    {
                        countOver = false;
                        break;
                    }
                }
                else if (nextBool && fCount < 23)
                {
                    button1.Text  = "";
                    button2.Text  = "";
                    button3.Text  = "";
                    button4.Text  = "";
                    button5.Text  = "";
                    button6.Text  = "";
                    button7.Text  = "";
                    button8.Text  = "";
                    button9.Text  = "";
                    button10.Text = "";
                    button11.Text = "";
                    button12.Text = "";
                    button13.Text = "";
                    button14.Text = "";
                    button15.Text = "";
                    button16.Text = "";
                    button17.Text = "";
                    button18.Text = "";
                    button19.Text = "";
                    button20.Text = "";
                    button21.Text = "";
                    button22.Text = "";
                    textBox3.Text = "";
                    break;
                }
                else if (!(fCount > count))
                {
                    break;
                }
                count++;
            }
        }