blog.csdn.net/u010105969/article/details/75133170 -(UIImage *)resizeImage:(UIImage *)image { float actualHeight maxHeight = 300.0; // 图片的最大高度 float maxWidth = 400.0; // 图片的最大宽度 float imgRatio = actualWidth/actualHeight ; actualWidth = imgRatio * actualWidth; actualHeight = maxHeight; = imgRatio * actualHeight; actualWidth = maxWidth; } else { (0.0, 0.0, actualWidth, actualHeight); UIGraphicsBeginImageContext(rect.size); [image drawInRect
Extensions 为 FrameworkElement 提供了一种简单的绑定实际尺寸的方式,扩展利用 EnableActualSizeBinding 来指定是否允许实时绑定实际尺寸中的 ActualWidth 和 ActualHeight 和 ActualWidrh 一直都是变为 False 时最后一个值,不管尺寸怎么改变都不会被更新和监听; 而通过扩展设置的绑定,和直接设置 ActualHeight 和 ActualWidth 的绑定的区别就是 -= UpdateActualSizeProperties; } } 在下面的 UpdateActualSizeProperties(sender, args) 方法中,可以看到绑定目标的 ActualHeight = baseElement.ActualHeight) { SetActualHeight(baseElement, baseElement.ActualHeight); baseElement.ActualWidth); } } 代码简单分析如上,大家在实际项目中可以对这个类进行扩展,比如把 Opacity,Color 等也作为可以实时绑定的值,实现方式和 ActualHeight
new Point(this.ActualWidth / 3*2, 0); var point2 = new Point(this.ActualWidth / 3*2, this.ActualHeight /3*2); var point3 = new Point(this.ActualWidth, this.ActualHeight/3*2); var point4 = new Point(this.ActualWidth / 2, this.ActualHeight); var point5 = new Point(0, this.ActualHeight /3*2); var point6 = new Point(this.ActualWidth/3,this.ActualHeight/3*2); using
OvservedWidth = (sender as FrameworkElement).ActualWidth; OvseredHeight = (sender as FrameworkElement).ActualHeight True"> <Canvas > <ItemsControl x:Name="root1" Height="{Binding Path=<em>ActualHeight</em> Right"VerticalAlignment="Stretch" Opacity="0.5"ViewportSize="{Binding ElementName=ContentBorder, Path=<em>ActualHeight</em> " /> <Binding ElementName="ContentItemsControl" Path="<em>ActualHeight</em>" /> " /> <Binding ElementName="ContentItemsControl" Path="<em>ActualHeight</em>" />
position.x = 0; velocity.x *= -1; } if (position.y > stage.ActualHeight ) { position.y = stage.ActualHeight; velocity.y *= -1; { position.x = stage.ActualWidth; } if (position.y > stage.ActualHeight = 0; } if (position.y < 0) { position.y = stage.ActualHeight
screen.Bounds.Top / dpiYRatio + (screen.Bounds.Height / dpiYRatio - subWindow.ActualHeight parentWindow.ActualWidth - subWindow.ActualWidth) / 2; subWindow.Top = parentWindow.Top + (parentWindow.ActualHeight - subWindow.ActualHeight) / 2; } } 2)当前屏幕内居中-CenterScreen; 窗口位置设置和上面的一样,值得注意的是DPI。 screen.Bounds.Top / dpiYRatio + (screen.Bounds.Height / dpiYRatio - subWindow.ActualHeight
canvas.ActualWidth - 100)); Canvas.SetTop(canvas.Children[canvas.Children.Count - 1], rd.Next(0, (int)canvas.ActualHeight (double)rd.Next(0, (int)win.ActualWidth - 100), (double)rd.Next(0, (int)win.ActualHeight bitmapImage; } } 调用gdi+绘制,10000个1-2s,10w个3-4s _bitmap = new System.Drawing.Bitmap((int)ActualWidth, (int)ActualHeight System.Windows.Point((double)rd.Next(0, (int)ActualWidth - 100), (double)rd.Next(0, (int)ActualHeight
ActualWidth, 0); var segment = new LineSegment { Point = new Point(ActualWidth, ActualHeight break; case Direction.Up: figure.StartPoint = new Point(0, ActualHeight figure.Segments.Add(segment); segment = new LineSegment { Point = new Point(ActualWidth, ActualHeight figure.StartPoint = new Point(0, 0); segment = new LineSegment { Point = new Point(ActualWidth, ActualHeight figure.Segments.Add(segment); segment = new LineSegment { Point = new Point(ActualWidth / 2, ActualHeight
target.PointToScreen(new Point()); var bottomRight = target.PointToScreen(new Point(target.ActualWidth, target.ActualHeight visual.ActualWidth, 0))); pixelBoundsToScreen.Union(visual.PointToScreen(new Point(0, visual.ActualHeight ))); pixelBoundsToScreen.Union(visual.PointToScreen(new Point(visual.ActualWidth, visual.ActualHeight visual.ActualWidth, 0))); pixelBoundsToScreen.Union(visual.PointToScreen(new Point(0, visual.ActualHeight ))); pixelBoundsToScreen.Union(visual.PointToScreen(new Point(visual.ActualWidth, visual.ActualHeight
double GetScalingRatio() { var logicalHeight = GetLogicalHeight(); var actualHeight = GetActualHeight(); if (logicalHeight > 0 && actualHeight > 0) { return logicalHeight / actualHeight; } return 1; } private var mouse = transform.Transform(GetMousePosition()); Left = mouse.X + 2; Top = mouse.Y - ActualHeight
e.ProgressPercentage) / Convert.ToDouble(100); loadBar.Height = (App.Current.Host.Content.ActualHeight App.Current.Host.Content.ActualWidth; (this as UserControl).Height = App.Current.Host.Content.ActualHeight
; if (left > width + ActualWidth) return true; if (top < -ActualHeight random.NextDouble() * ContentCanvas.ActualWidth; var top = random.NextDouble() * ContentCanvas.ActualHeight bubblecontrol.UpdatePosition(currentTransform); if (bubblecontrol.IsOutOfBounds(ActualWidth, ActualHeight ContentCanvas.ActualWidth; var size = random.Next(10, 50); CreateBubble(left, ContentCanvas.ActualHeight
ShowHeight(); } void ShowHeight() { tb1.Text = string.Format("ActualHeight :{0},VerticalOffset:{1},ViewportHeight:{2},ExtentHeight:{3}", sv.ActualHeight, sv.VerticalOffset, sv.ViewportHeight
同时无法获得 ActualHeight 和 ActualWidth 的值。 在 Loaded 的时候,可以获得属性的值,而且可以获得 ActualHeight 和 ActualWidth 的值。
{ drawingContext.DrawRectangle(Brushes.White, null, new Rect(0, 0, ActualWidth, ActualHeight Random.Shared.Next((int) (ActualWidth - size.Width)), Random.Shared.Next((int) (ActualHeight Random.Shared.Next((int) (ActualWidth - size.Width)), Random.Shared.Next((int) (ActualHeight Random.Shared.Next((int) (ActualWidth - size.Width)), Random.Shared.Next((int) (ActualHeight Random.Shared.Next((int) (ActualWidth - size.Width)), Random.Shared.Next((int) (ActualHeight
return; _canvas.Children.Clear(); var pieWidth = _canvas.ActualWidth > _canvas.ActualHeight _canvas.ActualHeight : _canvas.ActualWidth; var pieHeight = _canvas.ActualWidth > _canvas.ActualHeight _canvas.ActualHeight : _canvas.ActualWidth; centenrX = pieWidth / 2; centenrY = pieHeight / 2; radius = this.ActualWidth > this.ActualHeight ? this.ActualHeight / 2 : this.ActualWidth / 2; double angle = 0; double prevAngle
relativeLocationY = relativeLocation.Y + 12; //防止悬浮框超出列表区域 if (relativeLocationY + ShowArea.Height > TjSv.ActualHeight ) { relativeLocationY = TjSv.ActualHeight - ShowArea.Height; } ShowArea.Margin =
* */ const actualWidth = getActualPixel(width); const actualHeight = getActualPixel(height); dom.width = actualWidth; dom.height = actualHeight; Object.assign(this, { width, height , actualWidth, actualHeight }); } translateX: number = 0; translateY: number = 0; translate render(scene: Scene, camera: Camera) { const { ctx, entityRenderMap, actualWidth, actualHeight ctx.clearRect( renderX, renderY, renderX + actualWidth, renderY + actualHeight
}; session.DrawImage(blur, new Rect(0, 0, sender.ActualWidth, sender.ActualHeight }; session.DrawImage(blur, new Rect(0, 0, sender.ActualWidth, sender.ActualHeight return; //我们剪辑覆盖,用于显示下面的图片 Clip.Rect = new Rect(0, 0, _x, this.ImagePanel2.ActualHeight / 重置剪辑显示完整的覆盖 Clip.Rect = new Rect(0, 0, this.ImagePanel2.ActualWidth, this.ImagePanel2.ActualHeight }; session.DrawImage(blur, new Rect(0, 0, sender.ActualWidth, sender.ActualHeight
rg1 = new RectangleGeometry(); rg1.Rect = new Rect(point.X - 5, point.Y - 5, fe.ActualWidth + 10, fe.ActualHeight new RectangleGeometry(); rg1.Rect = new Rect(point.X - 5, point.Y - 5, fe.ActualWidth + 10, fe.ActualHeight con, vis); Canvas.SetLeft(hit, point.X + fe.ActualWidth + 3); Canvas.SetTop(hit, point.Y + fe.ActualHeight