public void TestAddDialogResource() { Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase); string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath)); string gutilsdll = Path.Combine(uriPath, @"Binaries\gutils.dll"); int dialogsBefore = 0; using (ResourceInfo ri = new ResourceInfo()) { ri.Load(gutilsdll); dialogsBefore = ri.Resources[new ResourceId(Kernel32.ResourceTypes.RT_DIALOG)].Count; } string targetFilename = Path.Combine(Path.GetTempPath(), "testAddDialogResource.dll"); File.Copy(gutilsdll, targetFilename, true); // copy an existing dialog inside gutils.dll DialogResource sourceDialog = new DialogResource(); sourceDialog.Name = new ResourceId("GABRTDLG"); sourceDialog.LoadFrom(gutilsdll); sourceDialog.Name = new ResourceId("NEWGABRTDLG"); Console.WriteLine(targetFilename); sourceDialog.SaveTo(targetFilename); // check that the dialog was written sourceDialog.LoadFrom(targetFilename); DumpResource.Dump(sourceDialog); using (ResourceInfo ri = new ResourceInfo()) { ri.Load(targetFilename); int dialogsAfter = ri.Resources[new ResourceId(Kernel32.ResourceTypes.RT_DIALOG)].Count; DumpResource.Dump(ri); Assert.AreEqual(dialogsBefore + 1, dialogsAfter); } }
public void TestLoadDialogResource() { foreach (TestLoadDialogResourceTestDataEntry test in testdata) { Console.WriteLine("{0}: {1}", test.Filename, test.ResourceId); DialogResource rc = new DialogResource(); rc.Name = test.ResourceId; rc.LoadFrom(test.Filename); Console.WriteLine("DialogResource: {0}, {1}", rc.Name, rc.TypeName); Console.WriteLine(rc); Assert.AreEqual(test.NumberOfDialogControls, rc.Template.ControlCount); Assert.AreEqual(test.NumberOfDialogControls, rc.Template.Controls.Count); } }