private ProtectedBinary OpenBinaryDataLegacy(string name, ProtectedBinary binary) { ProtectedBinary modifiedData = null; var data = binary.ReadData(); var dataClass = BinaryDataClassifier.Classify(name, data); if (DataEditorForm.SupportsDataType(dataClass)) { var editor = new DataEditorForm(); editor.InitEx(name, data); editor.ShowDialog(); if (editor.EditedBinaryData != null) { modifiedData = new ProtectedBinary(binary.IsProtected, editor.EditedBinaryData); } UIUtil.DestroyForm(editor); } else { var viewer = new DataViewerForm(); viewer.InitEx(name, data); UIUtil.ShowDialogAndDestroy(viewer); } return(modifiedData); }
public static ProtectedBinary Open(string strName, ProtectedBinary pb, BinaryDataOpenOptions opt) { if (string.IsNullOrEmpty(strName)) { Debug.Assert(false); return(null); } if (pb == null) { Debug.Assert(false); return(null); } if (opt == null) { opt = new BinaryDataOpenOptions(); } byte[] pbData = pb.ReadData(); if (pbData == null) { Debug.Assert(false); return(null); } BinaryDataHandler h = opt.Handler; if (h == BinaryDataHandler.Default) { h = ChooseHandler(strName, pbData, opt); } byte[] pbModData = null; if (h == BinaryDataHandler.InternalViewer) { DataViewerForm dvf = new DataViewerForm(); dvf.InitEx(strName, pbData); UIUtil.ShowDialogAndDestroy(dvf); } else if (h == BinaryDataHandler.InternalEditor) { DataEditorForm def = new DataEditorForm(); def.InitEx(strName, pbData); def.ShowDialog(); if (def.EditedBinaryData != null) { pbModData = def.EditedBinaryData; } UIUtil.DestroyForm(def); } else if (h == BinaryDataHandler.ExternalApp) { pbModData = OpenExternal(strName, pbData, opt); } else { Debug.Assert(false); } if ((pbModData != null) && !MemUtil.ArraysEqual(pbData, pbModData) && !opt.ReadOnly) { return(new ProtectedBinary(pb.IsProtected, pbModData)); } return(null); }
public static ProtectedBinary Open(string strName, ProtectedBinary pb, BinaryDataOpenOptions opt) { if (string.IsNullOrEmpty(strName)) { Debug.Assert(false); return(null); } if (pb == null) { Debug.Assert(false); return(null); } if (opt == null) { opt = new BinaryDataOpenOptions(); } byte[] pbData = pb.ReadData(); if (pbData == null) { Debug.Assert(false); return(null); } BinaryDataHandler h = opt.Handler; if (h == BinaryDataHandler.Default) { h = ChooseHandler(strName, pbData, opt); } byte[] pbModData = null; if (h == BinaryDataHandler.InternalViewer) { DataViewerForm dvf = new DataViewerForm(); dvf.InitEx(strName, pbData); UIUtil.ShowDialogAndDestroy(dvf); } else if (h == BinaryDataHandler.InternalEditor) { DataEditorForm def = new DataEditorForm(); def.InitEx(strName, pbData); def.ShowDialog(); if (def.EditedBinaryData != null) { pbModData = def.EditedBinaryData; } UIUtil.DestroyForm(def); } else if (h == BinaryDataHandler.ExternalApp) { pbModData = OpenExternal(strName, pbData, opt); } else { Debug.Assert(false); } ProtectedBinary r = null; if ((pbModData != null) && !MemUtil.ArraysEqual(pbData, pbModData) && !opt.ReadOnly) { if (FileDialogsEx.CheckAttachmentSize(pbModData.LongLength, KPRes.AttachFailed + MessageService.NewParagraph + strName)) { r = new ProtectedBinary(pb.IsProtected, pbModData); } } if (pb.IsProtected) { MemUtil.ZeroByteArray(pbData); } return(r); }