private void PropertyWindowOnRequestBytesOpen(object sender, RequestByteArrayFileOpenArgs e) { if (e.Variable is IByteSource source) { var bytes = source.GetBytes(); if (bytes == null) { return; } byte[] Magic = { (byte)'C', (byte)'R', (byte)'2', (byte)'W' }; var isCr2wFile = bytes.Take(4).SequenceEqual(Magic); if (isCr2wFile) { OpenEmbeddedFile(e.Variable.GetFullDependencyStringName(), bytes, e.Variable); } else { //TODO: Handle xbms here? UIController.OpenHexEditorFor(e.Variable); } } else if (e.Variable is IArrayAccessor iarray) { Type InnerType = iarray.GetType().GetGenericArguments().Single(); if (InnerType.GetInterface(nameof(IREDPrimitive)) == null) { return; } // check if open if (csvEditor == null || csvEditor.IsDisposed) { csvEditor = new frmCsvEditor() { parentref = this, WrappedArray = iarray, DockAreas = DockAreas.Document }; csvEditor.Show(FormPanel, DockState.Document); } else { csvEditor.WrappedArray = iarray; csvEditor.Activate(); } } }
private void ByteArrayEditor_RequestBytesOpen(object sender, RequestByteArrayFileOpenArgs e) => RequestBytesOpen?.Invoke(this, e);