public static void Main(string[] args) { Huffman huf = new Huffman("acccbbdde"); Console.WriteLine(huf.Encode("abc")); Console.WriteLine(huf.Decode(huf.Encode("abc"))); Console.ReadKey(); }
private void MainWindow1_Loaded(object sender, RoutedEventArgs e) { mi_newfile_Click(sender, e); Settings = Settings.Load(); Settings.LoadAlphabet(); if (Settings.CheckAlphabet()) { Huffman = new Huffman(Settings.LoadCodeCombinations()); } else { Huffman = new Huffman(Settings.Alphabet); Settings.SaveCodeCombinations(Huffman.CodeCombinations); Settings.SaveAlphabet(); Settings.Save(Settings); } }
private void mi_changeAlphabet_Click(object sender, RoutedEventArgs e) { WindowChangeAlphabet = new WindowChangeAlphaber(); WindowChangeAlphabet.Owner = this; WindowChangeAlphabet.ShowDialog(); if(WindowChangeAlphabet.DialogResult.HasValue && WindowChangeAlphabet.DialogResult.Value) { Settings.Alphabet = WindowChangeAlphabet.Alphabet; Huffman = new Huffman(Settings.Alphabet); Settings.SaveCodeCombinations(Huffman.CodeCombinations); Settings.SaveAlphabet(); Settings.Save(Settings); } }