void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "ActiveDocument") { if (ActiveDocument is GridView) { if (!OtherCommands.Contains(GridModel)) { OtherCommands.Add(GridModel); OtherToolbarCommands = GridModel.Commands; OtherCommands.Remove(ChartModel); OtherCommands.Remove(Chart1Model); } } else { if (!OtherCommands.Contains(ChartModel)) { OtherCommands.Add(ChartModel); OtherToolbarCommands = ChartModel.Commands; OtherCommands.Add(Chart1Model); OtherCommands.Remove(GridModel); } } } else if (e.PropertyName == "IsChecked") { if (checkedModel != null) { checkedModel.IsChecked = false; } checkedModel = sender as CommandModel; } }
bool execute_other_command(int action) { OtherCommands c = (OtherCommands)action; // server.updateServerMsg("Received data from " + getTypeString(clientType) + clientID + " : " + c.ToString()); try { switch (c) { case OtherCommands.Disconnect_from_server_server_close_connection: // Disconnect from server server close connection foreach (myClient cc in server.clientList) { if (cc.clientID == clientID && cc.clientType == clientType) { try { isWorking = false; sendData(getTypeString(clientType) + clientID + " is Disconnected"); cc.sendClientSocket.Close(); cc.readClientSocket.Close(); server.clientList.Remove(cc); server.updateServerMsg(getTypeString(clientType) + clientID + " is Disconnected"); updateKinectInfo("Disconnected"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); server.clientList.Remove(cc); server.updateServerMsg(getTypeString(clientType) + clientID + "is Disconnected!"); } return(true); } } return(false); case OtherCommands.Disconnect_from_server_server_hangs_and_wait_for_this_client_to_close_connection: // Disconnect from server server hangs and wait for this client to close connection foreach (myClient cc in server.clientList) { if (cc.clientID == clientID && cc.clientType == clientType) { try { while (true) { sendData(getTypeString(clientType) + clientID + " is closing..."); Thread.Sleep(200); server.updateServerMsg(getTypeString(clientType) + clientID + " is closing..."); } } catch { isWorking = false; server.clientList.Remove(cc); server.updateServerMsg(getTypeString(clientType) + clientID + " is Disconnected!"); return(true); } } } return(false); default: return(false); } } catch { return(false); } }