public int Add (TreeNodeStyle style) { // It looks weird, but it seems that there must be at least one style saved in the control state, or // otherwise tests fail. The line below makes sure that, whether or not modified by user, the Underline // property will always have unaltered value _and_ the style collection will contain at least one item. style.Font.Underline = style.Font.Underline; return ((IList)this).Add (style); }
public int Add(TreeNodeStyle style) { // It looks weird, but it seems that there must be at least one style saved in the control state, or // otherwise tests fail. The line below makes sure that, whether or not modified by user, the Underline // property will always have unaltered value _and_ the style collection will contain at least one item. style.Font.Underline = style.Font.Underline; return(((IList)this).Add(style)); }
public void TreeNodeStyle_DefaultProperties () { TreeNodeStyle tns = new TreeNodeStyle (); Assert.AreEqual (0.0, tns.ChildNodesPadding.Value, "ChildNodesPadding"); Assert.AreEqual (0.0, tns.HorizontalPadding.Value, "HorizontalPadding"); Assert.AreEqual ("", tns.ImageUrl, "ImageUrl"); Assert.AreEqual (0.0, tns.NodeSpacing.Value, "NodeSpacing"); Assert.AreEqual (0.0, tns.VerticalPadding.Value, "VerticalPadding"); }
public void TreeNodeStyleCollection_Method_Contains () { TreeView tv = new TreeView (); TreeNodeStyle tns = new TreeNodeStyle (); tv.LevelStyles.Add (new TreeNodeStyle ()); Assert.AreEqual (false, tv.LevelStyles.Contains (tns), "BeforeContains"); tv.LevelStyles.Add (tns); tv.LevelStyles.Add (new TreeNodeStyle ()); Assert.AreEqual (true, tv.LevelStyles.Contains (tns), "AfterContains"); }
protected override void OnInsert(int index, object value) { base.OnInsert(index, value); if (!(value is TreeNodeStyle)) { throw new ArgumentException(System.Web.SR.GetString("TreeNodeStyleCollection_InvalidArgument"), "value"); } TreeNodeStyle style = (TreeNodeStyle)value; style.Font.Underline = style.Font.Underline; }
/// <devdoc> /// Copies non-blank elements from the specified style, overwriting existing /// style elements if necessary. /// </devdoc> public override void CopyFrom(Style s) { if (s != null) { base.CopyFrom(s); TreeNodeStyle tns = s as TreeNodeStyle; if (tns != null && !tns.IsEmpty) { // Only copy the paddings if they aren't in the source Style's registered CSS class if (s.RegisteredCssClass.Length != 0) { if (tns.IsSet(PROP_VPADDING)) { ViewState.Remove("VerticalPadding"); ClearBit(PROP_VPADDING); } if (tns.IsSet(PROP_HPADDING)) { ViewState.Remove("HorizontalPadding"); ClearBit(PROP_HPADDING); } } else { if (tns.IsSet(PROP_VPADDING)) { this.VerticalPadding = tns.VerticalPadding; } if (tns.IsSet(PROP_HPADDING)) { this.HorizontalPadding = tns.HorizontalPadding; } } if (tns.IsSet(PROP_NODESPACING)) { this.NodeSpacing = tns.NodeSpacing; } if (tns.IsSet(PROP_CHILDNODESPADDING)) { this.ChildNodesPadding = tns.ChildNodesPadding; } if (tns.IsSet(PROP_IMAGEURL)) { this.ImageUrl = tns.ImageUrl; } } } }
public void TreeNodeStyleCollection_Method_CopyTo () { TreeView tv = new TreeView (); TreeNodeStyle[] styleArray = new TreeNodeStyle[10]; tv.LevelStyles.Add (new TreeNodeStyle ()); TreeNodeStyle tns = new TreeNodeStyle (); tns.ImageUrl = "StyleImageUrl"; tv.LevelStyles.Add (tns); tv.LevelStyles.Add (new TreeNodeStyle ()); Assert.AreEqual (3, tv.LevelStyles.Count, "BeforeCopyTo"); tv.LevelStyles.CopyTo (styleArray, 3); Assert.AreEqual ("StyleImageUrl", styleArray[4].ImageUrl, "AfterCopyTo"); }
/// <devdoc> /// Copies non-blank elements from the specified style, but will not overwrite /// any existing style elements. /// </devdoc> public override void MergeWith(Style s) { if (s != null) { if (IsEmpty) { // Merging with an empty style is equivalent to copying, // which is more efficient. CopyFrom(s); return; } base.MergeWith(s); TreeNodeStyle tns = s as TreeNodeStyle; if (tns != null && !tns.IsEmpty) { // Since we're already copying the registered CSS class in base.MergeWith, we don't // need to any attributes that would be included in that class. if (s.RegisteredCssClass.Length == 0) { if (tns.IsSet(PROP_VPADDING) && !this.IsSet(PROP_VPADDING)) { this.VerticalPadding = tns.VerticalPadding; } if (tns.IsSet(PROP_HPADDING) && !this.IsSet(PROP_HPADDING)) { this.HorizontalPadding = tns.HorizontalPadding; } } if (tns.IsSet(PROP_NODESPACING) && !this.IsSet(PROP_NODESPACING)) { this.NodeSpacing = tns.NodeSpacing; } if (tns.IsSet(PROP_CHILDNODESPADDING) && !this.IsSet(PROP_CHILDNODESPADDING)) { this.ChildNodesPadding = tns.ChildNodesPadding; } if (tns.IsSet(PROP_IMAGEURL) && !this.IsSet(PROP_IMAGEURL)) { this.ImageUrl = tns.ImageUrl; } } } }
public override void CopyFrom(Style s) { if (s != null) { base.CopyFrom(s); TreeNodeStyle style = s as TreeNodeStyle; if ((style != null) && !style.IsEmpty) { if (s.RegisteredCssClass.Length != 0) { if (style.IsSet(0x10000)) { base.ViewState.Remove("VerticalPadding"); base.ClearBit(0x10000); } if (style.IsSet(0x20000)) { base.ViewState.Remove("HorizontalPadding"); base.ClearBit(0x20000); } } else { if (style.IsSet(0x10000)) { this.VerticalPadding = style.VerticalPadding; } if (style.IsSet(0x20000)) { this.HorizontalPadding = style.HorizontalPadding; } } if (style.IsSet(0x40000)) { this.NodeSpacing = style.NodeSpacing; } if (style.IsSet(0x80000)) { this.ChildNodesPadding = style.ChildNodesPadding; } if (style.IsSet(0x100000)) { this.ImageUrl = style.ImageUrl; } } } }
public override void MergeWith(Style s) { if (s != null) { if (this.IsEmpty) { this.CopyFrom(s); } else { base.MergeWith(s); TreeNodeStyle style = s as TreeNodeStyle; if ((style != null) && !style.IsEmpty) { if (s.RegisteredCssClass.Length == 0) { if (style.IsSet(0x10000) && !base.IsSet(0x10000)) { this.VerticalPadding = style.VerticalPadding; } if (style.IsSet(0x20000) && !base.IsSet(0x20000)) { this.HorizontalPadding = style.HorizontalPadding; } } if (style.IsSet(0x40000) && !base.IsSet(0x40000)) { this.NodeSpacing = style.NodeSpacing; } if (style.IsSet(0x80000) && !base.IsSet(0x80000)) { this.ChildNodesPadding = style.ChildNodesPadding; } if (style.IsSet(0x100000) && !base.IsSet(0x100000)) { this.ImageUrl = style.ImageUrl; } } } } }
public override void CopyFrom(Style s) { if (s == null || s.IsEmpty) { return; } base.CopyFrom(s); TreeNodeStyle from = s as TreeNodeStyle; if (from == null) { return; } if (from.CheckBit((int)TreeNodeStyles.ChildNodesPadding)) { ChildNodesPadding = from.ChildNodesPadding; } if (from.CheckBit((int)TreeNodeStyles.HorizontalPadding)) { HorizontalPadding = from.HorizontalPadding; } if (from.CheckBit((int)TreeNodeStyles.ImageUrl)) { ImageUrl = from.ImageUrl; } if (from.CheckBit((int)TreeNodeStyles.NodeSpacing)) { NodeSpacing = from.NodeSpacing; } if (from.CheckBit((int)TreeNodeStyles.VerticalPadding)) { VerticalPadding = from.VerticalPadding; } }
public override void MergeWith(Style s) { if (s != null && !s.IsEmpty) { if (IsEmpty) { CopyFrom(s); return; } base.MergeWith(s); TreeNodeStyle with = s as TreeNodeStyle; if (with == null) { return; } if (with.CheckBit((int)TreeNodeStyles.ChildNodesPadding) && !CheckBit((int)TreeNodeStyles.ChildNodesPadding)) { ChildNodesPadding = with.ChildNodesPadding; } if (with.CheckBit((int)TreeNodeStyles.HorizontalPadding) && !CheckBit((int)TreeNodeStyles.HorizontalPadding)) { HorizontalPadding = with.HorizontalPadding; } if (with.CheckBit((int)TreeNodeStyles.ImageUrl) && !CheckBit((int)TreeNodeStyles.ImageUrl)) { ImageUrl = with.ImageUrl; } if (with.CheckBit((int)TreeNodeStyles.NodeSpacing) && !CheckBit((int)TreeNodeStyles.NodeSpacing)) { NodeSpacing = with.NodeSpacing; } if (with.CheckBit((int)TreeNodeStyles.VerticalPadding) && !CheckBit((int)TreeNodeStyles.VerticalPadding)) { VerticalPadding = with.VerticalPadding; } } }
public void TreeNodeStyle_Method_CopyFrom () { TreeNodeStyle tns = new TreeNodeStyle (); TreeNodeStyle copy = new TreeNodeStyle (); tns.BorderStyle = BorderStyle.Double; tns.BorderWidth = 3; tns.ChildNodesPadding = 4; tns.Height = 5; tns.HorizontalPadding = 6; tns.ImageUrl = "ImageUrl"; tns.NodeSpacing = 7; tns.VerticalPadding = 8; tns.Width = 9; copy.CopyFrom (tns); Assert.AreEqual (tns.BorderStyle, copy.BorderStyle, "BorderStyle"); Assert.AreEqual (tns.BorderWidth, copy.BorderWidth, "Borderidth"); Assert.AreEqual (tns.ChildNodesPadding, copy.ChildNodesPadding, "ChildNodesPadding"); Assert.AreEqual (tns.Height, copy.Height, "Height"); Assert.AreEqual (tns.HorizontalPadding, copy.HorizontalPadding, "HorizontalPadding"); Assert.AreEqual (tns.ImageUrl, copy.ImageUrl, "ImageUrl"); Assert.AreEqual (tns.NodeSpacing, copy.NodeSpacing, "NodeSpacing"); Assert.AreEqual (tns.VerticalPadding, copy.VerticalPadding, "VerticalPadding"); Assert.AreEqual (tns.Width, copy.Width, "Width"); }
public int Add(TreeNodeStyle style) { return(((IList)this).Add(style)); }
public void CopyTo (TreeNodeStyle[] array, int index) { ((IList)this).CopyTo (array, index); }
void AddNodeStyle (HtmlTextWriter writer, TreeNode node, int level, bool nodeIsSelected) { TreeNodeStyle style = new TreeNodeStyle (); if (Page.Header != null) { // styles are registered if (nodeStyle != null) { #if NET_4_0 style.PrependCssClass (nodeStyle.RegisteredCssClass); style.PrependCssClass (nodeStyle.CssClass); #else style.AddCssClass (nodeStyle.CssClass); style.AddCssClass (nodeStyle.RegisteredCssClass); #endif } if (node.IsLeafNode) { if (leafNodeStyle != null) { #if NET_4_0 style.PrependCssClass (leafNodeStyle.RegisteredCssClass); style.PrependCssClass (leafNodeStyle.CssClass); #else style.AddCssClass (leafNodeStyle.CssClass); style.AddCssClass (leafNodeStyle.RegisteredCssClass); #endif } } else if (node.IsRootNode) { if (rootNodeStyle != null) { #if NET_4_0 style.PrependCssClass (rootNodeStyle.RegisteredCssClass); style.PrependCssClass (rootNodeStyle.CssClass); #else style.AddCssClass (rootNodeStyle.CssClass); style.AddCssClass (rootNodeStyle.RegisteredCssClass); #endif } } else if (node.IsParentNode) { if (parentNodeStyle != null) { #if NET_4_0 style.AddCssClass (parentNodeStyle.RegisteredCssClass); style.AddCssClass (parentNodeStyle.CssClass); #else style.AddCssClass (parentNodeStyle.CssClass); style.AddCssClass (parentNodeStyle.RegisteredCssClass); #endif } } if (levelStyles != null && levelStyles.Count > level) { #if NET_4_0 style.PrependCssClass (levelStyles [level].RegisteredCssClass); style.PrependCssClass (levelStyles [level].CssClass); #else style.AddCssClass (levelStyles [level].CssClass); style.AddCssClass (levelStyles [level].RegisteredCssClass); #endif } if (nodeIsSelected) { #if NET_4_0 style.AddCssClass (selectedNodeStyle.RegisteredCssClass); style.AddCssClass (selectedNodeStyle.CssClass); #else style.AddCssClass (selectedNodeStyle.CssClass); style.AddCssClass (selectedNodeStyle.RegisteredCssClass); #endif } } else { // styles are not registered if (nodeStyle != null) { style.CopyFrom (nodeStyle); } if (node.IsLeafNode) { if (leafNodeStyle != null) { style.CopyFrom (leafNodeStyle); } } else if (node.IsRootNode) { if (rootNodeStyle != null) { style.CopyFrom (rootNodeStyle); } } else if (node.IsParentNode) { if (parentNodeStyle != null) { style.CopyFrom (parentNodeStyle); } } if (levelStyles != null && levelStyles.Count > level) style.CopyFrom (levelStyles [level]); if (nodeIsSelected) style.CopyFrom (selectedNodeStyle); } style.AddAttributesToRender (writer); }
public void TreeNodeStyle_ViewState () { TreeNodeStyle orig = new TreeNodeStyle (); ((IStateManager) orig).TrackViewState (); TreeNodeStyle copy = new TreeNodeStyle (); Assert.AreEqual (true, orig.IsEmpty, "TreeNodeStyle_ViewState"); orig.ChildNodesPadding = 4; orig.HorizontalPadding = 6; orig.ImageUrl = "ImageUrl"; orig.NodeSpacing = 7; orig.VerticalPadding = 8; Assert.AreEqual (false, orig.IsEmpty, "TreeNodeStyle_ViewState"); object state = ((IStateManager) orig).SaveViewState (); ((IStateManager) copy).LoadViewState (state); Assert.AreEqual (false, copy.IsEmpty, "TreeNodeStyle_ViewState"); Assert.AreEqual (4.0, copy.ChildNodesPadding.Value, "TreeNodeStyle_ViewState"); Assert.AreEqual (6.0, copy.HorizontalPadding.Value, "TreeNodeStyle_ViewState"); Assert.AreEqual ("ImageUrl", copy.ImageUrl, "TreeNodeStyle_ViewState"); Assert.AreEqual (7.0, copy.NodeSpacing.Value, "TreeNodeStyle_ViewState"); Assert.AreEqual (8.0, copy.VerticalPadding.Value, "TreeNodeStyle_ViewState"); }
public void TreeNodeStyleCollection_Method_Insert () { TreeView tv = new TreeView (); tv.LevelStyles.Add (new TreeNodeStyle ()); tv.LevelStyles.Add (new TreeNodeStyle ()); Assert.AreEqual (2, tv.LevelStyles.Count, "BeforeInsert"); TreeNodeStyle tns = new TreeNodeStyle (); tns.ImageUrl = "StyleImageUrl"; tv.LevelStyles.Insert (1, tns); Assert.AreEqual (3, tv.LevelStyles.Count, "AfterInsert1"); Assert.AreEqual ("StyleImageUrl", tv.LevelStyles[1].ImageUrl, "AfterInsert2"); }
public void Insert(int index, TreeNodeStyle style) { }
public int Add(TreeNodeStyle style) { return ((IList)this).Add(style); }
public void Remove (TreeNodeStyle style) { ((IList)this).Remove (style); }
public bool Contains(TreeNodeStyle style) { return(default(bool)); }
public void TreeNodeStyleCollection_Method_IndexOf () { TreeView tv = new TreeView (); TreeNodeStyle tns = new TreeNodeStyle (); tv.LevelStyles.Add (new TreeNodeStyle ()); tv.LevelStyles.Add (new TreeNodeStyle ()); Assert.AreEqual (-1, tv.LevelStyles.IndexOf (tns), "BeforeIndexOf"); tv.LevelStyles.Add (tns); tv.LevelStyles.Add (new TreeNodeStyle ()); Assert.AreEqual (2, tv.LevelStyles.IndexOf (tns), "AfterIndexOf"); }
public int IndexOf(TreeNodeStyle style) { return(default(int)); }
public void TreeNodeStyleCollection_ViewState () { TreeView tv = new TreeView (); ((IStateManager) tv.LevelStyles).TrackViewState (); TreeNodeStyle style = new TreeNodeStyle (); tv.LevelStyles.Add (style); Assert.AreEqual (false, style.IsEmpty, "TreeNodeStyleCollection_ViewState#1"); tv.LevelStyles.Remove (style); Assert.AreEqual (false, style.IsEmpty, "TreeNodeStyleCollection_ViewState#2"); tv.LevelStyles.Add (style); tv.LevelStyles.Add (new TreeNodeStyle ()); tv.LevelStyles [1].BackColor = Color.Blue; object state = ((IStateManager) tv.LevelStyles).SaveViewState (); TreeView copy = new TreeView (); ((IStateManager) copy.LevelStyles).TrackViewState (); ((IStateManager) copy.LevelStyles).LoadViewState (state); Assert.AreEqual (2, copy.LevelStyles.Count, "TreeNodeStyleCollection_ViewState#3"); Assert.AreEqual (false, copy.LevelStyles [0].IsEmpty, "TreeNodeStyleCollection_ViewState#4"); Assert.AreEqual (false, copy.LevelStyles [1].IsEmpty, "TreeNodeStyleCollection_ViewState#5"); Assert.AreEqual (Color.Blue, copy.LevelStyles [1].BackColor, "TreeNodeStyleCollection_ViewState#6"); }
public void TreeNodeStyleCollection_Method_RemoveAt () { TreeView tv = new TreeView (); TreeNodeStyle tns1 = new TreeNodeStyle (); tns1.ImageUrl = "first"; TreeNodeStyle tns2 = new TreeNodeStyle (); tns2.ImageUrl = "second"; TreeNodeStyle tns3 = new TreeNodeStyle (); tns3.ImageUrl = "third"; tv.LevelStyles.Add (tns1); tv.LevelStyles.Add (tns2); tv.LevelStyles.Add (tns3); Assert.AreEqual (3, tv.LevelStyles.Count, "BeforeRemove1"); Assert.AreEqual ("second", tv.LevelStyles[1].ImageUrl, "BeforeRemove2"); tv.LevelStyles.RemoveAt (1); Assert.AreEqual (2, tv.LevelStyles.Count, "AfterRemove1"); Assert.AreEqual ("third", tv.LevelStyles[1].ImageUrl, "AfterRemove2"); }
public int IndexOf (TreeNodeStyle style) { return ((IList)this).IndexOf (style); }
public bool Contains(TreeNodeStyle style) { return(((IList)this).Contains(style)); }
public void Insert (int index, TreeNodeStyle style) { ((IList)this).Insert (index, style); }
public void Insert(int index, TreeNodeStyle style) { ((IList)this).Insert(index, style); }
public void Remove(TreeNodeStyle style) { }
public int IndexOf(TreeNodeStyle style) { return(((IList)this).IndexOf(style)); }
public bool Contains(TreeNodeStyle style) { return default(bool); }
public void Remove(TreeNodeStyle style) { ((IList)this).Remove(style); }
public static void pageLoadRenderLevelStyleCssClass (Page page) { TreeView tv = new TreeView (); tv.EnableClientScript = false; tv.ID = "treeview1"; TreeNodeStyle tns = new TreeNodeStyle (); tns.CssClass = "TestCssClass1"; tv.LevelStyles.Add (tns); tns = new TreeNodeStyle (); tns.CssClass = "TestCssClass2"; tv.LevelStyles.Add (tns); XmlDataSource xmlds = new XmlDataSource (); xmlds.EnableCaching = false; xmlds.Data = xmlDataBind; tv.DataSource = xmlds; tv.DataBind (); LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG); LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG); page.Form.Controls.Add (lcb); page.Form.Controls.Add (tv); page.Form.Controls.Add (lce); }
public int IndexOf(TreeNodeStyle style) { return default(int); }
public int Add(TreeNodeStyle style) { return(default(int)); }
public void TreeNodeStyle_Method_Reset () { TreeNodeStyle tns = new TreeNodeStyle (); tns.BorderStyle = BorderStyle.Double; tns.BorderWidth = 3; tns.ChildNodesPadding = 4; tns.Height = 5; tns.HorizontalPadding = 6; tns.ImageUrl = "ImageUrl"; tns.NodeSpacing = 7; tns.VerticalPadding = 8; tns.Width = 9; Assert.AreEqual (BorderStyle.Double, tns.BorderStyle, "BorderStyle1"); Assert.AreEqual (3.0, tns.BorderWidth.Value, "BorderWidth1"); Assert.AreEqual (4.0, tns.ChildNodesPadding.Value, "ChildNodesPadding1"); Assert.AreEqual (5.0, tns.Height.Value, "Height1"); Assert.AreEqual (6.0, tns.HorizontalPadding.Value, "HorizontalPadding1"); Assert.AreEqual ("ImageUrl", tns.ImageUrl, "ImageUrl1"); Assert.AreEqual (7.0, tns.NodeSpacing.Value, "NodeSpacing1"); Assert.AreEqual (8.0, tns.VerticalPadding.Value, "VerticalPadding1"); Assert.AreEqual (9.0, tns.Width.Value, "Width1"); tns.Reset (); Assert.AreEqual (0.0, tns.BorderWidth.Value, "BorderWidth2"); Assert.AreEqual (0.0, tns.ChildNodesPadding.Value, "ChildNodesPadding2"); Assert.AreEqual (0.0, tns.Height.Value, "Height2"); Assert.AreEqual (0.0, tns.HorizontalPadding.Value, "HorizontalPadding2"); Assert.AreEqual ("", tns.ImageUrl, "ImageUrl2"); Assert.AreEqual (0.0, tns.NodeSpacing.Value, "NodeSpacing2"); Assert.AreEqual (0.0, tns.VerticalPadding.Value, "VerticalPadding2"); Assert.AreEqual (0.0, tns.Width.Value, "Width2"); }
public bool Contains (TreeNodeStyle style) { return ((IList)this).Contains (style); }
public void CopyTo(TreeNodeStyle[] styleArray, int index) { base.CopyTo(styleArray, index); }
public void TreeNodeStyle_Method_MergeWith () { TreeNodeStyle tns = new TreeNodeStyle (); TreeNodeStyle copy = new TreeNodeStyle (); tns.BorderStyle = BorderStyle.Double; tns.BorderWidth = 3; tns.ChildNodesPadding = 4; tns.Height = 5; tns.HorizontalPadding = 6; tns.ImageUrl = "ImageUrl"; tns.NodeSpacing = 7; tns.VerticalPadding = 8; tns.Width = 9; copy.ImageUrl = "NewImageUrl"; copy.NodeSpacing = 10; copy.VerticalPadding = 11; copy.Width = 12; copy.MergeWith (tns); Assert.AreEqual (tns.BorderStyle, copy.BorderStyle, "BorderStyle"); Assert.AreEqual (tns.BorderWidth, copy.BorderWidth, "Borderidth"); Assert.AreEqual (tns.ChildNodesPadding, copy.ChildNodesPadding, "ChildNodesPadding"); Assert.AreEqual (tns.Height, copy.Height, "Height"); Assert.AreEqual (tns.HorizontalPadding, copy.HorizontalPadding, "HorizontalPadding"); Assert.AreEqual ("NewImageUrl", copy.ImageUrl, "ImageUrl1"); Assert.AreEqual (Unit.Pixel (10), copy.NodeSpacing, "NodeSpacing1"); Assert.AreEqual (Unit.Pixel (11), copy.VerticalPadding, "VerticalPadding1"); Assert.AreEqual (Unit.Pixel (12), copy.Width, "Width1"); Assert.AreEqual ("NewImageUrl", copy.ImageUrl, "ImageUrl2"); Assert.AreEqual (10.0, copy.NodeSpacing.Value, "NodeSpacing2"); Assert.AreEqual (11.0, copy.VerticalPadding.Value, "VerticalPadding2"); Assert.AreEqual (12.0, copy.Width.Value, "Width2"); }
public int Add(TreeNodeStyle style) { return default(int); }