Пример #1
0
        private void savel2ini_Click(object sender, EventArgs e)
        {
            if (selectedIniComboName == null || selectedIniIntFile == null)
            {
                return;
            }

            Lineage2Ver ver = (Lineage2Ver)selectedIniIntFile.GetType().GetField(selectedIniIntFile.ToString()).GetCustomAttributes(typeof(Lineage2Ver), true)[0];

            string dst_fname = Path.Combine(RConfig.Instance.LineageDirectory, selectedIniComboName);

            if (RConfig.Instance.SaveBakFiles)
            {
                try
                {
                    if (File.Exists(Path.ChangeExtension(dst_fname, ".bak")))
                    {
                        File.Delete(Path.ChangeExtension(dst_fname, ".bak"));
                    }

                    File.Move(dst_fname, Path.ChangeExtension(dst_fname, ".bak"));
                }
                catch
                {
                }
            }

            IniTextBox.SaveFile(dst_fname, RichTextBoxStreamType.PlainText);

            L2EncDec.Encrypt(selectedIniComboName, ver.Ver);

            clearl2ini_Click(sender, e);
        }
Пример #2
0
        private void OpenIniButton_Click(object sender, EventArgs e)
        {
            if (selectedIniComboName == null || selectedIniIntFile == null)
            {
                return;
            }

            Lineage2Ver ver = (Lineage2Ver)selectedIniIntFile.GetType().GetField(selectedIniIntFile.ToString()).GetCustomAttributes(typeof(Lineage2Ver), true)[0];

            // пожалуста подождите
            StatusLabel.Text = Localizate.getMessage(Word.PLEASE_WAIT);

            if (!File.Exists(Path.Combine(RConfig.Instance.LineageDirectory, selectedIniComboName)))
            {
                StatusLabel.Text = Localizate.getMessage(Word.ERROR) + " " + Localizate.getMessage(Word.FILE_NOT_FOUND);
                return;
            }

            try
            {
                BinaryReader f = L2EncDec.Decrypt(selectedIniComboName, Encoding.Default);
                if (f == null)
                {
                    return;
                }
                char[] IniText = f.ReadChars((int)f.BaseStream.Length);
                f.Close();
                IniTextBox.Text = new String(IniText);
            }
            catch (Exception ex)
            {
                _log.Info("Exception: " + ex, ex);
            }
            finally
            {
                Enabled = true;
                FileNameCombo.Enabled = true;
                savel2ini.Enabled     = true;
                clearl2ini.Enabled    = true;
                IniTextBox.Enabled    = true;
                EnCod.Text            = ver.Ver.ToString();
                Char     c  = '\n';
                String[] st = IniTextBox.Text.Split(c);
                Counts.Text = st.Length.ToString();
                IniTextBox.Update();
            }
            StatusLabel.Text = "";
        }