protected override void ArrangeContent(SizeF finalSize) { var padding = this.Padding; var availableSize = new SizeF( finalSize.Width - padding.HorizontalThicknessF() - this.Margin.HorizontalThicknessF(), finalSize.Height - padding.VerticalThicknessF() - this.Margin.VerticalThicknessF()); var contentSize = this.MessureContent(availableSize); var contentFrame = new RectangleF(padding.LeftF(), padding.TopF(), contentSize.Width, contentSize.Height); this.NativeArrangeContent(contentFrame); }
public ImageScrollView(UIView View, nfloat Height, nfloat Width, UIColor BackgroundColor, CoreGraphics.CGSize imageSize) { this.Height = Height; this.Width = Width; this.scrollView = new UIScrollView { Frame = new CoreGraphics.CGRect (View.Bounds.Top, View.Bounds.Bottom - this.Height, View.Bounds.Width, this.Height), BackgroundColor = BackgroundColor }; this.ImageSize = imageSize; View.AddSubview (this.scrollView); }
public ImageScrollView(UIView View) { this.Height = 100.0f; this.Width = View.Bounds.Width; this.scrollView = new UIScrollView { Frame = new CoreGraphics.CGRect (View.Bounds.Top, View.Bounds.Bottom - this.Height, View.Bounds.Width, this.Height), BackgroundColor = new UIColor(0, 0, 255, 0) }; this.ImageSize = new CoreGraphics.CGSize(100.0f, 100.0f); this.Blur (View); View.AddSubview (this.scrollView); }
public void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { GetOrCreateUser(uid); }
static extern RectangleF AVMakeRectWithAspectRatioInsideRect(/* CGSize */ SizeF aspectRatio, /* CGRect */ RectangleF boundingRect);
public override SizeF MeasureOverride(SizeF availableSize) { if (this.controlTemplateInstance != null) { var isMeasureNotActual = !this.IsMeasureValid; isMeasureNotActual |= isMeasureNotActual |= this.measuredFor == null || this.measuredFor.Value != availableSize; // || (availableSize.Height < this.measuredFor.Value.Height && this.measuredSize.Height > availableSize.Height) // || (availableSize.Width < this.measuredFor.Value.Width && this.measuredSize.Width > availableSize.Width)); if (!isMeasureNotActual) { return this.measuredSize; } this.measuredFor = availableSize; if (this.Visibility == Controls.Visibility.Collapsed) { return new System.Drawing.SizeF(); } if (!double.IsNaN(this.Height)) { availableSize.Height = (nfloat)this.Height; } else { availableSize.Height -= this.Margin.VerticalThicknessF() + this.Padding.VerticalThicknessF(); } if (!double.IsNaN(this.Width)) { availableSize.Width = (nfloat)this.Width; } else { availableSize.Width -= this.Margin.HorizontalThicknessF() + this.Padding.HorizontalThicknessF(); } this.measuredSize = this.controlTemplateInstance.MeasureOverride(availableSize); if (!double.IsNaN(this.Height)) { measuredSize.Height = (nfloat)this.Height; } if (!double.IsNaN(this.Width)) { measuredSize.Width = (nfloat)this.Width; } this.measuredSize.Height += this.Margin.VerticalThicknessF() + this.Padding.VerticalThicknessF(); this.measuredSize.Width += this.Margin.HorizontalThicknessF() + this.Padding.HorizontalThicknessF(); this.measuredSizeCashe = this.measuredSize; this.IsMeasureValid = true; } else { this.measuredSize = base.MeasureOverride(availableSize); } return this.measuredSize; }
public static SizeF ToSystemSizeF(this iOSSize size) => new SizeF((float)size.Width, (float)size.Height);
//----------------------------------------------------------------------------------------------------------------------- static public void ExpandWidthToSize(CoreGraphics.CGSize toSize, UIView view, double rightBorder) { view.Frame = new CoreGraphics.CGRect(view.Frame.X, view.Frame.Y, toSize.Width - view.Frame.X - rightBorder, view.Frame.Height); }
/* /// <summary> /// Returns an instance of grid line renderer when we need it, or null - otherwise /// </summary> /// <returns></returns> private GridLinesRenderer EnsureGridLinesRenderer() { if (this.ShowGridLines && (_GridLinesRenderer == null)) { _GridLinesRenderer = new GridLinesRenderer(this); //AddVisualChild(_GridLinesRenderer); this.Children.Add(_GridLinesRenderer); } if (!this.ShowGridLines && (_GridLinesRenderer != null)) { //RemoveVisualChild(_GridLinesRenderer); this.Children.Remove(_GridLinesRenderer); _GridLinesRenderer = null; } return _GridLinesRenderer; } * */ /// <summary> /// Initializes cells cache when it is empty or obsolete /// </summary> /// <param name="finalSize"></param> private void InitCellsCacheIfNeeded(ref SizeF finalSize) { if (this.cells == null || this.CellsStructureDirty || this.lastMeasuredSize != finalSize) { this.InitCellsCache(ref finalSize); this.lastMeasuredSize = finalSize; } }
private void InitCellsCache(ref SizeF finalSize) { ////using (new PerformanceChecker(this, new object[] { finalSize })) ////{ if (finalSize.IsEmpty) { return; } #region Prepare SizeF avaliableSize = new SizeF(finalSize.Width, finalSize.Height); this.CellsStructureDirty = false; bool treatColumnStarAsAuto = this.HorizontalAlignment != HorizontalAlignment.Stretch || nfloat.IsInfinity(finalSize.Width); bool treatRowStarAsAuto = this.VerticalAlignment != VerticalAlignment.Stretch || nfloat.IsInfinity(finalSize.Height); this.cells = this.PrepareCells(avaliableSize, treatColumnStarAsAuto, treatRowStarAsAuto); #endregion // Prepare #region Calculating draft sizes and offfsets for columns and rows int columnIndex = 0; double currentX = 0; foreach (var column in this.ColumnDefinitionsInternal) { column.FinalOffset = currentX; // This is draft value if (column.Width.IsAbsolute) { column.ActualWidth = column.Width.Value; } else { column.ActualWidth = column.MinWidth; } currentX += column.ActualWidth; ++columnIndex; } int rowIndex = 0; double currentY = 0; foreach (var row in this.RowDefinitionsInternal) { row.FinalOffset = currentY; // This is draft value if (row.Height.IsAbsolute) { row.ActualHeight = row.Height.Value; } else { row.ActualHeight = row.MinHeight; } currentY += row.ActualHeight; ++rowIndex; } #endregion //Calculating draft sizes and offfsets for columns and rows #region Pre-measure foreach (var cell in this.cells) { if (cell.IsColumnsStar && cell.IsRowsStar) { continue; } double availableWidth; double availableHeight; if (cell.IsColumnsAbsolute) { availableWidth = this.ColumnDefinitionsInternal.EnumerableRange(cell.ColumnStart, cell.ColumnSpan).Sum(x => x.ActualWidth); } else { availableWidth = avaliableSize.Width - this.ColumnDefinitionsInternal[cell.ColumnStart].Offset; } if (cell.IsRowsAbsolute) { availableHeight = this.RowDefinitionsInternal.EnumerableRange(cell.RowStart, cell.RowSpan).Sum(x => x.ActualHeight); } else { availableHeight = avaliableSize.Height - this.RowDefinitionsInternal[cell.RowStart].Offset; } var t = cell.Measure(new SizeF((nfloat)availableWidth, (nfloat)availableHeight)); } #endregion // Pre-measure #region Add size for 'auto' columns and rows if content doesn't fit in them foreach (var cellCache in this.cells.OrderBy(x => x.ColumnSpan).ThenBy(x => x.RowSpan)) { if (cellCache.IsColumnsAuto && !cellCache.IsColumnsStar) { var columns = this.ColumnDefinitionsInternal.EnumerableRange(cellCache.ColumnStart, cellCache.ColumnSpan, true); var widthToAdd = cellCache.MeasuredSize.Width - columns.Sum(x => x.ActualWidth); if (widthToAdd > 0) { foreach (var column in columns.Where(x => x.Width.IsAuto || (x.Width.IsStar && treatColumnStarAsAuto))) { var maxWidthToAdd = column.MaxWidth - column.ActualWidth; if (widthToAdd > maxWidthToAdd) { column.ActualWidth = column.MaxWidth; widthToAdd -= maxWidthToAdd; } else { column.ActualWidth += widthToAdd; break; } } } } } foreach (var cellCache in this.cells.OrderBy(x => x.RowSpan)) { if (cellCache.IsRowsAuto && !cellCache.IsRowsStar) { var rows = this.RowDefinitionsInternal.EnumerableRange(cellCache.RowStart, cellCache.RowSpan, true); var heighToAdd = cellCache.MeasuredSize.Height - rows.Sum(x => x.ActualHeight); if (heighToAdd > 0) { foreach (var row in rows.Where(x => x.Height.IsAuto || (x.Height.IsStar && treatRowStarAsAuto))) { var maxHeightToAdd = row.MaxHeight - row.ActualHeight; if (heighToAdd > maxHeightToAdd) { row.ActualHeight = row.MaxHeight; heighToAdd -= maxHeightToAdd; } else { row.ActualHeight += heighToAdd; break; } } } } } #endregion //Add size for 'auto' columns and rows if content doesn't fit in them #region Devide rest size between 'star' columns and rows if (!treatColumnStarAsAuto) { double fullWidth = this.ColumnDefinitionsInternal.Sum(x => x.ActualWidth); var widthToDevide = finalSize.Width - fullWidth; if (widthToDevide > 0) { var starWidthWeightSum = this.ColumnDefinitionsInternal.Where(x => x.Width.IsStar).Sum(x => x.Width.Value); var widthForWeightOne = widthToDevide / starWidthWeightSum; var possibleColumnsToRecalculateWidth = new List<ColumnDefinition>(); foreach (var columnDefinition in this.ColumnDefinitionsInternal.Where(x => x.Width.IsStar)) { columnDefinition.ActualWidth = columnDefinition.Width.Value * widthForWeightOne; if (columnDefinition.ActualWidth < columnDefinition.MinWidth) { columnDefinition.ActualWidth = columnDefinition.MinWidth; starWidthWeightSum -= columnDefinition.Width.Value; } else if (columnDefinition.ActualWidth > columnDefinition.MaxWidth) { columnDefinition.ActualWidth = columnDefinition.MaxWidth; starWidthWeightSum -= columnDefinition.Width.Value; } else { possibleColumnsToRecalculateWidth.Add(columnDefinition); } widthToDevide -= columnDefinition.ActualWidth; } if (possibleColumnsToRecalculateWidth.Count != 0 && widthToDevide > 0 && starWidthWeightSum > 0) { widthForWeightOne = widthToDevide / starWidthWeightSum; foreach (var columnDefinition in possibleColumnsToRecalculateWidth) { columnDefinition.ActualWidth += columnDefinition.Width.Value * widthForWeightOne; } } } } if (!treatRowStarAsAuto) { double fullHeight = this.RowDefinitionsInternal.Sum(x => x.ActualHeight); var heightToDevide = finalSize.Height - fullHeight; if (heightToDevide > 0) { var starHeightWeightSum = this.RowDefinitionsInternal.Where(x => x.Height.IsStar).Sum(x => x.Height.Value); var heightForWeightOne = heightToDevide / starHeightWeightSum; var possibleRowsToRecalculateHeight = new List<RowDefinition>(); foreach (var rowDefinition in this.RowDefinitionsInternal.Where(x => x.Height.IsStar)) { rowDefinition.ActualHeight = rowDefinition.Height.Value * heightForWeightOne; if (rowDefinition.ActualHeight < rowDefinition.MinHeight) { rowDefinition.ActualHeight = rowDefinition.MinHeight; starHeightWeightSum -= rowDefinition.Height.Value; } else if (rowDefinition.ActualHeight > rowDefinition.MaxHeight) { rowDefinition.ActualHeight = rowDefinition.MaxHeight; starHeightWeightSum -= rowDefinition.Height.Value; } else { possibleRowsToRecalculateHeight.Add(rowDefinition); } heightToDevide -= rowDefinition.ActualHeight; } if (possibleRowsToRecalculateHeight.Count != 0 && heightToDevide > 0 && starHeightWeightSum > 0) { heightForWeightOne = heightToDevide / starHeightWeightSum; foreach (var rowDefinition in possibleRowsToRecalculateHeight) { rowDefinition.ActualHeight += rowDefinition.Height.Value * heightForWeightOne; } } } } #endregion //Devide rest size between 'star' columns and rows #region Final remeasure for cells with 'star' size foreach (var cell in this.cells) { if (!cell.IsColumnsStar && !cell.IsRowsStar) { continue; } double width = 0.0; int startColumn = cell.ColumnStart; int endColumn = cell.ColumnStart + cell.ColumnSpan; for (int i = startColumn; i < endColumn; i++) { width += this.ColumnDefinitionsInternal[i].ActualWidth; } double height = 0.0; int startRow = cell.RowStart; int endRow = cell.RowStart + cell.RowSpan; for (int i = startRow; i < endRow; i++) { height += this.RowDefinitionsInternal[i].ActualHeight; } var t = cell.Measure(new SizeF((nfloat)width, (nfloat)height)); } #endregion // Final remeasure for cells with 'star' size #region Offsets calculation currentX = 0; foreach (var columnDefinition in this.ColumnDefinitionsInternal) { columnDefinition.FinalOffset = currentX; currentX += columnDefinition.ActualWidth; } currentY = 0; foreach (var rowDefinition in this.RowDefinitionsInternal) { rowDefinition.FinalOffset = currentY; currentY += rowDefinition.ActualHeight; } #endregion //Offsets calculation finalSize = new SizeF( ////(nfloat)(treatColumnStarAsAuto ? currentX : finalSize.Width), ////(nfloat)(treatRowStarAsAuto ? currentY : finalSize.Height) (nfloat)currentX, (nfloat)currentY ); ////if (EnsureGridLinesRenderer() != null) ////{ //// _GridLinesRenderer.InitLines(finalSize); ////} ////} }
public override void UpdateLayout() { if (this.NativeUIElement != null) { base.UpdateLayout(); if (this.Content != null) { var contentWidth = (nfloat)this.ActualWidth; var contentHeight = (nfloat)this.ActualHeight; if (this.HorizontalScrollBarVisibility == ScrollBarVisibility.Disabled) { contentWidth = (nfloat)this.ActualWidth; } else { if (this.Content is UIElement && ((UIElement)this.Content).ReadLocalValue(UIElement.WidthProperty) == DependencyProperty.UnsetValue) { contentWidth = nfloat.PositiveInfinity; } else { contentWidth = (nfloat)this.ActualWidth; } } if (this.VerticalScrollBarVisibility == ScrollBarVisibility.Disabled) { contentHeight = (nfloat)this.ActualHeight; } else { if (this.Content is UIElement && ((UIElement)this.Content).ReadLocalValue(UIElement.HeightProperty) == DependencyProperty.UnsetValue) { contentHeight = nfloat.PositiveInfinity; } else { contentHeight = (nfloat)this.ActualHeight; } } var contentSize = new SizeF(contentWidth, contentHeight); contentSize = ((UIElement)this.Content).SizeThatFitsMaxAndMin(contentSize); this.contentSize = this.MeasureContent(contentSize); this.ArrangeContent(this.contentSize); var measuredWidth = default(nfloat); var measuredHeight = default(nfloat); if (this.HorizontalScrollBarVisibility == ScrollBarVisibility.Disabled) { measuredWidth = (nfloat)this.ActualWidth; } else { measuredWidth = (nfloat)Math.Max(this.contentSize.Width, this.ActualWidth); } if (this.VerticalScrollBarVisibility == ScrollBarVisibility.Disabled) { measuredHeight = (nfloat)this.ActualHeight; } else { measuredHeight = (nfloat)Math.Max(this.contentSize.Height, this.ActualHeight); } this.SetContentScrolableSize(new SizeF(measuredWidth, measuredHeight)); } } }
/// <summary> /// Arranges specified cell. /// </summary> /// <param name="cell">Target cell to arrange.</param> /// <param name="finalSize">Size of area for the cell.</param> private void ArrangeCell(CellCache cell, SizeF finalSize) { var rows = this.RowDefinitionsInternal.ListRange(cell.RowStart, cell.RowSpan); var columns = this.ColumnDefinitionsInternal.ListRange(cell.ColumnStart, cell.ColumnSpan); if (rows.Count == 0 || columns.Count == 0) { return; } var left = (nfloat)columns[0].Offset; var top = (nfloat)rows[0].Offset; var width = (nfloat)columns.Sum(x => x.ActualWidth); var height = (nfloat)rows.Sum(x => x.ActualHeight); if (left + width > finalSize.Width) { width = finalSize.Width - left; } if (width < 0) { width = 0; } if (top + height > finalSize.Height) { height = finalSize.Height - top; } if (height < 0) { height = 0; } RectangleF contentRectangle = new RectangleF(left, top, width, height); if (cell.Element.ReadLocalValue(UIElement.VerticalAlignmentProperty) != DependencyProperty.UnsetValue) { switch (cell.Element.VerticalAlignment) { case VerticalAlignment.Bottom: contentRectangle.Y = top + height - cell.MeasuredSize.Height; contentRectangle.Height = cell.MeasuredSize.Height; break; case VerticalAlignment.Center: contentRectangle.Y = top + height / 2f - cell.MeasuredSize.Height / 2f; contentRectangle.Height = cell.MeasuredSize.Height; break; case VerticalAlignment.Stretch: contentRectangle.Y = top; contentRectangle.Height = height; break; case VerticalAlignment.Top: contentRectangle.Y = top; contentRectangle.Height = cell.MeasuredSize.Height; break; } } else { if (cell.Element.ReadLocalValue(UIElement.HeightProperty) != DependencyProperty.UnsetValue || cell.Element.ReadValueFromStyle(UIElement.HeightProperty) != DependencyProperty.UnsetValue) { contentRectangle.Y = top + height / 2f - (nfloat)cell.Element.Height / 2f; contentRectangle.Height = (nfloat)cell.Element.Height; } else { contentRectangle.Y = top; contentRectangle.Height = height; } } if (cell.Element.ReadLocalValue(UIElement.HorizontalAlignmentProperty) != DependencyProperty.UnsetValue) { switch (cell.Element.HorizontalAlignment) { case HorizontalAlignment.Center: contentRectangle.X = left + width / 2f - cell.MeasuredSize.Width / 2f; contentRectangle.Width = cell.MeasuredSize.Width; break; case HorizontalAlignment.Left: contentRectangle.X = left; contentRectangle.Width = cell.MeasuredSize.Width; break; case HorizontalAlignment.Right: contentRectangle.X = left + width - cell.MeasuredSize.Width; contentRectangle.Width = cell.MeasuredSize.Width; break; case HorizontalAlignment.Stretch: contentRectangle.X = left; contentRectangle.Width = width; break; } } else { if (cell.Element.ReadLocalValue(UIElement.WidthProperty) != DependencyProperty.UnsetValue || cell.Element.ReadValueFromStyle(UIElement.WidthProperty) != DependencyProperty.UnsetValue) { contentRectangle.X = left + width / 2f - (nfloat)cell.Element.Width / 2f; contentRectangle.Width = (nfloat)cell.Element.Width; } else { contentRectangle.X = left; contentRectangle.Width = width; } } cell.Element.Arrange(contentRectangle); }
/// <summary> /// Arranges cells /// </summary> /// <param name="finalSize"></param> private void ArrangeCells(SizeF finalSize) { ////if (_InitCellsInProgress) return; ////try ////{ ////_InitCellsInProgress = true; var margin = this.Margin; var availableContentSize = new SizeF(finalSize.Width - margin.HorizontalThicknessF(), finalSize.Height - margin.VerticalThicknessF()); this.InitCellsCacheIfNeeded(ref availableContentSize); if (this.cells != null) { foreach (var cell in this.cells) { this.ArrangeCell(cell, availableContentSize); } } ////if (EnsureGridLinesRenderer() != null) ////{ //// _GridLinesRenderer.Measure(finalSize); //// _GridLinesRenderer.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height)); ////} ////} ////finally ////{ //// _InitCellsInProgress = false; ////} }
/// <summary> /// Measures the children of a System.Windows.Controls.Grid in anticipation of /// arranging them during the System.Windows.Controls.Grid.ArrangeOverride(SizeF) /// pass. /// </summary> /// <param name="availableSize">Indicates an upper limit size that should not be exceeded.</param> /// <returns>SizeF that represents the required size to arrange child content.</returns> public override SizeF MeasureOverride(SizeF availableSize) { if (this.Visibility == Visibility.Collapsed) { this.measuredFor = availableSize; return this.measuredSize = SizeF.Empty; } var isMeasureNotActual = !this.IsMeasureValid; isMeasureNotActual |= (this.measuredFor == null || (availableSize.Height < this.measuredFor.Value.Height && this.measuredSize.Height > availableSize.Height) || (availableSize.Width < this.measuredFor.Value.Width && this.measuredSize.Width > availableSize.Width)); if (!isMeasureNotActual) { return this.measuredSize; } this.measuredFor = availableSize; this.CellsStructureDirty = true; availableSize = this.SizeThatFitsMaxAndMin(availableSize); var height = this.ReadLocalValue(Grid.HeightProperty) != DependencyProperty.UnsetValue ? (nfloat)this.Height : 0; var width = this.ReadLocalValue(Grid.WidthProperty) != DependencyProperty.UnsetValue ? (nfloat)this.Width : 0; if ((availableSize.Width == 0 && width == 0) || (availableSize.Height == 0 && height == 0) || this.Width == 0 || this.Height == 0) { this.measuredSize = this.SizeThatFitsMaxAndMin(new SizeF(width, height)); this.IsMeasureValid = true; return this.measuredSize; } // Why is it here? ////var res = base.MeasureOverride(availableSize); SizeF availableContentSize = new SizeF(availableSize); if (!nfloat.IsPositiveInfinity(availableSize.Width)) { availableContentSize.Width -= this.Margin.HorizontalThicknessF(); } if (!nfloat.IsPositiveInfinity(availableSize.Height)) { availableContentSize.Height -= this.Margin.VerticalThicknessF(); } this.InitCellsCacheIfNeeded(ref availableContentSize); if (this.ReadLocalValue(Grid.HeightProperty) != DependencyProperty.UnsetValue) { availableContentSize.Height = (nfloat)this.Height; } if (this.ReadLocalValue(Grid.WidthProperty) != DependencyProperty.UnsetValue) { availableContentSize.Width = (nfloat)this.Width; } availableContentSize.Width += this.Margin.HorizontalThicknessF(); availableContentSize.Height += this.Margin.VerticalThicknessF(); this.measuredSize = availableContentSize; this.IsMeasureValid = true; return availableContentSize; }
public SizeF Measure(SizeF availableSize) { ////using (new PerformanceChecker(this.Element, new object[] { availableSize })) ////{ ////var empty = SizeF.Empty; bool needReMeasure = this.MeasuredFor == null || (availableSize.Height < this.MeasuredFor.Value.Height && this.MeasuredSize.Height > availableSize.Height) || (availableSize.Width < this.MeasuredFor.Value.Width && this.MeasuredSize.Width > availableSize.Width); if (needReMeasure) { var newMeasuredSize = this.Element.MeasureOverride(availableSize); this.MeasuredFor = availableSize; this.MeasuredSize = newMeasuredSize; } return this.MeasuredSize; ////} }
private List<CellCache> PrepareCells(SizeF avaliableSize, bool treatColumnStarAsAuto, bool treatRowStarAsAuto) { var res = this.InternalChildren.Cast<UIElement>().Select(x => new CellCache() { Element = x, ColumnStart = GetColumn(x), ColumnSpan = GetColumnSpan(x), RowStart = GetRow(x), RowSpan = GetRowSpan(x), }).ToList(); res.ForEach(x => { if (x.ColumnStart >= this.ColumnDefinitionsInternal.Count) { x.ColumnStart = this.ColumnDefinitionsInternal.Count - 1; } if (x.ColumnStart + x.ColumnSpan - 1 >= this.ColumnDefinitionsInternal.Count) { x.ColumnSpan = this.ColumnDefinitionsInternal.Count - x.ColumnStart; } if (x.RowStart >= this.RowDefinitionsInternal.Count) { x.RowStart = this.RowDefinitionsInternal.Count - 1; } if (x.RowStart + x.RowSpan - 1 >= this.RowDefinitionsInternal.Count) { x.RowSpan = this.RowDefinitionsInternal.Count - x.RowStart; } var columns = this.ColumnDefinitionsInternal.EnumerableRange(x.ColumnStart, x.ColumnSpan); var rows = this.RowDefinitionsInternal.EnumerableRange(x.RowStart, x.RowSpan); x.IsColumnsAuto = columns.Any(y => y.Width.IsAuto); x.IsColumnsStar = columns.Any(y => y.Width.IsStar); x.IsRowsAuto = rows.Any(y => y.Height.IsAuto); x.IsRowsStar = rows.Any(y => y.Height.IsStar); if (treatColumnStarAsAuto) { x.IsColumnsAuto |= x.IsColumnsStar; x.IsColumnsStar = false; } if (treatRowStarAsAuto) { x.IsRowsAuto |= x.IsRowsStar; x.IsRowsStar = false; } }); return res; }
/// <summary> /// Firsts the remote video decoded of uid. /// </summary> /// <param name="engine">Engine.</param> /// <param name="uid">Uid.</param> /// <param name="size">Size.</param> /// <param name="elapsed">Elapsed.</param> public virtual void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { var id = (uint)uid; _knownStreams.Add(id); if (!_containers.Any(a => a.StreamUID == id)) { if (_containers.Any(a => a.StreamUID == Consts.UnknownRemoteStreamId)) { var viewHolder = _containers.First(a => a.StreamUID == Consts.UnknownRemoteStreamId); viewHolder.StreamUID = id; viewHolder.VideoView.IsOffline = false; } else { OnNewStream(id, (int)size.Width, (int)size.Height); } } }
public override SizeF MeasureOverride(SizeF availableSize) { if (this.Visibility == Visibility.Collapsed) { this.measuredFor = availableSize; return this.measuredSize = SizeF.Empty; } // TODO: size cashing this.measuredFor = availableSize; availableSize = this.SizeThatFitsMaxAndMin(availableSize); var verticalMargin = this.Margin.VerticalThicknessF(); var horizontalMargin = this.Margin.HorizontalThicknessF(); var verticalPadding = this.Padding.VerticalThicknessF(); var horizontalPadding = this.Padding.HorizontalThicknessF(); // here we count size without content but with margins, and some platfoms specific actions this.measuredSize = this.SizeThatFitsMaxAndMin(this.NativeMeasureOverride(availableSize)); var width = availableSize.Width - horizontalMargin - horizontalPadding; var height = availableSize.Height - verticalMargin - verticalPadding; if (this.HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled) { width = nfloat.PositiveInfinity; } if (this.VerticalScrollBarVisibility != ScrollBarVisibility.Disabled) { height = nfloat.PositiveInfinity; } this.contentSize = this.MeasureContent(new SizeF(width, height)); if (this.ReadLocalValue(UIElement.WidthProperty) == DependencyProperty.UnsetValue && this.ReadValueFromStyle(UIElement.WidthProperty) == DependencyProperty.UnsetValue) { this.measuredSize.Width += this.contentSize.Width + horizontalPadding; this.measuredSize.Width = MathF.Min(this.measuredSize.Width, availableSize.Width); } else { this.measuredSize.Width = (nfloat)this.Width + horizontalMargin; } if (this.ReadLocalValue(UIElement.HeightProperty) == DependencyProperty.UnsetValue && this.ReadValueFromStyle(UIElement.HeightProperty) == DependencyProperty.UnsetValue) { this.measuredSize.Height += this.contentSize.Height + verticalPadding; this.measuredSize.Height = MathF.Min(this.measuredSize.Height, availableSize.Height); } else { this.measuredSize.Height = (nfloat)this.Height + verticalMargin; } this.ViewportWidth = this.measuredSize.Width; this.ViewportHeight = this.measuredSize.Height; return this.measuredSize; }
public static RectangleF WithAspectRatio(this RectangleF self, SizeF aspectRatio) { return(AVMakeRectWithAspectRatioInsideRect(aspectRatio, self)); }
public override void Arrange(RectangleF finalRect) { if (this.ExtentWidth != finalRect.Width) { this.ExtentWidth = finalRect.Width; } if (this.ExtentHeight != finalRect.Height) { this.ExtentHeight = finalRect.Height; } if (this.IsArrangeValid && finalRect.Size == this.arrangedSize) { base.Arrange(finalRect); return; } this.arrangedSize = finalRect.Size; var verticalMargin = this.Margin.VerticalThicknessF(); var horizontalMargin = this.Margin.HorizontalThicknessF(); var verticalPadding = this.Padding.VerticalThicknessF(); var horizontalPadding = this.Padding.HorizontalThicknessF(); if (this.Content is UIElement) { bool widthSetByUser = ((UIElement)this.Content).ReadLocalValue(UIElement.WidthProperty) != DependencyProperty.UnsetValue || ((UIElement)this.Content).ReadValueFromStyle(UIElement.WidthProperty) != DependencyProperty.UnsetValue; bool heightSetByUser = ((UIElement)this.Content).ReadLocalValue(UIElement.HeightProperty) != DependencyProperty.UnsetValue || ((UIElement)this.Content).ReadValueFromStyle(UIElement.HeightProperty) != DependencyProperty.UnsetValue; if (((UIElement)this.Content).HorizontalAlignment == HorizontalAlignment.Stretch && !widthSetByUser && this.contentSize.Width < (finalRect.Width - horizontalMargin - horizontalPadding)) { this.contentSize.Width = finalRect.Width - horizontalMargin - horizontalPadding; } if (((UIElement)this.Content).VerticalAlignment == VerticalAlignment.Stretch && !heightSetByUser && this.contentSize.Height < (finalRect.Height - verticalMargin - verticalPadding)) { this.contentSize.Height = finalRect.Height - verticalMargin - verticalPadding; } this.contentSize = ((UIElement)this.Content).SizeThatFitsMaxAndMin(this.contentSize); } var measuredWidth = default(nfloat); var measuredHeight = default(nfloat); if (this.HorizontalScrollBarVisibility == ScrollBarVisibility.Disabled) { measuredWidth = finalRect.Width - horizontalMargin - horizontalPadding; } else { measuredWidth = MathF.Max(this.contentSize.Width, finalRect.Width - horizontalMargin - horizontalPadding); } if (this.VerticalScrollBarVisibility == ScrollBarVisibility.Disabled) { measuredHeight = finalRect.Height - verticalMargin - verticalPadding; } else { measuredHeight = MathF.Max(this.contentSize.Height, finalRect.Height - verticalMargin - verticalPadding); } this.ScrollableHeight = measuredHeight; this.ScrollableWidth = measuredWidth; this.SetContentScrolableSize(new SizeF(measuredWidth, measuredHeight)); base.Arrange(finalRect); }
public unsafe void ProcessARFrame(ARSession session, ARFrame frame) { var arcamera = frame?.Camera; var transform = arcamera.Transform; var viewportSize = new CoreGraphics.CGSize(Application.Graphics.Width, Application.Graphics.Height); float near = 0.001f; float far = 1000f; var prj = arcamera.GetProjectionMatrix(Orientation.Value, viewportSize, near, far); var dt = frame.GetDisplayTransform(Orientation.Value, viewportSize); var urhoProjection = *(Matrix4 *)(void *)&prj; urhoProjection.M43 /= 2f; urhoProjection.M33 = far / (far - near); urhoProjection.M34 *= -1; //prj.M13 = 0; //center of projection //prj.M23 = 0; //urhoProjection.Row2 *= -1; urhoProjection.Transpose(); Camera.SetProjection(urhoProjection); ApplyOpenTkTransform(Camera.Node, transform); if (!yuvTexturesInited) { var img = frame.CapturedImage; // texture for UV-plane; cameraUVtexture = new Texture2D(); cameraUVtexture.SetNumLevels(1); cameraUVtexture.SetSize((int)img.GetWidthOfPlane(1), (int)img.GetHeightOfPlane(1), Graphics.LuminanceAlphaFormat, TextureUsage.Dynamic); cameraUVtexture.FilterMode = TextureFilterMode.Bilinear; cameraUVtexture.SetAddressMode(TextureCoordinate.U, TextureAddressMode.Clamp); cameraUVtexture.SetAddressMode(TextureCoordinate.V, TextureAddressMode.Clamp); cameraUVtexture.Name = nameof(cameraUVtexture); Application.ResourceCache.AddManualResource(cameraUVtexture); // texture for Y-plane; cameraYtexture = new Texture2D(); cameraYtexture.SetNumLevels(1); cameraYtexture.FilterMode = TextureFilterMode.Bilinear; cameraYtexture.SetAddressMode(TextureCoordinate.U, TextureAddressMode.Clamp); cameraYtexture.SetAddressMode(TextureCoordinate.V, TextureAddressMode.Clamp); cameraYtexture.SetSize((int)img.Width, (int)img.Height, Graphics.LuminanceFormat, TextureUsage.Dynamic); cameraYtexture.Name = nameof(cameraYtexture); Application.ResourceCache.AddManualResource(cameraYtexture); var viewport = Application.Renderer.GetViewport(0); var videoRp = new RenderPathCommand(RenderCommandType.Quad); videoRp.PixelShaderName = (UrhoString)ArkitShader; videoRp.VertexShaderName = (UrhoString)ArkitShader; videoRp.SetOutput(0, "viewport"); videoRp.SetTextureName(TextureUnit.Diffuse, cameraYtexture.Name); //sDiffMap videoRp.SetTextureName(TextureUnit.Normal, cameraUVtexture.Name); //sNormalMap if (Orientation != UIInterfaceOrientation.Portrait) { videoRp.PixelShaderDefines = new UrhoString("ARKIT_LANDSCAPE"); } viewport.RenderPath.InsertCommand(1, videoRp); var vrp = viewport.RenderPath.GetCommand(1); vrp->SetShaderParameter("Tx", (float)dt.x0); vrp->SetShaderParameter("Ty", (float)dt.y0); vrp->SetShaderParameter("ScaleX", (float)dt.xx); vrp->SetShaderParameter("ScaleY", (float)dt.yy); vrp->SetShaderParameter("ScaleYX", (float)dt.yx); vrp->SetShaderParameter("ScaleXY", (float)dt.xy); float imageAspect = (float)img.Width / img.Height; float yoffset; if (ARConfiguration is ARFaceTrackingConfiguration) { yoffset = 0.013f; } else { yoffset = 64.0f / Math.Max(img.Width, img.Height); } vrp->SetShaderParameter("YOffset", yoffset); yuvTexturesInited = true; } if (yuvTexturesInited) { UpdateBackground(frame); } ARFrame?.Invoke(frame); // required! frame.Dispose(); }
protected override void ArrangeContent(SizeF finalSize) { if(finalSize.IsEmpty) { return; } if (this.Content is UIElement) { var padding = this.Padding; var x = padding.LeftF(); var y = padding.RightF(); var verticalPadding = padding.VerticalThicknessF(); var horizontalPadding = padding.HorizontalThicknessF(); var widthAvailableForContent = (nfloat)this.ActualWidth - horizontalPadding; var heightAvailableForContent = (nfloat)this.ActualHeight - verticalPadding; switch (((UIElement)this.Content).HorizontalAlignment) { case HorizontalAlignment.Right: x = MathF.Max(x, (nfloat)this.ActualWidth - padding.RightF() - this.contentSize.Width); break; case HorizontalAlignment.Center: x = (widthAvailableForContent - this.contentSize.Width == 0) ? x : x + (widthAvailableForContent - this.contentSize.Width) / 2; break; case HorizontalAlignment.Stretch: x = (widthAvailableForContent - this.contentSize.Width <= 0) ? x : x + (widthAvailableForContent - this.contentSize.Width) / 2; break; case HorizontalAlignment.Left: default: break; } switch (((UIElement)this.Content).VerticalAlignment) { case VerticalAlignment.Bottom: y = MathF.Max(y, (nfloat)this.ActualHeight - padding.BottomF() - this.contentSize.Height); break; case VerticalAlignment.Center: y = (heightAvailableForContent - this.contentSize.Height == 0) ? y : y + (heightAvailableForContent - this.contentSize.Height) / 2; break; case VerticalAlignment.Top: default: break; } var contentRect = new RectangleF(x, y, this.contentSize.Width, this.contentSize.Height); this.NativeArrangeContent(contentRect); } }
public override void ResizeSubviewsWithOldSize(CoreGraphics.CGSize oldSize) { base.ResizeSubviewsWithOldSize(oldSize); PlaybackManager.Shared.NativePlayer.VideoLayer.Frame = Bounds; }
public override SizeF MeasureOverride(SizeF availableSize) { if (this.Visibility == Visibility.Collapsed) { this.measuredFor = availableSize; return this.measuredSize = SizeF.Empty; } var isMeasureNotActual = !this.IsMeasureValid; isMeasureNotActual |= this.measuredFor == null || this.measuredFor.Value != availableSize; if (!isMeasureNotActual) { return this.measuredSize; } availableSize = this.SizeThatFitsMaxAndMin(availableSize); var size = base.MeasureOverride(availableSize); this.measuredFor = availableSize; if (this.Template == null) { var nativePadding = this.GetNativePadding(); var totalHorizontalOffsets = this.Padding.HorizontalThicknessF() + nativePadding.HorizontalThicknessF(); var totalVerticalOffsets = this.Padding.VerticalThicknessF() + nativePadding.VerticalThicknessF(); var isWidthNotSet = double.IsNaN(this.Width); var isHeightNotSet = double.IsNaN(this.Height); var widthForContent = isWidthNotSet ? availableSize.Width - totalHorizontalOffsets - this.Margin.HorizontalThicknessF() : (nfloat)this.Width - totalHorizontalOffsets; var heightForContent = isHeightNotSet ? availableSize.Height - totalVerticalOffsets - this.Margin.VerticalThicknessF() : (nfloat)this.Height - totalVerticalOffsets; this.contentSize = this.MessureContent(new SizeF(widthForContent, heightForContent)); if (isWidthNotSet) { size.Width += this.contentSize.Width + totalHorizontalOffsets; } if (isHeightNotSet) { size.Height += this.contentSize.Height + totalVerticalOffsets; } } this.IsMeasureValid = true; this.measuredSize = size; return size; }
public void DrawableSizeWillChange(MTKView view, CoreGraphics.CGSize size) { }
public override void UpdateLayout() { if (this.NativeUIElement != null) { base.UpdateLayout(); if (this.Content != null) { this.contentSize = this.MessureContent(this.RenderSize); } } }
public override SizeF MeasureOverride(SizeF availableSize) { if (this.Visibility == Visibility.Collapsed) { this.measuredFor = availableSize; return this.measuredSize = SizeF.Empty; } // TODO: size caching this.measuredFor = availableSize; var height = this.ReadLocalValue(StackPanel.HeightProperty) != DependencyProperty.UnsetValue ? (nfloat)this.Height : 0; var width = this.ReadLocalValue(StackPanel.WidthProperty) != DependencyProperty.UnsetValue ? (nfloat)this.Width : 0; foreach (var child in this.Children) { this.childSizeCache[child] = child.MeasureOverride(new SizeF(nfloat.PositiveInfinity, nfloat.PositiveInfinity)); } width += this.Margin.HorizontalThicknessF(); height += this.Margin.VerticalThicknessF(); return this.measuredSize = this.SizeThatFitsMaxAndMin(new SizeF(width, height)); }
protected virtual void ArrangeContent(SizeF finalSize) { Thickness nativePadding = this.GetNativePadding(); var totalLeftOffset = this.Padding.LeftF() + nativePadding.LeftF(); var totalTopOffset = this.Padding.TopF() + nativePadding.TopF(); var totalRightOffset = this.Padding.RightF() + nativePadding.RightF(); var totalBottomOffset = this.Padding.BottomF() + nativePadding.BottomF(); var rawWidthOfRect = finalSize.Width - this.Margin.HorizontalThicknessF(); var rawHeigthOfRect = finalSize.Height - this.Margin.VerticalThicknessF(); var x = (nfloat)totalLeftOffset; var y = (nfloat)totalTopOffset; var width = this.contentSize.Width; var heigth = this.contentSize.Height; if ((rawWidthOfRect - totalLeftOffset - totalRightOffset - this.contentSize.Width) > 0) { x += (rawWidthOfRect - totalLeftOffset - totalRightOffset - this.contentSize.Width) / 2; width = this.contentSize.Width; } if ((rawHeigthOfRect - totalTopOffset - totalBottomOffset - this.contentSize.Height) > 0) { y += (rawHeigthOfRect - totalTopOffset - totalBottomOffset - this.contentSize.Height) / 2; heigth = this.contentSize.Height; } var contentFrame = new RectangleF(x, y, width, heigth); if (this.contentTemplateInstance == null) { this.NativeArrangeContent(contentFrame); } else { this.contentTemplateInstance.Arrange(contentFrame); } }
public override SizeF SizeThatFits(SizeF size) { return ContentCell.SizeThatFits(size); }
protected SizeF MessureContent(SizeF availableSize) { if (availableSize.Width <= 0 || availableSize.Height <= 0) { return this.contentSize = SizeF.Empty; } if (this.contentTemplateInstance != null) { return this.contentTemplateInstance.MeasureOverride(availableSize); } if (this.contentTemplateInstance == null) { this.contentSize = this.NativeMeasureContent(availableSize); } return this.contentSize; }
public override SizeF SizeThatFits(SizeF size) { var measured = base.SizeThatFits(size); return(_buttonLayoutManager?.SizeThatFits(size, measured) ?? measured); }
public override void Arrange(RectangleF finalRect) { base.Arrange(finalRect); var content = this.Content; if (content == null) { return; } if (content.HorizontalAlignment == HorizontalAlignment.Stretch && content.ReadLocalValue(UIElement.WidthProperty) == DependencyProperty.UnsetValue) { this.contentSize.Width = finalRect.Width - this.Margin.HorizontalThicknessF(); } if (content.VerticalAlignment == VerticalAlignment.Stretch && content.ReadLocalValue(UIElement.HeightProperty) == DependencyProperty.UnsetValue) { this.contentSize.Height = finalRect.Height - this.Margin.VerticalThicknessF(); } this.contentSize = content.SizeThatFitsMaxAndMin(this.contentSize); var padding = this.Padding; var x = this.ActualWidth - this.contentSize.Width < 0 ? padding.Left : padding.Left + (this.ActualWidth - this.contentSize.Width - padding.HorizontalThickness()) / 2; var y = this.ActualHeight - this.contentSize.Height < 0 ? padding.Top : padding.Top + (this.ActualHeight - this.contentSize.Height - padding.VerticalThickness()) / 2; this.ArrangeContent(new RectangleF(new PointF((nfloat)x, (nfloat)y), this.contentSize)); }
public virtual override CoreGraphics.CGSize GetAccessibilityScreenForLayout(CoreGraphics.CGSize size) { throw new NotImplementedException(); }
public override SizeF MeasureOverride(SizeF availableSize) { if (this.Visibility == Visibility.Collapsed) { this.measuredFor = availableSize; return this.measuredSize = SizeF.Empty; } var isMeasureNotActual = !this.IsMeasureValid; isMeasureNotActual |= this.measuredFor == null || (availableSize.Height < this.measuredFor.Value.Height && this.measuredSize.Height > availableSize.Height) || (availableSize.Width < this.measuredFor.Value.Width && this.measuredSize.Width > availableSize.Width); if (!isMeasureNotActual) { return this.measuredSize; } this.measuredFor = availableSize; availableSize = this.SizeThatFitsMaxAndMin(availableSize); var margin = this.Margin; var padding = this.Padding; var widthReduce = margin.HorizontalThicknessF() + padding.HorizontalThicknessF(); var heightReduce = margin.VerticalThicknessF() + padding.VerticalThicknessF(); var width = this.ReadLocalValue(UIElement.WidthProperty) == DependencyProperty.UnsetValue ? (nfloat?)null : (nfloat)this.Width; var height = this.ReadLocalValue(UIElement.HeightProperty) == DependencyProperty.UnsetValue ? (nfloat?)null : (nfloat)this.Height; var availableContentWidth = width.HasValue ? width.Value - padding.HorizontalThicknessF() : availableSize.Width - widthReduce; var availableContentHeight = height.HasValue ? height.Value - padding.VerticalThicknessF() : availableSize.Height - heightReduce; var content = this.Content; var contentSize = content == null ? SizeF.Empty : (this.contentSize = content.MeasureOverride(new SizeF(availableContentWidth, availableContentHeight))); var needWidth = width.HasValue ? width.Value + margin.HorizontalThicknessF() : contentSize.Width + widthReduce; var needHeight = width.HasValue ? height.Value + margin.VerticalThicknessF() : contentSize.Height + heightReduce; this.measuredSize = this.SizeThatFitsMaxAndMin(new SizeF(Math.Min(availableSize.Width, needWidth), Math.Min(availableSize.Height, needHeight))); return this.measuredSize; }
static extern /* CGRect */ RectangleF AVMakeRectWithAspectRatioInsideRect(/* CGSize */ SizeF aspectRatio, /* CGRect */ RectangleF boundingRect);
public override SizeF SizeThatFits(SizeF size) { IVisualElementRenderer renderer; if (!_rendererRef.TryGetTarget(out renderer)) return base.SizeThatFits(size); double width = size.Width; var height = size.Height > 0 ? size.Height : double.PositiveInfinity; var result = renderer.Element.Measure(width, height); // make sure to add in the separator return new SizeF(size.Width, (float)result.Request.Height + 1f / UIScreen.MainScreen.Scale); }
private Size OnArrange(Size finalSize) { if (TickmarkPositions == null || TickmarkPositions.Count() < 2) { return(finalSize); } var majorTickmarksBounds = new List <Rect>(); var minorTickmarksBounds = new List <Rect>(); // Iterate all child ticks and calculate bounds for each foreach (UIElement child in Children) { FrameworkElement c = child as FrameworkElement; if (c == null) { continue; } double position = GetPosition(c); var isMajorTickmark = GetIsMajorTickmark(c); if (isMajorTickmark && !ShowTickLabels) { continue; // Don't worry about calculating bounds for major ticks if labels are hidden } // Calculate the bounds of the tick mark position = finalSize.Width * position; var desiredSize = GetDesiredSize(c); var x = position - (desiredSize.Width * .5); #if __ANDROID__ // In the implementation of the Android time slider, the tickbar is aligned horizontally with its parent to allow // tick labels to use the entire space within the control. The TickInset property defines how much extra room is // available outside the bounds of the Tickbar and needs to be taken into account in the placement of ticks. // This inset also needs to be adjusted slightly, as it yields a position that is slightly offset for reasons as // yet unknown. var pixelsPerDip = Android.Util.TypedValue.ApplyDimension(Android.Util.ComplexUnitType.Dip, 1, ViewExtensions.GetDisplayMetrics()); x += TickInset - (2 * pixelsPerDip); #endif var childBounds = new Rect(0, 0, desiredSize.Width, finalSize.Height); childBounds.SetX(x); // Store the bounds for application later once tick (i.e. label) collision has been accounted for if (isMajorTickmark) { majorTickmarksBounds.Add(childBounds); } else { minorTickmarksBounds.Add(childBounds); } } if (ShowTickLabels) { // Calculate positioning of tick labels and major/minor ticks var minimumLabelSpacing = 6; var majorTickInterval = 2; var doMajorTicksCollide = false; var firstMajorTickIndex = 0; var tickCount = _minorTickmarks.Count; // Calculate the largest number of ticks to allow between major ticks. This prevents scenarios where // there are two major ticks placed undesirably close to the end of the tick bar. var maxMajorTickInterval = Math.Ceiling(tickCount / 2d); // Calculate the number of ticks between each major tick and the index of the first major tick for (int i = majorTickInterval; i <= maxMajorTickInterval; i++) { var prospectiveInterval = i; var allowsEqualNumberOfTicksOnEnds = false; // Check that the prospective interval between major ticks results in an equal number of minor // ticks on both ends of the tick bar for (int m = prospectiveInterval; m < tickCount; m += prospectiveInterval) { var totalNumberOfTicksOnEnds = tickCount - m + 1; // If the total number of minor ticks on both ends of the tick bar (i.e. before and after the // first and last major ticks) is less than the major tick interval being tested, then we've // found the number of minor ticks that would be on the ends if we use this major tick interval. // If that total is divisible by two, then the major tick interval under test allows for an // equal number of minor ticks on the ends. if (totalNumberOfTicksOnEnds / 2 < prospectiveInterval && totalNumberOfTicksOnEnds % 2 == 0) { allowsEqualNumberOfTicksOnEnds = true; break; } } // Only consider intervals that leave an equal number of ticks on the ends if (!allowsEqualNumberOfTicksOnEnds) { continue; } // Calculate the tick index of the first major tick if we were to use the prospective interval. // The index is calculated such that there will be an equal number of minor ticks before and // after the first and last major tick mark. firstMajorTickIndex = (int)Math.Truncate(((tickCount - 1) % prospectiveInterval) / 2d); doMajorTicksCollide = false; // With the given positioning of major tick marks, check whether they (i.e. their labels) will overlap for (var j = firstMajorTickIndex; j < tickCount - prospectiveInterval; j += i) { // Get the bounds of the major tick marks at index j and the one subsequent to that var currentBounds = majorTickmarksBounds[j]; var nextBounds = majorTickmarksBounds[j + i]; if (currentBounds.Right + minimumLabelSpacing > nextBounds.Left) { doMajorTicksCollide = true; break; } } if (!doMajorTicksCollide) { // The ticks don't at the given interval, so use that majorTickInterval = prospectiveInterval; break; } } if (doMajorTicksCollide) { // Multiple major ticks (and their labels) won't fit without overlapping. Display one major tick // in the middle instead majorTickInterval = tickCount; // Calculate the index of the middle tick. Note that, if there are an even number of ticks, there // is not one perfectly centered. This logic takes the one before the true center of the tick bar. if (tickCount % 2 == 0) { firstMajorTickIndex = (int)Math.Truncate(tickCount / 2d) - 1; } else { firstMajorTickIndex = (int)Math.Truncate(tickCount / 2d); } } // Apply the ticks' layouts for (var i = 0; i < tickCount; i++) { // Check whether the current tick index refers to a major or minor tick var isMajorTickIndex = (i - firstMajorTickIndex) % majorTickInterval == 0; // Arrange either the major or minor tick for the current index if (isMajorTickIndex) { _majorTickmarks[i].Arrange(majorTickmarksBounds[i]); _minorTickmarks[i].Arrange(new Rect(0, 0, 0, 0)); } else { _minorTickmarks[i].Arrange(minorTickmarksBounds[i]); _majorTickmarks[i].Arrange(new Rect(0, 0, 0, 0)); } } } else { // !ShowTickLabels for (var i = 0; i < _minorTickmarks.Count; i++) { _minorTickmarks[i].Arrange(minorTickmarksBounds[i]); } foreach (var majorTick in _majorTickmarks) { majorTick.Arrange(new Rect(0, 0, 0, 0)); } } return(finalSize); }
public override SizeF SizeThatFits(SizeF size) { ResolveLayoutChanges(); return(new SizeF(0, 0)); }
//----------------------------------------------------------------------------------------------------------------------- static public void ExpandHeightToSize(CoreGraphics.CGSize toSize, UIView view, double bottomBorder) { view.Frame = new CoreGraphics.CGRect(view.Frame.X, view.Frame.Y, view.Frame.Width, toSize.Height - view.Frame.Y - bottomBorder); }
public override SizeF SizeThatFits(SizeF size) => AddInsets(base.SizeThatFits(size));
public override SizeF SizeThatFits(SizeF size) { return(_fitSize); }
public override SizeF MeasureOverride(SizeF availableSize) { if (this.scrollViewer == null) { this.measuredFor = availableSize; return base.MeasureOverride(availableSize); } if (this.Visibility == Visibility.Collapsed) { this.measuredFor = availableSize; this.scrollViewer.MeasureOverride(SizeF.Empty); return this.measuredSize = SizeF.Empty; } var isMeasureNotActual = !this.IsMeasureValid || !this.scrollViewer.IsMeasureValid; isMeasureNotActual |= this.measuredFor == null || (availableSize.Height < this.measuredFor.Value.Height && this.measuredSize.Height > availableSize.Height) || (availableSize.Width < this.measuredFor.Value.Width && this.measuredSize.Width > availableSize.Width); if (!isMeasureNotActual) { return this.measuredSize; } this.measuredFor = availableSize; var margin = this.Margin; availableSize = new SizeF( MathF.Max(0, availableSize.Width - margin.HorizontalThicknessF()), MathF.Max(0, availableSize.Height - margin.VerticalThicknessF())); var size = this.SizeThatFitsMaxAndMin(this.scrollViewer.MeasureOverride(this.SizeThatFitsMaxAndMin(availableSize))); this.measuredSize = new SizeF(size.Width + margin.HorizontalThicknessF(), size.Height + margin.VerticalThicknessF()); this.IsMeasureValid = true; return this.measuredSize; }
public override SizeF SizeThatFits(SizeF size) { return(ContentCell.SizeThatFits(size)); }
public static Praeclarum.Graphics.SizeF ToSizeF(this NativeSize size) { return(new Praeclarum.Graphics.SizeF((float)size.Width, (float)size.Height)); }
SizeF AddInsets(SizeF size) => new SizeF( width: size.Width + TextInsets.Left + TextInsets.Right, height: size.Height + TextInsets.Top + TextInsets.Bottom);
/// <summary> /// Firsts the remote video frame of uid. /// </summary> /// <param name="engine">Engine.</param> /// <param name="uid">Uid.</param> /// <param name="size">Size.</param> /// <param name="elapsed">Elapsed.</param> public override void FirstRemoteVideoFrameOfUid(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { Console.WriteLine($"FirstRemoteVideoFrameOfUid: {uid}, {size}, {elapsed}"); }
public override void ResizeSubviewsWithOldSize(CoreGraphics.CGSize oldSize) { base.ResizeSubviewsWithOldSize(oldSize); tabView.Frame = Bounds; }
/// <summary> /// Firsts the size of the local video frame with. /// </summary> /// <param name="engine">Engine.</param> /// <param name="size">Size.</param> /// <param name="elapsed">Elapsed.</param> public override void FirstLocalVideoFrameWithSize(AgoraRtcEngineKit engine, CoreGraphics.CGSize size, nint elapsed) { Console.WriteLine($"FirstLocalVideoFrameWithSize: {size}, {elapsed}"); //_controller.FirstLocalVideoFrameWithSize(engine, size, elapsed); }
public override SizeF SizeThatFits(SizeF size) { return(new SizeF(0, 0)); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.flexGrid.IsReadOnly = true; this.flexGrid.ItemsSource = Customer.GetCustomerList(100); this.flexGrid.ColumnHeaderFont = UIFont.BoldSystemFontOfSize(this.flexGrid.Font.PointSize); this.flexGrid.FormatItem += (Xuni.iOS.FlexGrid.FlexGrid sender, Xuni.iOS.FlexGrid.GridPanel panel, Xuni.iOS.FlexGrid.GridCellRange range, CoreGraphics.CGContext context) => { if (panel == sender.Cells) { if (this.searchText.Text == null || this.searchText.Text.Length == 0 || (sender.EditRange != null && sender.EditRange.Intersects(range))) { return(false); } NSError error = null; NSRegularExpression regex = new NSRegularExpression(new NSString(this.searchText.Text), NSRegularExpressionOptions.CaseInsensitive, out error); NSString data = new NSString(panel.GetCellData(range.Row, range.Col, true).ToString()); if (error == null) { NSMutableAttributedString attributedString = new NSMutableAttributedString(data); regex.EnumerateMatches(data, 0, new NSRange(0, data.Length), (NSTextCheckingResult result, NSMatchingFlags flags, ref bool stop) => { NSRange thisrange = result.Range; UIStringAttributes stringAttributes = new UIStringAttributes(); stringAttributes.Font = UIFont.BoldSystemFontOfSize(this.flexGrid.Font.PointSize); stringAttributes.ForegroundColor = UIColor.Red; attributedString.SetAttributes(stringAttributes, thisrange); } ); CoreGraphics.CGRect t = panel.GetCellRect(range.Row, range.Col); CoreGraphics.CGSize sz = attributedString.Size; UITextAlignment align = this.flexGrid.Columns[range.Col].HorizontalAlignment; if (align == UITextAlignment.Right) { nfloat mod = t.Size.Width - sz.Width - 4; if (mod < 4) { mod = 4; } t.Location = new CoreGraphics.CGPoint(t.Location.X + mod, t.Location.Y); } else if (align == UITextAlignment.Center) { nfloat mod = (t.Size.Width - sz.Width) / 2; if (mod < 4) { mod = 4; } t.Location = new CoreGraphics.CGPoint(t.Location.X + mod, t.Location.Y); } else { t.Location = new CoreGraphics.CGPoint(t.Location.X + 4, t.Location.Y); } nfloat mrg = (t.Size.Height - sz.Height) / 2; if (mrg < 4) { mrg = 4; } t.Location = new CoreGraphics.CGPoint(t.Location.X, t.Location.Y + mrg); attributedString.DrawString(t); return(true); } } return(false); }; }
public override void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { Debug.WriteLine($"FirstRemoteVideoDecodedOfUid {uid}"); _controller.FirstRemoteVideoDecodedOfUid(engine, uid, size, elapsed); }
public void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { if (remoteVideo.Hidden) { remoteVideo.Hidden = false; } var videoCanvas = new AgoraRtcVideoCanvas(); videoCanvas.Uid = uid; videoCanvas.View = remoteVideo; videoCanvas.RenderMode = VideoRenderMode.Adaptive; agoraKit.SetupRemoteVideo(videoCanvas); }
public static Xwt.Size ToXwtSize(this CoreGraphics.CGSize s) { throw new NotImplementedException(); }
public static override AppKit.NSImage ImageWithSize(CoreGraphics.CGSize size, bool flipped, AppKit.NSCustomImageRepDrawingHandler drawingHandler) { throw new NotImplementedException(); }
private void ArrangeChild(UIElement child) { if (child.NativeUIElement != null) { SizeF needSize = new SizeF(); if (this.childSizeCache.ContainsKey(child)) { needSize = this.childSizeCache[child]; } else { needSize = child.MeasureOverride(new SizeF(nfloat.PositiveInfinity, nfloat.PositiveInfinity)); this.childSizeCache[child] = needSize; } child.Arrange(new RectangleF((nfloat)Canvas.GetLeft(child), (nfloat)Canvas.GetTop(child), needSize.Width, needSize.Height)); } }
public override void ResizeSubviewsWithOldSize(CoreGraphics.CGSize oldSize) { base.ResizeSubviewsWithOldSize(oldSize); LayoutSubviews(); }
internal override SizeF MeasureContentViewPort(SizeF availableSize) { var padding = this.Padding; availableSize.Width -= padding.HorizontalThicknessF(); availableSize.Height -= padding.VerticalThicknessF(); return base.MeasureContentViewPort(availableSize); }
public override void ViewDidLoad() { base.ViewDidLoad(); PreferredContentSize = new CoreGraphics.CGSize(500, 250); }
public override SizeF MeasureOverride(SizeF availableSize) { if (this.Visibility == Visibility.Collapsed) { this.measuredFor = availableSize; return this.measuredSize = SizeF.Empty; } var isMeasureNotActual = !this.IsMeasureValid || this.measuredFor == null || this.measuredFor != availableSize || this.needsResizeChilds.Count > 0; if (!isMeasureNotActual) { return this.measuredSize; } this.measuredFor = availableSize; availableSize = this.SizeThatFitsMaxAndMin(availableSize); var height = this.ReadLocalValue(StackPanel.HeightProperty) != DependencyProperty.UnsetValue ? (nfloat)this.Height : 0; var width = this.ReadLocalValue(StackPanel.WidthProperty) != DependencyProperty.UnsetValue ? (nfloat)this.Width : 0; if ((availableSize.Width == 0 && width == 0) || (availableSize.Height == 0 && height == 0) || this.Width == 0 || this.Height == 0) { this.measuredSize = this.SizeThatFitsMaxAndMin(new SizeF(width, height)); this.IsMeasureValid = true; return this.measuredSize; } var size = this.MeasureContentViewPort(availableSize); if (this.Orientation == Controls.Orientation.Vertical) { if (this.ReadLocalValue(UIElement.HeightProperty) == DependencyProperty.UnsetValue) { if (this.ReadLocalValue(UIElement.WidthProperty) == DependencyProperty.UnsetValue) { var sizeForChild = new SizeF(size.Width, nfloat.PositiveInfinity); foreach (var child in this.Children) { if (child.NativeUIElement != null) { var measuredChild = child.MeasureOverride(sizeForChild); width = MathF.Max(width, measuredChild.Width); if (height < availableSize.Height) { height += measuredChild.Height; } } } } else { var sizeForChild = new SizeF((nfloat)this.Width, nfloat.PositiveInfinity); width = (nfloat)this.Width; foreach (var child in this.Children) { if (child.NativeUIElement != null) { var measuredChild = child.MeasureOverride(sizeForChild); if (height < availableSize.Height) { height += measuredChild.Height; } } } } } else { height = (nfloat)this.Height; if (this.ReadLocalValue(UIElement.WidthProperty) == DependencyProperty.UnsetValue) { var sizeForChild = new SizeF(size.Width, (nfloat)this.Height); foreach (var child in this.Children) { if (child.NativeUIElement != null) { var measuredChild = child.MeasureOverride(sizeForChild); width = MathF.Max(width, measuredChild.Width); } } } else { width = (nfloat)this.Width; } } } else if (this.Orientation == Controls.Orientation.Horizontal) { if (this.ReadLocalValue(UIElement.WidthProperty) == DependencyProperty.UnsetValue) { if (this.ReadLocalValue(UIElement.HeightProperty) == DependencyProperty.UnsetValue) { var sizeForChild = new SizeF(nfloat.PositiveInfinity, size.Height); foreach (var child in this.Children) { if (child.NativeUIElement != null) { var measuredChild = child.MeasureOverride(sizeForChild); height = MathF.Max(height, measuredChild.Height); if (width < availableSize.Width) { width += measuredChild.Width; } } } } else { var sizeForChild = new SizeF(nfloat.PositiveInfinity, (nfloat)this.Height); height = (nfloat)this.Height; foreach (var child in this.Children) { if (child.NativeUIElement != null) { var measuredChild = child.MeasureOverride(sizeForChild); if (width < availableSize.Width) { width += measuredChild.Width; } } } } } else { width = (nfloat)this.Width; if (this.ReadLocalValue(UIElement.HeightProperty) == DependencyProperty.UnsetValue) { var sizeForChild = new SizeF((nfloat)this.Width, size.Height); foreach (var child in this.Children) { if (child.NativeUIElement != null) { var measuredChild = child.MeasureOverride(sizeForChild); height = MathF.Max(height, measuredChild.Height); } } } else { height = (nfloat)this.Height; } } } var margin = this.Margin; height += margin.VerticalThicknessF(); width += margin.HorizontalThicknessF(); this.IsMeasureValid = true; this.measuredSize = this.SizeThatFitsMaxAndMin(new SizeF(Math.Min(availableSize.Width, width), Math.Min(availableSize.Height, height))); return this.measuredSize; }
public static RectangleF WithAspectRatio(this RectangleF self, SizeF aspectRatio) { return AVMakeRectWithAspectRatioInsideRect (aspectRatio, self); }