private static void CreateDirectionalMarkerBox(float x, float y, float dx, float dy, AnnotationBox.JustificationBehaviour justification, string identifier, AnnotationBox newBox) { RectangleF normalizedRectangle = new RectangleF(x, y, dx, dy); newBox.NormalizedRectangle = normalizedRectangle; newBox.AnnotationItem = AnnotationLayoutFactory.GetAnnotationItem(identifier); newBox.Justification = justification; }
private void DeserializeBoxSettings(AnnotationBox boxSettings, XmlElement boxSettingsNode) { string font = boxSettingsNode.GetAttribute("font"); string color = boxSettingsNode.GetAttribute("color"); string italics = boxSettingsNode.GetAttribute("italics"); string bold = boxSettingsNode.GetAttribute("bold"); string numberOfLines = boxSettingsNode.GetAttribute("number-of-lines"); string truncation = boxSettingsNode.GetAttribute("truncation"); string justification = boxSettingsNode.GetAttribute("justification"); string verticalAlignment = boxSettingsNode.GetAttribute("vertical-alignment"); string fitWidth = boxSettingsNode.GetAttribute("fit-width"); string alwaysVisible = boxSettingsNode.GetAttribute("always-visible"); if (!String.IsNullOrEmpty(font)) { boxSettings.Font = font; } if (!String.IsNullOrEmpty(color)) { boxSettings.Color = color; } if (!String.IsNullOrEmpty(italics)) { boxSettings.Italics = (String.Compare("true", italics, true) == 0); } if (!String.IsNullOrEmpty(bold)) { boxSettings.Bold = (String.Compare("true", bold, true) == 0); } if (!String.IsNullOrEmpty(numberOfLines)) { byte result; if (!byte.TryParse(numberOfLines, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out result)) { result = 1; } boxSettings.NumberOfLines = result; } if (!String.IsNullOrEmpty(fitWidth)) { boxSettings.FitWidth = (String.Compare("true", fitWidth) == 0); } if (!String.IsNullOrEmpty(alwaysVisible)) { boxSettings.AlwaysVisible = (String.Compare("true", alwaysVisible, true) == 0); } if (!String.IsNullOrEmpty(truncation)) { AnnotationBox.TruncationBehaviour fromString = boxSettings.Truncation; EnumConverter converter = new EnumConverter(typeof(AnnotationBox.TruncationBehaviour)); if (converter.IsValid(truncation)) { boxSettings.Truncation = (AnnotationBox.TruncationBehaviour)converter.ConvertFromString(truncation); } } if (!String.IsNullOrEmpty(justification)) { AnnotationBox.JustificationBehaviour fromString = boxSettings.Justification; EnumConverter converter = new EnumConverter(typeof(AnnotationBox.JustificationBehaviour)); if (converter.IsValid(justification)) { boxSettings.Justification = (AnnotationBox.JustificationBehaviour)converter.ConvertFromString(justification); } } if (!String.IsNullOrEmpty(verticalAlignment)) { AnnotationBox.VerticalAlignmentBehaviour fromString = boxSettings.VerticalAlignment; EnumConverter converter = new EnumConverter(typeof(AnnotationBox.VerticalAlignmentBehaviour)); if (converter.IsValid(verticalAlignment)) { boxSettings.VerticalAlignment = (AnnotationBox.VerticalAlignmentBehaviour)converter.ConvertFromString(verticalAlignment); } } XmlElement configurationSettings = (XmlElement)boxSettingsNode.SelectSingleNode("configuration-settings"); if (configurationSettings != null) { string showLabel = configurationSettings.GetAttribute("show-label"); string showLabelIfEmpty = configurationSettings.GetAttribute("show-label-if-empty"); if (!String.IsNullOrEmpty(showLabel)) { boxSettings.ConfigurationOptions.ShowLabel = (String.Compare("true", showLabel, true) == 0); } if (!String.IsNullOrEmpty(showLabelIfEmpty)) { boxSettings.ConfigurationOptions.ShowLabelIfValueEmpty = (String.Compare("true", showLabelIfEmpty, true) == 0); } } }