首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏DannyHoo的专栏

    iOS开发中压缩图片的质量以及缩小图片尺寸

    -(UIImage *)resizeImage:(UIImage *)image { float actualHeight = image.size.height; float actualWidth )         { //adjust height according to maxWidth             imgRatio = maxWidth / actualWidth;             actualHeight = imgRatio * actualHeight;             actualWidth = maxWidth;         } else         {             actualHeight = maxHeight;             actualWidth = maxWidth;         }     } CGRect rect = CGRectMake(0.0, 0.0, actualWidth, actualHeight); UIGraphicsBeginImageContext

    1.8K30发布于 2018-09-13
  • 来自专栏Windows Community

    Extensions in UWP Community Toolkit - FrameworkElement Extensions

    FrameworkElement Extensions 为 FrameworkElement 提供了一种简单的绑定实际尺寸的方式,扩展利用 EnableActualSizeBinding 来指定是否允许实时绑定实际尺寸中的 ActualWidth 获取到的 ActualHeight 和 ActualWidrh 一直都是变为 False 时最后一个值,不管尺寸怎么改变都不会被更新和监听; 而通过扩展设置的绑定,和直接设置 ActualHeight 和 ActualWidth = baseElement.ActualWidth) { SetActualWidth(baseElement, baseElement.ActualWidth); } } 代码简单分析如上,大家在实际项目中可以对这个类进行扩展,比如把 Opacity,Color 等也作为可以实时绑定的值,实现方式和 ActualHeight ActualWidth 很类似,大家可以自行扩展 调用示例 我们创建了三个 Rectangle,第一个是绑定目标,第二和第三个去绑定第一个的实际尺寸;可以看到因为第二个红色矩形使用 ActualHeight 和 ActualWidth 直接进行绑定,所以并没有绑定到正确的值

    98180发布于 2018-04-28
  • 来自专栏快乐阿超

    字体按宽度自适应大小

    nameElement.style.scale = String(); return; } const boundingBox = nameElement.getBoundingClientRect(); const actualWidth = boundingBox.width; const scale = 84 / actualWidth; console.log({ [`${nameElement.textContent}` ]: actualWidth, scale }); if (scale >= 1) { return; } nameElement.style.scale = String(scale

    63330编辑于 2023-09-14
  • 来自专栏全栈程序员必看

    WPF 用代码实现WrapPanel右侧自动对齐(解决多余空白问题)

    lst[i]; var nxtChild = lst[i + 1]; var plWidth = WpKeyWords.ActualWidth 算出多余的空白宽度 var surplusWidth = plWidth - childPoint.X - child.Margin.Right - child.ActualWidth foreach (var b in tempLst) { b.Width = b.ActualWidth

    79220编辑于 2022-09-15
  • 来自专栏.NET开发那点事

    豆瓣电台WP7客户端 开发记录7

                 this.sb.Stop();  7             double sysWidth = System.Windows.Application.Current.Host.Content.ActualWidth ;//屏幕宽度  8             if (sysWidth <= this.SongName.ActualWidth)  9             { 10                  animation.From = sysWidth; 11                 animation.To = -this.SongName.ActualWidth - (sysWidth -              {//canvas居中 16                 this.SongName.SetValue(Canvas.LeftProperty, 180-this.SongName.ActualWidth

    49510编辑于 2022-05-07
  • 来自专栏个人编程笔记

    C#-利用自定义控件创建箭头控件

    StreamGeometry streamGeometry = new StreamGeometry(); var point0 = new Point(this.ActualWidth /3,0); var point1 = 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

    1.6K20编辑于 2023-03-03
  • 来自专栏施炯的IoT开发专栏

    How-to: 创建Windows Phone 7自定义控件

    var left = Canvas.GetLeft(this); var top = Canvas.GetTop(this); if (left < -ActualWidth ) return true; if (left > width + ActualWidth) return true int i = 0; i < 25; i++) { var left = random.NextDouble() * ContentCanvas.ActualWidth bubblecontrol.UpdatePosition(currentTransform); if (bubblecontrol.IsOutOfBounds(ActualWidth private void AddNewbubblecontrol() { var left = random.NextDouble() * ContentCanvas.ActualWidth

    1.1K70发布于 2018-01-10
  • 来自专栏我的WPF笔记

    记一次自定义基因分类图实现(二)

    object sender, SizeChangedEventArgs e) { OvservedWidth = (sender as FrameworkElement).ActualWidth <Canvas > <ItemsControl x:Name="root" Grid.Row="1" Width="{Binding Path=<em>ActualWidth</em> <MultiBinding.Bindings> <Binding ElementName="ContentBorder" Path="<em>ActualWidth</em> " /> <Binding ElementName="ContentItemsControl" Path="<em>ActualWidth</em>" /> " /> <Binding ElementName="ContentItemsControl" Path="<em>ActualWidth</em>" />

    21500编辑于 2025-04-26
  • 来自专栏sofu456

    wpf绘图性能分析

    FontSize = 40 }); Canvas.SetLeft(canvas.Children[canvas.Children.Count - 1], rd.Next(0, (int)canvas.ActualWidth 10000; i++) { Point pt = new Point((double)rd.Next(0, (int)win.ActualWidth return bitmapImage; } } 调用gdi+绘制,10000个1-2s,10w个3-4s _bitmap = new System.Drawing.Bitmap((int)ActualWidth 100000; i++) { System.Windows.Point pt = new System.Windows.Point((double)rd.Next(0, (int)ActualWidth

    1.4K30编辑于 2022-10-31
  • 来自专栏林德熙的博客

    win10 uwp 拖动控件 Margin 移动Canvas 拖动控件Manipulation 拖动控件

    PointerPoint point = e.GetCurrentPoint(btn); 这样point.Position.X就是移动的左边 我们可以通过x += point.Position.X - btn.ActualWidth / 2.0; 这是因为btn.ActualWidth / 2.0不用的话会是控件的左上角。 double y = (double)btn.GetValue(Canvas.TopProperty); x += point.Position.X - btn.ActualWidth double y = (double)btn.GetValue(Canvas.TopProperty); x += point.Position.X - btn.ActualWidth

    3.1K00发布于 2018-09-18
  • 来自专栏我和未来有约会

    [Silverlight动画]转向行为 - 机车

    { Content stage = App.Current.Host.Content; if (position.x > stage.ActualWidth ) { position.x = stage.ActualWidth; velocity.x *= -1; { Content stage = App.Current.Host.Content; if (position.x > stage.ActualWidth = 0; } if (position.x < 0) { position.x = stage.ActualWidth

    1.1K60发布于 2018-01-16
  • 来自专栏独立观察员博客

    WPF 窗口居中 & 变更触发机制

    screen.Bounds.Left / dpiXRatio + (screen.Bounds.Width / dpiXRatio - subWindow.ActualWidth 2; } else { //窗口居中显示 subWindow.Left = parentWindow.Left + (parentWindow.ActualWidth - subWindow.ActualWidth) / 2; subWindow.Top = parentWindow.Top + (parentWindow.ActualHeight screen.Bounds.Left / dpiXRatio + (screen.Bounds.Width / dpiXRatio - subWindow.ActualWidth

    1.7K20编辑于 2022-12-06
  • 来自专栏dino.c的专栏

    [UWP]不怎么实用的Shape指南:自定义Shape

    { case Direction.Left: figure.StartPoint = new Point(ActualWidth , 0); var segment = new LineSegment { Point = new Point(ActualWidth, ActualHeight figure.StartPoint = new Point(0, ActualHeight); segment = new LineSegment { Point = new Point(ActualWidth figure.StartPoint = new Point(0, 0); segment = new LineSegment { Point = new Point(ActualWidth figure.StartPoint = new Point(0, 0); segment = new LineSegment { Point = new Point(ActualWidth

    71540发布于 2019-01-18
  • 来自专栏林德熙的博客

    win10 uwp 自定义控件初始化

    同时无法获得 ActualHeight 和 ActualWidth 的值。 在 Loaded 的时候,可以获得属性的值,而且可以获得 ActualHeight 和 ActualWidth 的值。

    69710发布于 2018-09-18
  • 来自专栏walterlv - 吕毅的博客

    准确判断一个 WPF 控件 / UI 元素当前是否显示在屏幕内

    topLeft = target.PointToScreen(new Point()); var bottomRight = target.PointToScreen(new Point(target.ActualWidth visual.PointToScreen(new Point(0, 0))); pixelBoundsToScreen.Union(visual.PointToScreen(new Point(visual.ActualWidth (0, visual.ActualHeight))); pixelBoundsToScreen.Union(visual.PointToScreen(new Point(visual.ActualWidth visual.PointToScreen(new Point(0, 0))); pixelBoundsToScreen.Union(visual.PointToScreen(new Point(visual.ActualWidth (0, visual.ActualHeight))); pixelBoundsToScreen.Union(visual.PointToScreen(new Point(visual.ActualWidth

    1.7K40编辑于 2023-10-22
  • 来自专栏林德熙的博客

    WPF 动画性能测试应用 一千个半透明矩形做动画

    drawingGroup.Open()) { drawingContext.DrawRectangle(Brushes.White, null, new Rect(0, 0, ActualWidth 添加矩形需要设置矩形的起点,以及动画的终点,如此界面才会比较复杂 var startPoint = new Point(Random.Shared.Next((int) (ActualWidth (ActualHeight - size.Height))); var endPoint = new Point(Random.Shared.Next((int) (ActualWidth 使用随机数生成矩形的起点和终点,不要超过画布的大小,如此将不会导致画布缩放 var startPoint = new Point(Random.Shared.Next((int) (ActualWidth (ActualHeight - size.Height))); var endPoint = new Point(Random.Shared.Next((int) (ActualWidth

    87840编辑于 2023-04-07
  • 来自专栏独立观察员博客

    WPF 实现扇形统计图

    ) return; _canvas.Children.Clear(); var pieWidth = _canvas.ActualWidth _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

    1.8K10编辑于 2022-12-06
  • 来自专栏独立观察员博客

    WPF怎么做新手引导界面?

    这个部分应该是指擦除 RectangleGeometry rg1 = new RectangleGeometry(); rg1.Rect = new Rect(point.X - 5, point.Y - 5, fe.ActualWidth Path> 显示内容的部分是一个Textblock,当时遇到了一个问题,就是换行问题,Textblock必须要有Width,才会换行,但是由于最外层是Viewbox,所以,尝试过获取UC的Width或者ActualWidth RectangleGeometry rg1 = new RectangleGeometry(); rg1.Rect = new Rect(point.X - 5, point.Y - 5, fe.ActualWidth borGeometry; HintUC hit = new HintUC(xh.ToString(), con, vis); Canvas.SetLeft(hit, point.X + fe.ActualWidth

    1.5K10编辑于 2022-12-06
  • 来自专栏林德熙的博客

    WPF 布局 在有限空间内让两个元素尽可能撑开的例子

    OuterStackPanel" Path="MaxWidth"/> <Binding ElementName="SSIDTextBlock" Path="<em>ActualWidth</em> "/> <Binding ElementName="SSIDContentTextBlock" Path="<em>ActualWidth</em>"/> <Binding ElementName="SpaceTextBlock" Path="<em>ActualWidth</em>"/> <Binding ElementName ="PasswordTextBlock" Path="<em>ActualWidth</em>"/> </MultiBinding> </TextBlock.MaxWidth

    53130编辑于 2021-12-09
  • 来自专栏林德熙的博客

    win10 uwp 毛玻璃 Compositor 创建毛玻璃win2D最简单方法

    Source = _bitmap }; session.DrawImage(blur, new Rect(0, 0, sender.ActualWidth Source = _bitmap }; session.DrawImage(blur, new Rect(0, 0, sender.ActualWidth ManipulationStartedRoutedEventArgs e) { // 重新设置 _x _x = (float) this.ImagePanel2.ActualWidth += (float) e.Delta.Translation.X; //如果当前的x超过了,或者已经最小 if (_x > ImagePanel2.ActualWidth Source = _bitmap }; session.DrawImage(blur, new Rect(0, 0, sender.ActualWidth

    1.3K10发布于 2018-09-18
领券