Exemple #1
0
		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();
        }
Exemple #2
0
		/// <summary>
		/// Creates new instance of BaseItem and assigns item name and item text.
		/// </summary>
		/// <param name="sItemName">Item Name</param>
		/// <param name="ItemText">Item Text</param>
		public BaseItem(string sItemName, string ItemText)
		{
            if (ItemText == null)
                ItemText = "";
			m_Text=ItemText;
			if(m_Text!="")
				m_AccessKey=NativeFunctions.GetAccessKey(m_Text);
			m_Rect=System.Drawing.Rectangle.Empty;
			m_ContainerControl=null;
			m_HotSubItem=null;
			m_IsContainer=false;
			m_SubItems=null;
			m_Parent=null;
			m_NeedRecalcSize=true;
			m_Visible=true;
			m_Expanded=false;
			m_AutoExpand=false;
			m_ItemData="";
			m_Enabled=true;
			m_BeginGroup=false;
			m_Style=eDotNetBarStyle.OfficeXP;
			m_Description="";
			m_Tooltip="";
			m_Name=sItemName;
			m_Category="";
			m_Orientation=eOrientation.Horizontal;
			m_ToolTipWnd=null;
			m_Id=++s_IdCounter;
			m_IsOnCustomizeMenu=false;
			m_IsOnCustomizeDialog=false;
			m_SystemItem=false;
			//m_AccessKey=;
			m_Shortcuts=null;
			m_DesignMode=false;
			m_CanCustomize=true;
			m_ShowSubItems=true;
			m_ItemAlignment=eItemAlignment.Near;
			m_Focused=false;
			m_Owner=null;
            MarkupTextChanged();
        }