private void SetupPlaceHolder() { string sizeString = (string)(VirtualizedContainerService.GetHintSize(this.modelItem.GetCurrentValue())); Size? size = null; if (!string.IsNullOrEmpty(sizeString)) { size = Size.Parse(sizeString); } if (size == null) { size = defaultContainerSize; } this.MinWidth = size.Value.Width; this.MinHeight = size.Value.Height; }
public VirtualizingContainer(VirtualizedContainerService containerService, ModelItem modelItem, ICompositeView sourceContainer) { this.containerService = containerService; this.modelItem = modelItem; this.sourceContainer = sourceContainer; this.Focusable = false; this.BorderThickness = new Thickness(1); SetupPlaceHolder(); this.children = new List <VirtualizingContainer>(); this.Unloaded += (sender, args) => { this.containerService.tree.Remove(this); this.oldBounds = new Rect(0, 0, 0, 0); UnRegisterFromParentContainer(); }; this.Loaded += (sender, args) => { RegisterWithParentContainer(); }; }
public VirtualizingContainer(VirtualizedContainerService containerService, ModelItem modelItem, ICompositeView sourceContainer) { this.containerService = containerService; this.modelItem = modelItem; this.sourceContainer = sourceContainer; this.Focusable = false; this.BorderThickness = new Thickness(1); SetupPlaceHolder(); this.children = new List<VirtualizingContainer>(); this.Unloaded += (sender, args) => { this.containerService.tree.Remove(this); this.oldBounds = new Rect(0, 0, 0, 0); UnRegisterFromParentContainer(); }; this.Loaded += (sender, args) => { RegisterWithParentContainer(); }; }
private void AddToQuadTree() { try { Point currentPoint = GetPosition(); if (this.ActualHeight > 0 && this.ActualWidth > 0) { Rect bounds = new Rect(currentPoint, new Size(this.ActualWidth, this.ActualHeight)); Rect viewerBounds = this.containerService.GetViewerBounds(); bool isInView = viewerBounds.IntersectsWith(bounds) || viewerBounds.Contains(bounds) || bounds.Contains(viewerBounds); if (isInView) { this.Populate(); currentPoint = GetPosition(); bounds = new Rect(currentPoint, new Size(this.ActualWidth, this.ActualHeight)); } else { // a previous Arrange could have led to adding this to the quadtree already. // so remove previos instances from quadtree. if (!this.isPopulated) { if (this.BorderBrush != SystemColors.GrayTextBrush) { this.BorderBrush = SystemColors.GrayTextBrush; } } } if (this.oldBounds != bounds) { this.containerService.tree.Remove(this); this.containerService.tree.Insert(this, bounds); if (this.oldBounds != Rect.Empty) { this.Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { foreach (VirtualizingContainer childContainer in this.children) { // if there were designers registered under the old bounds let them re-register childContainer.AddToQuadTree(); } })); } this.oldBounds = bounds; } if (this.IsPopulated) { VirtualizedContainerService.SetHintSize(this.modelItem.GetCurrentValue(), bounds.Size.ToString(CultureInfo.InvariantCulture)); } } } catch (InvalidOperationException) { // This can happen if an arrange happened within the child of the container, when not in the visual tree // for the current breadcrumb root. The GetTransform will throw invalidoperation in this case. this.containerService.tree.Remove(this); } }