Summary for DrawArea.
Inheritance: IContent, IContentContainer
Exemplo n.º 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ImageMap"/> class.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="drawareas">Array of drawareas.</param>
		public ImageMap(IDocument document, DrawArea[] drawareas)
		{
			this.Document			= document;
			this.InitStandards();
			this.NewXmlNode();

			if (drawareas != null)
			{
				foreach (DrawArea d in drawareas)
				{
					_content.Add(d);
				}
			}
		}
		/// <summary>
		/// Gets the draw rectangle as HTML.
		/// </summary>
		/// <param name="drawArea">The draw area.</param>
		/// <returns></returns>
		public string GetDrawAreaAsHtml(DrawArea drawArea)
		{
			string html					= "<area shape=\"#type#\" coords=\"#coords#\" href=\"#link#\" target=\"_top\">\n";
			string coords				= null;
			int cx, cy, cxx, cyy, r		= 0;

			try
			{
				if (drawArea != null)
				{
					if (drawArea is DrawAreaRectangle)
					{
						html				= html.Replace("#link#", ((DrawAreaRectangle)drawArea).Href);
						
						cx					= SizeConverter.GetPixelFromAnOfficeSizeValue(
							((DrawAreaRectangle)drawArea).X);
						cy					= SizeConverter.GetPixelFromAnOfficeSizeValue(
							((DrawAreaRectangle)drawArea).Y);
						int w				= SizeConverter.GetPixelFromAnOfficeSizeValue(
							((DrawAreaRectangle)drawArea).Width);
						int h				= SizeConverter.GetPixelFromAnOfficeSizeValue(
							((DrawAreaRectangle)drawArea).Height);
						
						cxx					= cx+w;
						cyy					= cy+h;

						coords				= cx.ToString()+","+cy.ToString()+","+cxx.ToString()+","+cyy.ToString();
						html				= html.Replace("#coords#", coords);
						html				= html.Replace("#type#", "rect");
					}
					else if (drawArea is DrawAreaCircle)
					{
						html				= html.Replace("#link#", ((DrawAreaCircle)drawArea).Href);
						
						cx					= SizeConverter.GetPixelFromAnOfficeSizeValue(
							((DrawAreaCircle)drawArea).CX);
						cy					= SizeConverter.GetPixelFromAnOfficeSizeValue(
							((DrawAreaCircle)drawArea).CY);
						r					= SizeConverter.GetPixelFromAnOfficeSizeValue(
							((DrawAreaCircle)drawArea).Radius);

						coords				= cx.ToString()+","+cy.ToString()+","+r.ToString();
						html				= html.Replace("#coords#", coords);
						html				= html.Replace("#type#", "circle");
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML string from a ImageMap object.", ex);
			}

			return html;
		}
Exemplo n.º 3
0
		public void ImageMapTest()
		{
			TextDocument document			= new TextDocument();
			document.New();
			//Create standard paragraph
			Paragraph paragraphOuter		= ParagraphBuilder.CreateStandardTextParagraph(document);
			//Create the frame with graphic
			Frame frame						= new Frame(document, "frame1", "graphic1", _imagefile);
			//Create a Draw Area Rectangle
			DrawAreaRectangle drawAreaRec	= new DrawAreaRectangle(
				document, "0cm", "0cm", "1.5cm", "2.5cm", null);
			drawAreaRec.Href				= "http://OpenDocument4all.com";
			//Create a Draw Area Circle
			DrawAreaCircle drawAreaCircle	= new DrawAreaCircle(
				document, "4cm", "4cm", "1.5cm", null);
			drawAreaCircle.Href				= "http://AODL.OpenDocument4all.com";
			DrawArea[] drawArea				= new DrawArea[2] { drawAreaRec, drawAreaCircle };
			//Create a Image Map
			ImageMap imageMap				= new ImageMap(document, drawArea);
			//Add Image Map to the frame
			frame.Content.Add(imageMap);
			//Add frame to paragraph
			paragraphOuter.Content.Add(frame);
			//Add paragraph to document
			document.Content.Add(paragraphOuter);
			//Save the document
			document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"simpleImageMap.odt");
		}