Пример #1
0
        private void importAllOneFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_DataMessage.Count() <= 0 || _IsBusy)
            {
                return;
            }
            string jsonFile = DiaglogManager.FileBrowser("export.json", "JSON files (*.json)|*.json");

            if (string.IsNullOrEmpty(jsonFile))
            {
                return;
            }
            _IsBusy = true;
            Task.Run(() =>
            {
                try
                {
                    Operation.ImportJSON(jsonFile, this.progressBar);
                }
                catch (Exception err)
                {
                    _IsBusy = false;
                    MessageBox.Show($"An error occurred:\n\n{err.Message}", _MessageBoxTitle);
                }
            }).GetAwaiter().OnCompleted(() => { _IsBusy = false; });
        }
Пример #2
0
        private void exportAllOneFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_DataMessage.Count() <= 0 || _IsBusy)
            {
                return;
            }
            string fileName = DiaglogManager.SaveFile("Sqex03DataMessage.txt", "Text files (*.txt)|*.txt|All files (*.*)|*.*");

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            _IsBusy = true;
            Task.Run(() =>
            {
                try
                {
                    Operation.ExportAll(fileName, _DataMessage, this.progressBar);
                }
                catch (Exception err)
                {
                    _IsBusy = false;
                    MessageBox.Show($"An error occurred:\n\n{err.Message}", _MessageBoxTitle);
                }
            }).GetAwaiter().OnCompleted(() => { _IsBusy = false; });
        }
Пример #3
0
        private void importAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_DataMessage.Count() <= 0 || _IsBusy)
            {
                return;
            }
            string dir = DiaglogManager.FolderBrowser("Export");

            if (string.IsNullOrEmpty(dir))
            {
                return;
            }
            _IsBusy = true;
            Task.Run(() =>
            {
                try
                {
                    Operation.ImportDirectory(dir, this.progressBar);
                }
                catch (Exception err)
                {
                    _IsBusy = false;
                    MessageBox.Show($"An error occurred:\n\n{err.Message}", _MessageBoxTitle);
                }
            }).GetAwaiter().OnCompleted(() => { _IsBusy = false; });
        }
Пример #4
0
        private void btnSelectGameLocation_Click(object sender, EventArgs e)
        {
            string folderPath = DiaglogManager.FolderBrowser("Drakengard 3");

            if (!string.IsNullOrEmpty(folderPath))
            {
                txtBoxGameLocation.Text = folderPath;
                if (_JsonConfig.ContainsKey("GameLocation"))
                {
                    _JsonConfig["GameLocation"] = folderPath;
                }
                else
                {
                    _JsonConfig.Add("GameLocation", folderPath);
                }
                string configStr = new JavaScriptSerializer().Serialize(_JsonConfig);
                try
                {
                    File.WriteAllText(_ConfigFile, configStr);
                }
                catch (Exception err)
                {
                    MessageBox.Show($"An error occurred:\n\n{err.Message}", _MessageBoxTitle);
                }
            }
        }
Пример #5
0
        public static void Export(DataMessage dataMessage)
        {
            List <string> messages = new List <string>();

            if (dataMessage.Speakers == null)
            {
                messages = dataMessage.Strings;
            }
            else
            {
                for (int i = 0; i < dataMessage.Strings.Count; i++)
                {
                    messages.Add($"{dataMessage.Strings[i]}{(char)123}#Name={(char)34}{dataMessage.Speakers[i].Name}{(char)34}{(char)125}");
                }
            }
            byte[] data      = Encoding.UTF8.GetBytes(String.Join("\r\n", messages.ToArray()));
            Thread newThread = new Thread(new ThreadStart(() =>
            {
                string fileName = DiaglogManager.SaveFile($"{dataMessage.Name}", "Text files (*.txt)|*.txt|All files (*.*)|*.*");
                if (!string.IsNullOrEmpty(fileName))
                {
                    File.WriteAllBytes(fileName, data);
                }
            }));

            newThread.SetApartmentState(ApartmentState.STA);
            newThread.Start();
            newThread.Join();
        }
Пример #6
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_DataMessage.Count() <= 0 || _IsBusy || listFiles.SelectedIndex <= -1)
            {
                return;
            }
            int    index      = listFiles.SelectedIndex;
            string fileName   = _DataMessage[index].Name;
            string fileImport = DiaglogManager.FileBrowser(fileName, "Text files (*.txt)|*.txt|All files (*.*)|*.*");

            if (string.IsNullOrEmpty(fileImport))
            {
                return;
            }
            _IsBusy = true;
            Task.Run(() =>
            {
                try
                {
                    double percent = 100.0 / _DataMessage[index].Strings.Count;
                    string[] lines = File.ReadAllLines(fileImport);
                    for (int i = 0; i < _DataMessage[index].Strings.Count; i++)
                    {
                        if (lines[i].Contains("{#Name="))
                        {
                            lines[i] = lines[i].Split(new string[] { "{#Name=" }, StringSplitOptions.None).First();
                        }
                        _DataMessage[index].Strings[i] = lines[i];
                        percent += 100.0 / _DataMessage[index].Strings.Count;
                        Operation.ProgressBar(this.progressBar, (int)percent);
                    }
                }
                catch (Exception err)
                {
                    _IsBusy = false;
                    MessageBox.Show($"An error occurred:\n\n{err.Message}", _MessageBoxTitle);
                }
            }).GetAwaiter().OnCompleted(() => { _IsBusy = false; });
        }