/// <summary> /// 已重载:从XML节点加载对象数据 /// </summary> /// <param name="myElement">XML节点</param> /// <returns>操作是否成功</returns> public override bool FromXML(System.Xml.XmlElement myElement) { if (base.FromXML(myElement)) { this.Width = 30; this.Height = 30; if (myImage != null) { myImage.Dispose(); myImage = null; imagecontent = string.Empty; } if (this.SaveInFile) { try { myImage = StringCommon.ImageFromBase64String(myElement.InnerText); } catch { //如果不能加载出图片,则说明是该图片已经被修改过了 //需要使用图片编辑器 myImage = null; } if (myImage == null) { imagecontent = myElement.InnerText; MemoryStream ms = new MemoryStream(Convert.FromBase64String(imagecontent)); m_temppanel.LoadImage(ms); myImage = m_temppanel.CurrentImage; } } else { myImage = ZYTextConst.ImageFromURL(this.Src); //todo } if (myImage != null) { this.Width = myImage.Size.Width; this.Height = myImage.Size.Height; } if (myElement.HasAttribute(ZYTextConst.c_Width)) { this.Width = StringCommon.ToInt32Value(myElement.GetAttribute(ZYTextConst.c_Width), intWidth); } if (myElement.HasAttribute(ZYTextConst.c_Height)) { this.Height = StringCommon.ToInt32Value(myElement.GetAttribute(ZYTextConst.c_Height), intHeight); } myAttributes.SetValue(ZYTextConst.c_Width, intWidth.ToString()); myAttributes.SetValue(ZYTextConst.c_Height, intHeight.ToString()); return(true); } return(false); }