[chronojump] Chronopic win detects also disconnected Chronopics



commit ef40a87076f68da5861e2a3728f2efdb81e76d99
Author: Xavier de Blas <xaviblas master gnome org>
Date:   Wed Jun 2 16:31:06 2010 +0800

    Chronopic win detects also disconnected Chronopics

 src/gui/chronopic.cs |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index 6aac2cf..d0a35f6 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -177,6 +177,7 @@ public class ChronopicWindow
 		}
 		
 		ChronopicWindowBox.volumeOn = volumeOn;
+		ChronopicWindowBox.checkChronopicDisconnected();
 		ChronopicWindowBox.createCombos();
 		ChronopicWindowBox.chronopic_window.Show();
 	
@@ -216,6 +217,52 @@ public class ChronopicWindow
 		image_cp4_yes.Hide();
 	}
 	
+	//check if user has disconnected chronopic or port has changed
+	private void checkChronopicDisconnected() {
+		foreach(ChronopicPortData a in cpd) {
+			Chronopic myCP;
+			Chronopic.Plataforma myPS;
+			if(a.Num == 1) {
+				myCP = cp;
+				myPS = platformState;
+			} else if(a.Num == 2) {
+				myCP = cp2;
+				myPS = platformState2;
+			} else if(a.Num == 3) {
+				myCP = cp3;
+				myPS = platformState3;
+			} else { //if(a.Num == 4) {
+				myCP = cp4;
+				myPS = platformState4;
+			}
+			
+			int errorCount = 0;
+			bool ok = false;	
+			if(a.Connected) {
+				//try {
+					ok = myCP.Read_platform(out myPS);
+				//} catch { 
+				//	Log.WriteLine("catch at 1"); 
+				//}
+				if(!ok) {
+					Log.WriteLine("false at 1");
+					errorCount ++;
+				}
+			}
+			if(errorCount > 0) {
+				ArrayList myCPD = new ArrayList();
+				for(int i=1; i<=4;i++) {
+					ChronopicPortData b = new ChronopicPortData(i,"",false);
+					myCPD.Add(b);
+				}
+				Create (myCPD, true, volumeOn);
+				new DialogMessage(Constants.MessageTypes.WARNING, 
+						Catalog.GetString("One or more Chronopics have been disconnected.") + "\n" + 
+						Catalog.GetString("Please connect again, and configure on Chronopic window."));
+			}
+		}
+	}
+	
 	private void createCombos() {
 		if(isWindows)
 			ChronopicWindowBox.createComboWindows();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]