WPF 截图控件之画笔(八)「仿微信」

WPF 截图控件之画笔(八)「仿微信」

WWPF 截图控件之画笔(八)「仿微信」

作者:WPFDevelopersOrg

原文链接: https://github.com/WPFDevelopersOrg/WPFDevelopers

  • 接着上周写的截图控件继续更新添加 画笔

1.WPF实现截屏「仿微信」
2.WPF 实现截屏控件之移动(二)「仿微信」
3.WPF 截图控件之伸缩(三) 「仿微信」
4.WPF 截图控件之绘制方框与椭圆(四) 「仿微信」
5.WPF 截图控件之绘制箭头(五)「仿微信」
6.WPF 截图控件之绘制箭头禁止越界(六)「仿微信」
7.WPF 截图控件之文字(七)「仿微信」

正文

一、接着ScreenCut继续发电;
1)添加画笔操作只允许在可编辑区域内;

  • 再添加画笔、使用Polyline来实现;
  • 当前坐标X大于Left 并小于Right允许绘制;
  • 当前坐标Y大于Top并小于Bootom允许绘制;

  void DrwaInkControl(Point current)
        {
            CheckPoint(current);
            if (current.X >= rect.Left
            &&
            current.X <= rect.Right
            &&
            current.Y >= rect.Top
            &&
            current.Y <= rect.Bottom)
            {
                if (polyLine == null)
                {
                    polyLine = new Polyline();
                    polyLine.Stroke = _currentBrush == null ? Brushes.Red : _currentBrush;
                    polyLine.Cursor = Cursors.Hand;
                    polyLine.StrokeThickness = 3;
                    polyLine.StrokeLineJoin = PenLineJoin.Round;
                    polyLine.StrokeStartLineCap = PenLineCap.Round;
                    polyLine.StrokeEndLineCap = PenLineCap.Round;
                    polyLine.MouseLeftButtonDown += (s, e) =>
                    {
                        _radioButtonInk.IsChecked = true;
                        _radioButtonInk_Click(null, null);
                        SelectElement();
                        frameworkElement = s as Polyline;
                        frameworkElement.Opacity = .7;
                    };
                    _canvas.Children.Add(polyLine);
                }
                polyLine.Points.Add(current);
            }
                
        }

完整代码如下

项目地址

  • 框架名:WPFDevelopers
  • 作者:WPFDevelopers
  • GitHub
  • Gitee
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值