public EmoteControlPanel() { InitializeComponent(); StudentDatabaseMenuItem.IsEnabled = false; _client = LearnersDbThalamusClient.GetInstance(); _client.ClientConnected += delegate { _db = new ThalamusStudentDatabase(); _db.ConnectedEvent += DbOnConnectedEvent; _db.TimeoutEvent += DbOnTimeoutEvent; this.Dispatcher.Invoke(new Action(() => { StudentDatabaseMenuItem.IsEnabled = true; DatabaseStatus.Text = "Connecting..."; ControlPanelS2.IsEnabled = true; ControlPanelS2.Init(_client,_db); ControlPanelS1.IsEnabled = true; ControlPanelS1.Init(_client, _db); })); }; ThalamusStatus.WatchedClient = _client; MainTabPanel.SelectedIndex = Properties.Settings.Default.SelectedTab; #if !DEBUG ControlPanelS2.IsEnabled = false; #endif }
public static LearnersDbThalamusClient GetInstance() { string[] args = Environment.GetCommandLineArgs(); string charName = ""; if (args.Length > 1) charName = args[1]; if (_instance==null) _instance = new LearnersDbThalamusClient(charName); return _instance; }
public ThalamusStudentDatabase() { Console.WriteLine(DateTime.Now.ToShortTimeString() + ": Constructor"); _client = LearnersDbThalamusClient.GetInstance(); _client.AllLearnerInfoEvent += _client_AllLearnerInfoEvent; _client.NextThalamusIdEvent += ClientOnNextThalamusIdEvent; // Having a control like this makes it easy to check the state of the db from the interface CheckConnection(); _connected = false; }
public void Init(LearnersDbThalamusClient client, IStudentsDatabase database) { Client = client; Database = database; database.StudentListUpdatedEvent += delegate(object sender, StudentListEventArgs args) { if (args.StudentList != null) { this.Dispatcher.Invoke(new Action(() => { Student1ComboBox.ItemsSource = Student2ComboBox.ItemsSource = args.StudentList; })); } }; Database.ConnectedEvent += delegate(object sender, EventArgs args) { Database.GetAllStudentsAsync(); }; }
private void ClientOnNextThalamusIdEvent(object sender, LearnersDbThalamusClient.NextThalamusIdEventArgs nextThalamusIdEventArgs) { _nextThalamusId = nextThalamusIdEventArgs.Id; _resultsReady = true; Console.WriteLine("Next thalamus id: "+nextThalamusIdEventArgs.Id); }
void _client_AllLearnerInfoEvent(object sender, LearnersDbThalamusClient.AllLearnerInfoEventArgs e) { _studentsList = e.Learners; _resultsReady = true; }