@@ -118,9 +118,9 @@ public void Generate_Chat(string Name) {
118118 writer . WriteLine (
119119 this . Username +
120120 ":" +
121- this . Key . Encrypt ( SymmetricKey . Item1 , User . Read_User_PublicKey ( Name ) ) +
121+ this . Key . Encrypt ( SymmetricKey . Item1 , User . Read_User_PublicKey ( this . Username ) ) +
122122 ":" +
123- this . Key . Encrypt ( SymmetricKey . Item2 , User . Read_User_PublicKey ( Name ) )
123+ this . Key . Encrypt ( SymmetricKey . Item2 , User . Read_User_PublicKey ( this . Username ) )
124124 ) ;
125125
126126 // User.Read_User_PublicKey(Name);
@@ -208,9 +208,7 @@ public string[] Read_Messages_Chat(string[] EncryptedMessages) {
208208
209209
210210 for ( int i = 2 ; i < EncryptedMessages . Length ; i ++ ) {
211-
212211 DecryptedMessages [ i - 2 ] = SymmetricEncryption . DecryptString ( SymmetricKey . Item1 , EncryptedMessages [ i ] , SymmetricKey . Item2 ) ;
213-
214212 }
215213
216214 return DecryptedMessages ;
@@ -322,6 +320,33 @@ public static string Read_User_PublicKey(string User) {
322320 }
323321 }
324322
323+ public Tuple < int , int > Read_User_BoardSettings ( ) {
324+ string User = this . Username ;
325+ var conn = new SQLiteConnection ( @"Data Source=UserList.db;Version=3;" ) ;
326+ conn . Open ( ) ;
327+
328+ string stm = "SELECT Width, Height FROM Main WHERE Username = @username" ;
329+ var cmd = new SQLiteCommand ( stm , conn ) ;
330+ cmd . Parameters . AddWithValue ( "@username" , User ) ;
331+
332+ SQLiteDataReader rdr = cmd . ExecuteReader ( ) ;
333+
334+ if ( rdr . Read ( ) )
335+ {
336+ //string TempString2 = rdr.GetString(0);
337+ Tuple < int , int > BoardDimensions = new Tuple < int , int > ( rdr . GetInt32 ( 0 ) , rdr . GetInt32 ( 1 ) ) ;
338+ rdr . Close ( ) ;
339+ return BoardDimensions ;
340+ }
341+ else
342+ {
343+ while ( true ) {
344+ Console . WriteLine ( "error at chat Read_User_BoardSettings (Width)" ) ;
345+ Console . Read ( ) ;
346+ }
347+ }
348+ }
349+
325350 public class Display
326351 {
327352 public class With
@@ -356,8 +381,33 @@ public static void Content(string[] Content, Tuple<int, int> BoardDimensions, st
356381 Board = Square . Create ( new Square ( Board . Width , Board . Height , Tuple . Create ( 0 , 0 ) ) , Board ) ;
357382
358383 if ( IfChat ) {
359- for ( int i = Content . Length - 1 ; i >= 0 ; i -- ) {
360- Board = Text . Create ( new Text ( Tuple . Create ( 2 , 2 - ( i - ( Content . Length - 1 ) ) ) , Content [ i ] ) , Board ) ;
384+ int Interval = ( BoardDimensions . Item1 - 3 ) * 2 ; // your interval
385+ List < string > DisplayedMessages = new List < string > ( ) ; // we use a List for simplicity, you can convert it to an array later
386+
387+ foreach ( string message in Content )
388+ {
389+ if ( message . Length > Interval )
390+ {
391+ int startIndex = 0 ;
392+ while ( startIndex < message . Length )
393+ {
394+ int length = Math . Min ( Interval , message . Length - startIndex ) ;
395+ DisplayedMessages . Add ( message . Substring ( startIndex , length ) ) ;
396+ startIndex += length ;
397+ }
398+ }
399+ else
400+ {
401+ DisplayedMessages . Add ( message ) ;
402+ }
403+ }
404+
405+ string [ ] DisplayedMessagesArray = DisplayedMessages . ToArray ( ) ; // if you need an array
406+ Array . Reverse ( DisplayedMessagesArray ) ;
407+
408+ int VerticalBorder = 5 ;
409+ for ( int i = 0 ; ( i < BoardDimensions . Item2 - VerticalBorder ) && ( i < DisplayedMessagesArray . Length ) ; i ++ ) {
410+ Board = Text . Create ( new Text ( Tuple . Create ( 2 , 2 + i ) , DisplayedMessagesArray [ i ] ) , Board ) ;
361411 }
362412 } else {
363413 for ( int i = 0 ; i < Content . Length ; i ++ ) {
0 commit comments