@@ -18,6 +18,7 @@ public partial class MainWindow : Window
1818 "Словарный метод сжатия LZ77" , "Код Хемминга" , "Линейный код тима (5,2)" , "Словарный метод сжатия LZ78" } ;
1919 int IndexOfCurrentAlgorithm = 0 ;
2020 List < Border > Borders = new List < Border > ( ) ;
21+ bool ExtendedAlgm = false ;
2122 public MainWindow ( )
2223 {
2324 InitializeComponent ( ) ;
@@ -106,6 +107,13 @@ private void LinearCodesType52ClicButton(object sender, RoutedEventArgs e)
106107 //_Border.Visibility = Visibility.Visible;
107108 }
108109
110+ private void ExtendedEncodeClicButton ( object sender , RoutedEventArgs e )
111+ {
112+ ExtendedAlgm = true ;
113+ EncodeClicButton ( sender , e ) ;
114+ ExtendedAlgm = false ;
115+ }
116+
109117 private void EncodeClicButton ( object sender , RoutedEventArgs e )
110118 {
111119 string str = "" ;
@@ -116,7 +124,7 @@ private void EncodeClicButton(object sender, RoutedEventArgs e)
116124 TextAfterDecoding . Text = string . Empty ;
117125 if ( TextForEncoding . Text . Length == 0 ) { NoTextForEncoding = true ; break ; }
118126
119- var Huf = HuffmanAlgm . Encode ( TextForEncoding . Text ) ;
127+ var Huf = HuffmanAlgm . Encode ( TextForEncoding . Text , ExtendedAlgm ) ;
120128 EncodedText . Text = Huf . ToString ( ) ;
121129 foreach ( var i in Huf . GetData ( ) )
122130 str += i . Key . ToString ( ) + " " + i . Value . ToString ( ) + '\n ' ;
@@ -127,7 +135,7 @@ private void EncodeClicButton(object sender, RoutedEventArgs e)
127135 TextAfterDecoding . Text = string . Empty ;
128136 if ( TextForEncoding . Text . Length == 0 ) { NoTextForEncoding = true ; break ; }
129137
130- var Sha = ShannonFanoAlgm . Encode ( TextForEncoding . Text ) ;
138+ var Sha = ShannonFanoAlgm . Encode ( TextForEncoding . Text , ExtendedAlgm ) ;
131139 EncodedText . Text = Sha . ToString ( ) ;
132140 foreach ( var i in Sha . GetData ( ) )
133141 str += i . Key . ToString ( ) + " " + i . Value . ToString ( ) + '\n ' ;
@@ -138,7 +146,7 @@ private void EncodeClicButton(object sender, RoutedEventArgs e)
138146 TextAfterDecoding . Text = string . Empty ;
139147 if ( TextForEncoding . Text . Length == 0 ) { NoTextForEncoding = true ; break ; }
140148
141- var Ari = ArithmeticCodingAlgm . Encode ( TextForEncoding . Text ) ;
149+ var Ari = ArithmeticCodingAlgm . Encode ( TextForEncoding . Text , ExtendedAlgm ) ;
142150 EncodedText . Text = Ari . ToString ( ) ;
143151 foreach ( var i in Ari . GetData ( ) . GetData ( ) )
144152 str += i . Key . ToString ( ) + " " + i . Value . ToString ( ) + '\n ' ;
@@ -149,23 +157,23 @@ private void EncodeClicButton(object sender, RoutedEventArgs e)
149157 Text1AfterDecoding . Text = string . Empty ;
150158 if ( Text1ForEncoding . Text . Length == 0 ) { NoTextForEncoding = true ; break ; }
151159
152- var Rle = RLEAlgm . Encode ( Text1ForEncoding . Text ) ;
160+ var Rle = RLEAlgm . Encode ( Text1ForEncoding . Text , ExtendedAlgm ) ;
153161 Encoded1Text . Text = Rle . ToString ( ) ;
154162 CompressionRatio1 . Text = Rle . GetCompressionRatio ( ) . ToString ( ) ;
155163 break ;
156164 case 4 :
157165 Text1AfterDecoding . Text = string . Empty ;
158166 if ( Text1ForEncoding . Text . Length == 0 ) { NoTextForEncoding = true ; break ; }
159167
160- var Lz = LZ77Algm . Encode ( Text1ForEncoding . Text ) ;
168+ var Lz = LZ77Algm . Encode ( Text1ForEncoding . Text , ExtendedAlgm ) ;
161169 Encoded1Text . Text = Lz . ToString ( ) ;
162170 CompressionRatio1 . Text = Lz . GetCompressionRatio ( ) . ToString ( ) ;
163171 break ;
164172 case 5 :
165173 Text2AfterDecoding . Text = string . Empty ;
166174 if ( Text2ForEncoding . Text . Length == 0 ) { NoTextForEncoding = true ; break ; }
167175
168- var Ham = HammingAlgm . Encode ( Text2ForEncoding . Text ) ;
176+ var Ham = HammingAlgm . Encode ( Text2ForEncoding . Text , ExtendedAlgm ) ;
169177 Encoded2Text . Text = Ham . ToString ( ) ;
170178 break ;
171179 case 6 :
@@ -174,7 +182,7 @@ private void EncodeClicButton(object sender, RoutedEventArgs e)
174182 Text1AfterDecoding . Text = string . Empty ;
175183 if ( Text1ForEncoding . Text . Length == 0 ) { NoTextForEncoding = true ; break ; }
176184
177- var Lz78 = LZ78Algm . Encode ( Text1ForEncoding . Text ) ;
185+ var Lz78 = LZ78Algm . Encode ( Text1ForEncoding . Text , ExtendedAlgm ) ;
178186 Encoded1Text . Text = Lz78 . ToString ( ) ;
179187 CompressionRatio1 . Text = Lz78 . GetCompressionRatio ( ) . ToString ( ) ;
180188 break ;
0 commit comments