public Decompress(string compressMessage, int dictSize)
 {
     InitializeComponent();
     messageBox.Text = compressMessage;
     lz = new LZ77()
     {
         DictionarySize = dictSize
     };
 }
Esempio n. 2
0
 private void btnDecode_Click(object sender, EventArgs e)
 {
     if (compressedFileName != "")
     {
         coder = new LZ77();
         var ok = coder.decompress(compressedFileName);
         if (ok == true)
         {
             tbTokens.Text += "\r\nDecompression was a great success.\r\n";
         }
     }
     else
     {
         throw new Exception("You haven't selecetd any file.");
     }
 }
Esempio n. 3
0
        private void compressButton_Click(object sender, EventArgs e)
        {
            LZ77 lz     = new LZ77();
            int  result = 0;

            if (dictionarySizeBox.Text != String.Empty)
            {
                if (Int32.TryParse(dictionarySizeBox.Text, out result))
                {
                    lz.DictionarySize = result;
                }
                else
                {
                    MessageBox.Show("Ошибка в размере словаря");
                }
            }
            if (bufferSizeBox.Text != String.Empty)
            {
                if (Int32.TryParse(bufferSizeBox.Text, out result))
                {
                    lz.BufferSize = result;
                }
                else
                {
                    MessageBox.Show("Ошибка в размере буфера");
                }
            }
            dictionarySizeBox.Text = lz.DictionarySize.ToString();
            bufferSizeBox.Text     = lz.BufferSize.ToString();
            string compressMessage = lz.Compression(messageBox.Text);

            informBox.Text = compressMessage;
            Decompress window = new Decompress(compressMessage, lz.DictionarySize);

            window.Show();
        }