public static StateStatus Desserialize(byte[] data) { StateStatus result = new StateStatus(); using (MemoryStream m = new MemoryStream(data)) { using (BinaryReader reader = new BinaryReader(m)) { result.Id = reader.ReadInt32(); result.State = reader.ReadString(); result.Status = reader.ReadString(); result.User = reader.ReadString(); } } return result; }
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { ConnSQL connSQL = new ConnSQL(); connSQL.update(user.Username, (comboBox1.SelectedItem as ComboBoxItem).Content.ToString()); if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Offline") == 0) { StateStatus mess = new StateStatus(); mess.Id = 1; mess.State = "Offline"; mess.Status = ""; mess.User = user.Username; byte[] buff = mess.Serialize(); ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5); parrentwdw.Show(); signout = true; this.Close(); } if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Available") == 0) { StateStatus mess = new StateStatus() ; mess.Id = 1; mess.State ="Available"; mess.Status = ""; mess.User = user.Username; byte[] buff = mess.Serialize(); ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5); } if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Invisible") == 0) { StateStatus mess = new StateStatus(); mess.Id = 1; mess.State = "Invisible"; mess.Status = ""; mess.User = user.Username; byte[] buff = mess.Serialize(); ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5); } }