Exemplo n.º 1
0
        private void NewTask_Click(object sender, EventArgs e)
        {
            #region ResumeLastTask
            if (Program.TaskInfo.LastTaskPos > 0)
            {
                string[] Existents = new string[0];
                bool     AllExists = true;
                for (uint i = Program.TaskInfo.LastTaskPos; i < Program.TaskInfo.LastTask.LongLength; i++)
                {
                    if (!File.Exists(Program.TaskInfo.LastTask[i]))
                    {
                        AllExists = false;
                    }
                    else
                    {
                        Existents = Existents.AppendArray(Program.TaskInfo.LastTask[i]);
                    }
                }

                if (DialogResult.Yes == MessageBox.Show("You want Continue the last stoped task?", "TLBOT 2", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    if (!AllExists)
                    {
                        string Message = $"Some Files of the last task are not found ({Existents.Length} Founds of {Program.TaskInfo.LastTask.LongLength - Program.TaskInfo.LastTaskPos} Files)\nContinue?";
                        if (DialogResult.Yes != MessageBox.Show(Message, "TLBOT 2", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            return;
                        }

                        Program.TaskInfo = new TaskInfo()
                        {
                            LastTask    = Existents,
                            LastTaskPos = 0
                        };
                    }
                    ProcessFiles(Program.TaskInfo.LastTask, Program.TaskInfo.LastTaskPos);
                    return;
                }
            }
            #endregion

            FilesSelector TaskCreator = new FilesSelector();
            if (TaskCreator.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            ProcessFiles(TaskCreator.SelectedFiles);
        }
Exemplo n.º 2
0
        private void ImportLstBnt_Click(object sender, EventArgs e)
        {
            FilesSelector Selector = new FilesSelector()
            {
                Filter = "*.lst"
            };

            if (DialogResult.OK != Selector.ShowDialog())
            {
                return;
            }
            foreach (string FN in Selector.SelectedFiles)
            {
                using (StreamReader Reader = new StreamReader(FN)) {
                    try {
                        while (Reader.Peek() >= 0)
                        {
                            string L1 = Reader.ReadLine().Unescape();
                            string L2 = Reader.ReadLine().Unescape();
                            if (string.IsNullOrEmpty(L1))
                            {
                                continue;
                            }
                            if (string.IsNullOrEmpty(L2))
                            {
                                continue;
                            }
                            if (Program.Cache.ContainsKey(L1))
                            {
                                continue;
                            }
                            Program.Cache.Add(L1, L2);
                        }
                    } catch { }
                    Reader.Close();
                }
            }

            MessageBox.Show("LST's Imported.", "TLBOT", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 3
0
        private void GenDBBnt_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Select all original scripts", "TLBOT 2", MessageBoxButtons.OK);
            FilesSelector Selector = new FilesSelector();

            if (Selector.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            MessageBox.Show("Select the directory with your translated scripts", "TLBOT 2", MessageBoxButtons.OK);
            CommonOpenFileDialog OFD = new CommonOpenFileDialog();

            OFD.IsFolderPicker = true;
            OFD.Multiselect    = false;
            OFD.Title          = "Select the directory with translated scripts";
            if (OFD.ShowDialog() != CommonFileDialogResult.Ok)
            {
                return;
            }

            string[] Scripts   = Selector.SelectedFiles;
            string   Directory = OFD.FileName;

            if (!Directory.EndsWith("\\"))
            {
                Directory += "\\";
            }

            string LOG   = string.Empty;
            uint   Lines = 0;

            Wrapper Wrapper = new Wrapper();

            foreach (string Script in Scripts)
            {
                string TLFile = Directory + Path.GetFileName(Script);
                if (!File.Exists(TLFile))
                {
                    LOG += $"\n{Path.GetFileName(Script)} Not Found";
                    continue;
                }
                string[] OStrings = Wrapper.Import(Script);
                string[] TStrings = Wrapper.Import(TLFile);
                if (OStrings.Length != TStrings.Length)
                {
                    LOG += $"\n{Path.GetFileName(Script)} Isn't the same script";
                    continue;
                }
                for (uint i = 0; i < OStrings.Length; i++)
                {
                    if (OStrings[i] == TStrings[i])
                    {
                        continue;
                    }
                    Program.Cache[OStrings[i]] = TStrings[i];
                    Lines++;
                }
            }

            if (LOG != string.Empty && Lines == 0)
            {
                MessageBox.Show("Failed to generate the DB" + LOG, "TLBOT 2", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (LOG != string.Empty)
            {
                MessageBox.Show($"\"{Lines}\" Entrys Imported, but...{LOG}", "TLBOT 2", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (Lines == 0)
            {
                MessageBox.Show("Something is wrong...", "TLBOT 2", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show($"\"{Lines}\" Entrys Imported", "TLBOT 2", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }