internal static LogPacket ReadFromStream(Stream stream) { BinaryReader reader = new BinaryReader(stream); return(new LogPacket() { Timestamp = DateTime.FromFileTimeUtc(reader.ReadInt64()), Tag = reader.ReadString(), Uuid = new Guid(reader.ReadString()), NetId = new Guid(reader.ReadString()), Network = reader.ReadString(), Color = ColorValue.Parse(reader.ReadString()), Frame = Convert.FromBase64String(reader.ReadString()).ToDataFrame() }); }
private void btnOK_Click(object sender, EventArgs e) { Type selectedType = comboBoxTypes.SelectedItem as Type; if (selectedType == null) { MessageBox.Show(this, Properties.Resources.EditConfigPropertyForm_SelectAType, Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!IsValidName()) { MessageBox.Show(this, Properties.Resources.EditConfigPropertyForm_SpecifyAName, Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { object defaultValue = null; try { if (selectedType == typeof(string)) { defaultValue = textBoxStringValue.Text; } else if (selectedType == typeof(string[])) { defaultValue = textBoxStringValue.Lines; } else if (selectedType == typeof(byte[])) { defaultValue = hexEditorControl.Bytes; } else if (selectedType == typeof(ColorValue)) { defaultValue = ColorValue.Parse(textBoxStringValue.Text); } else if (!typeof(IDocumentObject).IsAssignableFrom(selectedType)) { defaultValue = Convert.ChangeType(textBoxStringValue.Text, selectedType, CultureInfo.CurrentUICulture); } Property = new DynamicNodeConfigProperty(textBoxName.Text, selectedType, defaultValue, textBoxDescription.Text); DialogResult = DialogResult.OK; Close(); } catch (InvalidCastException ex) { MessageBox.Show(this, ex.Message, Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (OverflowException ex) { MessageBox.Show(this, ex.Message, Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FormatException ex) { MessageBox.Show(this, ex.Message, Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }