Commit 16647705 by liulongfei

引入WPFToolKit

parent 2e633d23
...@@ -116,6 +116,21 @@ ...@@ -116,6 +116,21 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="Xceed.Wpf.AvalonDock, Version=4.4.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=4.4.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=4.4.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=4.4.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.Toolkit, Version=4.4.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="MessageBox\MessageBoxEx.xaml"> <Page Include="MessageBox\MessageBoxEx.xaml">
...@@ -138,6 +153,10 @@ ...@@ -138,6 +153,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Widgets\ColorPickButton\ColorPickWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Widgets\GPIOPinTestControl\GPIOPinTestControl.xaml"> <Page Include="Widgets\GPIOPinTestControl\GPIOPinTestControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
...@@ -275,6 +294,9 @@ ...@@ -275,6 +294,9 @@
<Compile Include="VideoControl\Stream\VideoStreamOptionBase.cs" /> <Compile Include="VideoControl\Stream\VideoStreamOptionBase.cs" />
<Compile Include="VideoControl\Stream\VideoStreamTaskBase.cs" /> <Compile Include="VideoControl\Stream\VideoStreamTaskBase.cs" />
<Compile Include="Widgets\ColorPickButton\ColorPickButton.cs" /> <Compile Include="Widgets\ColorPickButton\ColorPickButton.cs" />
<Compile Include="Widgets\ColorPickButton\ColorPickWindow.xaml.cs">
<DependentUpon>ColorPickWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Widgets\DebugBorder\DebugBorder.cs" /> <Compile Include="Widgets\DebugBorder\DebugBorder.cs" />
<Compile Include="Widgets\DragWindowBar\DragWindowBar.cs" /> <Compile Include="Widgets\DragWindowBar\DragWindowBar.cs" />
<Compile Include="Widgets\GPIOPinTestControl\GPIOPinTestControl.cs" /> <Compile Include="Widgets\GPIOPinTestControl\GPIOPinTestControl.cs" />
......
...@@ -51,12 +51,15 @@ namespace VIZ.Framework.Common ...@@ -51,12 +51,15 @@ namespace VIZ.Framework.Common
{ {
base.OnClick(); base.OnClick();
System.Windows.Forms.ColorDialog cd = new System.Windows.Forms.ColorDialog(); ColorPickWindow window = new ColorPickWindow();
if (cd.ShowDialog() != System.Windows.Forms.DialogResult.OK) window.Owner = Window.GetWindow(this);
window.OldColor = this.Color;
window.SelectedColor = this.Color;
if (window.ShowDialog() != true)
return; return;
string color_str = $"#{cd.Color.A.ToString("X2")}{cd.Color.R.ToString("X2")}{cd.Color.G.ToString("X2")}{cd.Color.B.ToString("X2")}"; this.Color = window.SelectedColor;
this.Color = (Color)ColorConverter.ConvertFromString(color_str);
} }
} }
} }
<Window x:Class="VIZ.Framework.Common.ColorPickWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VIZ.Framework.Common"
mc:Ignorable="d" WindowStartupLocation="CenterOwner" WindowStyle="SingleBorderWindow"
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
x:Name="window" ResizeMode="NoResize"
Title="选择颜色" Height="360" Width="260">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>
<toolkit:ColorCanvas Margin="5" SelectedColor="{Binding ElementName=window,Path=SelectedColor,Mode=TwoWay}"></toolkit:ColorCanvas>
<Button Content="还原" Width="60" Height="30" Grid.Row="1" HorizontalAlignment="Left" Margin="5,0,0,0"
x:Name="btReset" Click="btReset_Click"></Button>
<Grid Grid.Row="1" Width="200" HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Content="确定" Width="60" Height="30" Grid.Column="1"
x:Name="btEnter" Click="btEnter_Click"></Button>
<Button Content="取消" Width="60" Height="30" Grid.Column="2"
x:Name="btCancel" Click="btCancel_Click"></Button>
</Grid>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Xceed.Wpf.Toolkit;
namespace VIZ.Framework.Common
{
/// <summary>
/// ColorPickWindow.xaml 的交互逻辑
/// </summary>
public partial class ColorPickWindow : Window
{
public ColorPickWindow()
{
InitializeComponent();
}
#region SelectedColor -- 选择的颜色
/// <summary>
/// 选择的颜色
/// </summary>
public Color SelectedColor
{
get { return (Color)GetValue(SelectedColorProperty); }
set { SetValue(SelectedColorProperty, value); }
}
/// <summary>
/// Using a DependencyProperty as the backing store for SelectedColor. This enables animation, styling, binding, etc...
/// </summary>
public static readonly DependencyProperty SelectedColorProperty =
DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorPickWindow), new PropertyMetadata(Colors.Red));
#endregion
#region OldColor -- 原始颜色
/// <summary>
/// 原始颜色
/// </summary>
public Color OldColor
{
get { return (Color)GetValue(OldColorProperty); }
set { SetValue(OldColorProperty, value); }
}
/// <summary>
/// Using a DependencyProperty as the backing store for OldColor. This enables animation, styling, binding, etc...
/// </summary>
public static readonly DependencyProperty OldColorProperty =
DependencyProperty.Register("OldColor", typeof(Color), typeof(ColorPickWindow), new PropertyMetadata(Colors.Transparent));
#endregion
/// <summary>
/// 确定
/// </summary>
private void btEnter_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.Close();
}
/// <summary>
/// 取消
/// </summary>
private void btCancel_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
/// <summary>
/// 还原
/// </summary>
private void btReset_Click(object sender, RoutedEventArgs e)
{
this.SelectedColor = this.OldColor;
}
}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Extended.Wpf.Toolkit" version="4.4.0" targetFramework="net48" />
<package id="log4net" version="2.0.14" targetFramework="net48" /> <package id="log4net" version="2.0.14" targetFramework="net48" />
<package id="OpenCvSharp4" version="4.6.0.20220608" targetFramework="net48" /> <package id="OpenCvSharp4" version="4.6.0.20220608" targetFramework="net48" />
<package id="SharpDX" version="4.2.0" targetFramework="net48" /> <package id="SharpDX" version="4.2.0" targetFramework="net48" />
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment