⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemlook.cs

📁 ComponentArt Web.UI 2006.1252 for asp.net2.0
💻 CS
📖 第 1 页 / 共 3 页
字号:
      {
        if(FlatObject)
        {
          return _activeLeftIconUrl;
        }
        else if(this.Item != null)
        {
          return this.GetProperty("ActiveLeftIconUrl");
        }
        else
        {
          return (string)m_oProperties["ActiveLeftIconUrl"];
        }
      }
      set
      {
        if(FlatObject)
        {
          _activeLeftIconUrl = value;
        }
        else if(this.Item != null)
        {
          this.SetProperty("ActiveLeftIconUrl", value);
        }
        else
        {
          m_oProperties["ActiveLeftIconUrl"] = value;
        }
      }
    }

    private string _activeRightIconUrl;
    /// <summary>
    /// The right icon to use in this look, when active.
    /// </summary>
    [DefaultValue(null)]
    public string ActiveRightIconUrl
    {
      get
      {
        if(FlatObject)
        {
          return _activeRightIconUrl;
        }
        else if(this.Item != null)
        {
          return this.GetProperty("ActiveRightIconUrl");
        }
        else
        {
          return (string)m_oProperties["ActiveRightIconUrl"];
        }
      }
      set
      {
        if(FlatObject)
        {
          _activeRightIconUrl = value;
        }
        else if(this.Item != null)
        {
          this.SetProperty("ActiveRightIconUrl", value);
        }
        else
        {
          m_oProperties["ActiveRightIconUrl"] = value;
        }
      }
    }

    private string _activeImageUrl;
    /// <summary>
    /// The URL of the image to use in this look, when active.
    /// </summary>
    [DefaultValue(null)]
    public string ActiveImageUrl
    {
      get
      {
        if(FlatObject)
        {
          return _activeImageUrl;
        }
        else if(this.Item != null)
        {
          return this.GetProperty("ActiveImageUrl");
        }
        else
        {
          return (string)m_oProperties["ActiveImageUrl"];
        }
      }
      set
      {
        if(FlatObject)
        {
          _activeImageUrl = value;
        }
        else if(this.Item != null)
        {
          this.SetProperty("ActiveImageUrl", value);
        }
        else
        {
          m_oProperties["ActiveImageUrl"] = value;
        }
      }
    }

    private string _expandedCssClass;
    /// <summary>
    /// The CSS class to use in this look, when the item in question is expanded.
    /// </summary>
    [DefaultValue(null)]
    public string ExpandedCssClass
    {
      get
      {
        if(FlatObject)
        {
          return _expandedCssClass;
        }
        else if(this.Item != null)
        {
          return this.GetProperty("ExpandedCssClass");
        }
        else
        {
          return (string)m_oProperties["ExpandedCssClass"];
        }
      }
      set
      {
        if(FlatObject)
        {
          _expandedCssClass = value;
        }
        else if(this.Item != null)
        {
          this.SetProperty("ExpandedCssClass", value);
        }
        else
        {
          m_oProperties["ExpandedCssClass"] = value;
        }
      }
    }

    private string _expandedLeftIconUrl;
    /// <summary>
    /// The left icon to use in this look, when the item is expanded.
    /// </summary>
    [DefaultValue(null)]
    public string ExpandedLeftIconUrl
    {
      get
      {
        if(FlatObject)
        {
          return _expandedLeftIconUrl;
        }
        else if(this.Item != null)
        {
          return this.GetProperty("ExpandedLeftIconUrl");
        }
        else
        {
          return (string)m_oProperties["ExpandedLeftIconUrl"];
        }
      }
      set
      {
        if(FlatObject)
        {
          _expandedLeftIconUrl = value;
        }
        else if(this.Item != null)
        {
          this.SetProperty("ExpandedLeftIconUrl", value);
        }
        else
        {
          m_oProperties["ExpandedLeftIconUrl"] = value;
        }
      }
    }

    private string _expandedRightIconUrl;
    /// <summary>
    /// The right icon to use when expanded.
    /// </summary>
    [DefaultValue(null)]
    public string ExpandedRightIconUrl
    {
      get
      {
        if(FlatObject)
        {
          return _expandedRightIconUrl;
        }
        else if(this.Item != null)
        {
          return this.GetProperty("ExpandedRightIconUrl");
        }
        else
        {
          return (string)m_oProperties["ExpandedRightIconUrl"];
        }
      }
      set
      {
        if(FlatObject)
        {
          _expandedRightIconUrl = value;
        }
        else if(this.Item != null)
        {
          this.SetProperty("ExpandedRightIconUrl", value);
        }
        else
        {
          m_oProperties["ExpandedRightIconUrl"] = value;
        }
      }
    }
    
    private string _expandedImageUrl;
    /// <summary>
    /// The image to use when expanded.
    /// </summary>
    [DefaultValue(null)]
    public string ExpandedImageUrl
    {
      get
      {
        if(FlatObject)
        {
          return _expandedImageUrl;
        }
        else if(this.Item != null)
        {
          return this.GetProperty("ExpandedImageUrl");
        }
        else
        {
          return (string)m_oProperties["ExpandedImageUrl"];
        }
      }
      set
      {
        if(FlatObject)
        {
          _expandedImageUrl = value;
        }
        else if(this.Item != null)
        {
          this.SetProperty("ExpandedImageUrl", value);
        }
        else
        {
          m_oProperties["ExpandedImageUrl"] = value;
        }
      }
    }

    /// <summary>
    /// Whether nothing at all has been set in this look. Read-only.
    /// </summary>
    [Browsable(false)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public bool IsEmpty
    {
      get
      {
        return (
          this.CssClass == null && this.ImageUrl == null && this.LeftIconUrl == null && this.RightIconUrl == null &&
          this.ActiveCssClass == null && this.ActiveImageUrl == null && this.ActiveLeftIconUrl == null && this.ActiveRightIconUrl == null &&
          this.HoverCssClass == null && this.HoverImageUrl == null && this.HoverLeftIconUrl == null && this.HoverRightIconUrl == null &&
          this.ExpandedCssClass == null && this.ExpandedImageUrl == null && this.ExpandedLeftIconUrl == null && this.ExpandedRightIconUrl == null
          );
      }
    }

    #endregion

    #region Methods

    public ItemLook()
    {
      m_oProperties = new Hashtable();
    }

    internal ItemLook(bool bTranslator, bool bFlat)
    {
      FlatObject = bFlat;
    }

    internal ItemLook(bool bTranslator)
    {
    }

    /// <summary>
    /// Clear the contents of this look.
    /// </summary>
    public void Clear()
    {
      ItemLook oClearLook = new ItemLook();
      oClearLook.CopyTo(this);
    }

    /// <summary>
    /// Creates an exact duplicate of the this look object.
    /// </summary>
    /// <returns>The cloned ItemLook</returns>
    public object Clone()
    {
      ItemLook oClone = new ItemLook();

      this.CopyTo(oClone);      

      return oClone;
    }

    /// <summary>
    /// Copy the settings of this ItemLook to the specified ItemLook object.
    /// </summary>
    /// <param name="otherLook">The ItemLook to copy settings to</param>
    public void CopyTo(ItemLook otherLook)
    {
      CopyTo(otherLook, false);
    }

    /// <summary>
    /// Copy the settings of this ItemLook to the specified ItemLook object.
    /// </summary>
    /// <param name="otherLook">The ItemLook to copy settings to</param>
    /// <param name="bToNullsOnly">Whether to only copy to properties which are undefined, leaving the rest</param>
    public void CopyTo(ItemLook otherLook, bool bToNullsOnly)
    {
      CopyTo(otherLook, bToNullsOnly, false);
    }

    /// <summary>
    /// Copy the settings of this ItemLook to the specified ItemLook object.
    /// </summary>
    /// <param name="otherLook">The ItemLook to copy settings to</param>
    /// <param name="bToNullsOnly">Whether to only copy to properties which are undefined, leaving the rest</param>
    /// <param name="bFromNonNullsOnly">Whether to only copy from properties which are undefined, leaving the rest</param>
    public void CopyTo(ItemLook otherLook, bool bToNullsOnly, bool bFromNonNullsOnly)
    {
      if((!bToNullsOnly || otherLook.LookId == null) && (!bFromNonNullsOnly || this.LookId != null)) otherLook.LookId = this.LookId; // for internal use

      if((!bToNullsOnly || otherLook.LeftIconHeight == Unit.Empty) && (!bFromNonNullsOnly || this.LeftIconHeight != Unit.Empty)) otherLook.LeftIconHeight = this.LeftIconHeight;
      if((!bToNullsOnly || otherLook.LeftIconWidth == Unit.Empty) && (!bFromNonNullsOnly || this.LeftIconWidth != Unit.Empty)) otherLook.LeftIconWidth = this.LeftIconWidth;
      if((!bToNullsOnly || otherLook.RightIconHeight == Unit.Empty) && (!bFromNonNullsOnly || this.RightIconHeight != Unit.Empty)) otherLook.RightIconHeight = this.RightIconHeight;
      if((!bToNullsOnly || otherLook.RightIconWidth == Unit.Empty) && (!bFromNonNullsOnly || this.RightIconWidth != Unit.Empty)) otherLook.RightIconWidth = this.RightIconWidth;
      
      if((!bToNullsOnly || otherLook.ImageHeight == Unit.Empty) && (!bFromNonNullsOnly || this.ImageHeight != Unit.Empty)) otherLook.ImageHeight = this.ImageHeight;
      if((!bToNullsOnly || otherLook.ImageWidth == Unit.Empty) && (!bFromNonNullsOnly || this.ImageWidth != Unit.Empty)) otherLook.ImageWidth = this.ImageWidth;
      
      if((!bToNullsOnly || otherLook.LabelPaddingBottom == Unit.Empty) && (!bFromNonNullsOnly || this.LabelPaddingBottom != Unit.Empty)) otherLook.LabelPaddingBottom = this.LabelPaddingBottom;
      if((!bToNullsOnly || otherLook.LabelPaddingLeft == Unit.Empty) && (!bFromNonNullsOnly || this.LabelPaddingLeft != Unit.Empty)) otherLook.LabelPaddingLeft = this.LabelPaddingLeft;
      if((!bToNullsOnly || otherLook.LabelPaddingRight == Unit.Empty) && (!bFromNonNullsOnly || this.LabelPaddingRight != Unit.Empty)) otherLook.LabelPaddingRight = this.LabelPaddingRight;
      if((!bToNullsOnly || otherLook.LabelPaddingTop == Unit.Empty) && (!bFromNonNullsOnly || this.LabelPaddingTop != Unit.Empty)) otherLook.LabelPaddingTop = this.LabelPaddingTop;

      if((!bToNullsOnly || otherLook.CssClass == null) && (!bFromNonNullsOnly || this.CssClass != null)) otherLook.CssClass = this.CssClass;
      if((!bToNullsOnly || otherLook.ImageUrl == null) && (!bFromNonNullsOnly || this.ImageUrl != null)) otherLook.ImageUrl = this.ImageUrl;
      if((!bToNullsOnly || otherLook.LeftIconUrl == null) && (!bFromNonNullsOnly || this.LeftIconUrl != null)) otherLook.LeftIconUrl = this.LeftIconUrl;
      if((!bToNullsOnly || otherLook.RightIconUrl == null) && (!bFromNonNullsOnly || this.RightIconUrl != null)) otherLook.RightIconUrl = this.RightIconUrl;

      if((!bToNullsOnly || otherLook.HoverCssClass == null) && (!bFromNonNullsOnly || this.HoverCssClass != null)) otherLook.HoverCssClass = this.HoverCssClass;
      if((!bToNullsOnly || otherLook.HoverImageUrl == null) && (!bFromNonNullsOnly || this.HoverImageUrl != null)) otherLook.HoverImageUrl = this.HoverImageUrl;
      if((!bToNullsOnly || otherLook.HoverLeftIconUrl == null) && (!bFromNonNullsOnly || this.HoverLeftIconUrl != null)) otherLook.HoverLeftIconUrl = this.HoverLeftIconUrl;
      if((!bToNullsOnly || otherLook.HoverRightIconUrl == null) && (!bFromNonNullsOnly || this.HoverRightIconUrl != null)) otherLook.HoverRightIconUrl = this.HoverRightIconUrl;

      if((!bToNullsOnly || otherLook.ActiveCssClass == null) && (!bFromNonNullsOnly || this.ActiveCssClass != null)) otherLook.ActiveCssClass = this.ActiveCssClass;
      if((!bToNullsOnly || otherLook.ActiveImageUrl == null) && (!bFromNonNullsOnly || this.ActiveImageUrl != null)) otherLook.ActiveImageUrl = this.ActiveImageUrl;
      if((!bToNullsOnly || otherLook.ActiveLeftIconUrl == null) && (!bFromNonNullsOnly || this.ActiveLeftIconUrl != null)) otherLook.ActiveLeftIconUrl = this.ActiveLeftIconUrl;
      if((!bToNullsOnly || otherLook.ActiveRightIconUrl == null) && (!bFromNonNullsOnly || this.ActiveRightIconUrl != null)) otherLook.ActiveRightIconUrl = this.ActiveRightIconUrl;

      if((!bToNullsOnly || otherLook.ExpandedCssClass == null) && (!bFromNonNullsOnly || this.ExpandedCssClass != null)) otherLook.ExpandedCssClass = this.ExpandedCssClass;
      if((!bToNullsOnly || otherLook.ExpandedImageUrl == null) && (!bFromNonNullsOnly || this.ExpandedImageUrl != null)) otherLook.ExpandedImageUrl = this.ExpandedImageUrl;
      if((!bToNullsOnly || otherLook.ExpandedLeftIconUrl == null) && (!bFromNonNullsOnly || this.ExpandedLeftIconUrl != null)) otherLook.ExpandedLeftIconUrl = this.ExpandedLeftIconUrl;
      if((!bToNullsOnly || otherLook.ExpandedRightIconUrl == null) && (!bFromNonNullsOnly || this.ExpandedRightIconUrl != null)) otherLook.ExpandedRightIconUrl = this.ExpandedRightIconUrl;
    }

    private string GetProperty(string sProperty)
    {
      string sPrefix = this.ForDefaultSubItem? "DefaultSubItem" : "";
      string sLookType = this.LookType == ItemLookType.Normal ? "" : this.LookType.ToString();

      return Item.Properties[Item.GetAttributeVarName(sPrefix + sLookType + "Look-" + sProperty)]; 
    }

    private void SetProperty(string sProperty, string sValue)
    {
      string sPrefix = this.ForDefaultSubItem? "DefaultSubItem" : "";
      string sLookType = this.LookType == ItemLookType.Normal ? "" : this.LookType.ToString();

      string sKey = Item.GetAttributeVarName(sPrefix + sLookType + "Look-" + sProperty);

      Item.Properties.Remove(sKey);

      if(sValue != null)
      {
        Item.Properties.Add(sKey, sValue);
      }
    }

    internal string GetXml()
    {
      StringBuilder oSB = new StringBuilder();
      
      oSB.Append("<Look");

      foreach(string sKey in m_oProperties.Keys)
      {
        oSB.AppendFormat(" {0}=\"{1}\"", sKey, m_oProperties[sKey]);
      }

      oSB.Append(" />");

      return oSB.ToString();
    }

    internal void LoadXml(string sXml)
    {
      XmlDocument oXmlDoc = new XmlDocument();
      oXmlDoc.LoadXml(sXml);

      foreach(XmlAttribute oAttr in oXmlDoc.DocumentElement.Attributes)
      {
        m_oProperties[oAttr.Name] = oAttr.Value;
      }
    }

    #endregion
	}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -