Ejemplo n.º 1
0
        private void ArtBtnDe_Click(object sender, RoutedEventArgs e)
        {
            string txt = EnTxtEn.Text;

            byte[]       bytes = Encoding.ASCII.GetBytes(txt);
            ArithmeticCl ar    = new ArithmeticCl(bytes);

            double res = Convert.ToDouble(DeTxtEn.Text);

            string w = ar.Decode(res, false);

            DeTxtRes.Text = w;
        }
Ejemplo n.º 2
0
        private void ArtBtnEn_Click(object sender, RoutedEventArgs e)
        {
            EnTxtRes.Text = "";

            string txt = EnTxtEn.Text;

            byte[] bytes = Encoding.ASCII.GetBytes(txt);

            ArithmeticCl ar     = new ArithmeticCl(bytes);
            List <float> result = ar.Encode();

            foreach (var item in result)
            {
                EnTxtRes.Text += item.ToString() + "\n";
            }
        }
Ejemplo n.º 3
0
        private void FileBtnEn_Click(object sender, RoutedEventArgs e)
        {
            byte[]         file;
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = @"K:\PROJEKTY VS\GolombCoding\GolombCoding\bin";
            openFileDialog.DefaultExt       = ".txt";
            openFileDialog.Filter           = "Text documents (.txt)|*.txt";
            openFileDialog.Multiselect      = false;

            if (openFileDialog.ShowDialog() == true)
            {
                file = File.ReadAllBytes(openFileDialog.FileName);
            }
            else
            {
                file = new byte[] { }
            };

            ArithmeticCl ar = new ArithmeticCl(file);

            globalArithmetic = new ArithmeticCl(file);
            List <float> result = ar.Encode();

            TextWriter tw = new StreamWriter(@"..\ArtEncode.txt");
            int        i  = 0;

            while (result[i] != 0)
            {
                string s = result[i].ToString().Substring(2);
                tw.Write(s);
                i++;
            }

            tw.Close();
        }