public KeySettings copy() { IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(this)); Marshal.StructureToPtr(this, p, true); KeySettings copyOne = (KeySettings)Marshal.PtrToStructure(p, typeof(KeySettings)); Marshal.FreeHGlobal(p); return(copyOne); }
private void readKeyConfig() { currentPort.WriteLine(KeyConsts.STR_COM_READ); string line = currentPort.ReadLine(); tbData.Text = ""; tbData.AppendText(line + "\n"); int size = int.Parse(line); lbExact.Text = line; byte[] data = new byte[size]; for (int i = 0; i < size; i++) { data[i] = (byte)currentPort.ReadByte(); } tbData.AppendText(byte2Hex(data)); currentPort.ReadByte(); settings = KeySettings.readFromBytes(data); settingsReady = true; fillControls(); enableControls(); }