Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.ShowDialog();
            File        = new D2IFile(dialog.FileName);
            this.Values = File.GetAllText();
            BindDataSource((from item in Values select new { Item = item.Key, Price = item.Value }).ToArray());
        }
Пример #2
0
        private void Open()
        {
            var uiTexts = m_file.GetAllUiText();

            foreach (var uiText in uiTexts)
            {
                m_rows.Add(new D2ITextUiRow(uiText.Key, uiText.Value));
            }

            var texts = m_file.GetAllText();

            foreach (var text in texts)
            {
                m_rows.Add(new D2ITextRow(text.Key, text.Value));
            }
            m_highestId = texts.Keys.Max();
        }
Пример #3
0
        public static void ReadD2IFiles()
        {
            var langs   = Program._accessor.Database.Query <LangText>(LangTextRelator.FetchQuery, new object[0]).ToDictionary(entry => entry.Id);
            var langsUI = Program._accessor.Database.Query <LangTextUi>(LangTextUiRelator.FetchQuery, new object[0]).ToDictionary(entry => entry.Name);

            foreach (var item in Directory.GetFiles(string.Format(@"{0}\app\data\i18n\", _clientPath), "*.d2i*", SearchOption.TopDirectoryOnly))
            {
                var match = Regex.Match(Path.GetFileName(item), "i18n_(?<lang>[a-zA-Z]{2}).d2i");
                if (match.Success)
                {
                    var d2iFile = new D2IFile(item);

                    Action <LangText, string>   langAction   = null;
                    Action <LangTextUi, string> langUIAction = null;

                    switch (match.Groups["lang"].Value)
                    {
                    case "de":
                        langAction   = new Action <LangText, string>((lang, value) => { lang.Dutsh = value; });
                        langUIAction = new Action <LangTextUi, string>((lang, value) => { lang.Dutsh = value; });
                        break;

                    case "en":
                        langAction   = new Action <LangText, string>((lang, value) => { lang.English = value; });
                        langUIAction = new Action <LangTextUi, string>((lang, value) => { lang.English = value; });
                        break;

                    case "es":
                        langAction   = new Action <LangText, string>((lang, value) => { lang.Spanish = value; });
                        langUIAction = new Action <LangTextUi, string>((lang, value) => { lang.Spanish = value; });
                        break;

                    case "fr":
                        langAction   = new Action <LangText, string>((lang, value) => { lang.French = value; });
                        langUIAction = new Action <LangTextUi, string>((lang, value) => { lang.French = value; });
                        break;

                    case "it":
                        langAction   = new Action <LangText, string>((lang, value) => { lang.Italian = value; });
                        langUIAction = new Action <LangTextUi, string>((lang, value) => { lang.Italian = value; });
                        break;

                    case "ja":
                        langAction   = new Action <LangText, string>((lang, value) => { lang.Japanish = value; });
                        langUIAction = new Action <LangTextUi, string>((lang, value) => { lang.Japanish = value; });
                        break;

                    case "pt":
                        langAction   = new Action <LangText, string>((lang, value) => { lang.Portugese = value; });
                        langUIAction = new Action <LangTextUi, string>((lang, value) => { lang.Portugese = value; });
                        break;

                    case "ru":
                        langAction   = new Action <LangText, string>((lang, value) => { lang.Russish = value; });
                        langUIAction = new Action <LangTextUi, string>((lang, value) => { lang.Russish = value; });
                        break;

                    default:
                        break;
                    }

                    foreach (var lang in d2iFile.GetAllText())
                    {
                        if (!langs.ContainsKey((uint)lang.Key))
                        {
                            langs.Add((uint)lang.Key, new LangText {
                                Id = (uint)lang.Key
                            });
                        }

                        langAction(langs[(uint)lang.Key], lang.Value);
                    }
                    foreach (var langUi in d2iFile.GetAllUiText())
                    {
                        if (!langsUI.ContainsKey(langUi.Key))
                        {
                            langsUI.Add(langUi.Key, new LangTextUi {
                                Name = langUi.Key
                            });
                        }

                        langUIAction(langsUI[langUi.Key], langUi.Value);
                    }
                }
            }

            foreach (var item in langs)
            {
                Program._accessor.Database.Insert(item.Value);
            }
            foreach (var item in langsUI)
            {
                Program._accessor.Database.Insert(item.Value);
            }
        }