internal static void BuildOpenWithMenu(DynamicMenu dm, string strItem, ProtectedBinary pb, bool bReadOnly) { if (dm == null) { Debug.Assert(false); return; } dm.Clear(); if (string.IsNullOrEmpty(strItem)) { Debug.Assert(false); return; } if (pb == null) { Debug.Assert(false); return; } byte[] pbData = pb.ReadData(); if (pbData == null) { Debug.Assert(false); return; } BinaryDataClass bdc = BinaryDataClassifier.Classify(strItem, pbData); BinaryDataOpenOptions oo = new BinaryDataOpenOptions(); oo.Handler = BinaryDataHandler.InternalViewer; dm.AddItem(KPRes.InternalViewer, Properties.Resources.B16x16_View_Detailed, oo); oo = new BinaryDataOpenOptions(); oo.Handler = BinaryDataHandler.InternalEditor; ToolStripMenuItem tsmiIntEditor = dm.AddItem(KPRes.InternalEditor, Properties.Resources.B16x16_View_Detailed, oo); oo = new BinaryDataOpenOptions(); oo.Handler = BinaryDataHandler.ExternalApp; ToolStripMenuItem tsmiExt = dm.AddItem(KPRes.ExternalApp, Properties.Resources.B16x16_Make_KDevelop, oo); if (!DataEditorForm.SupportsDataType(bdc) || bReadOnly) { tsmiIntEditor.Enabled = false; } if (bReadOnly) { tsmiExt.Enabled = false; } }
private static BinaryDataHandler ChooseHandler(string strName, byte[] pbData, BinaryDataOpenOptions opt) { BinaryDataClass bdc = BinaryDataClassifier.Classify(strName, pbData); if (DataEditorForm.SupportsDataType(bdc) && !opt.ReadOnly) { return(BinaryDataHandler.InternalEditor); } if (DataViewerForm.SupportsDataType(bdc)) { return(BinaryDataHandler.InternalViewer); } return(BinaryDataHandler.ExternalApp); }