public override SpecificLayout Clone() { Specific_ContainerLayout clone = new Specific_ContainerLayout(); clone.CopyFrom(this); return(clone); }
public override SpecificLayout GetBestLayout(LayoutQuery query) { double width = query.MaxWidth; if (this.pixelWidth > 0) { width = Math.Floor(query.MaxWidth / this.pixelWidth) * this.pixelWidth; } double height = query.MaxHeight; if (this.pixelHeight > 0) { height = Math.Floor(query.MaxHeight / this.pixelHeight) * this.pixelHeight; } if (width != query.MaxWidth || height != query.MaxHeight) { query = query.WithDimensions(width, height); } SpecificLayout internalLayout = this.layoutToManage.GetBestLayout(query); if (internalLayout != null) { Size size = new Size(Math.Ceiling(internalLayout.Width / this.pixelWidth) * this.pixelWidth, Math.Ceiling(internalLayout.Height / this.pixelHeight) * this.pixelHeight); Specific_ContainerLayout result = new Specific_ContainerLayout(null, size, new LayoutScore(), internalLayout, new Thickness(0)); return(this.prepareLayoutForQuery(result, query)); } return(null); }
public void CopyFrom(Specific_ContainerLayout original) { base.CopyFrom(original); this.view = original.view; this.Size = original.Size; this.bonusScore = original.bonusScore; this.subLayout = original.subLayout; this.BorderThickness = original.BorderThickness; this.ChildFillsAvailableSpace = original.ChildFillsAvailableSpace; }
public override SpecificLayout GetBestLayout(LayoutQuery query) { Specific_ContainerLayout result; SpecificLayout sublayoutResult; if (this.SubLayout != null) { // We have a sublayout and haven't been asked to wrap it in another view, so we can just forward the query on to it sublayoutResult = this.SubLayout.GetBestLayout(query); if (this.view == null) { // If we haven't been asked to wrap the sublayout's result, we can just directly use it return(sublayoutResult); } else { if (sublayoutResult == null) { return(null); } result = this.makeSpecificLayout(this.view, sublayoutResult.Size, LayoutScore.Zero, sublayoutResult, new Thickness()); this.prepareLayoutForQuery(result, query); return(result); } } // if there is no subLayout, for now we just return an empty size Specific_ContainerLayout empty = this.makeSpecificLayout(this.view, new Size(), LayoutScore.Zero, null, new Thickness()); if (query.Accepts(empty)) { result = empty; } else { result = null; } this.prepareLayoutForQuery(result, query); return(result); }
public override SpecificLayout GetBestLayout(LayoutQuery query) { Specific_ContainerLayout result; // Determine whether there's room for the border double borderWidth = this.BorderThickness.Left + this.BorderThickness.Right; double borderHeight = this.BorderThickness.Top + this.BorderThickness.Bottom; LayoutQuery subQuery = query.WithDimensions(query.MaxWidth - borderWidth, query.MaxHeight - borderHeight); if (subQuery.MaxWidth < 0 || subQuery.MaxHeight < 0) { return(null); } // Query sublayout if it exists if (this.SubLayout != null) { SpecificLayout best_subLayout = this.SubLayout.GetBestLayout(subQuery); if (best_subLayout != null) { result = this.makeSpecificLayout(this.view, new Size(best_subLayout.Width + borderWidth, best_subLayout.Height + borderHeight), LayoutScore.Zero, best_subLayout, this.BorderThickness); result.ChildFillsAvailableSpace = this.ChildFillsAvailableSpace; this.prepareLayoutForQuery(result, query); return(result); } return(null); } // if there is no subLayout, for now we just return an empty size Specific_ContainerLayout empty = this.makeSpecificLayout(this.view, new Size(), LayoutScore.Zero, null, new Thickness()); if (query.Accepts(empty)) { result = empty; } else { result = null; } this.prepareLayoutForQuery(result, query); return(result); }