A Dialog For Brush Configure(SolidColorBrush,LinearGradientBrush,RadioGradientBrush)

本文介绍了一种在WPF中实现颜色选择对话框的方法,包括纯色、线性渐变和径向渐变画刷的配置。通过自定义对话框类ColorDialog,实现了与Windows颜色对话框相似的功能。
文章链接:http://www.codeproject.com/KB/WPF/FormatColorDialog.aspx

 

FormatColorDialog.JPG

FormatColorDialogExpanded.JPG

ColorDialog.JPG

BrushConfigureDialog4SolidColorBrush.JPG

BrushConfigureDialog4RadioGradientBrush.JPG

BrushConfigureDialog4LinearGradientBrush.JPG

Introduction

由于WPF现在还未实现颜色选择对话框,但是很多的软件中需要用到颜色对话框,次对话框是在毕设中的一个实现模块,其能够实现纯色,线性渐变画刷,径向渐变画刷的配置。

Background

Using the code

类ColorDialog是个类似windows颜色对话框的WPF颜色对话框。                    
     FormatColorDialog dlg = new FormatColorDialog(this.b.BorderBrush, this.b.Background, this.rect.Fill);
    dlg.Owner = this;
    if (true == dlg.ShowDialog())
    {
          this.border.BorderBrush = dlg.LineBrush;
          this.border.Background = dlg.FillBrush;
          this.rectangle.Fill = dlg.BackgroundBrush;
    }
      
类FormatColorDialog是应用了三个ColorChooser画刷选择列表,用来分别配置线画刷,填充画刷和背景画刷。


类ColorChooser是封装了一个BrushConfigurer的颜色选择下拉列表控件。
     xmlns:c="clr-namespace:NWPU.CS.ConfigurationSoftware.DialogControls"
    <c:ColorChooser x:Name="cbLine"></c:ColorChooser>


类BrushConfigurer是封装了SolidBrushConfigurer,LinearGradientBrushConfigurer,RadioGradientBrushConfigurer的实例的画刷配置控件。


类SolidBrushConfigurer,LinearGradientBrushConfigurer,RadioGradientBrushConfigurer分别为纯色,线性渐变,径向渐变画刷的配置控件。         
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值