public Game(OppCommMode mode, string strategy, string sessionSSID, sendMessageDelegate msgDelegate, updateListbox msgListBoxDelegate, updateCredibility credibilityDelegate, restartProbing reProbingDelegate) { this.gameMode = mode; this.strategy = strategy; this.sessionID = sessionSSID; this.sendMsgDelegate = msgDelegate; this.msgListBoxDelegate = msgListBoxDelegate; this.credibilityDelegate = credibilityDelegate; this.restartProbingDelegate = reProbingDelegate; this.state = GameState.Started; }
/// <summary> /// Used by other threads to update message list box, /// because control cannot be directly accessed by the threads that haven't created it. /// </summary> /// <param name="s"></param> public void addMessageToListBox(string s) { try { if (msgListBox.InvokeRequired) { updateListbox del = new updateListbox(this.addMessageToListBox); msgListBox.Invoke(del, new object[] { s }); } else { msgListBox.Items.Add((object)s); msgListBox.SelectedIndex = msgListBox.Items.Count - 1; } } catch (ObjectDisposedException ex) { Logger.addEntry("MainForm:addMessageToListBox-" + ex.ToString()); } }
public MainForm() { InitializeComponent(); strategyComboBox.SelectedItem = (object)"Select Strategy"; messageDelegate = SendMessage; updateMsgListBox = addMessageToListBox; credibilityDelegate = UpdateCredibility; OppCommRequestCallBack = NeighborJoined; restartProbingDelegate = RestartProbing; ToggleControls(true); CommonUtilities.Logger.flushAll(); //This only initiates the device advertisement oppCommHandler = OppCommHandler.getInstance(); deviceIDLabel.Text = DeviceID.GetInstance().ToIDString(); //Read existing credibility history. ReadCredibilityHistory(); }