AODL.Document.Import.OpenDocument.NodeProcessors.MainContentProcessor.CreateFrame C# (CSharp) Метод

CreateFrame() публичный Метод

Creates the frame.
public CreateFrame ( XmlNode frameNode ) : Frame
frameNode System.Xml.XmlNode The framenode.
Результат AODL.Document.Content.Draw.Frame
		public Frame CreateFrame(XmlNode frameNode)
		{
			try
			{
				#region Old code Todo: delete
				//				Frame frame					= null;
				//				XmlNode graphicnode			= null;
				//				XmlNode graphicproperties	= null;
				//				string realgraphicname		= "";
				//				string stylename			= "";
				//				stylename					= this.GetStyleName(framenode.OuterXml);
				//				XmlNode stylenode			= this.GetAStyleNode("style:style", stylename);
				//				realgraphicname				= this.GetAValueFromAnAttribute(framenode, "@draw:name");
				//
				//				//Console.WriteLine("frame: {0}", framenode.OuterXml);
				//
				//				//Up to now, the only sopported, inner content of a frame is a graphic
				//				if (framenode.ChildNodes.Count > 0)
				//					if (framenode.ChildNodes.Item(0).OuterXml.StartsWith("<draw:image"))
				//						graphicnode			= framenode.ChildNodes.Item(0).CloneNode(true);
				//
				//				//If not graphic, it could be text-box, ole or something else
				//				//try to find graphic frame inside
				//				if (graphicnode == null)
				//				{
				//					XmlNode child		= framenode.SelectSingleNode("//draw:frame", this._document.NamespaceManager);
				//					if (child != null)
				//						frame		= this.CreateFrame(child);
				//					return frame;
				//				}
				//
				//				string graphicpath			= this.GetAValueFromAnAttribute(graphicnode, "@xlink:href");
				//
				//				if (stylenode != null)
				//					if (stylenode.ChildNodes.Count > 0)
				//						if (stylenode.ChildNodes.Item(0).OuterXml.StartsWith("<style:graphic-properties"))
				//							graphicproperties	= stylenode.ChildNodes.Item(0).CloneNode(true);
				//
				//				if (stylename.Length > 0 && stylenode != null && realgraphicname.Length > 0
				//					&& graphicnode != null && graphicpath.Length > 0 && graphicproperties != null)
				//				{
				//					graphicpath				= graphicpath.Replace("Pictures", "");
				//					graphicpath				= OpenDocumentTextImporter.dirpics+graphicpath.Replace("/", @"\");
				//
				//					frame					= new Frame(this._document, stylename,
				//												realgraphicname, graphicpath);
				//
				//					frame.Style.Node		= stylenode;
				//					frame.Graphic.Node		= graphicnode;
				//					((FrameStyle)frame.Style).GraphicProperties.Node = graphicproperties;
				//
				//					XmlNode nodeSize		= framenode.SelectSingleNode("@svg:height",
				//						this._document.NamespaceManager);
				//
				//					if (nodeSize != null)
				//						if (nodeSize.InnerText != null)
				//							frame.GraphicHeight	= nodeSize.InnerText;
				//
				//					nodeSize		= framenode.SelectSingleNode("@svg:width",
				//						this._document.NamespaceManager);
				//
				//					if (nodeSize != null)
				//						if (nodeSize.InnerText != null)
				//							frame.GraphicWidth	= nodeSize.InnerText;
				//				}
				#endregion
				
				//Create a new Frame
				Frame frame					= new Frame(this._document, null);
				frame.Node					= frameNode;
				ContentCollection iColl	= new ContentCollection();
				//Revieve the FrameStyle
				IStyle frameStyle			= this._document.Styles.GetStyleByName(frame.StyleName);

				if (frameStyle != null)
					frame.Style					= frameStyle;
				else
				{
					this.OnWarning(new AODLWarning("Couldn't recieve a FrameStyle.", frameNode));
				}

				//Create the frame content
				foreach(XmlNode nodeChild in frame.Node.ChildNodes)
				{
					IContent iContent				= this.CreateContent(nodeChild);
					if (iContent != null)
						AddToCollection(iContent, iColl);
					//iColl.Add(iContent);
					else
					{
						this.OnWarning(new AODLWarning("Couldn't create a IContent object for a frame.", nodeChild));
					}
				}

				frame.Node.InnerXml					= "";

				foreach(IContent iContent in iColl)
				{
					AddToCollection(iContent, frame.Content);
					//frame.Content.Add(iContent);
					if (iContent is Graphic)
					{
						LoadFrameGraphic(frame, iContent as Graphic);
					}

					if (iContent is EmbedObject)
					{
						//(EmbedObject(iContent)).Frame  =frame;
						(iContent as EmbedObject).Frame = frame;
					}
				}
				return frame;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a Frame.", ex);
			}
		}