protected override VisualGroup CreateVisual(IRenderContext context, IStripe stripe) { IRectangle layout = stripe.Layout.ToRectD(); InsetsD stripeInsets; var group = new VisualGroup(); int index; if (stripe is IColumn) { var col = (IColumn)stripe; stripeInsets = new InsetsD(0, col.GetActualInsets().Top, 0, col.GetActualInsets().Bottom); index = col.ParentColumn.ChildColumns.ToList().FindIndex(curr => col == curr); } else { var row = (IRow)stripe; stripeInsets = new InsetsD(row.GetActualInsets().Left, 0, row.GetActualInsets().Right, 0); index = row.ParentRow.ChildRows.ToList().FindIndex((curr) => row == curr); } StripeDescriptor descriptor = index % 2 == 0 ? EvenStripeDescriptor : OddStripeDescriptor; group.Add(new RectangleVisual(layout.X, layout.Y, layout.Width, layout.Height) { Brush = descriptor.BackgroundBrush, Pen = new Pen(descriptor.BorderBrush, descriptor.BorderThickness) }); //Draw the insets if (stripeInsets.Left > 0) { group.Add(new RectangleVisual(layout.X, layout.Y, stripeInsets.Left, layout.Height) { Brush = descriptor.InsetBrush }); } if (stripeInsets.Top > 0) { group.Add(new RectangleVisual(layout.X, layout.Y, layout.Width, stripeInsets.Top) { Brush = descriptor.InsetBrush }); } if (stripeInsets.Right > 0) { group.Add(new RectangleVisual(layout.GetMaxX() - stripeInsets.Right, layout.Y, stripeInsets.Right, layout.Height) { Brush = descriptor.InsetBrush }); } if (stripeInsets.Bottom > 0) { group.Add(new RectangleVisual(layout.X, layout.GetMaxY() - stripeInsets.Bottom, layout.Width, stripeInsets.Bottom) { Brush = descriptor.InsetBrush }); } return(group); }
public bool Equals(StripeDescriptor other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other.backgroundBrush, backgroundBrush) && Equals(other.insetBrush, insetBrush) && Equals(other.borderBrush, borderBrush) && other.borderThickness.Equals(borderThickness)); }
protected override VisualGroup UpdateVisual(IRenderContext context, VisualGroup oldVisual, IStripe stripe) { var layout = stripe.Layout.ToRectD(); if (oldVisual.Children.Count == 2) { Thickness stripeInsets; int index; if (stripe is IColumn) { var col = (IColumn)stripe; stripeInsets = new Thickness(0, col.GetActualInsets().Top, 0, col.GetActualInsets().Bottom); index = col.ParentColumn.ChildColumns.ToList().FindIndex((curr) => col == curr); } else { var row = (IRow)stripe; stripeInsets = new Thickness(row.GetActualInsets().Left, 0, row.GetActualInsets().Right, 0); index = row.ParentRow.ChildRows.ToList().FindIndex((curr) => row == curr); } StripeDescriptor descriptor = index % 2 == 0 ? EvenStripeDescriptor : OddStripeDescriptor; var border = (Border)oldVisual.Children[0]; border.Background = descriptor.BackgroundBrush; border.BorderBrush = descriptor.InsetBrush; border.BorderThickness = stripeInsets; border.Width = layout.Width; border.Height = layout.Height; var border2 = (Border)oldVisual.Children[1]; border2.Background = Brushes.Transparent; border2.BorderBrush = descriptor.BorderBrush; border2.BorderThickness = descriptor.BorderThickness; border2.Width = layout.Width; border2.Height = layout.Height; oldVisual.SetCanvasArrangeRect(layout.ToRectD()); return(oldVisual); } else { return(CreateVisual(context, stripe)); } }
protected override VisualGroup CreateVisual(IRenderContext context, IStripe stripe) { var layout = stripe.Layout.ToRectD(); var cc = new VisualGroup(); Thickness stripeInsets; int index; if (stripe is IColumn) { var col = (IColumn)stripe; stripeInsets = new Thickness(0, col.GetActualInsets().Top, 0, col.GetActualInsets().Bottom); index = col.ParentColumn.ChildColumns.ToList().FindIndex((curr) => col == curr); } else { var row = (IRow)stripe; stripeInsets = new Thickness(row.GetActualInsets().Left, 0, row.GetActualInsets().Right, 0); index = row.ParentRow.ChildRows.ToList().FindIndex((curr) => row == curr); } StripeDescriptor descriptor = index % 2 == 0 ? EvenStripeDescriptor : OddStripeDescriptor; cc.Add(new Border { Background = descriptor.BackgroundBrush, BorderBrush = descriptor.InsetBrush, BorderThickness = stripeInsets, Width = layout.Width, Height = layout.Height }); cc.Add(new Border { Background = Brushes.Transparent, BorderBrush = descriptor.BorderBrush, BorderThickness = descriptor.BorderThickness, Width = layout.Width, Height = layout.Height }); cc.SetCanvasArrangeRect(layout.ToRectD()); return(cc); }
protected override VisualGroup UpdateVisual(IRenderContext context, VisualGroup group, IStripe stripe) { IRectangle layout = stripe.Layout.ToRectD(); InsetsD stripeInsets; int index; if (stripe is IColumn) { var col = (IColumn)stripe; stripeInsets = new InsetsD(0, col.GetActualInsets().Top, 0, col.GetActualInsets().Bottom); index = col.ParentColumn.ChildColumns.ToList().FindIndex((curr) => col == curr); } else { var row = (IRow)stripe; stripeInsets = new InsetsD(row.GetActualInsets().Left, 0, row.GetActualInsets().Right, 0); index = row.ParentRow.ChildRows.ToList().FindIndex((curr) => row == curr); } StripeDescriptor descriptor = index % 2 == 0 ? EvenStripeDescriptor : OddStripeDescriptor; var rect = (RectangleVisual)group.Children[0]; rect.Rectangle = layout; rect.Brush = descriptor.BackgroundBrush; if (rect.Pen.Brush != descriptor.BorderBrush) { rect.Pen = new Pen(descriptor.BorderBrush, descriptor.BorderThickness); } int count = 1; //Draw the insets if (stripeInsets.Left > 0) { if (count >= group.Children.Count) { group.Add(new RectangleVisual(layout.X, layout.Y, stripeInsets.Left, layout.Height) { Brush = descriptor.InsetBrush }); } else { rect = (RectangleVisual)group.Children[count]; rect.Rectangle = new RectD(layout.X, layout.Y, stripeInsets.Left, layout.Height); } count++; } if (stripeInsets.Top > 0) { if (count >= group.Children.Count) { group.Add(new RectangleVisual(layout.X, layout.Y, layout.Width, stripeInsets.Top) { Brush = descriptor.InsetBrush }); } else { rect = (RectangleVisual)group.Children[count]; rect.Rectangle = new RectD(layout.X, layout.Y, layout.Width, stripeInsets.Top); } count++; } if (stripeInsets.Right > 0) { if (count >= group.Children.Count) { group.Add(new RectangleVisual(layout.GetMaxX() - stripeInsets.Right, layout.Y, stripeInsets.Right, layout.Height) { Brush = descriptor.InsetBrush }); } else { rect = (RectangleVisual)group.Children[count]; rect.Rectangle = new RectD(layout.GetMaxX() - stripeInsets.Right, layout.Y, stripeInsets.Right, layout.Height); } count++; } if (stripeInsets.Bottom > 0) { if (count >= group.Children.Count) { group.Add(new RectangleVisual(layout.X, layout.GetMaxY() - stripeInsets.Bottom, layout.Width, stripeInsets.Bottom) { Brush = descriptor.InsetBrush }); } else { rect = (RectangleVisual)group.Children[count]; rect.Rectangle = new RectD(layout.X, layout.GetMaxY() - stripeInsets.Bottom, layout.Width, stripeInsets.Bottom); } count++; } while (group.Children.Count > count) { group.Children.RemoveAt(group.Children.Count - 1); } return(group); }