public void AssembleAcknowledgements_FindsSILCoreAcknowledgements() { var html = AcknowledgementsProvider.AssembleAcknowledgements(); Assert.That(html, Contains.Substring("<a href='http://www.codeplex.com/DotNetZip'>Ionic.Zip</a>")); Assert.That(html, Contains.Substring("<a href='https://www.nuget.org/packages/NDesk.DBus/'>NDesk.DBus</a>")); Assert.That(html, Contains.Substring("<a href='https://www.nuget.org/packages/Newtonsoft.Json/'>Json.NET</a>")); }
/// <summary> /// When the window handle gets created we want to initialize the controls /// </summary> protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); try { // Set the Application label to the name of the app var viProvider = new VersionInfoProvider(ProductExecutableAssembly, true); lblName.Text = viProvider.ProductName; lblAppVersion.Text = viProvider.ApplicationVersion; lblFwVersion.Text = viProvider.MajorVersion; // List the copyright information var acknowlegements = AcknowledgementsProvider.CollectAcknowledgements(); var list = acknowlegements.Keys.ToList(); list.Sort(); var text = viProvider.CopyrightString + Environment.NewLine + viProvider.LicenseString + Environment.NewLine + viProvider.LicenseURL; foreach (var key in list) { text += "\r\n" + "\r\n" + key + "\r\n" + acknowlegements[key].Copyright + " " + acknowlegements[key].Url + " " + acknowlegements[key].LicenseUrl; } txtCopyright.Text = text; // Set the title bar text Text = string.Format(m_sTitleFmt, viProvider.ProductName); var strRoot = Path.GetPathRoot(Application.ExecutablePath); if (MiscUtils.IsUnix) { return; } // Set the memory information var memStatEx = new Win32.MemoryStatusEx(); memStatEx.dwLength = (uint)Marshal.SizeOf(memStatEx); Win32.GlobalMemoryStatusEx(ref memStatEx); edtAvailableMemory.Text = string.Format(m_sAvailableMemoryFmt, memStatEx.ullAvailPhys / BytesPerMiB, memStatEx.ullTotalPhys / BytesPerMiB); // Set the available disk space information. ulong _, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes; Win32.GetDiskFreeSpaceEx(strRoot, out _, out lpTotalNumberOfBytes, out lpTotalNumberOfFreeBytes); var gbFree = lpTotalNumberOfFreeBytes / BytesPerGiB; var gbTotal = lpTotalNumberOfBytes / BytesPerGiB; edtAvailableDiskSpace.Text = string.Format(m_sAvailableDiskSpaceFmt, gbFree, gbTotal, strRoot); } catch (Exception ex) { Console.WriteLine("HelpAbout ignoring exception: " + ex); } }
public void CollectAcknowledgementsAndRemoveDuplicates_HandlesDuplicateKeys() { var ack1 = new AcknowledgementAttribute("myKey1") { Name = "my Name" }; var ack2 = new AcknowledgementAttribute("myKey1") { Name = "my Other Name" }; var ackList = new List <AcknowledgementAttribute> { ack1, ack2 }; AcknowledgementsProvider.CollectAcknowledgementsAndRemoveDuplicates(_ackDict, ackList); Assert.AreEqual(1, _ackDict.Count, "Should have stripped out a duplicate key."); Assert.AreEqual("my Name", _ackDict["myKey1"].Name); }
public void SortByNameAndConcatenateHtml_SortsCorrectly() { var ack1 = new AcknowledgementAttribute("myKey1") { Name = "my Name" }; var ack2 = new AcknowledgementAttribute("bobKey") { Name = "Bob's project", LicenseUrl = "MIT License", Copyright = "2017 Bob Programmer" }; _ackDict.Add(ack1.Key, ack1); _ackDict.Add(ack2.Key, ack2); var html = AcknowledgementsProvider.SortByNameAndConcatenateHtml(_ackDict); Assert.That(html, Is.StringStarting("<li>Bob\'s project")); Assert.That(html, Is.StringContaining("my Name")); }
private void SILAboutBoxShown(object sender, EventArgs e) { //review: EB had changed from Navigate to this in ab66af23393f74b767ffd78c2182bd1fdc8eb963, presumably to // get around the AllowNavigation=false problem. It may work on Linux, but it didn't on Windows, which would just show a blank browser. //_browser.Url = new Uri(_pathToAboutBoxHtml); // So I've instead modified the browser wrapper to always let the first navigation get through, regardless var filePath = AcknowledgementsProvider.GetFullNonUriFileName(_pathToAboutBoxHtml); var aboutBoxHtml = File.ReadAllText(filePath); if (!aboutBoxHtml.Contains(DependencyMarker)) { _browser.Navigate(_pathToAboutBoxHtml); } else { // Without a charset='UTF-8' meta tag attribute, things like copyright symbols don't show up correctly. Debug.Assert(aboutBoxHtml.Contains(" charset"), "At a minimum, the About Box html should contain a meta charset='UTF-8' tag."); var insertableAcknowledgements = AcknowledgementsProvider.AssembleAcknowledgements(); var newHtmlContents = aboutBoxHtml.Replace(DependencyMarker, insertableAcknowledgements); // Create a temporary file with the DependencyMarker replaced with our collected Acknowledgements. // This file will be deleted OnClosed. // This means that if your project uses the DependencyMarker in your html file, you will not be able to // link to a file on a relative path for css styles or images. // ---------- // Comments on possible ways around this limitation from John Thomson: // 1.Document that an About Box HTML file which uses dependency injection must live in its own folder // with all dependent files, and copy the whole folder to a temp folder. // (could work but is a nuisance, especially for anyone who doesn't need any dependencies) // 2.Document that an About Box HTML file which uses dependency injection may only use a few common kinds // of relative links, search for matching links, and copy the appropriate files to a temp directory along // with the temp file. // (I rather like this idea. A fairly simple regular expression will search for src or rel followed by a value // with no path separators...something like(src | rel) = (['"])([^/\]*)\1 (or something similar... // handle white space...). That will catch all references to images, stylesheets, and scripts, // and if the bit of the RegEx that matches the filename corresponds to an existing file in the same folder // as the HTML we can just copy it. Unless they're doing relative paths to different folders that will do it, // and I think it's reasonable to have SOME restrictions in the interests of simplicity. // ---------- _tempAboutBoxHtmlFile = new TempFile(newHtmlContents); _browser.Navigate(_tempAboutBoxHtmlFile.Path); } }
public void AssembleAcknowledgements_FindsSILCoreAcknowledgements() { var html = AcknowledgementsProvider.AssembleAcknowledgements(); Assert.That(html, Contains.Substring("<a href='https://www.nuget.org/packages/Newtonsoft.Json/'>Json.NET</a>")); }