@@ -50,7 +50,7 @@ static void Main(string[] args)
5050 Start :
5151
5252
53- string [ ] Content = new string [ 3 ] { "Login" , "New" , "Public Room (404 not found) "} ;
53+ string [ ] Content = new string [ 2 ] { "Login" , "New" } ;
5454
5555 Tuple < int , string > Tuple = MenuLoop ( Content , BoardDimensions , false ) ;
5656
@@ -66,8 +66,8 @@ static void Main(string[] args)
6666 Tuple = MenuLoop ( Content , BoardDimensions , true ) ;
6767
6868 if ( BadWords . BadWords . list . Any ( Tuple . Item2 . Contains ) ) {
69- Console . WriteLine ( "bad Word Found, Redo Step" ) ;
70- System . Threading . Thread . Sleep ( 5000 ) ;
69+ Console . WriteLine ( "bad Word Found, Redo Step (wait a sec) " ) ;
70+ System . Threading . Thread . Sleep ( 3000 ) ;
7171 goto BadNameUsername ;
7272 }
7373
@@ -81,13 +81,8 @@ static void Main(string[] args)
8181
8282 new User . User ( TempUsername , TempPassword ) . Generate ( ) ;
8383
84- Console . WriteLine ( "Account Made" ) ;
85- System . Threading . Thread . Sleep ( 5000 ) ;
86- goto Start ;
87- } else if ( Tuple . Item1 == 2 ) {
88- Console . WriteLine ( "Public Chat not exist yet" ) ;
89- System . Threading . Thread . Sleep ( 5000 ) ;
90- //Not Valid Account Username
84+ Console . WriteLine ( "Account Made (wait a sec)" ) ;
85+ System . Threading . Thread . Sleep ( 3000 ) ;
9186 goto Start ;
9287 }
9388
@@ -109,13 +104,46 @@ static void Main(string[] args)
109104
110105 if ( ! ( User . User . Exists ( Username ) && User . User . Exists_PublicKey ( CurrentUser . Key . Public ) ) ) {
111106 Console . WriteLine ( "Not The Correct Password" ) ;
112- System . Threading . Thread . Sleep ( 5000 ) ;
107+ Console . WriteLine ( "Login Timeout: 5" ) ;
108+ System . Threading . Thread . Sleep ( 500 ) ;
109+ Console . WriteLine ( "Login Timeout: 4" ) ;
110+ System . Threading . Thread . Sleep ( 500 ) ;
111+ Console . WriteLine ( "Login Timeout: 3" ) ;
112+ System . Threading . Thread . Sleep ( 500 ) ;
113+ Console . WriteLine ( "Login Timeout: 2" ) ;
114+ System . Threading . Thread . Sleep ( 500 ) ;
115+ Console . WriteLine ( "Login Timeout: 1" ) ;
116+ System . Threading . Thread . Sleep ( 500 ) ;
113117 goto Start ;
114118 }
115119
116120 Console . WriteLine ( "Correct Password" ) ;
117121
118- BoardDimensions = CurrentUser . Read_User_BoardSettings ( ) ;
122+
123+
124+ while ( true ) {
125+ Content = new string [ 3 ] { "Private Chat" , "Public Chat (404 not found)" , "Settings" } ;
126+ BoardDimensions = CurrentUser . Read_User_BoardSettings ( ) ;
127+ Tuple = MenuLoop ( Content , BoardDimensions , false ) ;
128+
129+ if ( Tuple . Item1 == 0 ) {
130+ PrivateChat ( CurrentUser ) ;
131+ } else if ( Tuple . Item1 == 1 ) {
132+ Console . WriteLine ( "Not Quite Yet Here" ) ;
133+ System . Threading . Thread . Sleep ( 1000 ) ;
134+ } else if ( Tuple . Item1 == 2 ) {
135+ ChangeSettings ( CurrentUser ) ;
136+ }
137+ }
138+ }
139+
140+
141+
142+
143+ public static void PrivateChat ( User . User CurrentUser ) {
144+ DMSExtras . DMSExtras . TextListener TextListener = new DMSExtras . DMSExtras . TextListener ( ) ;
145+ Tuple < int , string > Tuple = new Tuple < int , string > ( 0 , "" ) ;
146+ Tuple < int , int > BoardDimensions = CurrentUser . Read_User_BoardSettings ( ) ;
119147
120148 ChooseChat :
121149 bool ChooseChatLoop = true ;
@@ -157,7 +185,9 @@ static void Main(string[] args)
157185 for ( int i = 0 ; i < Step - 1 ; i ++ ) {
158186 if ( ( Multiplyer * Step ) + i < var . Length ) {
159187 DisplayedChats [ i ] = var [ ( Multiplyer * Step ) + i ] ;
160- } if ( ( Multiplyer * Step ) + i >= var . Length ) { DisplayedChats [ i ] = "{EMPTY}" ; }
188+ } if ( ( Multiplyer * Step ) + i >= var . Length ) {
189+ DisplayedChats [ i ] = "{EMPTY}" ;
190+ }
161191 }
162192 DisplayedChats [ Step - 1 ] = "Go Back" ;
163193 DisplayedChats [ Step ] = "Next (pg " + Multiplyer + "/" + Math . Ceiling ( ( decimal ) ( var . Length / Step ) ) + ")" ;
@@ -175,30 +205,14 @@ static void Main(string[] args)
175205 CurrentUser . Generate_Chat ( DisplayedChats [ Tuple . Item1 ] ) ;
176206 }
177207 }
178-
179-
180-
181208 string SelectedChat = DisplayedChats [ Tuple . Item1 ] ;
182-
209+ string OtherUser = SelectedChat ;
183210 SelectedChat = CurrentUser . Read_Messages_FileName ( SelectedChat ) ;
184-
185-
186211 string [ ] ChatContent = File . ReadLines ( @"chats\" + SelectedChat + ".txt" ) . ToArray ( ) ;
187-
188-
189212 string [ ] DecryptedChatContent = CurrentUser . Read_Messages_Chat ( ChatContent ) ;
190-
191- //User.Display.Content(DecryptedChatContent);
192-
193213 Tuple < string , string > SymmetricKey = CurrentUser . Read_Chat_SymmetricKey ( ChatContent ) ;
194-
195-
196- // while (true) { System.Threading.Thread.Sleep(5000); }
197-
198-
199- PrivateChatLoop ( SelectedChat , BoardDimensions , CurrentUser , SymmetricKey ) ;
200-
201-
214+ TextListener . StopListening ( ) ;
215+ PrivateChatLoop ( SelectedChat , BoardDimensions , CurrentUser , SymmetricKey , OtherUser ) ;
202216 }
203217
204218
@@ -246,7 +260,7 @@ public static Tuple<int, string> MenuLoop(string[] Content, Tuple<int,int> Board
246260 return new Tuple < int , string > ( Pointer , TypedText ) ;
247261 }
248262
249- public static void PrivateChatLoop ( string SelectedChat , Tuple < int , int > BoardDimensions , User . User CurrentUser , Tuple < string , string > SymmetricKey ) {
263+ public static void PrivateChatLoop ( string SelectedChat , Tuple < int , int > BoardDimensions , User . User CurrentUser , Tuple < string , string > SymmetricKey , string OtherUser ) {
250264 DMSExtras . DMSExtras . TextListener TextListener = new DMSExtras . DMSExtras . TextListener ( ) ;
251265 DMSExtras . DMSExtras . ChatListener ChatListener = new DMSExtras . DMSExtras . ChatListener ( ) ;
252266
@@ -273,16 +287,19 @@ public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDim
273287 TextListener . StartListening ( ) ;
274288 while ( true )
275289 {
276- // Console.WriteLine("start");
290+
277291 Thread . Sleep ( 50 ) ;
278292
279293 if ( TextListener . GetEndProgram ( ) && ! string . IsNullOrEmpty ( TypedText ) ) {
280294
281295 if ( BadWords . BadWords . list . Any ( TypedText . Contains ) ) {
282296 Console . WriteLine ( "bad Word Found, Message not Sent" ) ;
283297 System . Threading . Thread . Sleep ( 1000 ) ;
298+ TextListener . StopListening ( ) ;
299+ TextListener . SetEndProgram ( false ) ;
300+ TextListener . StartListening ( ) ;
284301 } else {
285- CurrentUser . Write_Messages_Chat ( SymmetricKey , SelectedChat , TypedText ) ;
302+ CurrentUser . Write_Messages_Chat ( SymmetricKey , SelectedChat , "[" + CurrentUser . Username + "] " + TypedText ) ;
286303
287304 TextListener . StopListening ( ) ;
288305 TextListener . SetTypedText ( "" ) ;
@@ -297,7 +314,7 @@ public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDim
297314
298315 TypedText = TextListener . GetTypedText ( ) ;
299316
300- User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true ) ;
317+ User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true , OtherUser ) ;
301318 // Console.WriteLine("text end");
302319
303320 }
@@ -309,12 +326,98 @@ public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDim
309326 ChatMessages = ChatListener . GetChatContent ( ) ;
310327 DecryptedMessages = CurrentUser . Read_Messages_Chat ( ChatMessages ) ;
311328
312-
313- User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true ) ;
329+ User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true , OtherUser ) ;
314330 // Console.WriteLine("chat end");
315331
316332 }
317333 // Console.WriteLine("end");
318334 }
319335 }
336+
337+ public static void ChangeSettings ( User . User CurrentUser ) {
338+ Tuple < int , int > BoardDimensions = CurrentUser . Read_User_BoardSettings ( ) ;
339+ DMSExtras . DMSExtras . TextListener TextListener = new DMSExtras . DMSExtras . TextListener ( ) ;
340+ string connectionString = "Data Source=UserList.db;Version=3;" ;
341+
342+ string [ ] Content = new string [ 3 ] { "Exit Settings" , "Width: " + BoardDimensions . Item1 , "Height: " + BoardDimensions . Item2 } ;
343+
344+ TextListener . SetPointer ( 0 ) ;
345+ TextListener . SetTypedText ( " " ) ;
346+ TextListener . SetEndProgram ( false ) ;
347+
348+ int Pointer = 0 ;
349+ string TypedText = " " ;
350+ int TempInt = 0 ;
351+ string TempString = "" ;
352+ var Value = 0 ;
353+
354+ User . User . Display . With . Pointer ( Content , BoardDimensions , Pointer , TypedText ) ;
355+
356+ TextListener . StartListening ( ) ;
357+
358+ while ( true ) {
359+ Thread . Sleep ( 50 ) ;
360+ // Console.WriteLine(Pointer);
361+ if ( TypedText != TextListener . GetTypedText ( ) ) {
362+
363+ TypedText = TextListener . GetTypedText ( ) ;
364+
365+ User . User . Display . With . Pointer ( Content , BoardDimensions , Pointer , TypedText ) ;
366+ }
367+
368+ if ( Pointer != TextListener . GetPointer ( ) ) {
369+
370+ Pointer = TextListener . GetPointer ( ) ;
371+
372+ if ( Pointer >= Content . Length ) {
373+ TextListener . SetPointer ( 0 ) ;
374+ } else if ( Pointer < 0 ) {
375+ TextListener . SetPointer ( Content . Length - 1 ) ;
376+ }
377+
378+ User . User . Display . With . Pointer ( Content , BoardDimensions , Pointer , TypedText ) ;
379+
380+ }
381+
382+ if ( TextListener . GetEndProgram ( ) ) {
383+ if ( Pointer == 0 ) {
384+ TextListener . StopListening ( ) ;
385+ return ;
386+ } else if ( Pointer == 1 ) {
387+ if ( int . TryParse ( TypedText , out TempInt ) ) {
388+ Value = int . Parse ( TypedText ) ;
389+ } else {
390+ Value = 25 ;
391+ }
392+ TempString = "Width" ;
393+ } else if ( Pointer == 2 ) {
394+ if ( int . TryParse ( TypedText , out TempInt ) ) {
395+ Value = int . Parse ( TypedText ) ;
396+ } else {
397+ Value = 25 ;
398+ }
399+ TempString = "Height" ;
400+ }
401+
402+ using ( SQLiteConnection connection = new SQLiteConnection ( connectionString ) )
403+ {
404+ connection . Open ( ) ;
405+ string sql = "UPDATE Main SET " + TempString + " = @newValue WHERE Username = @username" ;
406+ using ( SQLiteCommand command = new SQLiteCommand ( sql , connection ) )
407+ {
408+ command . Parameters . AddWithValue ( "@newValue" , Value ) ;
409+ command . Parameters . AddWithValue ( "@username" , CurrentUser . Username ) ;
410+ command . ExecuteNonQuery ( ) ;
411+ }
412+ }
413+
414+ TextListener . StopListening ( ) ;
415+ TextListener . SetEndProgram ( false ) ;
416+ TextListener . SetTypedText ( " " ) ;
417+ TextListener . StartListening ( ) ;
418+ BoardDimensions = CurrentUser . Read_User_BoardSettings ( ) ;
419+ Content = new string [ 3 ] { "Exit" , "Width: " + BoardDimensions . Item1 , "Height: " + BoardDimensions . Item2 } ;
420+ }
421+ }
422+ }
320423}
0 commit comments