public virtual void Deserialize(ItemSerializationContext context) { System.Xml.XmlElement ItemXmlSource = context.ItemXmlElement; m_Name=ItemXmlSource.GetAttribute("name"); if (ItemXmlSource.HasAttribute("globalname")) m_GlobalName = ItemXmlSource.GetAttribute("globalname"); m_Text=ItemXmlSource.GetAttribute("text"); m_AccessKey=NativeFunctions.GetAccessKey(m_Text); m_IsContainer=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("iscontainer")); if (context._DesignerHost == null) m_Visible = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("visible")); else TypeDescriptor.GetProperties(this)["Visible"].SetValue(this, System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("visible"))); if(ItemXmlSource.GetAttribute("itemdata")!="") m_ItemData=ItemXmlSource.GetAttribute("itemdata"); else m_ItemData=""; m_Enabled=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("enabled")); m_BeginGroup=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("begingroup")); m_Style=(eDotNetBarStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("style")); m_Description=ItemXmlSource.GetAttribute("desc"); m_Tooltip=ItemXmlSource.GetAttribute("tooltip"); m_Category=ItemXmlSource.GetAttribute("category"); m_CanCustomize=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("cancustomize")); m_ShowSubItems=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("showsubitems")); m_ItemAlignment=(eItemAlignment)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("itemalignment")); if(ItemXmlSource.HasAttribute("stretch")) m_Stretch=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("stretch")); else m_Stretch=false; if(ItemXmlSource.HasAttribute("global")) m_GlobalItem=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("global")); if(ItemXmlSource.HasAttribute("themes")) m_ThemeAware=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("themes")); if(ItemXmlSource.HasAttribute("adefdesc")) m_AccessibleDefaultActionDescription=ItemXmlSource.GetAttribute("adefdesc"); if(ItemXmlSource.HasAttribute("adesc")) m_AccessibleDescription=ItemXmlSource.GetAttribute("adesc"); if(ItemXmlSource.HasAttribute("aname")) m_AccessibleName=ItemXmlSource.GetAttribute("aname"); if(ItemXmlSource.HasAttribute("arole")) m_AccessibleRole=(System.Windows.Forms.AccessibleRole)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("arole")); if(ItemXmlSource.HasAttribute("autocollapse")) m_AutoCollapseOnClick=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("autocollapse")); else m_AutoCollapseOnClick=true; if(ItemXmlSource.HasAttribute("autorepeat")) m_ClickAutoRepeat=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("autorepeat")); else m_ClickAutoRepeat=false; if(ItemXmlSource.HasAttribute("clickrepinterv")) m_ClickRepeatInterval=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("clickrepinterv")); else m_ClickRepeatInterval=600; //if (ItemXmlSource.HasAttribute("GenerateCommandLink")) // m_GenerateCommandLink = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("GenerateCommandLink")); //else // m_GenerateCommandLink = false; // Load Cursor if(ItemXmlSource.HasAttribute("cur")) { switch(ItemXmlSource.GetAttribute("cur")) { case "4": m_Cursor=System.Windows.Forms.Cursors.Hand; break; case "1": m_Cursor=System.Windows.Forms.Cursors.AppStarting; break; case "2": m_Cursor=System.Windows.Forms.Cursors.Arrow; break; case "3": m_Cursor=System.Windows.Forms.Cursors.Cross; break; case "5": m_Cursor=System.Windows.Forms.Cursors.Help; break; case "6": m_Cursor=System.Windows.Forms.Cursors.HSplit; break; case "7": m_Cursor=System.Windows.Forms.Cursors.IBeam; break; case "8": m_Cursor=System.Windows.Forms.Cursors.No; break; case "9": m_Cursor=System.Windows.Forms.Cursors.NoMove2D; break; case "10": m_Cursor=System.Windows.Forms.Cursors.NoMoveHoriz; break; case "11": m_Cursor=System.Windows.Forms.Cursors.NoMoveVert; break; case "12": m_Cursor=System.Windows.Forms.Cursors.PanEast; break; case "13": m_Cursor=System.Windows.Forms.Cursors.PanNE; break; case "14": m_Cursor=System.Windows.Forms.Cursors.PanNorth; break; case "15": m_Cursor=System.Windows.Forms.Cursors.PanNW; break; case "16": m_Cursor=System.Windows.Forms.Cursors.PanSE; break; case "17": m_Cursor=System.Windows.Forms.Cursors.PanSouth; break; case "18": m_Cursor=System.Windows.Forms.Cursors.PanSW; break; case "19": m_Cursor=System.Windows.Forms.Cursors.PanWest; break; case "20": m_Cursor=System.Windows.Forms.Cursors.SizeAll; break; case "21": m_Cursor=System.Windows.Forms.Cursors.SizeNESW; break; case "22": m_Cursor=System.Windows.Forms.Cursors.SizeNS; break; case "23": m_Cursor=System.Windows.Forms.Cursors.SizeNWSE; break; case "24": m_Cursor=System.Windows.Forms.Cursors.SizeWE; break; case "25": m_Cursor=System.Windows.Forms.Cursors.UpArrow; break; case "26": m_Cursor=System.Windows.Forms.Cursors.VSplit; break; case "27": m_Cursor=System.Windows.Forms.Cursors.WaitCursor; break; } } System.Xml.XmlNodeList list=ItemXmlSource.GetElementsByTagName("subitems"); if(list.Count>0) { foreach(System.Xml.XmlElement xmlChild in list[0].ChildNodes) { // BaseItem oi=null; // System.Reflection.Assembly a=System.Reflection.Assembly.Load(xmlChild.GetAttribute("assembly")); // if(a==null) continue; // oi=a.CreateInstance(xmlChild.GetAttribute("class")) as BaseItem; BaseItem oi=context.CreateItemFromXml(xmlChild); if(oi!=null) { this.SubItems.Add(oi); context.ItemXmlElement = xmlChild; oi.Deserialize(context); context.ItemXmlElement = ItemXmlSource; } } } if(ItemXmlSource.HasAttribute("shortcuts")) { if(m_Shortcuts==null) m_Shortcuts=new ShortcutsCollection(this); m_Shortcuts.FromString(ItemXmlSource.GetAttribute("shortcuts"),","); } if (context.HasDeserializeItemHandlers) { System.Xml.XmlNodeList customDataList=ItemXmlSource.GetElementsByTagName("customData"); if (customDataList.Count > 0) { System.Xml.XmlElement customData = customDataList[0] as System.Xml.XmlElement; SerializeItemEventArgs e = new SerializeItemEventArgs(this, ItemXmlSource, customData); context.Serializer.InvokeDeserializeItem(e); } } MarkupTextChanged(); }
/// <summary> /// Invokes DeserializeItem event. /// </summary> /// <param name="e">Provides data for the event.</param> void ICustomSerialization.InvokeDeserializeItem(SerializeItemEventArgs e) { if (DeserializeItem != null) DeserializeItem(this, e); }
/// <summary> /// Serializes the item and all sub-items into the XmlElement. /// </summary> /// <param name="ThisItem">XmlElement to serialize the item to.</param> protected internal virtual void Serialize(ItemSerializationContext context) { System.Xml.XmlElement ThisItem = context.ItemXmlElement; Type t=this.GetType(); System.Reflection.AssemblyName aname=t.Assembly.GetName(); if(aname.Name!="DevComponents.DotNetBar") ThisItem.SetAttribute("assembly",aname.Name+", PublicKeyToken="+System.Text.Encoding.ASCII.GetString(aname.GetPublicKey())); else ThisItem.SetAttribute("assembly",aname.Name); ThisItem.SetAttribute("class",t.FullName); ThisItem.SetAttribute("name",m_Name); ThisItem.SetAttribute("globalname", m_GlobalName); ThisItem.SetAttribute("text",m_Text); ThisItem.SetAttribute("iscontainer",System.Xml.XmlConvert.ToString(m_IsContainer)); ThisItem.SetAttribute("visible",System.Xml.XmlConvert.ToString(m_Visible)); if(m_ItemData!=null && m_ItemData.ToString()!="") ThisItem.SetAttribute("itemdata",m_ItemData.ToString()); else ThisItem.SetAttribute("itemdata",""); ThisItem.SetAttribute("enabled",System.Xml.XmlConvert.ToString(m_Enabled)); ThisItem.SetAttribute("begingroup",System.Xml.XmlConvert.ToString(m_BeginGroup)); ThisItem.SetAttribute("style",System.Xml.XmlConvert.ToString((int)m_Style)); ThisItem.SetAttribute("desc",m_Description); ThisItem.SetAttribute("tooltip",m_Tooltip); ThisItem.SetAttribute("category",m_Category); ThisItem.SetAttribute("cancustomize",System.Xml.XmlConvert.ToString(m_CanCustomize)); ThisItem.SetAttribute("showsubitems",System.Xml.XmlConvert.ToString(m_ShowSubItems)); ThisItem.SetAttribute("itemalignment",System.Xml.XmlConvert.ToString((int)m_ItemAlignment)); ThisItem.SetAttribute("stretch",System.Xml.XmlConvert.ToString(m_Stretch)); ThisItem.SetAttribute("global",System.Xml.XmlConvert.ToString(m_GlobalItem)); ThisItem.SetAttribute("themes",System.Xml.XmlConvert.ToString(m_ThemeAware)); if(m_AccessibleDefaultActionDescription!="") ThisItem.SetAttribute("adefdesc",m_AccessibleDefaultActionDescription); if(m_AccessibleDescription!="") ThisItem.SetAttribute("adesc",m_AccessibleDescription); if(m_AccessibleName!="") ThisItem.SetAttribute("aname",m_AccessibleName); if(m_AccessibleRole!=System.Windows.Forms.AccessibleRole.Default) ThisItem.SetAttribute("arole",System.Xml.XmlConvert.ToString((int)m_AccessibleRole)); if(!m_AutoCollapseOnClick) ThisItem.SetAttribute("autocollapse",System.Xml.XmlConvert.ToString(m_AutoCollapseOnClick)); if(m_ClickAutoRepeat) ThisItem.SetAttribute("autorepeat",System.Xml.XmlConvert.ToString(m_ClickAutoRepeat)); if(m_ClickRepeatInterval!=600) ThisItem.SetAttribute("clickrepinterv",System.Xml.XmlConvert.ToString(m_ClickRepeatInterval)); //if(m_GenerateCommandLink) // ThisItem.SetAttribute("GenerateCommandLink", System.Xml.XmlConvert.ToString(m_GenerateCommandLink)); if(m_Cursor!=null) { if(m_Cursor==System.Windows.Forms.Cursors.Hand) ThisItem.SetAttribute("cur","4"); else if(m_Cursor==System.Windows.Forms.Cursors.AppStarting) ThisItem.SetAttribute("cur","1"); else if(m_Cursor==System.Windows.Forms.Cursors.Arrow) ThisItem.SetAttribute("cur","2"); else if(m_Cursor==System.Windows.Forms.Cursors.Cross) ThisItem.SetAttribute("cur","3"); else if(m_Cursor==System.Windows.Forms.Cursors.Help) ThisItem.SetAttribute("cur","5"); else if(m_Cursor==System.Windows.Forms.Cursors.HSplit) ThisItem.SetAttribute("cur","6"); else if(m_Cursor==System.Windows.Forms.Cursors.IBeam) ThisItem.SetAttribute("cur","7"); else if(m_Cursor==System.Windows.Forms.Cursors.No) ThisItem.SetAttribute("cur","8"); else if(m_Cursor==System.Windows.Forms.Cursors.NoMove2D) ThisItem.SetAttribute("cur","9"); else if(m_Cursor==System.Windows.Forms.Cursors.NoMoveHoriz) ThisItem.SetAttribute("cur","10"); else if(m_Cursor==System.Windows.Forms.Cursors.NoMoveVert) ThisItem.SetAttribute("cur","11"); else if(m_Cursor==System.Windows.Forms.Cursors.PanEast) ThisItem.SetAttribute("cur","12"); else if(m_Cursor==System.Windows.Forms.Cursors.PanNE) ThisItem.SetAttribute("cur","13"); else if(m_Cursor==System.Windows.Forms.Cursors.PanNorth) ThisItem.SetAttribute("cur","14"); else if(m_Cursor==System.Windows.Forms.Cursors.PanNW) ThisItem.SetAttribute("cur","15"); else if(m_Cursor==System.Windows.Forms.Cursors.PanSE) ThisItem.SetAttribute("cur","16"); else if(m_Cursor==System.Windows.Forms.Cursors.PanSouth) ThisItem.SetAttribute("cur","17"); else if(m_Cursor==System.Windows.Forms.Cursors.PanSW) ThisItem.SetAttribute("cur","18"); else if(m_Cursor==System.Windows.Forms.Cursors.PanWest) ThisItem.SetAttribute("cur","19"); else if(m_Cursor==System.Windows.Forms.Cursors.SizeAll) ThisItem.SetAttribute("cur","20"); else if(m_Cursor==System.Windows.Forms.Cursors.SizeNESW) ThisItem.SetAttribute("cur","21"); else if(m_Cursor==System.Windows.Forms.Cursors.SizeNS) ThisItem.SetAttribute("cur","22"); else if(m_Cursor==System.Windows.Forms.Cursors.SizeNWSE) ThisItem.SetAttribute("cur","23"); else if(m_Cursor==System.Windows.Forms.Cursors.SizeWE) ThisItem.SetAttribute("cur","24"); else if(m_Cursor==System.Windows.Forms.Cursors.UpArrow) ThisItem.SetAttribute("cur","25"); else if(m_Cursor==System.Windows.Forms.Cursors.VSplit) ThisItem.SetAttribute("cur","26"); else if(m_Cursor==System.Windows.Forms.Cursors.WaitCursor) ThisItem.SetAttribute("cur","27"); } if(SubItems.Count>0 && this.ShouldSerializeSubItems()) { System.Xml.XmlElement subitems=ThisItem.OwnerDocument.CreateElement("subitems"); ThisItem.AppendChild(subitems); foreach(BaseItem objItem in this.SubItems) { if(objItem.ShouldSerialize) { System.Xml.XmlElement ChildItem=ThisItem.OwnerDocument.CreateElement("item"); t=objItem.GetType(); subitems.AppendChild(ChildItem); context.ItemXmlElement = ChildItem; objItem.Serialize(context); context.ItemXmlElement = ThisItem; } } } // Serialize Shortcuts if(m_Shortcuts!=null && m_Shortcuts.Count>0) ThisItem.SetAttribute("shortcuts",m_Shortcuts.ToString(",")); if (context.HasSerializeItemHandlers) { System.Xml.XmlElement customData = ThisItem.OwnerDocument.CreateElement("customData"); SerializeItemEventArgs e = new SerializeItemEventArgs(this, ThisItem, customData); context.Serializer.InvokeSerializeItem(e); if (customData.Attributes.Count > 0 || customData.ChildNodes.Count > 0) ThisItem.AppendChild(customData); } }
/// <summary> /// Invokes DeserializeItem event. /// </summary> /// <param name="e">Provides data for the event.</param> void ICustomSerialization.InvokeDeserializeItem(SerializeItemEventArgs e) { if (DeserializeItem != null) DeserializeItem(this, e); if (this.Owner != this && this.Owner is ICustomSerialization) ((ICustomSerialization)this.Owner).InvokeDeserializeItem(e); }