public void ActionFontSizeIsFloat() { var foo = "<viewer type=\"Text\" buffer=\"5000\" forecolor=\"Lime\" backcolor=\"Black\" font=\"Courier New\" fontsize=\"9\">" + "<action type=\"Highlight\" pattern=\"Document\" color=\"White\" font-name=\"Microsoft Sans Serif\" font-size=\"8.25\" font-style=\"Regular\" />" + "</viewer>"; var xml = new XmlDocument(); xml.LoadXml(foo); var n = xml.FirstChild.ChildNodes[0]; var a = Action.CreateGenericEventAction(n); var s = 8.25f; Assert.AreEqual(s, a.Font.Size); }
private void loadConfiguration(string configuration) { var d = new XmlDocument(); try { d.LoadXml(configuration); var foo = false; if (d.FirstChild.Attributes.GetNamedItem("useLog") != null) { bool.TryParse(d.FirstChild.Attributes["useLog"].InnerText, out foo); } chkUseLogFile.Checked = foo; _viewer.LogToFile = foo; if (d.FirstChild.Attributes.GetNamedItem("logFileName") != null) { txtLogFile.Text = d.FirstChild.Attributes["logFileName"].InnerText; _viewer.LogFile = d.FirstChild.Attributes["logFileName"].InnerText; } if (d.FirstChild.Attributes.GetNamedItem("logRoll") != null) { _viewer.LogRolling = d.FirstChild.Attributes["logRoll"].InnerText; var i = cboRolling.FindStringExact(_viewer.LogRolling); cboRolling.SelectedIndex = i; } if (d.FirstChild.Attributes.GetNamedItem("buffer") != null) { int intFoo; if (int.TryParse(d.FirstChild.Attributes["buffer"].InnerText, out intFoo)) { _viewer.BufferSize = intFoo; intFoo /= 1000; if (udBufferSize.Maximum >= intFoo && udBufferSize.Minimum <= intFoo) { udBufferSize.Value = intFoo; } else { if (udBufferSize.Maximum < intFoo) { udBufferSize.Value = udBufferSize.Maximum; } if (udBufferSize.Minimum > intFoo) { udBufferSize.Value = udBufferSize.Minimum; } } } else { _viewer.BufferSize = 1000000; } } foo = true; if (d.FirstChild.Attributes.GetNamedItem("cacheOnPause") != null) { bool.TryParse(d.FirstChild.Attributes["cacheOnPause"].InnerText, out foo); } chkCache.Checked = foo; _viewer.CacheOnPause = foo; txtExample.ForeColor = Color.FromName(d.FirstChild.Attributes["forecolor"].InnerText); cpForeColor.Text = d.FirstChild.Attributes["forecolor"].InnerText; _viewer.TextForeColor = txtExample.ForeColor; txtExample.BackColor = Color.FromName(d.FirstChild.Attributes["backcolor"].InnerText); cpBackColor.Text = d.FirstChild.Attributes["backcolor"].InnerText; _viewer.TextBackColor = txtExample.BackColor; var f = new Font(d.FirstChild.Attributes["font"].InnerText, Helpers.SafeFloatParse(d.FirstChild.Attributes["fontsize"].InnerText)); txtExample.Font = f; _viewer.TextFont = f; var actions = d.SelectNodes("//action"); foreach (XmlNode actionNode in actions) { _viewer.AddAction(Action.CreateGenericEventAction(actionNode)); } } catch (Exception ex) { _log.Error(GetHashCode(), ex.ToString(), ex); } }