public bool AddRegion(string description) { bool confirmation = false; Regions regionManager = new Regions(); confirmation = regionManager.AddRegion(description); return(confirmation); }
void getHREFRegions(Regions regions, List <AAtom>[] text, int[] x, int y) { for (int alignment = 0; alignment < 3; alignment++) { // variables for the open href region bool isRegionOpen = false; Region region = null; int regionHeight = 0; int additionalwidth = 0; int dx = x[alignment]; for (int i = 0; i < text[alignment].Count; i++) { AAtom atom = text[alignment][i]; if ((region == null && atom.HREFAttributes != null) || (region != null && atom.HREFAttributes != region.HREFAttributes)) { // close the current href tag if one is open. if (isRegionOpen) { region.Area.Width = (dx - region.Area.X) + additionalwidth; region.Area.Height = (y + regionHeight - region.Area.Y); isRegionOpen = false; region = null; } // did we open a href? if (atom.HREFAttributes != null) { isRegionOpen = true; region = regions.AddRegion(atom.HREFAttributes); region.Area.X = dx; region.Area.Y = y; regionHeight = 0; } } if (atom is ImageAtom) { // we need regions for images so that we can do mouse over images. // if we're currently in an open href region, we'll use that one. // if we don't have an open region, we'll create one just for this image. Image image = ((ImageAtom)atom).AssociatedImage; if (image != null) { if (!isRegionOpen) { region = regions.AddRegion(atom.HREFAttributes); isRegionOpen = true; region.Area.X = dx; region.Area.Y = y; regionHeight = 0; } image.RegionIndex = region.Index; } } dx += atom.Width; if (atom is CharacterAtom && ((CharacterAtom)atom).Style_IsItalic) { additionalwidth = 2; } else if (atom is CharacterAtom && ((CharacterAtom)atom).Style_IsOutlined) { additionalwidth = 2; } else { additionalwidth = 0; } if (isRegionOpen && atom.Height > regionHeight) { regionHeight = atom.Height; } } // we've reached the last atom in this set. // if a href tag is still open, close it. if (isRegionOpen) { region.Area.Width = (dx - region.Area.X); region.Area.Height = (y + regionHeight - region.Area.Y); } } }