diff --git a/src/WPFDevelopers.Net40/Themes/Generic.xaml b/src/WPFDevelopers.Net40/Themes/Generic.xaml
index 2847a498..04a35980 100644
--- a/src/WPFDevelopers.Net40/Themes/Generic.xaml
+++ b/src/WPFDevelopers.Net40/Themes/Generic.xaml
@@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:control="clr-namespace:WPFDevelopers.Controls"
xmlns:converts="clr-namespace:WPFDevelopers.Converts"
+ xmlns:resx="clr-namespace:WPFDevelopers"
xmlns:shell="clr-namespace:Microsoft.Windows.Shell"
xmlns:wd="clr-namespace:WPFDevelopers.Net40">
@@ -74,7 +75,8 @@
Padding="0"
Command="{Binding Source={x:Static shell:SystemCommands.MinimizeWindowCommand}}"
IsTabStop="False"
- Style="{DynamicResource WD.WindowButtonStyle}">
+ Style="{DynamicResource WD.WindowButtonStyle}"
+ ToolTip="{Binding [Minimize], Source={x:Static resx:LanguageManager.Instance}}">
+ Style="{DynamicResource WD.WindowButtonStyle}"
+ ToolTip="{Binding [Maximize], Source={x:Static resx:LanguageManager.Instance}}">
+ Style="{DynamicResource WD.WindowButtonStyle}"
+ ToolTip="{Binding [Close], Source={x:Static resx:LanguageManager.Instance}}">
+
#AA000000
#909399
@@ -145,6 +145,8 @@
6
6
+
+
0,0,0,2
-
-
-
+
+
+
-
-
+
+
@@ -346,26 +348,26 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -772,23 +774,23 @@
-
-
+
@@ -860,7 +862,7 @@
-
+
@@ -940,9 +942,9 @@
-
+
-
+
@@ -1401,14 +1403,28 @@
-
-
+
@@ -2973,6 +2992,8 @@
+
+
@@ -2986,10 +3007,11 @@
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
+
+
@@ -346,26 +348,26 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -773,23 +775,23 @@
-
+
-
+
-
+
-
+
@@ -861,7 +863,7 @@
-
+
@@ -941,9 +943,9 @@
-
+
-
+
@@ -1402,14 +1404,28 @@
-
-
+
@@ -2974,6 +2993,8 @@
+
+
@@ -2987,10 +3008,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/AcrylicBlurWindowExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/AcrylicBlurWindowExample.xaml
index f0ae2710..7b853af8 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/AcrylicBlurWindowExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/AcrylicBlurWindowExample.xaml
@@ -4,13 +4,13 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
ResizeMode="CanMinimize"
Title="Login" Height="350" Width="400">
-
-
-
+
+
+
@@ -33,8 +33,8 @@
-
-
+
+
-
@@ -19,16 +19,16 @@
-
-
+
+
-
-
@@ -37,7 +37,7 @@
-
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/AnimationNavigationBar3DExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/AnimationNavigationBar3DExample.xaml
index 5dd6b579..45122367 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/AnimationNavigationBar3DExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/AnimationNavigationBar3DExample.xaml
@@ -20,34 +20,77 @@
Height="235"
Margin="10,0"
VerticalAlignment="Top"
- Background="#F9F7F9"
+ Background="{DynamicResource WD.BackgroundSolidColorBrush}"
SnapsToDevicePixels="True">
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ wd:ElementHelper.Watermark="请弹幕内容"/>
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicBarChartExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicBarChartExample.xaml
deleted file mode 100644
index eb5894aa..00000000
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicBarChartExample.xaml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml
index 569f7811..791196ee 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml
@@ -181,8 +181,8 @@
+ wd:ElementHelper.CornerRadius="3"
+ Content="Default" />
@@ -323,8 +324,11 @@
FontSize="20"
Text="TextBox" />
-
-
+
+
-
-
+
+
Option 5
-
+
Option 1
Option 2
Option 3
@@ -386,7 +396,7 @@
FontSize="20"
Text="DatePicker" />
-
+
-
+
@@ -417,7 +427,7 @@
FontSize="20"
Text="Slider" />
-
+
+
-
+
-
+
-
+
@@ -591,7 +616,7 @@
FontSize="20"
Text="ListView" />
-
+
@@ -606,7 +631,6 @@
@@ -629,7 +653,7 @@
Height="400"
Margin="0,10"
Columns="2">
-
+
@@ -641,7 +665,6 @@
@@ -658,7 +681,7 @@
FontSize="20"
Text="Expander" />
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/BreatheLightExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/BreatheLightExample.xaml
index a358774c..bfe7858c 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/BreatheLightExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/BreatheLightExample.xaml
@@ -1,149 +1,201 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- 周星星|达叔
-
- 正在直播
-
-
-
-
-
+
+
+ 周星星|达叔
+
+ 正在直播
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- 大话西游之大圣娶亲
-
- 正在直播
-
-
+
+ 大话西游之大圣娶亲
+
+ 正在直播
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ VerticalAlignment="Bottom"
+ Content="进入直播"
+ Style="{StaticResource WD.PrimaryButton}" />
+
+
+
-
-
- XXXYYY
-
- 正在直播
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ XXXYYY
+
+ 正在直播
+
+
-
-
+ VerticalAlignment="Bottom"
+ Content="进入直播"
+ Style="{StaticResource WD.PrimaryButton}" />
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- WPF开发者
-
- 正在直播
-
-
-
-
-
+
+
+ WPF开发者
+
+ 正在直播
+
+
+
+
+
-
-
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/BubblleControlExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/BubblleControlExample.xaml
index 76b3fd87..ce14c814 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/BubblleControlExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/BubblleControlExample.xaml
@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
@@ -13,8 +13,8 @@
-
-
+
+
WPF
ASP.NET
@@ -26,11 +26,11 @@
WinForm
UWP
-
-
+
+
-
+
@@ -94,7 +94,7 @@
-
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/CarouselExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/CarouselExample.xaml
index 7e18545e..198b3012 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/CarouselExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/CarouselExample.xaml
@@ -4,18 +4,18 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicBarChartExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartBarExample.xaml.cs
similarity index 81%
rename from src/WPFDevelopers.Samples.Shared/ExampleViews/BasicBarChartExample.xaml.cs
rename to src/WPFDevelopers.Samples.Shared/ExampleViews/ChartBarExample.xaml.cs
index 04e7bdc0..c5b48bfd 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicBarChartExample.xaml.cs
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartBarExample.xaml.cs
@@ -1,23 +1,14 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
-using System.Text;
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.Navigation;
-using System.Windows.Shapes;
namespace WPFDevelopers.Samples.ExampleViews
{
///
- /// BasicBarChartExample.xaml 的交互逻辑
+ /// ChartBarExample.xaml 的交互逻辑
///
- public partial class BasicBarChartExample : UserControl
+ public partial class ChartBarExample : UserControl
{
public IEnumerable> SeriesModels
{
@@ -26,7 +17,7 @@ public IEnumerable> SeriesModels
}
public static readonly DependencyProperty SeriesModelsProperty =
- DependencyProperty.Register("SeriesModels", typeof(IEnumerable>), typeof(BasicBarChartExample), new PropertyMetadata(null));
+ DependencyProperty.Register("SeriesModels", typeof(IEnumerable>), typeof(ChartBarExample), new PropertyMetadata(null));
Dictionary>> keyValues = new Dictionary>>();
@@ -36,9 +27,9 @@ public string KeyBarChart
set { SetValue(KeyBarChartProperty, value); }
}
public static readonly DependencyProperty KeyBarChartProperty =
- DependencyProperty.Register("KeyBarChart", typeof(string), typeof(BasicBarChartExample), new PropertyMetadata(null));
+ DependencyProperty.Register("KeyBarChart", typeof(string), typeof(ChartBarExample), new PropertyMetadata(null));
private int _index = 0;
- public BasicBarChartExample()
+ public ChartBarExample()
{
InitializeComponent();
var Models1 = new[]
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml
new file mode 100644
index 00000000..26a69c63
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml.cs
new file mode 100644
index 00000000..6da42b8a
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml.cs
@@ -0,0 +1,62 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ ///
+ /// ChartLineExample.xaml 的交互逻辑
+ ///
+ public partial class ChartLineExample : UserControl
+ {
+ public IEnumerable> Datas
+ {
+ get { return (IEnumerable>)GetValue(DatasProperty); }
+ set { SetValue(DatasProperty, value); }
+ }
+
+ public static readonly DependencyProperty DatasProperty =
+ DependencyProperty.Register("Datas", typeof(IEnumerable>), typeof(ChartLineExample), new PropertyMetadata(null));
+
+ private Dictionary>> keyValues = new Dictionary>>();
+ private int _index = 0;
+ public ChartLineExample()
+ {
+ InitializeComponent();
+ var models1 = new[]
+ {
+ new KeyValuePair("Mon", 120),
+ new KeyValuePair("Tue", 530),
+ new KeyValuePair("Wed", 1060),
+ new KeyValuePair("Thu", 140),
+ new KeyValuePair("Fri", 8000) ,
+ new KeyValuePair("Sat", 200) ,
+ new KeyValuePair("Sun", 300) ,
+ };
+ var models2 = new[]
+ {
+ new KeyValuePair("(1)月", 120),
+ new KeyValuePair("(2)月", 170),
+ new KeyValuePair("(3)月", 30),
+ new KeyValuePair("(4)月", 200),
+ new KeyValuePair("(5)月", 100) ,
+ new KeyValuePair("(6)月", 180) ,
+ new KeyValuePair("(7)月", 90) ,
+ };
+ keyValues.Add("1", models1);
+ keyValues.Add("2", models2);
+ Datas = models1;
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ _index++;
+ if (_index >= keyValues.Count)
+ {
+ _index = 0;
+ }
+ Datas = keyValues.ToList()[_index].Value;
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/RadarChartExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml
similarity index 75%
rename from src/WPFDevelopers.Samples.Shared/ExampleViews/RadarChartExample.xaml
rename to src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml
index 3b7c834c..705ce488 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/RadarChartExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml
@@ -1,12 +1,12 @@
@@ -40,12 +40,12 @@
FontSize="18"
FontWeight="Black"
Foreground="#2B579A"
- Text="{Binding NowPlayerName, RelativeSource={RelativeSource AncestorType=local:RadarChartExample}}" />
+ Text="{Binding NowPlayerName, RelativeSource={RelativeSource AncestorType=local:ChartRadarExample}}" />
-
+ Datas="{Binding Datas, RelativeSource={RelativeSource AncestorType=local:ChartRadarExample}}" />
-
-
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/RadarChartExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml.cs
similarity index 69%
rename from src/WPFDevelopers.Samples.Shared/ExampleViews/RadarChartExample.xaml.cs
rename to src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml.cs
index b7837dc4..d946a885 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/RadarChartExample.xaml.cs
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml.cs
@@ -10,17 +10,19 @@
namespace WPFDevelopers.Samples.ExampleViews
{
///
- /// RadarChartExample.xaml 的交互逻辑
+ /// ChartRadarExample.xaml 的交互逻辑
///
- public partial class RadarChartExample : UserControl
+ public partial class ChartRadarExample : UserControl
{
- public ObservableCollection RadarModels
+ public IEnumerable> Datas
{
- get { return (ObservableCollection)GetValue(RadarModelsProperty); }
- set { SetValue(RadarModelsProperty, value); }
+ get { return (IEnumerable>)GetValue(DatasProperty); }
+ set { SetValue(DatasProperty, value); }
}
- public static readonly DependencyProperty RadarModelsProperty =
- DependencyProperty.Register("RadarModels", typeof(ObservableCollection), typeof(RadarChartExample), new PropertyMetadata(null));
+
+ public static readonly DependencyProperty DatasProperty =
+ DependencyProperty.Register("Datas", typeof(IEnumerable>), typeof(ChartRadarExample), new PropertyMetadata(null));
+
List Players = new List();
private int NowPlayerIndex = 0;
public string NowPlayerName
@@ -29,23 +31,22 @@ public string NowPlayerName
set { SetValue(NowPlayerNameProperty, value); }
}
public static readonly DependencyProperty NowPlayerNameProperty =
- DependencyProperty.Register("NowPlayerName", typeof(string), typeof(RadarChartExample), new PropertyMetadata(null));
+ DependencyProperty.Register("NowPlayerName", typeof(string), typeof(ChartRadarExample), new PropertyMetadata(null));
- List> collectionList = new List>();
- public RadarChartExample()
+ List>> collectionList = new List>>();
+ public ChartRadarExample()
{
InitializeComponent();
- RadarModels = new ObservableCollection();
Player theShy = new Player()
{
姓名 = "The Shy",
- 击杀 = 80,
- 助攻 = 50,
+ 击杀 = 800,
+ 助攻 = 500,
物理 = 90,
- 生存 = 10,
- 金钱 = 60,
- 防御 = 30,
- 魔法 = 30
+ 生存 = 120,
+ 金钱 = 360,
+ 防御 = 230,
+ 魔法 = 130
};
Player xiaoHu = new Player()
{
@@ -77,7 +78,7 @@ public RadarChartExample()
物理 = 80,
生存 = 70,
金钱 = 80,
- 防御 = 80,
+ 防御 = 100,
魔法 = 30
};
Players.AddRange(new[] { theShy, xiaoHu, yinHang, flandre });
@@ -88,14 +89,14 @@ public RadarChartExample()
foreach (var player in Players)
{
- var collectionpPayer = new ObservableCollection();
+ var collectionpPayer = new List>();
Array.ForEach(pArray, p =>
{
- collectionpPayer.Add(new RadarModel { Text = $"{p.Name}({(int)p.GetValue(player, null)}分)", ValueMax = (int)p.GetValue(player, null) });
+ collectionpPayer.Add(new KeyValuePair( $"{p.Name}({(int)p.GetValue(player, null)}分)", (int)p.GetValue(player, null)));
});
collectionList.Add(collectionpPayer);
}
- RadarModels = collectionList[0];
+ Datas = collectionList[0];
NowPlayerName = Players[0].姓名;
}
@@ -106,7 +107,7 @@ private void Button_Click(object sender, RoutedEventArgs e)
{
NowPlayerIndex = 0;
}
- RadarModels = collectionList[NowPlayerIndex];
+ Datas = collectionList[NowPlayerIndex];
NowPlayerName = Players[NowPlayerIndex].姓名;
}
}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChatEmojiExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChatEmojiExample.xaml
index 6ea48ee2..45552b88 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChatEmojiExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChatEmojiExample.xaml
@@ -6,7 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
@@ -87,7 +87,7 @@
-
+
-
+
@@ -13,7 +13,7 @@
-
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/CircularProgressBarExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/CircularProgressBarExample.xaml
index c06727a6..7b8f195d 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/CircularProgressBarExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/CircularProgressBarExample.xaml
@@ -4,32 +4,32 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
-
-
-
+
@@ -16,7 +16,7 @@
-
+
@@ -30,4 +30,4 @@
-
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/CutImageExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/CutImageExample.xaml
index 1bfaad04..6a427b6b 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/CutImageExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/CutImageExample.xaml
@@ -6,7 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ElementAdorner.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ElementAdorner.cs
new file mode 100644
index 00000000..2bf60451
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ElementAdorner.cs
@@ -0,0 +1,301 @@
+using System;
+using System.ComponentModel;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using WPFDevelopers.Helpers;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ public class ElementAdorner : Adorner
+ {
+ private const double ThumbSize = 16, ElementMiniSize = 20;
+ private const double RotateThumbSize = 20;
+ private readonly Thumb tLeft;
+ private readonly Thumb tRight;
+ private readonly Thumb bLeftBottom;
+ private readonly Thumb bRightBottom;
+ private readonly Thumb tMove;
+ private readonly VisualCollection visualCollection;
+ private readonly Thumb tRotate;
+
+ private Canvas canvas;
+ private Point centerPoint;
+ private FrameworkElement designerItem;
+ private double initialAngle;
+ private RotateTransform rotateTransform;
+ private Vector startVector;
+ public ElementAdorner(UIElement adornedElement) : base(adornedElement)
+ {
+ visualCollection = new VisualCollection(this);
+ visualCollection.Add(tMove = CreateMoveThumb());
+ visualCollection.Add(tLeft = CreateThumb(Cursors.SizeNWSE, HorizontalAlignment.Left,
+ VerticalAlignment.Top));
+ visualCollection.Add(tRight =
+ CreateThumb(Cursors.SizeNESW, HorizontalAlignment.Right, VerticalAlignment.Top));
+ visualCollection.Add(bLeftBottom =
+ CreateThumb(Cursors.SizeNESW, HorizontalAlignment.Left, VerticalAlignment.Bottom));
+ visualCollection.Add(bRightBottom =
+ CreateThumb(Cursors.SizeNWSE, HorizontalAlignment.Right, VerticalAlignment.Bottom));
+ visualCollection.Add(tRotate = CreateRotateThumb());
+ }
+
+ protected override int VisualChildrenCount => visualCollection.Count;
+
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ var offset = ThumbSize / 2;
+ var sz = new Size(ThumbSize, ThumbSize);
+ var renderPen = new Pen(ControlsHelper.PrimaryNormalBrush, 2.0);
+ var startPoint = new Point(AdornedElement.RenderSize.Width / 2,
+ AdornedElement.RenderSize.Height - AdornedElement.RenderSize.Height);
+ var endPoint = new Point(AdornedElement.RenderSize.Width / 2,
+ AdornedElement.RenderSize.Height - AdornedElement.RenderSize.Height - 16);
+ drawingContext.DrawLine(renderPen, startPoint, endPoint);
+ tMove.Arrange(new Rect(new Point(0, 0), new Size(RenderSize.Width, RenderSize.Height)));
+ tLeft.Arrange(new Rect(new Point(-offset, -offset), sz));
+ tRight.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
+ bLeftBottom.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
+ bRightBottom.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
+ tRotate.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - 10, -(RotateThumbSize - 5)), new Size(20, 20)));
+
+ var adornedElementRect = new Rect(AdornedElement.RenderSize);
+ var pen = new Pen(ControlsHelper.Brush, 2);
+ drawingContext.DrawRectangle(null, pen, adornedElementRect);
+ }
+
+ private Thumb CreateMoveThumb()
+ {
+ var thumb = new Thumb
+ {
+ Cursor = Cursors.SizeAll,
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetFactory(GetMoveEllipse())
+ }
+ };
+ thumb.DragDelta += (s, e) =>
+ {
+ var element = AdornedElement as FrameworkElement;
+ if (element == null)
+ return;
+
+ var transform = element.RenderTransform;
+ if (transform != null)
+ {
+ if (transform as RotateTransform != null)
+ {
+ var rotateTransform = transform as RotateTransform;
+
+ Point ptChange = rotateTransform.Transform(new Point(e.HorizontalChange, e.VerticalChange));
+
+ SetPositon(element, Canvas.GetLeft(element) + ptChange.X, Canvas.GetTop(element) + ptChange.Y);
+ }
+ else
+ {
+ SetPositon(element, Canvas.GetLeft(element) + e.HorizontalChange, Canvas.GetTop(element) + e.VerticalChange);
+ }
+ }
+
+ };
+ return thumb;
+ }
+
+ private Brush GetMoveEllipse()
+ {
+ return new DrawingBrush(new GeometryDrawing(Brushes.Transparent, null, null));
+ }
+
+ ///
+ /// 创建Thumb
+ ///
+ /// 鼠标
+ /// 水平
+ /// 垂直
+ ///
+ private Thumb CreateThumb(Cursor cursor, HorizontalAlignment horizontal, VerticalAlignment vertical)
+ {
+ var thumb = new Thumb
+ {
+ Cursor = cursor,
+ Width = ThumbSize,
+ Height = ThumbSize,
+ HorizontalAlignment = horizontal,
+ VerticalAlignment = vertical,
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetFactory(ControlsHelper.PrimaryNormalBrush)
+ }
+ };
+
+ thumb.DragDelta += (s, e) =>
+ {
+ var element = AdornedElement as FrameworkElement;
+ if (element == null) return;
+ Resize(element);
+ switch (thumb.VerticalAlignment)
+ {
+ case VerticalAlignment.Bottom:
+ if (element.Height + e.VerticalChange > ElementMiniSize) element.Height += e.VerticalChange;
+ break;
+ case VerticalAlignment.Top:
+ if (element.Height - e.VerticalChange > ElementMiniSize)
+ {
+ element.Height -= e.VerticalChange;
+ Canvas.SetTop(element, Canvas.GetTop(element) + e.VerticalChange);
+ }
+
+ break;
+ }
+
+ switch (thumb.HorizontalAlignment)
+ {
+ case HorizontalAlignment.Left:
+ if (element.Width - e.HorizontalChange > ElementMiniSize)
+ {
+ element.Width -= e.HorizontalChange;
+ Canvas.SetLeft(element, Canvas.GetLeft(element) + e.HorizontalChange);
+ }
+
+ break;
+ case HorizontalAlignment.Right:
+ if (element.Width + e.HorizontalChange > ElementMiniSize) element.Width += e.HorizontalChange;
+ break;
+ }
+
+ e.Handled = true;
+ };
+ return thumb;
+ }
+
+ private void Resize(FrameworkElement fElement)
+ {
+ if (double.IsNaN(fElement.Width))
+ fElement.Width = fElement.RenderSize.Width;
+ if (double.IsNaN(fElement.Height))
+ fElement.Height = fElement.RenderSize.Height;
+ }
+
+ private FrameworkElementFactory GetFactory(Brush back)
+ {
+ var elementFactory = new FrameworkElementFactory(typeof(Ellipse));
+ elementFactory.SetValue(Shape.FillProperty, back);
+ return elementFactory;
+ }
+
+
+ protected override Visual GetVisualChild(int index)
+ {
+ return visualCollection[index];
+ }
+
+ private void SetPositon(FrameworkElement element, double left, double top)
+ {
+ var parent = VisualTreeHelper.GetParent(element) as Canvas;
+
+ if (left <= 0)
+ {
+ left = 0;
+ }
+
+ if (top <= 0)
+ {
+ top = 0;
+ }
+
+ if (left + element.Width > parent.ActualWidth)
+ {
+ left = parent.ActualWidth - element.Width;
+ }
+ if (top + element.Height > parent.ActualHeight)
+ {
+ top = parent.ActualHeight - element.Height;
+ }
+
+ Canvas.SetLeft(element, left);
+ Canvas.SetTop(element, top);
+ }
+ ///
+ /// 旋转
+ ///
+ ///
+ private Thumb CreateRotateThumb()
+ {
+ Thumb thumb = new Thumb()
+ {
+ Cursor = Cursors.Hand,
+ Width = RotateThumbSize,
+ Height = RotateThumbSize,
+ VerticalAlignment = VerticalAlignment.Top,
+ Margin = new Thickness(0, -RotateThumbSize, 0, 0),
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetFactory(GetFactoryRotate()),
+ },
+ };
+ thumb.DragDelta += Thumb_DragDelta;
+ thumb.DragStarted += Thumb_DragStarted;
+ return thumb;
+ }
+
+
+ private Brush GetFactoryRotate()
+ {
+ var lan =
+ "M242 842l60-60c48 36 106 60 168 68v86c-86-8-164-42-228-94zM554 850c62-8 120-32 166-68l62 60c-64 52-142 86-228 94v-86zM782 722c36-48 60-104 68-166h86c-8 86-42 162-94 226zM640 512c0 70-58 128-128 128s-128-58-128-128 58-128 128-128 128 58 128 128zM174 554c8 62 32 120 68 166l-60 62c-52-64-86-142-94-228h86zM242 302c-36 48-60 106-68 168h-86c8-86 42-164 94-228zM850 470c-8-62-32-120-68-168l60-60c52 64 86 142 94 228h-86zM782 182l-60 60c-48-36-106-60-168-68v-86c86 8 164 42 228 94zM470 174c-62 8-120 32-168 68l-60-60c64-52 142-86 228-94v86z";
+ var converter = TypeDescriptor.GetConverter(typeof(Geometry));
+ var geometry = (Geometry)converter.ConvertFrom(lan);
+ TileBrush bsh =
+ new DrawingBrush(new GeometryDrawing(ControlsHelper.PrimaryNormalBrush, new Pen(Brushes.Transparent, 2), geometry));
+ bsh.Stretch = Stretch.Fill;
+ return bsh;
+ }
+ private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
+ {
+ if (designerItem != null && canvas != null)
+ {
+ var currentPoint = Mouse.GetPosition(canvas);
+ var deltaVector = Point.Subtract(currentPoint, centerPoint);
+
+ var angle = Vector.AngleBetween(startVector, deltaVector);
+
+ var rotateTransform = designerItem.RenderTransform as RotateTransform;
+ rotateTransform.Angle = initialAngle + Math.Round(angle, 0);
+ designerItem.InvalidateMeasure();
+ }
+ }
+
+ private void Thumb_DragStarted(object sender, DragStartedEventArgs e)
+ {
+ var thumb = sender as Thumb;
+ designerItem = AdornedElement as FrameworkElement;
+ canvas = VisualTreeHelper.GetParent(designerItem) as Canvas;
+ if (canvas != null)
+ {
+ centerPoint = designerItem.TranslatePoint(
+ new Point(designerItem.Width * designerItem.RenderTransformOrigin.X,
+ designerItem.Height * designerItem.RenderTransformOrigin.Y),
+ canvas);
+
+ var startPoint = Mouse.GetPosition(canvas);
+ startVector = Point.Subtract(startPoint, centerPoint);
+
+ rotateTransform = designerItem.RenderTransform as RotateTransform;
+ if (rotateTransform == null)
+ {
+ designerItem.RenderTransform = new RotateTransform(0);
+ initialAngle = 0;
+ }
+ else
+ {
+ initialAngle = rotateTransform.Angle;
+ }
+ }
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAdorner.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAdorner.cs
new file mode 100644
index 00000000..f535a0f4
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAdorner.cs
@@ -0,0 +1,418 @@
+using System;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using WPFDevelopers.Helpers;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ public class ThumbAdorner : Adorner
+ {
+ private const double THUMB_SIZE = 5;
+ private const double MINIMAL_SIZE = 20;
+ private const double RotateThumbSize = 20;
+ private readonly Thumb lc;
+ private readonly Thumb tl;
+ private readonly Thumb tc;
+ private readonly Thumb tr;
+ private readonly Thumb rc;
+ private readonly Thumb br;
+ private readonly Thumb bc;
+ private readonly Thumb bl;
+ private readonly Thumb tMove;
+ private readonly Thumb tRotate;
+ private readonly VisualCollection visCollec;
+ private Canvas canvas;
+ private readonly FrameworkElement child;
+ private Point centerPoint;
+ private FrameworkElement designerItem;
+ private double initialAngle;
+ private RotateTransform rotateTransform;
+ private Vector startVector;
+ private TransformThumb parentElemt;
+
+ public ThumbAdorner(UIElement adorned) : base(adorned)
+ {
+ canvas = FindParent(adorned) as Canvas;
+ child = FindVisualChild(adorned);
+ parentElemt = adorned as TransformThumb;
+ visCollec = new VisualCollection(this);
+ // 创建移动
+ visCollec.Add(tMove = CreateMoveThumb());
+ visCollec.Add(lc = GetResizeThumb(Cursors.SizeWE, HorizontalAlignment.Left, VerticalAlignment.Center));
+ visCollec.Add(tl = GetResizeThumb(Cursors.SizeNWSE, HorizontalAlignment.Left, VerticalAlignment.Top));
+ visCollec.Add(tc = GetResizeThumb(Cursors.SizeNS, HorizontalAlignment.Center, VerticalAlignment.Top));
+ visCollec.Add(tr = GetResizeThumb(Cursors.SizeNESW, HorizontalAlignment.Right, VerticalAlignment.Top));
+ visCollec.Add(rc = GetResizeThumb(Cursors.SizeWE, HorizontalAlignment.Right, VerticalAlignment.Center));
+ visCollec.Add(br = GetResizeThumb(Cursors.SizeNWSE, HorizontalAlignment.Right, VerticalAlignment.Bottom));
+ visCollec.Add(bc = GetResizeThumb(Cursors.SizeNS, HorizontalAlignment.Center, VerticalAlignment.Bottom));
+ visCollec.Add(bl = GetResizeThumb(Cursors.SizeNESW, HorizontalAlignment.Left, VerticalAlignment.Bottom));
+ visCollec.Add(tRotate = CreateRotateThumb());
+ }
+
+ protected override int VisualChildrenCount => visCollec.Count;
+
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ var offset = THUMB_SIZE / 2;
+ var sz = new Size(THUMB_SIZE, THUMB_SIZE);
+ var renderPen = new Pen(ControlsHelper.PrimaryNormalBrush, 2.0);
+ var startPoint = new Point(AdornedElement.RenderSize.Width / 2,
+ AdornedElement.RenderSize.Height - AdornedElement.RenderSize.Height);
+ var endPoint = new Point(AdornedElement.RenderSize.Width / 2,
+ AdornedElement.RenderSize.Height - AdornedElement.RenderSize.Height - 16);
+ drawingContext.DrawLine(renderPen, startPoint, endPoint);
+ tMove.Arrange(new Rect(new Point(0, 0), new Size(RenderSize.Width, RenderSize.Height)));
+
+ lc.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height / 2 - offset), sz));
+ tl.Arrange(new Rect(new Point(-offset, -offset), sz));
+ tc.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - offset, -offset), sz));
+ tr.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
+ rc.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height / 2 - offset),
+ sz));
+ br.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
+ bc.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width / 2 - offset, AdornedElement.RenderSize.Height - offset),
+ sz));
+ bl.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
+
+ tRotate.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - 10, -(RotateThumbSize - 5)), new Size(20, 20)));
+
+ }
+
+
+ private Thumb CreateMoveThumb()
+ {
+ var thumb = new Thumb
+ {
+ Cursor = Cursors.SizeAll,
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetFactory(GetMoveEllipse())
+ }
+ };
+
+ thumb.DragDelta += (s, e) =>
+ {
+ var element = AdornedElement as FrameworkElement;
+ if (element == null)
+ return;
+
+ var transform = element.RenderTransform;
+ if (transform != null)
+ {
+ if (transform as RotateTransform != null)
+ {
+ var rotateTransform = transform as RotateTransform;
+
+ Point ptChange = rotateTransform.Transform(new Point(e.HorizontalChange, e.VerticalChange));
+
+ SetPositon(element, Canvas.GetLeft(element) + ptChange.X, Canvas.GetTop(element) + ptChange.Y);
+ }
+ else
+ {
+ SetPositon(element, Canvas.GetLeft(element) + e.HorizontalChange, Canvas.GetTop(element) + e.VerticalChange);
+ }
+ }
+
+ };
+ return thumb;
+ }
+
+ private void SetPositon(FrameworkElement element, double left, double top)
+ {
+ var parent = VisualTreeHelper.GetParent(element) as Canvas;
+
+ if (left <= 0)
+ {
+ left = 0;
+ }
+
+ if (top <= 0)
+ {
+ top = 0;
+ }
+
+ if (left + element.Width > parent.ActualWidth)
+ {
+ left = parent.ActualWidth - element.Width;
+ }
+ if (top + element.Height > parent.ActualHeight)
+ {
+ top = parent.ActualHeight - element.Height;
+ }
+
+ Canvas.SetLeft(element, left);
+ Canvas.SetTop(element, top);
+ }
+
+ private Brush GetMoveEllipse()
+ {
+ return new DrawingBrush(new GeometryDrawing(Brushes.Transparent, null, null));
+ }
+
+ ///
+ /// 旋转
+ ///
+ ///
+ private Thumb CreateRotateThumb()
+ {
+ Thumb thumb = new Thumb()
+ {
+ Cursor = Cursors.ScrollAll,
+ Width = RotateThumbSize,
+ Height = RotateThumbSize,
+ VerticalAlignment = VerticalAlignment.Top,
+ Margin = new Thickness(0, -RotateThumbSize, 0, 0),
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetEllipseFactory(GetFactoryRotate()),
+ },
+ };
+ thumb.DragDelta += Thumb_DragDelta;
+ thumb.DragStarted += Thumb_DragStarted;
+ return thumb;
+ }
+
+ private FrameworkElementFactory GetEllipseFactory(Brush back)
+ {
+ var elementFactory = new FrameworkElementFactory(typeof(Ellipse));
+ elementFactory.SetValue(Shape.FillProperty, back);
+ return elementFactory;
+ }
+
+ private Brush GetFactoryRotate()
+ {
+ var lan =
+ "M242 842l60-60c48 36 106 60 168 68v86c-86-8-164-42-228-94zM554 850c62-8 120-32 166-68l62 60c-64 52-142 86-228 94v-86zM782 722c36-48 60-104 68-166h86c-8 86-42 162-94 226zM640 512c0 70-58 128-128 128s-128-58-128-128 58-128 128-128 128 58 128 128zM174 554c8 62 32 120 68 166l-60 62c-52-64-86-142-94-228h86zM242 302c-36 48-60 106-68 168h-86c8-86 42-164 94-228zM850 470c-8-62-32-120-68-168l60-60c52 64 86 142 94 228h-86zM782 182l-60 60c-48-36-106-60-168-68v-86c86 8 164 42 228 94zM470 174c-62 8-120 32-168 68l-60-60c64-52 142-86 228-94v86z";
+ var converter = TypeDescriptor.GetConverter(typeof(Geometry));
+ var geometry = (Geometry)converter.ConvertFrom(lan);
+ TileBrush bsh =
+ new DrawingBrush(new GeometryDrawing(ControlsHelper.PrimaryNormalBrush, new Pen(Brushes.Transparent, 2), geometry));
+ bsh.Stretch = Stretch.Fill;
+ return bsh;
+ }
+
+ private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
+ {
+ if (designerItem != null && canvas != null)
+ {
+ var currentPoint = Mouse.GetPosition(canvas);
+ var deltaVector = Point.Subtract(currentPoint, centerPoint);
+
+ var angle = Vector.AngleBetween(startVector, deltaVector);
+
+ var rotateTransform = designerItem.RenderTransform as RotateTransform;
+ rotateTransform.Angle = initialAngle + Math.Round(angle, 0);
+ designerItem.InvalidateMeasure();
+ }
+ }
+
+ private void Thumb_DragStarted(object sender, DragStartedEventArgs e)
+ {
+ var thumb = sender as Thumb;
+ designerItem = AdornedElement as FrameworkElement;
+ canvas = VisualTreeHelper.GetParent(designerItem) as Canvas;
+ if (canvas != null)
+ {
+ centerPoint = designerItem.TranslatePoint(
+ new Point(designerItem.Width * designerItem.RenderTransformOrigin.X,
+ designerItem.Height * designerItem.RenderTransformOrigin.Y),
+ canvas);
+
+ var startPoint = Mouse.GetPosition(canvas);
+ startVector = Point.Subtract(startPoint, centerPoint);
+
+ rotateTransform = designerItem.RenderTransform as RotateTransform;
+ if (rotateTransform == null)
+ {
+ designerItem.RenderTransform = new RotateTransform(0);
+ initialAngle = 0;
+ }
+ else
+ {
+ initialAngle = rotateTransform.Angle;
+ }
+ }
+ }
+
+ private static UIElement FindParent(UIElement element)
+ {
+ DependencyObject obj = element;
+ obj = VisualTreeHelper.GetParent(obj);
+ return obj as UIElement;
+ }
+
+ private childItem FindVisualChild(DependencyObject obj)
+ where childItem : DependencyObject
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(obj, i);
+ if (child != null && child is childItem)
+ {
+ return (childItem)child;
+ }
+ else
+ {
+ ContentPresenter element = child as ContentPresenter;
+ if (element != null && element.Content is childItem)
+ {
+ return (childItem)element.Content;
+ }
+ }
+ }
+ return null;
+ }
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ var offset = THUMB_SIZE / 2;
+ var sz = new Size(THUMB_SIZE, THUMB_SIZE);
+ lc.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height / 2 - offset), sz));
+ tl.Arrange(new Rect(new Point(-offset, -offset), sz));
+ tc.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - offset, -offset), sz));
+ tr.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
+ rc.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height / 2 - offset),
+ sz));
+ br.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
+ bc.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width / 2 - offset, AdornedElement.RenderSize.Height - offset),
+ sz));
+ bl.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
+ return finalSize;
+ }
+
+ private void Resize(FrameworkElement frameworkElement)
+ {
+ if (double.IsNaN(frameworkElement.Width))
+ frameworkElement.Width = frameworkElement.RenderSize.Width;
+ if (double.IsNaN(frameworkElement.Height))
+ frameworkElement.Height = frameworkElement.RenderSize.Height;
+ child.Width = frameworkElement.RenderSize.Width;
+ child.Height = frameworkElement.RenderSize.Height;
+ }
+
+ private Thumb GetResizeThumb(Cursor cur, HorizontalAlignment hor, VerticalAlignment ver)
+ {
+ // 设置拖拽控件实例
+ var thumb = new Thumb
+ {
+ Width = THUMB_SIZE,
+ Height = THUMB_SIZE,
+ HorizontalAlignment = hor,
+ VerticalAlignment = ver,
+ Cursor = cur,
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetFactory(ControlsHelper.PrimaryNormalBrush)
+ }
+ };
+
+ // 最大宽度
+ var maxWidth = double.IsNaN(canvas.Width) ? canvas.ActualWidth : canvas.Width;
+ // 最大高度
+ var maxHeight = double.IsNaN(canvas.Height) ? canvas.ActualHeight : canvas.Height;
+ // 订阅拖拽开始事件
+ thumb.DragStarted += (s, e) => {
+ Debug.WriteLine($"HorizontalOffset:{e.HorizontalOffset}");
+ Debug.WriteLine($"VerticalOffset:{e.VerticalOffset}");
+ };
+ // 订阅拖拽事件
+ thumb.DragDelta += (s, e) =>
+ {
+ // 转换遮罩目标节点元素为基础元素节点
+ var element = AdornedElement as FrameworkElement;
+ if (element == null)
+ return;
+ // 刷新节点大小
+ Resize(element);
+ // 判定拖动控件所属垂直位置
+ switch (thumb.VerticalAlignment)
+ {
+ case VerticalAlignment.Bottom:
+ if (element.Height + e.VerticalChange > MINIMAL_SIZE)
+ {
+ var newHeight = element.Height + e.VerticalChange;
+ var top = Canvas.GetTop(element) + newHeight;
+ if (newHeight > 0 && top <= canvas.ActualHeight)
+ element.Height = newHeight;
+ }
+ break;
+
+ case VerticalAlignment.Top:
+ if (element.Height - e.VerticalChange > MINIMAL_SIZE)
+ {
+
+ var newHeight = element.Height - e.VerticalChange;
+ var top = Canvas.GetTop(element);
+ if (newHeight > 0 && top + e.VerticalChange >= 0)
+ {
+ element.Height = newHeight;
+ Canvas.SetTop(element, top + e.VerticalChange);
+ }
+ }
+
+ break;
+ }
+ // 判定拖动控件所属水平位置
+ switch (thumb.HorizontalAlignment)
+ {
+ case HorizontalAlignment.Left:
+ if (element.Width - e.HorizontalChange > MINIMAL_SIZE)
+ {
+ var newWidth = element.Width - e.HorizontalChange;
+ var left = Canvas.GetLeft(element);
+ if (newWidth > 0 && left + e.HorizontalChange >= 0)
+ {
+ element.Width = newWidth;
+ Canvas.SetLeft(element, left + e.HorizontalChange);
+ }
+ }
+
+ break;
+ case HorizontalAlignment.Right:
+ if (element.Width + e.HorizontalChange > MINIMAL_SIZE)
+ {
+ var newWidth = element.Width + e.HorizontalChange;
+ var left = Canvas.GetLeft(element) + newWidth;
+ if (newWidth > 0 && left <= canvas.ActualWidth)
+ element.Width = newWidth;
+ }
+
+ break;
+ }
+
+ e.Handled = true;
+ };
+ thumb.DragCompleted += (s, e) => {
+ Debug.WriteLine($"HorizontalChange:{e.HorizontalChange}");
+ Debug.WriteLine($"VerticalChange:{e.VerticalChange}");
+ };
+ return thumb;
+ }
+
+ private FrameworkElementFactory GetFactory(Brush back)
+ {
+ var fef = new FrameworkElementFactory(typeof(Rectangle));
+ fef.SetValue(Shape.FillProperty, back);
+ fef.SetValue(Shape.StrokeProperty, ControlsHelper.PrimaryNormalBrush);
+ fef.SetValue(Shape.StrokeThicknessProperty, (double)1);
+ return fef;
+ }
+
+ protected override Visual GetVisualChild(int index)
+ {
+ return visCollec[index];
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAdorner2.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAdorner2.cs
new file mode 100644
index 00000000..cbbea3a2
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAdorner2.cs
@@ -0,0 +1,404 @@
+using System;
+using System.ComponentModel;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using WPFDevelopers.Helpers;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ public class ThumbAdorner2 : Adorner
+ {
+ private const double THUMB_SIZE = 15;
+ private const double MINIMAL_SIZE = 20;
+ private const double RotateThumbSize = 20;
+ private readonly Thumb lc;
+ private readonly Thumb tl;
+ private readonly Thumb tc;
+ private readonly Thumb tr;
+ private readonly Thumb rc;
+ private readonly Thumb br;
+ private readonly Thumb bc;
+ private readonly Thumb bl;
+ private readonly VisualCollection visCollec;
+ private Canvas canvas;
+ private readonly Thumb tMove;
+ private readonly Thumb tRotate;
+ private readonly FrameworkElement child;
+ private Point centerPoint;
+ private FrameworkElement designerItem;
+ private double initialAngle;
+ private RotateTransform rotateTransform;
+ private Vector startVector;
+ private TransformThumb parentElemt;
+
+ public ThumbAdorner2(UIElement adorned) : base(adorned)
+ {
+ canvas = FindParent(adorned) as Canvas;
+ parentElemt = adorned as TransformThumb;
+ child = FindVisualChild(adorned);
+ visCollec = new VisualCollection(this);
+ // 创建移动
+ visCollec.Add(tMove = CreateMoveThumb());
+ visCollec.Add(lc = GetResizeThumb(Cursors.SizeWE, HorizontalAlignment.Left, VerticalAlignment.Center));
+ visCollec.Add(tl = GetResizeThumb(Cursors.SizeNWSE, HorizontalAlignment.Left, VerticalAlignment.Top));
+ visCollec.Add(tc = GetResizeThumb(Cursors.SizeNS, HorizontalAlignment.Center, VerticalAlignment.Top));
+ visCollec.Add(tr = GetResizeThumb(Cursors.SizeNESW, HorizontalAlignment.Right, VerticalAlignment.Top));
+ visCollec.Add(rc = GetResizeThumb(Cursors.SizeWE, HorizontalAlignment.Right, VerticalAlignment.Center));
+ visCollec.Add(br = GetResizeThumb(Cursors.SizeNWSE, HorizontalAlignment.Right, VerticalAlignment.Bottom));
+ visCollec.Add(bc = GetResizeThumb(Cursors.SizeNS, HorizontalAlignment.Center, VerticalAlignment.Bottom));
+ visCollec.Add(bl = GetResizeThumb(Cursors.SizeNESW, HorizontalAlignment.Left, VerticalAlignment.Bottom));
+ visCollec.Add(tRotate = CreateRotateThumb());
+ }
+ ///
+ /// 旋转
+ ///
+ ///
+ private Thumb CreateRotateThumb()
+ {
+ Thumb thumb = new Thumb()
+ {
+ Cursor = Cursors.ScrollAll,
+ Width = RotateThumbSize,
+ Height = RotateThumbSize,
+ VerticalAlignment = VerticalAlignment.Top,
+ Margin = new Thickness(0, -RotateThumbSize, 0, 0),
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetEllipseFactory(GetFactoryRotate()),
+ },
+ };
+ thumb.DragDelta += Thumb_DragDelta;
+ thumb.DragStarted += Thumb_DragStarted;
+ return thumb;
+ }
+
+ private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
+ {
+ if (designerItem != null && canvas != null)
+ {
+ var currentPoint = Mouse.GetPosition(canvas);
+ var deltaVector = Point.Subtract(currentPoint, centerPoint);
+
+ var angle = Vector.AngleBetween(startVector, deltaVector);
+
+ var rotateTransform = designerItem.RenderTransform as RotateTransform;
+ rotateTransform.Angle = initialAngle + Math.Round(angle, 0);
+ designerItem.InvalidateMeasure();
+ }
+ }
+
+ private void Thumb_DragStarted(object sender, DragStartedEventArgs e)
+ {
+ var thumb = sender as Thumb;
+ designerItem = AdornedElement as FrameworkElement;
+ canvas = VisualTreeHelper.GetParent(designerItem) as Canvas;
+ if (canvas != null)
+ {
+ centerPoint = designerItem.TranslatePoint(
+ new Point(designerItem.Width * designerItem.RenderTransformOrigin.X,
+ designerItem.Height * designerItem.RenderTransformOrigin.Y),
+ canvas);
+
+ var startPoint = Mouse.GetPosition(canvas);
+ startVector = Point.Subtract(startPoint, centerPoint);
+
+ rotateTransform = designerItem.RenderTransform as RotateTransform;
+ if (rotateTransform == null)
+ {
+ designerItem.RenderTransform = new RotateTransform(0);
+ initialAngle = 0;
+ }
+ else
+ {
+ initialAngle = rotateTransform.Angle;
+ }
+ }
+ }
+
+ private FrameworkElementFactory GetEllipseFactory(Brush back)
+ {
+ var elementFactory = new FrameworkElementFactory(typeof(Ellipse));
+ elementFactory.SetValue(Shape.FillProperty, back);
+ return elementFactory;
+ }
+
+ private FrameworkElementFactory GetContentFactory(Brush back)
+ {
+ var elementFactory = new FrameworkElementFactory(parentElemt.ContentType);
+ elementFactory.SetValue(Shape.FillProperty, back);
+ return elementFactory;
+ }
+ private Brush GetFactoryRotate()
+ {
+ var lan =
+ "M242 842l60-60c48 36 106 60 168 68v86c-86-8-164-42-228-94zM554 850c62-8 120-32 166-68l62 60c-64 52-142 86-228 94v-86zM782 722c36-48 60-104 68-166h86c-8 86-42 162-94 226zM640 512c0 70-58 128-128 128s-128-58-128-128 58-128 128-128 128 58 128 128zM174 554c8 62 32 120 68 166l-60 62c-52-64-86-142-94-228h86zM242 302c-36 48-60 106-68 168h-86c8-86 42-164 94-228zM850 470c-8-62-32-120-68-168l60-60c52 64 86 142 94 228h-86zM782 182l-60 60c-48-36-106-60-168-68v-86c86 8 164 42 228 94zM470 174c-62 8-120 32-168 68l-60-60c64-52 142-86 228-94v86z";
+ var converter = TypeDescriptor.GetConverter(typeof(Geometry));
+ var geometry = (Geometry)converter.ConvertFrom(lan);
+ TileBrush bsh =
+ new DrawingBrush(new GeometryDrawing(ControlsHelper.PrimaryNormalBrush, new Pen(Brushes.Transparent, 2), geometry));
+ bsh.Stretch = Stretch.Fill;
+ return bsh;
+ }
+ private Thumb CreateMoveThumb()
+ {
+ var thumb = new Thumb
+ {
+ Cursor = Cursors.SizeAll,
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetContentFactory(GetMoveEllipse())
+ }
+ };
+
+ thumb.DragDelta += (s, e) =>
+ {
+ var element = AdornedElement as FrameworkElement;
+ if (element == null)
+ return;
+
+ var transform = element.RenderTransform;
+ if (transform != null)
+ {
+ if (transform as RotateTransform != null)
+ {
+ var rotateTransform = transform as RotateTransform;
+
+ Point ptChange = rotateTransform.Transform(new Point(e.HorizontalChange, e.VerticalChange));
+
+ SetPositon(element, Canvas.GetLeft(element) + ptChange.X, Canvas.GetTop(element) + ptChange.Y);
+ }
+ else
+ {
+ SetPositon(element, Canvas.GetLeft(element) + e.HorizontalChange, Canvas.GetTop(element) + e.VerticalChange);
+ }
+ }
+
+ };
+ return thumb;
+ }
+
+ private void SetPositon(FrameworkElement element, double left, double top)
+ {
+ var parent = VisualTreeHelper.GetParent(element) as Canvas;
+
+ if (left <= 0)
+ {
+ left = 0;
+ }
+
+ if (top <= 0)
+ {
+ top = 0;
+ }
+
+ if (left + element.Width > parent.ActualWidth)
+ {
+ left = parent.ActualWidth - element.Width;
+ }
+ if (top + element.Height > parent.ActualHeight)
+ {
+ top = parent.ActualHeight - element.Height;
+ }
+
+ Canvas.SetLeft(element, left);
+ Canvas.SetTop(element, top);
+ }
+
+ private Brush GetMoveEllipse()
+ {
+ return new DrawingBrush(new GeometryDrawing(Brushes.Transparent, null, null));
+ }
+
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ var offset = THUMB_SIZE / 2;
+ var sz = new Size(THUMB_SIZE, THUMB_SIZE);
+ var renderPen = new Pen(ControlsHelper.PrimaryNormalBrush, 2.0);
+ var startPoint = new Point(AdornedElement.RenderSize.Width / 2,
+ AdornedElement.RenderSize.Height - AdornedElement.RenderSize.Height);
+ var endPoint = new Point(AdornedElement.RenderSize.Width / 2,
+ AdornedElement.RenderSize.Height - AdornedElement.RenderSize.Height - 16);
+ drawingContext.DrawLine(renderPen, startPoint, endPoint);
+ tMove.Arrange(new Rect(new Point(0, 0), new Size(RenderSize.Width, RenderSize.Height)));
+
+ lc.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height / 2 - offset), sz));
+ tl.Arrange(new Rect(new Point(-offset, -offset), sz));
+ tc.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - offset, -offset), sz));
+ tr.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
+ rc.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height / 2 - offset),
+ sz));
+ br.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
+ bc.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width / 2 - offset, AdornedElement.RenderSize.Height - offset),
+ sz));
+ bl.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
+
+ tRotate.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - 10, -(RotateThumbSize - 5)), new Size(20, 20)));
+
+ var adornedElementRect = new Rect(AdornedElement.RenderSize);
+ var pen = new Pen(ControlsHelper.Brush, 2);
+ drawingContext.DrawRectangle(null, pen, adornedElementRect);
+ }
+ private static UIElement FindParent(UIElement element)
+ {
+ DependencyObject obj = element;
+ obj = VisualTreeHelper.GetParent(obj);
+ return obj as UIElement;
+ }
+ private FrameworkElement FindVisualChild(DependencyObject obj)
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(obj, i);
+ if (child != null && child.GetType() == parentElemt.ContentType)
+ {
+ return (FrameworkElement)child;
+ }
+ else
+ {
+ ContentPresenter element = child as ContentPresenter;
+ if (element != null && element.Content.GetType() == parentElemt.ContentType)
+ {
+ return (FrameworkElement)element.Content;
+ }
+ }
+ }
+ return null;
+ }
+ protected override int VisualChildrenCount => visCollec.Count;
+
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ var offset = THUMB_SIZE / 2;
+ var sz = new Size(THUMB_SIZE, THUMB_SIZE);
+ lc.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height / 2 - offset), sz));
+ tl.Arrange(new Rect(new Point(-offset, -offset), sz));
+ tc.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - offset, -offset), sz));
+ tr.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
+ rc.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height / 2 - offset),
+ sz));
+ br.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
+ bc.Arrange(new Rect(
+ new Point(AdornedElement.RenderSize.Width / 2 - offset, AdornedElement.RenderSize.Height - offset),
+ sz));
+ bl.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
+ return finalSize;
+ }
+
+ private void Resize(FrameworkElement frameworkElement)
+ {
+ if (double.IsNaN(frameworkElement.Width))
+ frameworkElement.Width = frameworkElement.RenderSize.Width;
+ if (double.IsNaN(frameworkElement.Height))
+ frameworkElement.Height = frameworkElement.RenderSize.Height;
+ child.Width = frameworkElement.RenderSize.Width;
+ child.Height = frameworkElement.RenderSize.Height;
+ }
+
+ private Thumb GetResizeThumb(Cursor cur, HorizontalAlignment hor, VerticalAlignment ver)
+ {
+ var thumb = new Thumb
+ {
+ Width = THUMB_SIZE,
+ Height = THUMB_SIZE,
+ HorizontalAlignment = hor,
+ VerticalAlignment = ver,
+ Cursor = cur,
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetFactory(new SolidColorBrush(Colors.White))
+ }
+ };
+ var maxWidth = double.IsNaN(canvas.Width) ? canvas.ActualWidth : canvas.Width;
+ var maxHeight = double.IsNaN(canvas.Height) ? canvas.ActualHeight : canvas.Height;
+ thumb.DragDelta += (s, e) =>
+ {
+ var element = AdornedElement as FrameworkElement;
+ if (element == null)
+ return;
+ Resize(element);
+
+ switch (thumb.VerticalAlignment)
+ {
+ case VerticalAlignment.Bottom:
+ if (element.Height + e.VerticalChange > MINIMAL_SIZE)
+ {
+ var newHeight = element.Height + e.VerticalChange;
+ var top = Canvas.GetTop(element) + newHeight;
+ if (newHeight > 0 && top <= canvas.ActualHeight)
+ element.Height = newHeight;
+ }
+ break;
+
+ case VerticalAlignment.Top:
+ if (element.Height - e.VerticalChange > MINIMAL_SIZE)
+ {
+
+ var newHeight = element.Height - e.VerticalChange;
+ var top = Canvas.GetTop(element);
+ if (newHeight > 0 && top + e.VerticalChange >= 0)
+ {
+ element.Height = newHeight;
+ Canvas.SetTop(element, top + e.VerticalChange);
+ }
+ }
+
+ break;
+ }
+
+ switch (thumb.HorizontalAlignment)
+ {
+ case HorizontalAlignment.Left:
+ if (element.Width - e.HorizontalChange > MINIMAL_SIZE)
+ {
+ var newWidth = element.Width - e.HorizontalChange;
+ var left = Canvas.GetLeft(element);
+ if (newWidth > 0 && left + e.HorizontalChange >= 0)
+ {
+ element.Width = newWidth;
+ Canvas.SetLeft(element, left + e.HorizontalChange);
+ }
+ }
+
+ break;
+ case HorizontalAlignment.Right:
+ if (element.Width + e.HorizontalChange > MINIMAL_SIZE)
+ {
+ var newWidth = element.Width + e.HorizontalChange;
+ var left = Canvas.GetLeft(element) + newWidth;
+ if (newWidth > 0 && left <= canvas.ActualWidth)
+ element.Width = newWidth;
+ }
+
+ break;
+ }
+
+ e.Handled = true;
+ };
+ return thumb;
+ }
+
+ private FrameworkElementFactory GetFactory(Brush back)
+ {
+ var fef = new FrameworkElementFactory(typeof(Ellipse));
+ fef.SetValue(Shape.FillProperty, back);
+ fef.SetValue(Shape.StrokeProperty, ControlsHelper.PrimaryNormalBrush);
+ fef.SetValue(Shape.StrokeThicknessProperty, (double)2);
+ return fef;
+ }
+
+ protected override Visual GetVisualChild(int index)
+ {
+ return visCollec[index];
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAngle.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAngle.cs
new file mode 100644
index 00000000..b5496758
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/ThumbAngle.cs
@@ -0,0 +1,99 @@
+using System;
+using System.ComponentModel;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Shapes;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ public class ThumbAngle : Thumb
+ {
+ private Canvas canvas;
+ private Point centerPoint;
+ private Border designerItem;
+ private double initialAngle;
+ private RotateTransform rotateTransform;
+ private Vector startVector;
+
+ public ThumbAngle()
+ {
+ Cursor = Cursors.Hand;
+ Width = 16;
+ Height = 16;
+ VerticalAlignment = VerticalAlignment.Top;
+ Margin = new Thickness(0, -28, 0, 0);
+ Template = new ControlTemplate(typeof(Thumb))
+ {
+ VisualTree = GetFactory(GetMoveEllipseBack())
+ };
+ ToolTip = "旋转";
+ DragDelta += Thumb_DragDelta;
+ DragStarted += Thumb_DragStarted;
+ }
+
+ private Brush GetMoveEllipseBack()
+ {
+ var lan =
+ "M242 842l60-60c48 36 106 60 168 68v86c-86-8-164-42-228-94zM554 850c62-8 120-32 166-68l62 60c-64 52-142 86-228 94v-86zM782 722c36-48 60-104 68-166h86c-8 86-42 162-94 226zM640 512c0 70-58 128-128 128s-128-58-128-128 58-128 128-128 128 58 128 128zM174 554c8 62 32 120 68 166l-60 62c-52-64-86-142-94-228h86zM242 302c-36 48-60 106-68 168h-86c8-86 42-164 94-228zM850 470c-8-62-32-120-68-168l60-60c52 64 86 142 94 228h-86zM782 182l-60 60c-48-36-106-60-168-68v-86c86 8 164 42 228 94zM470 174c-62 8-120 32-168 68l-60-60c64-52 142-86 228-94v86z";
+ var converter = TypeDescriptor.GetConverter(typeof(Geometry));
+ var geometry = (Geometry)converter.ConvertFrom(lan);
+ TileBrush bsh =
+ new DrawingBrush(new GeometryDrawing(Brushes.White, new Pen(Brushes.Transparent, 2), geometry));
+ bsh.Stretch = Stretch.Fill;
+ return bsh;
+ }
+
+ private FrameworkElementFactory GetFactory(Brush back)
+ {
+ var elementFactory = new FrameworkElementFactory(typeof(Ellipse));
+ elementFactory.SetValue(Shape.FillProperty, back);
+ return elementFactory;
+ }
+
+ private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
+ {
+ if (designerItem != null && canvas != null)
+ {
+ var currentPoint = Mouse.GetPosition(canvas);
+ var deltaVector = Point.Subtract(currentPoint, centerPoint);
+
+ var angle = Vector.AngleBetween(startVector, deltaVector);
+
+ var rotateTransform = designerItem.RenderTransform as RotateTransform;
+ rotateTransform.Angle = initialAngle + Math.Round(angle, 0);
+ designerItem.InvalidateMeasure();
+ }
+ }
+
+ private void Thumb_DragStarted(object sender, DragStartedEventArgs e)
+ {
+ var thumb = sender as Thumb;
+ designerItem = thumb.DataContext as Border;
+ canvas = VisualTreeHelper.GetParent(designerItem) as Canvas;
+ if (canvas != null)
+ {
+ centerPoint = designerItem.TranslatePoint(
+ new Point(designerItem.Width * designerItem.RenderTransformOrigin.X,
+ designerItem.Height * designerItem.RenderTransformOrigin.Y),
+ canvas);
+
+ var startPoint = Mouse.GetPosition(canvas);
+ startVector = Point.Subtract(startPoint, centerPoint);
+
+ rotateTransform = designerItem.RenderTransform as RotateTransform;
+ if (rotateTransform == null)
+ {
+ designerItem.RenderTransform = new RotateTransform(0);
+ initialAngle = 0;
+ }
+ else
+ {
+ initialAngle = rotateTransform.Angle;
+ }
+ }
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/TransformThumb.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/TransformThumb.cs
new file mode 100644
index 00000000..cd78616a
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/TransformThumb.cs
@@ -0,0 +1,242 @@
+using System;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Media;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ public class TransformThumb : ContentControl
+ {
+ public Guid Id { get; private set; }
+ public TransformThumb()
+ {
+ Id = Guid.NewGuid();
+ }
+ public Type ContentType
+ {
+ get { return (Type)GetValue(ContentTypeProperty); }
+ set { SetValue(ContentTypeProperty, value); }
+ }
+
+ public static readonly DependencyProperty ContentTypeProperty =
+ DependencyProperty.Register("ContentType", typeof(Type), typeof(TransformThumb));
+
+ // 选中事件
+
+ // 点击事件
+
+ public event EventHandler Click
+ {
+ add { AddHandler(ClickEvent, value); }
+ remove { RemoveHandler(ClickEvent, value); }
+ }
+
+ public static readonly RoutedEvent ClickEvent = EventManager.RegisterRoutedEvent(
+ "Click", RoutingStrategy.Bubble, typeof(EventHandler), typeof(TransformThumb));
+
+
+ public PrintState PrintState
+ {
+ get { return (PrintState)GetValue(PrintStateProperty); }
+ set { SetValue(PrintStateProperty, value); }
+ }
+
+ public static readonly DependencyProperty PrintStateProperty =
+ DependencyProperty.Register("PrintState", typeof(PrintState), typeof(TransformThumb), new PropertyMetadata(PrintState.Printing));
+
+ public bool IsSeleted
+ {
+ get { return (bool)GetValue(IsSeletedProperty); }
+ set { SetValue(IsSeletedProperty, value); }
+ }
+
+ public static readonly DependencyProperty IsSeletedProperty =
+ DependencyProperty.Register("IsSeleted", typeof(bool), typeof(TransformThumb), new FrameworkPropertyMetadata(false, (s, e) => {
+
+ // 显示遮罩
+ TransformThumb transform = s as TransformThumb;
+ if (transform != null)
+ {
+ // 判定为选中还是非选中
+ bool selected = (bool)e.NewValue;
+ string status = selected ? "选中" : "非选中";
+ // 控制选中效果
+ Debug.WriteLine($"节点:{transform.Id} 节点状态:{status}");
+ //transform.SetValue(ThumbTypeProperty, ThumbType.Style3);
+ UIElement element = transform as UIElement;
+ if (element == null)
+ {
+ return;
+ }
+ var adornerLayer = AdornerLayer.GetAdornerLayer(element);
+ if (adornerLayer != null)
+ {
+ var adorners = adornerLayer.GetAdorners(element);
+ Type oldtype = null;
+ switch (transform.ThumbType)
+ {
+ case ThumbType.Style1:
+ oldtype = typeof(ElementAdorner);
+ break;
+ case ThumbType.Style2:
+ oldtype = typeof(ThumbAdorner);
+ break;
+ case ThumbType.Style3:
+ oldtype = typeof(ThumbAdorner2);
+ break;
+ default:
+ oldtype = typeof(ThumbAdorner2);
+ break;
+ }
+ foreach (var adorner in adorners)
+ {
+ if (adorner.GetType() == oldtype)
+ {
+ adorner.Visibility = selected? Visibility.Visible:Visibility.Hidden;
+ }
+ }
+ }
+ }
+ }));
+
+
+ public ShapeType ShapeType
+ {
+ get { return (ShapeType)GetValue(ShapeTypeProperty); }
+ set { SetValue(ShapeTypeProperty, value); }
+ }
+
+ public static readonly DependencyProperty ShapeTypeProperty =
+ DependencyProperty.Register("ShapeType", typeof(ShapeType), typeof(TransformThumb));
+
+ public ThumbType ThumbType
+ {
+ get { return (ThumbType)GetValue(ThumbTypeProperty); }
+ set { SetValue(ThumbTypeProperty, value); }
+ }
+
+ public static readonly DependencyProperty ThumbTypeProperty =
+ DependencyProperty.Register("ThumbType", typeof(ThumbType), typeof(TransformThumb),new FrameworkPropertyMetadata(ThumbType.Style1, onPropertyChanged));
+
+ private static void onPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ UpdateAdorner(d, e);
+ }
+
+ static TransformThumb()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(TransformThumb), new FrameworkPropertyMetadata(typeof(TransformThumb)));
+ }
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ IsVisibleChanged += TransformThumb_IsVisibleChanged;
+ CreateAdorner();
+ }
+ void CreateAdorner()
+ {
+ var adornerLayer = AdornerLayer.GetAdornerLayer(this);
+ if (adornerLayer != null)
+ {
+ Adorner adorner;
+ switch (ThumbType)
+ {
+ case ThumbType.Style1:
+ adorner = new ElementAdorner(this);
+ break;
+ case ThumbType.Style2:
+ adorner = new ThumbAdorner(this);
+ break;
+ case ThumbType.Style3:
+ adorner = new ThumbAdorner2(this);
+ break;
+ default:
+ adorner = new ThumbAdorner2(this);
+ break;
+ }
+ if (adorner != null)
+ {
+ adorner.Visibility = Visibility.Hidden;
+ adornerLayer.Add(adorner);
+ }
+ }
+ }
+
+ static void UpdateAdorner(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ UIElement element = d as UIElement;
+ if (element == null)
+ {
+ return;
+ }
+ var adornerLayer = AdornerLayer.GetAdornerLayer(element as Visual);
+ if (adornerLayer != null)
+ {
+ ThumbType oldvalue = (ThumbType)e.OldValue;
+ var adorners = adornerLayer.GetAdorners(element as UIElement);
+ Type oldtype = null;
+ switch (oldvalue)
+ {
+ case ThumbType.Style1:
+ oldtype = typeof(ElementAdorner);
+ break;
+ case ThumbType.Style2:
+ oldtype = typeof(ThumbAdorner);
+ break;
+ case ThumbType.Style3:
+ oldtype = typeof(ThumbAdorner2);
+ break;
+ default:
+ oldtype = typeof(ThumbAdorner2);
+ break;
+ }
+ foreach (var adorner in adorners) {
+ if (adorner.GetType() == oldtype)
+ {
+ adornerLayer.Remove(adorner);
+ }
+ }
+
+ ThumbType newvalue = (ThumbType)e.NewValue;
+ Adorner Newadorner;
+ switch (newvalue)
+ {
+ case ThumbType.Style1:
+ Newadorner = new ElementAdorner(element);
+ break;
+ case ThumbType.Style2:
+ Newadorner = new ThumbAdorner(element);
+ break;
+ case ThumbType.Style3:
+ Newadorner = new ThumbAdorner2(element);
+ break;
+ default:
+ Newadorner = new ThumbAdorner2(element);
+ break;
+ }
+ if (Newadorner != null)
+ {
+ adornerLayer.Add(Newadorner);
+ }
+ }
+ }
+ private void TransformThumb_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ if (e.NewValue is bool isVisible)
+ {
+ if (isVisible)
+ {
+ CreateAdorner();
+ }
+
+ }
+ }
+
+ public override string ToString()
+ {
+ return $"{Id}";
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/TransformThumb.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/TransformThumb.xaml
new file mode 100644
index 00000000..2339ff95
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Controls/TransformThumb.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/PrintState.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/PrintState.cs
new file mode 100644
index 00000000..331fdcec
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/PrintState.cs
@@ -0,0 +1,15 @@
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ ///
+ /// 绘制状态
+ ///
+ public enum PrintState
+ {
+ // 绘制
+ Printing,
+ // 编辑
+ Edit,
+ // 静默
+ Normal
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/ShapeType.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/ShapeType.cs
new file mode 100644
index 00000000..30d01209
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/ShapeType.cs
@@ -0,0 +1,21 @@
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ ///
+ /// 几何类
+ ///
+ public enum ShapeType
+ {
+ // 点
+ Point,
+ // 线条
+ Line,
+ // 三角
+ Triangle,
+ // 矩形
+ Rectangle,
+ // 椭圆
+ Elliptical,
+ // 多边形
+ Polygon
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/ThumbType.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/ThumbType.cs
new file mode 100644
index 00000000..9b916976
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/Datas/ThumbType.cs
@@ -0,0 +1,15 @@
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ ///
+ /// 遮罩类型
+ ///
+ public enum ThumbType
+ {
+ // 样式一
+
+ // 样式二
+
+ // 样式三
+ Style1, Style2, Style3
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/DrapViewExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/DrapViewExample.xaml
new file mode 100644
index 00000000..c19976d2
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/DrapViewExample.xaml
@@ -0,0 +1,159 @@
+
+
+
+
+
+ #FFF0F0F0
+ #FFF5F5F5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/DrapViewExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/DrapViewExample.xaml.cs
new file mode 100644
index 00000000..d64a268d
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/DrapViewExample.xaml.cs
@@ -0,0 +1,229 @@
+using System.Windows.Controls;
+using System.Windows;
+using System.Windows.Shapes;
+using System.Diagnostics;
+using System.Windows.Input;
+using System.Windows.Media;
+using System;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ ///
+ /// DrapViewExample.xaml 的交互逻辑
+ ///
+ public partial class DrapViewExample : UserControl
+ {
+ Point start;
+ TransformThumb element;
+ Rectangle shape;
+ ThumbType selectThumb;
+ Brush currentBrush = new SolidColorBrush(Colors.Red);
+ public DrapViewExample()
+ {
+ InitializeComponent();
+ }
+ private void MainCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ //鼠标左键按下
+ Debug.WriteLine("鼠标左键按下");
+ // 更新选中项
+ UpdateDraw();
+ // 判定是否包含快捷键
+
+ // 判定左键按下
+ if (element != null && element.PrintState == PrintState.Edit)
+ {
+ // 设置选项选中
+ element.IsSeleted = true;
+ element = null;
+ e.Handled = true;
+ return;
+ }
+
+ start = e.GetPosition(MainCanvas);
+ // 创建几何实例
+ shape = new Rectangle();
+ shape.Stroke = currentBrush;
+ shape.Fill = currentBrush;
+ shape.StrokeThickness = 1;
+ shape.Width = 0;
+ shape.Height = 0;
+ shape.MouseLeftButtonDown += (s, e1) => {
+ e.Handled = false;
+ };
+ element = new TransformThumb();
+ element.MouseLeftButtonDown += (s, e2) => {
+ TransformThumb transform = s as TransformThumb;
+ if (transform != null)
+ {
+ Debug.WriteLine($"节点:{transform.Id} 节点按下");
+ transform.PrintState = PrintState.Edit;
+ element = transform;
+ e.Handled = false;
+ }
+ };
+ element.MouseLeftButtonUp += (s, e3) => {
+ e.Handled = false;
+ };
+
+ element.Content = shape;
+ element.Width = shape.Width;
+ element.Height = shape.Height;
+ element.ThumbType = selectThumb;
+ element.ContentType = shape.GetType();
+ element.PrintState = PrintState.Printing;
+
+ }
+
+ private void MainCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ // 鼠标左键键起
+ Debug.WriteLine("鼠标左键键起");
+
+ // 更新选中项
+ UpdateDraw();
+ // 键下和键起在同一个位置表示页面无选择项
+ Point end = Mouse.GetPosition(MainCanvas);
+ if (end == start)
+ {
+ // 移除节点
+ MainCanvas.Children.Remove(element);
+ // 重置绘制节点
+ element = null;
+ return;
+ }
+ if (element != null && element.PrintState != PrintState.Edit)
+ {
+ element.IsSeleted = true;
+ element.PrintState = PrintState.Edit;
+ }
+ // 重置绘制节点
+ element = null;
+ }
+
+ private void UpdateDraw()
+ {
+ // 设置其他项默认隐藏
+ foreach (var item in MainCanvas.Children)
+ {
+ var child = item as TransformThumb;
+ if (child != null && child.IsSeleted && element != null)
+ {
+ // 重置非选中项
+ if (child != element)
+ {
+ child.IsSeleted = false;
+ child.PrintState = PrintState.Normal;
+ }
+ }
+ }
+ }
+
+ private void MainCanvas_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (element == null)
+ {
+ return;
+ }
+ if (!NodeExist(element))
+ {
+ // 设置几何位置
+ Canvas.SetLeft(element, start.X);
+ Canvas.SetTop(element, start.Y);
+ // 更新其他选中项
+ UpdateDraw();
+ // 添加到面板中
+ MainCanvas.Children.Add(element);
+ lst_layers.Items.Add(element.ToString());
+ }
+ // 鼠标移动(鼠标未按下移动事件不生效)
+ if (e.LeftButton == MouseButtonState.Pressed && element.PrintState == PrintState.Printing)
+ {
+ Debug.WriteLine("鼠标移动绘制几何");
+ Point current = e.GetPosition(MainCanvas);
+ // 判定几何实例
+ // 判定鼠标移动点是否小于起始点
+ if (current.X - start.X < 0)
+ {
+ // 设置起始点为移动点
+ Canvas.SetLeft(element, current.X);
+ }
+ if (current.Y - start.Y < 0)
+ {
+ // 设置起始点为移动点
+ Canvas.SetTop(element, current.Y);
+ }
+ shape.SetValue(WidthProperty, Math.Abs(current.X - start.X));
+ shape.SetValue(HeightProperty, Math.Abs(current.Y - start.Y));
+ element.Width = Math.Abs(current.X - start.X);
+ element.Height = Math.Abs(current.Y - start.Y);
+ }
+ }
+
+ private void RadioButton_Checked(object sender, RoutedEventArgs e)
+ {
+ RadioButton radioButton = (RadioButton)sender;
+ if (radioButton != null)
+ {
+ ThumbType result;
+ if (Enum.TryParse(radioButton.Content.ToString(), out result))
+ {
+ selectThumb = result;
+ }
+ }
+ }
+
+ private void btn_remove_Click(object sender, RoutedEventArgs e)
+ {
+ for (int i = 0; i < MainCanvas.Children.Count; i++)
+ {
+ UIElement item = MainCanvas.Children[i];
+ if (item is TransformThumb)
+ {
+ var tranform = item as TransformThumb;
+ if (tranform != null && tranform.IsSeleted)
+ {
+ MainCanvas.Children.Remove(tranform);
+ lst_layers.Items.Remove(tranform.ToString());
+ }
+ }
+ }
+ }
+
+ private bool NodeExist(TransformThumb node)
+ {
+ bool result = false;
+ int count = MainCanvas.Children.Count;
+ for (int i = 0; i < count; i++)
+ {
+ UIElement item = MainCanvas.Children[i];
+ if (item is TransformThumb)
+ {
+ var tranform = item as TransformThumb;
+ if (tranform == node)
+ {
+ result = true;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private void btn_removeAll_Click(object sender, RoutedEventArgs e)
+ {
+ MainCanvas.Children.Clear();
+ lst_layers.Items.Clear();
+ }
+
+ private void StackPanel_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ if (e.Source is RadioButton)
+ {
+ var radioButton = (RadioButton)e.Source;
+ currentBrush = radioButton.Background;
+ }
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/DrawerMenuExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/DrawerMenuExample.xaml
index d915026e..1f6c98ae 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/DrawerMenuExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/DrawerMenuExample.xaml
@@ -6,7 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews.DrawerMenu"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
@@ -20,43 +20,43 @@
Name="myFrame"
Grid.Column="1"
NavigationUIVisibility="Hidden" />
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/EdgeLightExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/EdgeLightExample.xaml
index a3464394..4652f2a8 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/EdgeLightExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/EdgeLightExample.xaml
@@ -4,19 +4,19 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
+
-
-
+
-
+
-
+
-
+
-
+
-
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/Loading/RollLoadingExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/Loading/RollLoadingExample.xaml
index fbdc7386..ac2df61c 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/Loading/RollLoadingExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/Loading/RollLoadingExample.xaml
@@ -3,17 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
-
+
-
-
+
+
-
-
+
+
-
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/LoadingExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/LoadingExample.xaml.cs
index 5461ae43..c2b3a416 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/LoadingExample.xaml.cs
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/LoadingExample.xaml.cs
@@ -1,4 +1,9 @@
-using System.Windows.Controls;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using WPFDevelopers.Controls;
namespace WPFDevelopers.Samples.ExampleViews
{
@@ -11,5 +16,28 @@ public LoadingExample()
{
InitializeComponent();
}
+
+ private void Btn_LoadingExtClick(object sender, System.Windows.RoutedEventArgs e)
+ {
+ var loading = new LoadingExt();
+ loading.Show();
+ var task = new Task(() =>
+ {
+ for (int i = 0; i < 5; i++)
+ {
+ //模拟卡UI线程
+ Application.Current.Dispatcher.Invoke(new System.Action(() =>
+ {
+ Thread.Sleep(1000);
+ }));
+ }
+
+ });
+ task.ContinueWith(previousTask =>
+ {
+ loading.Close();
+ }, TaskScheduler.FromCurrentSynchronizationContext());
+ task.Start();
+ }
}
}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/MagnifierExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/MagnifierExample.xaml
index f9222e9a..d671426d 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/MagnifierExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/MagnifierExample.xaml
@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
@@ -18,7 +18,7 @@
Margin="0,10"/>
+ wd:Magnifier.Add="{x:Static wd:Magnifier.Default}"/>
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+ Background="{DynamicResource WD.BackgroundSolidColorBrush}">
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/PaginationExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/PaginationExample.xaml
index 830c077e..ee2f2731 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/PaginationExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/PaginationExample.xaml
@@ -6,7 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
@@ -42,27 +42,25 @@
-
-
@@ -18,19 +18,19 @@
-
-
-
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml
index 32e60cc4..cc8498ac 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml
@@ -3,14 +3,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
-
+
+
-
+
-
+
-
+
@@ -46,7 +46,7 @@
-
+
-
-
+
-
+
-
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/TaskbarItemInfoExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/TaskbarItemInfoExample.xaml
index 833bfb25..b466ff25 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/TaskbarItemInfoExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/TaskbarItemInfoExample.xaml
@@ -1,11 +1,11 @@
-
-
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ThermometerExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ThermometerExample.xaml
index 443ebb76..f7e56d9b 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ThermometerExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ThermometerExample.xaml
@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
mc:Ignorable="d"
@@ -31,7 +31,7 @@
Stroke="{DynamicResource WD.PrimaryMouseOverSolidColorBrush}"
StrokeThickness="1" Opacity=".6"
Data="{Binding ElementName=PART_Thermometer, Path=CurrentGeometry,Mode=TwoWay}"/>
-
@@ -20,10 +20,10 @@
Click="Button_Click"
Content="获取"/>
-
-
-
-
+
+
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs b/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs
index a05067e1..e9b21987 100644
--- a/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs
+++ b/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs
@@ -38,8 +38,8 @@ public enum MenuEnum
TransitionPanel,
SpotLight,
DrawerMenu,
- RadarChart,
- BasicBarChart,
+ ChartRadar,
+ ChartBar,
ZooSemy,
RulerControl,
RainbowBtn,
@@ -80,6 +80,8 @@ public enum MenuEnum
IPEditBox,
TimePicker,
WaterfallPanel,
+ ChartLine,
+ Drap,
VirtualizingWrapPanel,
AcrylicBlur,
TaskbarInfo
diff --git a/src/WPFDevelopers.Samples.Shared/Models/NavigateMenuModel.cs b/src/WPFDevelopers.Samples.Shared/Models/NavigateMenuModel.cs
index 6ded4048..eaa3dae6 100644
--- a/src/WPFDevelopers.Samples.Shared/Models/NavigateMenuModel.cs
+++ b/src/WPFDevelopers.Samples.Shared/Models/NavigateMenuModel.cs
@@ -1,7 +1,17 @@
namespace WPFDevelopers.Samples.Models
{
- public class NavigateMenuModel
+ public class NavigateMenuModel:ViewModelBase
{
+ private bool _isVisible = true;
public string Name { get; set; }
+ public bool IsVisible
+ {
+ get { return _isVisible; }
+ set
+ {
+ _isVisible = value;
+ NotifyPropertyChange("IsVisible");
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs b/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs
index 00ff9811..d873cb5b 100644
--- a/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs
+++ b/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs
@@ -1,5 +1,8 @@
-using System;
+using Microsoft.Expression.Drawing.Core;
+using System;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -18,11 +21,11 @@
namespace WPFDevelopers.Samples.ViewModels
{
- public class MainVM:ViewModelBase
+ public class MainVM : ViewModelBase
{
- private ObservableCollection _navigateMenuModelList;
+ private IList _navigateMenuModelList;
- public ObservableCollection NavigateMenuModelList
+ public IList NavigateMenuModelList
{
get { return _navigateMenuModelList; }
set { _navigateMenuModelList = value; }
@@ -38,7 +41,7 @@ public NavigateMenuModel NavigateMenuItem
set
{
_navigateMenuItem = value;
- this.NotifyPropertyChange("NavigateMenuItem");
+ NotifyPropertyChange("NavigateMenuItem");
}
}
private object _controlPanel;
@@ -51,32 +54,54 @@ public object ControlPanel
set
{
_controlPanel = value;
- this.NotifyPropertyChange("ControlPanel");
+ NotifyPropertyChange("ControlPanel");
}
}
public MainVM()
{
- NavigateMenuModelList = new ObservableCollection();
+ NavigateMenuModelList = new ObservableCollection();
foreach (MenuEnum menuEnum in Enum.GetValues(typeof(MenuEnum)))
{
- NavigateMenuModelList.Add(new ListBoxItem { Content = menuEnum.ToString() });
+ NavigateMenuModelList.Add(new NavigateMenuModel { Name = menuEnum.ToString() });
}
- NavigateMenuModelList.Add(new ListBoxItem { Content = "持续更新中" });
+ NavigateMenuModelList.Add(new NavigateMenuModel { Name = "持续更新中" });
ControlPanel = new AnimationNavigationBar3DExample();
}
+
public ICommand ViewLoaded => new RelayCommand(obj =>
{
-
+
});
+
+ public ICommand MenuSearchTextChanged => new RelayCommand(obj =>
+ {
+ var search = obj.ToString();
+ if (string.IsNullOrEmpty(search))
+ {
+ NavigateMenuModelList.ForEach(y => y.IsVisible = true);
+ }
+ else
+ {
+ var key = search.ToLower();
+ foreach (var item in NavigateMenuModelList)
+ {
+ if (item.Name.ToLower().Contains(key))
+ item.IsVisible = true;
+ else
+ item.IsVisible = false;
+ }
+ }
+ });
+
public ICommand MenuSelectionChangedCommand => new RelayCommand(obj =>
{
if (obj == null) return;
- var model = obj as ListBoxItem;
- MenuItemSelection(model.Content.ToString());
+ var model = obj as NavigateMenuModel;
+ MenuItemSelection(model.Name);
});
- public ICommand CloseCommand => new RelayCommand( obj =>
+ public ICommand CloseCommand => new RelayCommand(obj =>
{
Application.Current.MainWindow.Close();
});
@@ -87,7 +112,7 @@ void MenuItemSelection(string _menuName)
MenuEnum flag;
if (!Enum.TryParse(_menuName, true, out flag))
return;
- var menuEnum = (MenuEnum)Enum.Parse(typeof(MenuEnum), _menuName,true);
+ var menuEnum = (MenuEnum)Enum.Parse(typeof(MenuEnum), _menuName, true);
switch (menuEnum)
{
case MenuEnum.Navigation3D:
@@ -138,7 +163,7 @@ void MenuItemSelection(string _menuName)
case MenuEnum.BreatheLight:
ControlPanel = new BreatheLightExample();
break;
-
+
case MenuEnum.ChatEmoji:
ControlPanel = new ChatEmojiExample();
break;
@@ -184,8 +209,8 @@ void MenuItemSelection(string _menuName)
case MenuEnum.DrawerMenu:
ControlPanel = new DrawerMenuExample();
break;
- case MenuEnum.RadarChart:
- ControlPanel = new RadarChartExample();
+ case MenuEnum.ChartRadar:
+ ControlPanel = new ChartRadarExample();
break;
case MenuEnum.LoginWindow:
ControlPanel = new LoginExample();
@@ -195,8 +220,8 @@ void MenuItemSelection(string _menuName)
case MenuEnum.Pagination:
ControlPanel = new PaginationExample();
break;
- case MenuEnum.BasicBarChart:
- ControlPanel = new BasicBarChartExample();
+ case MenuEnum.ChartBar:
+ ControlPanel = new ChartBarExample();
break;
case MenuEnum.ZooSemy:
ControlPanel = new ZooSemyExample();
@@ -318,6 +343,12 @@ void MenuItemSelection(string _menuName)
case MenuEnum.WaterfallPanel:
ControlPanel = new WaterfallPanelExample();
break;
+ case MenuEnum.ChartLine:
+ ControlPanel = new ChartLineExample();
+ break;
+ case MenuEnum.Drap:
+ ControlPanel = new DrapViewExample();
+ break;
case MenuEnum.VirtualizingWrapPanel:
ControlPanel = new VirtualizingWrapPanel();
new VirtualizingWrapPanelExample().MaskShowDialog();
@@ -339,5 +370,5 @@ void MenuItemSelection(string _menuName)
- }
+ }
}
diff --git a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems
index 86ad8dcf..798e7ea1 100644
--- a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems
+++ b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems
@@ -25,6 +25,7 @@
+
@@ -69,9 +70,9 @@
Code
BarrageExample.xaml
-
+
Code
- BasicBarChartExample.xaml
+ ChartBarExample.xaml
Code
@@ -103,6 +104,9 @@
Code
CarouselExampleEx.xaml
+
+ ChartLineExample.xaml
+
Code
ChatEmojiExample.xaml
@@ -154,6 +158,17 @@
Code
DesktopPlayVideo.xaml
+
+
+
+
+
+
+
+
+
+ DrapViewExample.xaml
+
Code
DrawerMenuExample.xaml
@@ -318,9 +333,9 @@
Code
PieControlExample.xaml
-
+
Code
- RadarChartExample.xaml
+ ChartRadarExample.xaml
Code
@@ -473,6 +488,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -529,7 +548,7 @@
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
@@ -561,6 +580,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -613,6 +636,14 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -798,7 +829,7 @@
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
diff --git a/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj b/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj
index 6b43b722..c891665f 100644
--- a/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj
+++ b/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj
@@ -11,9 +11,7 @@
-
-
-
+
diff --git a/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj b/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj
index 8077602b..161ae3e3 100644
--- a/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj
+++ b/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj
@@ -2,9 +2,7 @@
-
-
-
+
diff --git a/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj b/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj
index 85717037..94a94a89 100644
--- a/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj
+++ b/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj
@@ -13,7 +13,7 @@
-
+
@@ -68,7 +68,7 @@
-
+
@@ -143,6 +143,7 @@
+
@@ -160,8 +161,8 @@
ExampleViews\BarrageExample.xaml
-
- ExampleViews\BasicBarChartExample.xaml
+
+ ExampleViews\ChartBarExample.xaml
ExampleViews\BasicControlsExample.xaml
@@ -316,8 +317,8 @@
ExampleViews\PieControlExample.xaml
-
- ExampleViews\RadarChartExample.xaml
+
+ ExampleViews\ChartRadarExample.xaml
ExampleViews\RainbowButtonsExample.xaml
@@ -484,5 +485,8 @@
ExampleViews\WaterfallPanelExample.xaml
+
+ ExampleViews\ChartLineExample.xaml
+
diff --git a/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3D.cs b/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3D.cs
index 48ce751c..9a60824f 100644
--- a/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3D.cs
+++ b/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3D.cs
@@ -3,29 +3,20 @@
namespace WPFDevelopers.Controls
{
- public class AnimationNavigationBar3D : ItemsControl
+ public class AnimationNavigationBar3D : ListBox
{
- public static readonly DependencyProperty ColumnsProperty =
- DependencyProperty.Register("Columns", typeof(int), typeof(AnimationNavigationBar3D),
- new PropertyMetadata(null));
-
static AnimationNavigationBar3D()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AnimationNavigationBar3D),
new FrameworkPropertyMetadata(typeof(AnimationNavigationBar3D)));
}
-
-
- public int Columns
+ protected override bool IsItemItsOwnContainerOverride(object item)
{
- get => (int)GetValue(ColumnsProperty);
- set => SetValue(ColumnsProperty, value);
+ return item is AnimationNavigationBar3DItem;
}
-
- public override void OnApplyTemplate()
+ protected override DependencyObject GetContainerForItemOverride()
{
- base.OnApplyTemplate();
- Columns = Items.Count;
+ return new AnimationNavigationBar3DItem();
}
}
}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3DItem.cs b/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3DItem.cs
index d717cbad..dd1444d0 100644
--- a/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3DItem.cs
+++ b/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3DItem.cs
@@ -1,69 +1,49 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+using WPFDevelopers.Helpers;
namespace WPFDevelopers.Controls
{
- public class AnimationNavigationBar3DItem : Control
+ public class AnimationNavigationBar3DItem : ListBoxItem
{
- public static readonly DependencyProperty FileBackgroundProperty =
- DependencyProperty.Register("FileBackground", typeof(Brush), typeof(AnimationNavigationBar3DItem),
+ public static readonly DependencyProperty FillProperty =
+ DependencyProperty.Register("Fill", typeof(Brush), typeof(AnimationNavigationBar3DItem),
new PropertyMetadata(null));
- public static readonly DependencyProperty BackFileBackgroundProperty =
- DependencyProperty.Register("BackFileBackground", typeof(Brush), typeof(AnimationNavigationBar3DItem),
+ public static readonly DependencyProperty ContentBackProperty =
+ DependencyProperty.Register("ContentBack", typeof(object), typeof(AnimationNavigationBar3DItem),
new PropertyMetadata(null));
- public static readonly DependencyProperty PathDateProperty =
- DependencyProperty.Register("PathDate", typeof(Geometry), typeof(AnimationNavigationBar3DItem),
- new PropertyMetadata());
-
- public static readonly DependencyProperty TextProperty =
- DependencyProperty.Register("Text", typeof(string), typeof(AnimationNavigationBar3DItem),
- new PropertyMetadata());
-
static AnimationNavigationBar3DItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AnimationNavigationBar3DItem),
new FrameworkPropertyMetadata(typeof(AnimationNavigationBar3DItem)));
}
- ///
- /// 默认颜色
- ///
- public Brush FileBackground
+ public override void OnApplyTemplate()
{
- get => (Brush)GetValue(FileBackgroundProperty);
- set => SetValue(FileBackgroundProperty, value);
+ base.OnApplyTemplate();
+ if (ContentBack == null)
+ ContentBack = ControlsHelper.GetXmlReader(Content);
}
///
- /// 背面颜色
+ /// Color fore
///
- public Brush BackFileBackground
+ public Brush Fill
{
- get => (Brush)GetValue(BackFileBackgroundProperty);
- set => SetValue(BackFileBackgroundProperty, value);
+ get => (Brush)GetValue(FillProperty);
+ set => SetValue(FillProperty, value);
}
-
- ///
- /// 设置PathData
- ///
- public Geometry PathDate
- {
- get => (Geometry)GetValue(PathDateProperty);
- set => SetValue(PathDateProperty, value);
- }
-
-
///
- /// 文本显示内容
+ /// The content after the mouse is moved in
///
- public string Text
+ public object ContentBack
{
- get => (string)GetValue(TextProperty);
- set => SetValue(TextProperty, value);
+ get => (object)GetValue(ContentBackProperty);
+ set => SetValue(ContentBackProperty, value);
}
}
}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Controls/BaseControls/SliderRepeatButton.cs b/src/WPFDevelopers.Shared/Controls/BaseControls/SliderRepeatButton.cs
new file mode 100644
index 00000000..fd744614
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/BaseControls/SliderRepeatButton.cs
@@ -0,0 +1,32 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+
+namespace WPFDevelopers.Controls
+{
+ public class SliderRepeatButton: RepeatButton
+ {
+ public RadiusOrientation RadiusOrientation
+ {
+ get { return (RadiusOrientation)GetValue(RadiusOrientationProperty); }
+ set { SetValue(RadiusOrientationProperty, value); }
+ }
+
+ public static readonly DependencyProperty RadiusOrientationProperty =
+ DependencyProperty.Register("RadiusOrientation", typeof(RadiusOrientation), typeof(SliderRepeatButton), new PropertyMetadata(null));
+
+ }
+
+ [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)]
+ public enum RadiusOrientation
+ {
+ Down = ExpandDirection.Down,
+ Up = ExpandDirection.Up,
+ Left = ExpandDirection.Left,
+ Right = ExpandDirection.Right,
+ TopLeft,
+ TopRight,
+ BottomRight,
+ BottomLeft
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Controls/BaseControls/WDBorder.cs b/src/WPFDevelopers.Shared/Controls/BaseControls/WDBorder.cs
new file mode 100644
index 00000000..f1aeb116
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/BaseControls/WDBorder.cs
@@ -0,0 +1,56 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using WPFDevelopers.Helpers;
+
+namespace WPFDevelopers.Controls
+{
+ public class WDBorder : Border
+ {
+ public Geometry ContentClip
+ {
+ get
+ {
+ return (Geometry)GetValue(ContentClipProperty);
+ }
+ set
+ {
+ SetValue(ContentClipProperty, value);
+ }
+ }
+
+ private Geometry CalculateContentClip()
+ {
+ var borderThickness = BorderThickness;
+ var cornerRadius = CornerRadius;
+ var renderSize = RenderSize;
+ var width = renderSize.Width - borderThickness.Left - borderThickness.Right;
+ var height = renderSize.Height - borderThickness.Top - borderThickness.Bottom;
+ if (width > 0.0 && height > 0.0)
+ {
+ var rect = new Rect(0.0, 0.0, width, height);
+ var radii = new GeometryHelper.Radii(cornerRadius, borderThickness, false);
+ var streamGeometry = new StreamGeometry();
+ using (StreamGeometryContext streamGeometryContext = streamGeometry.Open())
+ {
+ GeometryHelper.GenerateGeometry(streamGeometryContext, rect, radii);
+ streamGeometry.Freeze();
+ return streamGeometry;
+ }
+ }
+ return null;
+ }
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ SetValue(ContentClipPropertyKey, CalculateContentClip());
+ base.OnRender(dc);
+ }
+
+ public static readonly DependencyPropertyKey ContentClipPropertyKey =
+ DependencyProperty.RegisterReadOnly("ContentClip", typeof(Geometry), typeof(WDBorder), new PropertyMetadata(null));
+
+ public static readonly DependencyProperty ContentClipProperty = ContentClipPropertyKey.DependencyProperty;
+
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Controls/BasicBarChart/BasicBarChart.cs b/src/WPFDevelopers.Shared/Controls/BasicBarChart/BasicBarChart.cs
deleted file mode 100644
index cac5be86..00000000
--- a/src/WPFDevelopers.Shared/Controls/BasicBarChart/BasicBarChart.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media;
-using WPFDevelopers.Helpers;
-
-namespace WPFDevelopers.Controls
-{
- public class BasicBarChart : Control
- {
- public static readonly DependencyProperty SeriesArrayProperty =
- DependencyProperty.Register("SeriesArray", typeof(IEnumerable>),
- typeof(BasicBarChart), new UIPropertyMetadata(SeriesArrayChanged));
-
-
- static BasicBarChart()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(BasicBarChart),
- new FrameworkPropertyMetadata(typeof(BasicBarChart)));
- }
-
- public IEnumerable> SeriesArray
- {
- get => (IEnumerable>)GetValue(SeriesArrayProperty);
- set => SetValue(SeriesArrayProperty, value);
- }
-
- private static void SeriesArrayChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var radarChart = d as BasicBarChart;
- if (e.NewValue != null)
- radarChart.InvalidateVisual();
- }
-
- protected override void OnRender(DrawingContext drawingContext)
- {
- base.OnRender(drawingContext);
- if (SeriesArray == null || SeriesArray.Count() == 0)
- return;
- SnapsToDevicePixels = true;
- UseLayoutRounding = true;
- var brushConverter = new BrushConverter();
- var myPen = new Pen
- {
- Thickness = 1,
- Brush = (Brush)brushConverter.ConvertFromString("#6E7079")
- };
- myPen.Freeze();
-
- var h = ActualHeight / 2 + 160;
- var w = ActualWidth / 2;
- var startX = 0;
- var width = SeriesArray.Count() * 120 + startX;
- var stratNum = 0;
-
- drawingContext.DrawSnappedLinesBetweenPoints(myPen, myPen.Thickness, new Point(startX, h),
- new Point(width, h));
- var formattedText = DrawingContextHelper.GetFormattedText(stratNum.ToString(),
- (Brush)brushConverter.ConvertFromString("#6E7079"), FlowDirection.LeftToRight);
- drawingContext.DrawText(formattedText,
- new Point(startX - formattedText.Width * 2 - 10, h - formattedText.Height / 2));
- var x = startX;
- var y = h + myPen.Thickness;
- var points = new List();
- var rectBrush = ControlsHelper.PrimaryNormalBrush;
- for (var i = 0; i < SeriesArray.Count() + 1; i++)
- {
- points.Add(new Point(x, y));
- points.Add(new Point(x, y + 4));
- x = x + 120;
- }
-
- drawingContext.DrawSnappedLinesBetweenPoints(myPen, myPen.Thickness, points.ToArray());
-
- var xAxisPen = new Pen
- {
- Thickness = 1,
- Brush = (Brush)brushConverter.ConvertFromString("#E0E6F1")
- };
- xAxisPen.Freeze();
- var xAxis = h - 80;
- var max = Convert.ToInt32(SeriesArray.Max(kvp => kvp.Value));
- max = (max / 50 + (max % 50 == 0 ? 0 : 1)) * 50 / 50;
- var min = Convert.ToInt32(SeriesArray.Min(kvp => kvp.Value));
- points.Clear();
- for (var i = 0; i < max; i++)
- {
- points.Add(new Point(startX, xAxis));
- points.Add(new Point(width, xAxis));
- stratNum += 50;
- formattedText = DrawingContextHelper.GetFormattedText(stratNum.ToString(),
- (Brush)brushConverter.ConvertFromString("#6E7079"), FlowDirection.LeftToRight);
- drawingContext.DrawText(formattedText,
- new Point(startX - formattedText.Width - 10, xAxis - formattedText.Height / 2));
- xAxis = xAxis - 80;
- }
-
- drawingContext.DrawSnappedLinesBetweenPoints(xAxisPen, xAxisPen.Thickness, points.ToArray());
-
- x = startX;
- var rectWidth = 85;
- var rectHeight = 0D;
- for (var i = 0; i < SeriesArray.Count(); i++)
- {
- formattedText = DrawingContextHelper.GetFormattedText(SeriesArray.ToList()[i].Key,
- (Brush)brushConverter.ConvertFromString("#6E7079"), FlowDirection.LeftToRight);
- drawingContext.DrawText(formattedText, new Point(x + 120 / 2 - formattedText.Width / 2, y + 4));
- var _value = SeriesArray.ToList()[i].Value;
- rectHeight = (_value - 0) / (stratNum - 0) * (80 * max);
- drawingContext.DrawRectangle(rectBrush, null,
- new Rect(x + (120 - 85) / 2, h - rectHeight, rectWidth, rectHeight));
- x = x + 120;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartBar.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartBar.cs
new file mode 100644
index 00000000..dc764aec
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartBar.cs
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+using System.Windows;
+using System.Windows.Media;
+
+namespace WPFDevelopers.Controls
+{
+ public class ChartBar : ChartRect
+ {
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ base.OnRender(drawingContext);
+ var dicts = new Dictionary();
+ var x = StartX;
+ var rectWidth = 85;
+ var interval = Interval;
+ foreach (var item in Datas)
+ {
+ var formattedText = DrawingContextHelper.GetFormattedText(item.Key,
+ ChartFill, FlowDirection.LeftToRight);
+ drawingContext.DrawText(formattedText, new Point(x + interval / 2 - formattedText.Width / 2, StartY + 4));
+ var _value = item.Value;
+ var rectHeight = (_value - 0) / (IntervalY - 0) * (ScaleFactor * Rows);
+ var rect = new Rect(x + (interval - rectWidth) / 2, StartY - rectHeight, rectWidth, rectHeight);
+ drawingContext.DrawRectangle(NormalBrush, null, rect);
+ x += interval;
+ var nRect = new Rect(rect.Left - EllipsePadding, rect.Top - EllipsePadding, rect.Width + EllipsePadding, rect.Height + EllipsePadding);
+ dicts.Add(nRect, $"{item.Key} : {item.Value}");
+ }
+ PointCache = dicts;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartBase.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartBase.cs
new file mode 100644
index 00000000..cc3bfb86
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartBase.cs
@@ -0,0 +1,150 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Effects;
+using WPFDevelopers.Helpers;
+
+namespace WPFDevelopers.Controls
+{
+ public class ChartBase : Control
+ {
+ private Popup _popup;
+ private Border _border;
+ private TextBlock _textBlock;
+ public IDictionary PointCache;
+ private bool isPopupOpen = false;
+ private KeyValuePair _lastItem;
+
+ public static readonly DependencyProperty DatasProperty =
+ DependencyProperty.Register("Datas", typeof(IEnumerable>),
+ typeof(ChartBase), new UIPropertyMetadata(DatasChanged));
+
+ static ChartBase()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(ChartBase),
+ new FrameworkPropertyMetadata(typeof(ChartBase)));
+ }
+
+ protected double EllipseSize { get; } = 7;
+ protected double EllipsePadding{ get; } = 20;
+ protected double Rows { get; } = 5;
+
+ protected double Interval { get; } = 120;
+
+ protected double MaxY { get; }
+ protected double StartY { get; set; }
+ protected double StartX { get; set; } = 40;
+
+ protected Brush NormalBrush => ControlsHelper.PrimaryNormalBrush;
+
+
+ public IEnumerable> Datas
+ {
+ get => (IEnumerable>) GetValue(DatasProperty);
+ set => SetValue(DatasProperty, value);
+ }
+
+ private static void DatasChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var ctrl = d as ChartBase;
+ if (e.NewValue != null)
+ ctrl.InvalidateVisual();
+ }
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if (Datas == null || Datas.Count() == 0 || isPopupOpen)
+ return;
+ if (_popup == null)
+ {
+ _popup = new Popup
+ {
+ AllowsTransparency = true,
+ Placement = PlacementMode.MousePoint,
+ PlacementTarget = this,
+ StaysOpen = false,
+ };
+ _popup.MouseMove += (y, j) =>
+ {
+ var point = j.GetPosition(this);
+ if (isPopupOpen && _lastItem.Value != null)
+ {
+ if (!_lastItem.Key.Contains(point))
+ {
+ _popup.IsOpen = false;
+ isPopupOpen = false;
+ _lastItem = new KeyValuePair();
+ }
+ }
+ };
+ _popup.Closed += delegate
+ {
+ isPopupOpen = false;
+ };
+ _textBlock = new TextBlock()
+ {
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ Foreground = (Brush)Application.Current.TryFindResource("WD.WindowForegroundColorBrush")
+ };
+ _border = new Border
+ {
+ Child = _textBlock,
+ Background = (Brush)Application.Current.TryFindResource("WD.ChartFillSolidColorBrush"),
+ Effect = Application.Current.TryFindResource("WD.PopupShadowDepth") as DropShadowEffect,
+ Margin = new Thickness(10),
+ CornerRadius = new CornerRadius(3),
+ Padding = new Thickness(6)
+ };
+ _popup.Child = _border;
+ }
+ if (PointCache == null) return;
+ var currentPoint = e.GetPosition(this);
+ if (PointCache.Any(x => x.Key.Contains(currentPoint)))
+ {
+ isPopupOpen = true;
+
+ var currentItem = PointCache.FirstOrDefault(x => x.Key.Contains(currentPoint));
+ if (currentItem.Key == null) return;
+ _textBlock.Text = currentItem.Value;
+ _popup.IsOpen = true;
+ _lastItem = currentItem;
+ }
+ }
+
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ base.OnRender(drawingContext);
+ if (Datas == null || Datas.Count() == 0)
+ return;
+ SnapsToDevicePixels = true;
+ UseLayoutRounding = true;
+ }
+
+ public void DrawEllipse(IEnumerable rects, DrawingContext drawingContext)
+ {
+ var drawingPen = new Pen
+ {
+ Thickness = 2,
+ Brush = NormalBrush
+ };
+ drawingPen.Freeze();
+
+ var backgroupBrush = new SolidColorBrush()
+ {
+ Color = (Color)Application.Current.TryFindResource("WD.BackgroundColor")
+ };
+ backgroupBrush.Freeze();
+ foreach (var item in rects)
+ {
+ var ellipseGeom = new EllipseGeometry(item);
+ drawingContext.DrawGeometry(backgroupBrush, drawingPen, ellipseGeom);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartLine.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartLine.cs
new file mode 100644
index 00000000..21302a93
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartLine.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Media;
+
+namespace WPFDevelopers.Controls
+{
+ public class ChartLine : ChartRect
+ {
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ if (Datas == null || Datas.Count() == 0)
+ return;
+ base.OnRender(drawingContext);
+ var dicts = new Dictionary();
+ var rects = new List();
+ var points = new List();
+ var x = StartX;
+ var interval = Interval;
+ var drawingPen = new Pen
+ {
+ Thickness = 2,
+ Brush = NormalBrush
+ };
+ drawingPen.Freeze();
+ var firstDataPoint = Datas.FirstOrDefault();
+ if (firstDataPoint.Equals(default(KeyValuePair)))
+ return;
+ double proportion = firstDataPoint.Value / IntervalY;
+ double yPositionFromBottom = StartY - proportion * (ScaleFactor * Rows);
+ var startPoint = new Point(x + Interval / 2, yPositionFromBottom);
+ points.Add(startPoint);
+ foreach (var item in Datas)
+ {
+ var formattedText = DrawingContextHelper.GetFormattedText(item.Key,
+ ChartFill, FlowDirection.LeftToRight);
+ var point = new Point(x + interval / 2 - formattedText.Width / 2, StartY + 4);
+ drawingContext.DrawText(formattedText, point);
+
+ var y = StartY - (item.Value / IntervalY) * (ScaleFactor * Rows);
+ var endPoint = new Point(x + Interval / 2, y);
+ points.Add(endPoint);
+ drawingContext.DrawLine(drawingPen, startPoint, endPoint);
+ var ellipsePoint = new Point(endPoint.X - EllipseSize / 2, endPoint.Y - EllipseSize / 2);
+ var rect = new Rect(ellipsePoint, new Size(EllipseSize, EllipseSize));
+ rects.Add(rect);
+ startPoint = endPoint;
+ x += interval;
+ var nRect = new Rect(rect.Left - EllipsePadding, rect.Top - EllipsePadding, rect.Width + EllipsePadding, rect.Height + EllipsePadding);
+ dicts.Add(nRect, $"{item.Key} : {item.Value}");
+ }
+ PointCache = dicts;
+ if(points.Count > 1)
+ {
+ var color = (Color)Application.Current.TryFindResource("WD.PrimaryNormalColor");
+ var rectBrush = new SolidColorBrush(color);
+ rectBrush.Opacity = 0.3;
+ rectBrush.Freeze();
+ var streamGeometry = new StreamGeometry();
+ using (StreamGeometryContext geometryContext = streamGeometry.Open())
+ {
+ var sPoint = new Point(points[0].X, StartY);
+ geometryContext.BeginFigure(sPoint, true, true);
+
+ foreach (Point point in points)
+ geometryContext.LineTo(point, true, true);
+ var ePoint = new Point(points[points.Count - 1].X, StartY);
+ geometryContext.LineTo(ePoint, true, true);
+ geometryContext.Close();
+ }
+ drawingContext.DrawGeometry(rectBrush, null, streamGeometry);
+ }
+ DrawEllipse(rects, drawingContext);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Controls/RadarChart/RadarChart.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartRadar.cs
similarity index 50%
rename from src/WPFDevelopers.Shared/Controls/RadarChart/RadarChart.cs
rename to src/WPFDevelopers.Shared/Controls/Charts/ChartRadar.cs
index c197dc4d..1ec8d4fd 100644
--- a/src/WPFDevelopers.Shared/Controls/RadarChart/RadarChart.cs
+++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartRadar.cs
@@ -1,119 +1,118 @@
using System;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
+using System.Linq;
using System.Windows;
-using System.Windows.Controls;
using System.Windows.Media;
using WPFDevelopers.Helpers;
namespace WPFDevelopers.Controls
{
- public class RadarChart : Control
+ public class ChartRadar : ChartBase
{
-
- public static readonly DependencyProperty RadarArrayProperty =
- DependencyProperty.Register("RadarArray", typeof(ObservableCollection), typeof(RadarChart),
- new UIPropertyMetadata(OnRadarArrayChanged));
-
- static RadarChart()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(RadarChart),
- new FrameworkPropertyMetadata(typeof(RadarChart)));
- }
-
- public ObservableCollection RadarArray
- {
- get => (ObservableCollection)GetValue(RadarArrayProperty);
- set => SetValue(RadarArrayProperty, value);
- }
-
- private static void OnRadarArrayChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ private PointCollection _points;
+ private double _h, _w;
+ private Pen _penXAxis;
+ static ChartRadar()
{
- var radarChart = d as RadarChart;
- if (e.NewValue != null)
- radarChart.InvalidateVisual();
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(ChartRadar),
+ new FrameworkPropertyMetadata(typeof(ChartRadar)));
}
-
protected override void OnRender(DrawingContext drawingContext)
{
- //防止延迟加载时,RadarArray为null时报错,防止RadarArray.Count==0时,后续做 被除数(double perangle = 360 / polygonBound) 时溢出错误
- if (RadarArray == null || RadarArray.Count == 0)
- return;
- DrawPoints(150, drawingContext, true);
- DrawPoints(100, drawingContext);
- DrawPoints(50, drawingContext);
+ base.OnRender(drawingContext);
+ _penXAxis = new Pen
+ {
+ Thickness = 1,
+ Brush = Application.Current.TryFindResource("WD.ChartXAxisSolidColorBrush") as Brush
+ };
+ _penXAxis.Freeze();
+
+ var dicts = new Dictionary();
+ var rects = new List();
+ var max = Convert.ToInt32(Datas.Max(kvp => kvp.Value)) + 50;
+ double v = StartX;
+ for (var i = 0; i < Rows; i++)
+ {
+ DrawPoints(v, drawingContext, i == Rows - 1);
+ v += StartX;
+ }
var myPen = new Pen
{
- Thickness = 4,
- Brush = ControlsHelper.PrimaryNormalBrush
+ Thickness = 3,
+ Brush = NormalBrush
};
myPen.Freeze();
+
var streamGeometry = new StreamGeometry();
using (var geometryContext = streamGeometry.Open())
{
- var h = ActualHeight / 2;
- var w = ActualWidth / 2;
var points = new PointCollection();
- foreach (var item in RadarArray)
+ short index = 0;
+ foreach (var item in Datas)
{
- var model = new Point((item.PointValue.X - w) / 100 * item.ValueMax + w,
- (item.PointValue.Y - h) / 100 * item.ValueMax + h);
- points.Add(model);
+ if (index < _points.Count)
+ {
+ var startPoint = _points[index];
+ var point = new Point((startPoint.X - _w) / max * item.Value + _w,
+ (startPoint.Y - _h) / max * item.Value + _h);
+ points.Add(point);
+ var ellipsePoint = new Point(point.X - EllipseSize / 2, point.Y - EllipseSize / 2);
+ var rect = new Rect(ellipsePoint, new Size(EllipseSize, EllipseSize));
+ rects.Add(rect);
+ var nRect = new Rect(rect.Left - EllipsePadding, rect.Top - EllipsePadding, rect.Width + EllipsePadding, rect.Height + EllipsePadding);
+ dicts.Add(nRect, $"{item.Key} : {item.Value}");
+ }
+ index++;
}
-
geometryContext.BeginFigure(points[points.Count - 1], true, true);
geometryContext.PolyLineTo(points, true, true);
}
-
+ PointCache = dicts;
streamGeometry.Freeze();
var color = (Color)Application.Current.TryFindResource("WD.PrimaryNormalColor");
var rectBrush = new SolidColorBrush(color);
rectBrush.Opacity = 0.5;
+ rectBrush.Freeze();
drawingContext.DrawGeometry(rectBrush, myPen, streamGeometry);
+ DrawEllipse(rects, drawingContext);
}
-
- private void DrawPoints(int circleRadius, DrawingContext drawingContext, bool isDrawText = false)
+ private void DrawPoints(double circleRadius, DrawingContext drawingContext, bool isDrawText = false)
{
- var myPen = new Pen
- {
- Thickness = 2,
- Brush = Brushes.Gainsboro
- };
- myPen.Freeze();
+ var pieWidth = ActualWidth > ActualHeight ? ActualHeight : ActualWidth;
+ var pieHeight = ActualWidth > ActualHeight ? ActualHeight : ActualWidth;
+ _h = pieWidth / 2;
+ _w = pieHeight / 2;
var streamGeometry = new StreamGeometry();
using (var geometryContext = streamGeometry.Open())
{
- var h = ActualHeight / 2;
- var w = ActualWidth / 2;
- PointCollection points = null;
if (isDrawText)
- points = GetPolygonPoint(new Point(w, h), circleRadius, RadarArray.Count, drawingContext);
+ _points = GetPolygonPoint(new Point(_w, _h), circleRadius, drawingContext);
else
- points = GetPolygonPoint(new Point(w, h), circleRadius, RadarArray.Count);
- geometryContext.BeginFigure(points[points.Count - 1], true, true);
- geometryContext.PolyLineTo(points, true, true);
+ _points = GetPolygonPoint(new Point(_w, _h), circleRadius);
+ geometryContext.BeginFigure(_points[_points.Count - 1], true, true);
+ geometryContext.PolyLineTo(_points, true, true);
}
-
streamGeometry.Freeze();
- drawingContext.DrawGeometry(null, myPen, streamGeometry);
+ drawingContext.DrawGeometry(null, _penXAxis, streamGeometry);
}
- private PointCollection GetPolygonPoint(Point center, double r, int polygonBound,
+ private PointCollection GetPolygonPoint(Point center, double r,
DrawingContext drawingContext = null)
{
double g = 18;
- double perangle = 360 / polygonBound;
+ double perangle = 360 / Datas.Count();
var pi = Math.PI;
var values = new List();
- for (var i = 0; i < polygonBound; i++)
+ foreach (var item in Datas)
{
+ var p1 = new Point(_w, _h);
var p2 = new Point(r * Math.Cos(g * pi / 180) + center.X, r * Math.Sin(g * pi / 180) + center.Y);
if (drawingContext != null)
{
- var formattedText = DrawingContextHelper.GetFormattedText(RadarArray[i].Text, ControlsHelper.PrimaryNormalBrush,
+ drawingContext.DrawLine(_penXAxis, p1, p2);
+ var formattedText = DrawingContextHelper.GetFormattedText(item.Key, ControlsHelper.PrimaryNormalBrush,
flowDirection: FlowDirection.LeftToRight, textSize: 20.001D);
- RadarArray[i].PointValue = p2;
if (p2.Y > center.Y && p2.X < center.X)
drawingContext.DrawText(formattedText,
new Point(p2.X - formattedText.Width - 5, p2.Y - formattedText.Height / 2));
@@ -128,11 +127,9 @@ private PointCollection GetPolygonPoint(Point center, double r, int polygonBound
else
drawingContext.DrawText(formattedText, new Point(p2.X, p2.Y));
}
-
values.Add(p2);
g += perangle;
}
-
var pcollect = new PointCollection(values);
return pcollect;
}
diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartRect.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartRect.cs
new file mode 100644
index 00000000..bc61817d
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartRect.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Media;
+
+namespace WPFDevelopers.Controls
+{
+ public class ChartRect:ChartBase
+ {
+
+
+ protected Brush ChartFill { get; private set; }
+ protected double IntervalY { get; private set; }
+ protected short ScaleFactor { get; private set; } = 80;
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ base.OnRender(drawingContext);
+ ChartFill = Application.Current.TryFindResource("WD.ChartFillSolidColorBrush") as Brush;
+ var myPen = new Pen
+ {
+ Thickness = 1,
+ Brush = ChartFill
+ };
+ myPen.Freeze();
+
+ var xAxiHeight = 4;
+ StartY = ActualHeight - (xAxiHeight + myPen.Thickness) - 20;
+ var w = ActualWidth;
+ StartX = 40;
+ var width = Datas.Count() * Interval + StartX;
+ IntervalY = 0;
+ var x = StartX;
+ var y = StartY + myPen.Thickness;
+
+ drawingContext.DrawSnappedLinesBetweenPoints(myPen, myPen.Thickness, new Point(StartX, StartY),
+ new Point(width, StartY));
+
+ var points = new List();
+ for (var i = 0; i < Datas.Count() + 1; i++)
+ {
+ points.Add(new Point(x, y));
+ points.Add(new Point(x, y + xAxiHeight));
+ x += Interval;
+ }
+
+ drawingContext.DrawSnappedLinesBetweenPoints(myPen, myPen.Thickness, points.ToArray());
+
+ var formattedText = DrawingContextHelper.GetFormattedText(IntervalY.ToString(),
+ ChartFill, FlowDirection.LeftToRight);
+ drawingContext.DrawText(formattedText,
+ new Point(StartX - formattedText.Width * 2, StartY - formattedText.Height / 2));
+
+ var xAxisPen = new Pen
+ {
+ Thickness = 1,
+ Brush = Application.Current.TryFindResource("WD.ChartXAxisSolidColorBrush") as Brush
+ };
+ xAxisPen.Freeze();
+ var max = Convert.ToInt32(Datas.Max(kvp => kvp.Value));
+ var min = Convert.ToInt32(Datas.Min(kvp => kvp.Value));
+ ScaleFactor = Convert.ToInt16(StartY / Rows);
+ var yAxis = StartY - ScaleFactor;
+ points.Clear();
+ var average = Convert.ToInt32(max / Rows);
+ var result = Enumerable.Range(0, (Convert.ToInt32(max) - average) / average + 1)
+ .Select(i => average + i * average);
+ foreach (var item in result)
+ {
+ points.Add(new Point(StartX, yAxis));
+ points.Add(new Point(width, yAxis));
+ IntervalY = item;
+ formattedText = DrawingContextHelper.GetFormattedText(IntervalY.ToString(),
+ ChartFill, FlowDirection.LeftToRight);
+ drawingContext.DrawText(formattedText,
+ new Point(StartX - formattedText.Width - 10, yAxis - formattedText.Height / 2));
+ yAxis -= ScaleFactor;
+ }
+ drawingContext.DrawSnappedLinesBetweenPoints(xAxisPen, xAxisPen.Thickness, points.ToArray());
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartRound.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartRound.cs
new file mode 100644
index 00000000..88342af5
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartRound.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WPFDevelopers.Controls
+{
+ internal class ChartRound
+ {
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Controls/CropImage/CropImage.cs b/src/WPFDevelopers.Shared/Controls/CropImage/CropImage.cs
index 27e32570..a45c3fd4 100644
--- a/src/WPFDevelopers.Shared/Controls/CropImage/CropImage.cs
+++ b/src/WPFDevelopers.Shared/Controls/CropImage/CropImage.cs
@@ -147,11 +147,8 @@ public override void OnApplyTemplate()
private void DrawImage()
{
if (Source == null) return;
- if (_border.Visibility == Visibility.Visible)
- {
- _border.Visibility = Visibility.Collapsed;
+ if (_border.Visibility == Visibility.Collapsed)
_border.Visibility = Visibility.Visible;
- }
if (adornerLayer != null)
{
adornerLayer.Remove(screenCutAdorner);
diff --git a/src/WPFDevelopers.Shared/Controls/Loading/LoadingExt.cs b/src/WPFDevelopers.Shared/Controls/Loading/LoadingExt.cs
new file mode 100644
index 00000000..b4b42657
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/Loading/LoadingExt.cs
@@ -0,0 +1,32 @@
+using System.Diagnostics;
+using System.IO;
+using System.Windows;
+
+namespace WPFDevelopers.Controls
+{
+ public class LoadingExt
+ {
+ private Process process;
+
+ public void Show()
+ {
+ if (Helper.GetTempPathVersionExt != null && File.Exists(Helper.GetTempPathVersionExt))
+ {
+ process = new Process();
+ process.StartInfo.FileName = Helper.GetTempPathVersionExt;
+ process.StartInfo.Arguments = $"Loading {Application.Current.MainWindow.Title}";
+ process.EnableRaisingEvents = true;
+ process.Exited += (s, x) =>
+ {
+ process = null;
+ };
+ process.Start();
+ }
+ }
+ public void Close()
+ {
+ if (process != null)
+ process.Kill();
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Controls/MessageBox/MessageBox.cs b/src/WPFDevelopers.Shared/Controls/MessageBox/MessageBox.cs
index 1c2d3212..64354120 100644
--- a/src/WPFDevelopers.Shared/Controls/MessageBox/MessageBox.cs
+++ b/src/WPFDevelopers.Shared/Controls/MessageBox/MessageBox.cs
@@ -8,36 +8,36 @@ public static class MessageBox
{
public static MessageBoxResult Show(string messageBoxText,Window owner = null)
{
- var msg = new WPFMessageBox(messageBoxText);
+ var msg = new WDMessageBox(messageBoxText);
return GetWindow(msg, owner);
}
public static MessageBoxResult Show(string messageBoxText, string caption, Window owner = null)
{
- var msg = new WPFMessageBox(messageBoxText, caption);
+ var msg = new WDMessageBox(messageBoxText, caption);
return GetWindow(msg, owner);
}
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, Window owner = null)
{
- var msg = new WPFMessageBox(messageBoxText, caption, button);
+ var msg = new WDMessageBox(messageBoxText, caption, button);
return GetWindow(msg, owner);
}
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxImage icon, Window owner = null)
{
- var msg = new WPFMessageBox(messageBoxText, caption, icon);
+ var msg = new WDMessageBox(messageBoxText, caption, icon);
return GetWindow(msg, owner);
}
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button,
MessageBoxImage icon, Window owner = null)
{
- var msg = new WPFMessageBox(messageBoxText, caption, button, icon);
+ var msg = new WDMessageBox(messageBoxText, caption, button, icon);
return GetWindow(msg, owner);
}
- private static MessageBoxResult GetWindow(WPFMessageBox msg, Window owner = null)
+ private static MessageBoxResult GetWindow(WDMessageBox msg, Window owner = null)
{
msg.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if (owner != null)
diff --git a/src/WPFDevelopers.Shared/Controls/MessageBox/WPFMessageBox.cs b/src/WPFDevelopers.Shared/Controls/MessageBox/WDMessageBox.cs
similarity index 74%
rename from src/WPFDevelopers.Shared/Controls/MessageBox/WPFMessageBox.cs
rename to src/WPFDevelopers.Shared/Controls/MessageBox/WDMessageBox.cs
index 0cb1e911..eaa52f7f 100644
--- a/src/WPFDevelopers.Shared/Controls/MessageBox/WPFMessageBox.cs
+++ b/src/WPFDevelopers.Shared/Controls/MessageBox/WDMessageBox.cs
@@ -16,21 +16,29 @@ namespace WPFDevelopers.Controls
[TemplatePart(Name = MessageTemplateName, Type = typeof(TextBox))]
[TemplatePart(Name = ButtonCancelTemplateName, Type = typeof(Button))]
[TemplatePart(Name = ButtonCancelTemplateName, Type = typeof(Button))]
+ [TemplatePart(Name = ButtonYesTemplateName, Type = typeof(Button))]
+ [TemplatePart(Name = ButtonNoTemplateName, Type = typeof(Button))]
[TemplatePart(Name = PathTemplateName, Type = typeof(Path))]
- internal sealed class WPFMessageBox : Window
+ internal sealed class WDMessageBox : Window
{
private const string TitleTemplateName = "PART_Title";
private const string CloseButtonTemplateName = "PART_CloseButton";
private const string MessageTemplateName = "PART_Message";
private const string ButtonCancelTemplateName = "PART_ButtonCancel";
private const string ButtonOKTemplateName = "PART_ButtonOK";
+ private const string ButtonYesTemplateName = "PART_ButtonYes";
+ private const string ButtonNoTemplateName = "PART_ButtonNo";
private const string PathTemplateName = "PART_Path";
private readonly string _messageString;
private readonly string _titleString;
private Button _buttonCancel;
private Button _buttonOK;
+ private Button _buttonYes;
+ private Button _buttonNo;
private Visibility _cancelVisibility = Visibility.Collapsed;
+ private Visibility _yesVisibility = Visibility.Collapsed;
+ private Visibility _noVisibility = Visibility.Collapsed;
private Button _closeButton;
private Geometry _geometry;
private TextBox _message;
@@ -41,37 +49,37 @@ internal sealed class WPFMessageBox : Window
private TextBlock _title;
- static WPFMessageBox()
+ static WDMessageBox()
{
- DefaultStyleKeyProperty.OverrideMetadata(typeof(WPFMessageBox),
- new FrameworkPropertyMetadata(typeof(WPFMessageBox)));
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(WDMessageBox),
+ new FrameworkPropertyMetadata(typeof(WDMessageBox)));
}
- public WPFMessageBox(string message)
+ public WDMessageBox(string message)
{
_messageString = message;
}
- public WPFMessageBox(string message, string caption)
+ public WDMessageBox(string message, string caption)
{
_titleString = caption;
_messageString = message;
}
- public WPFMessageBox(string message, string caption, MessageBoxButton button)
+ public WDMessageBox(string message, string caption, MessageBoxButton button)
{
_titleString = caption;
_messageString = message;
}
- public WPFMessageBox(string message, string caption, MessageBoxImage image)
+ public WDMessageBox(string message, string caption, MessageBoxImage image)
{
_titleString = caption;
_messageString = message;
DisplayImage(image);
}
- public WPFMessageBox(string message, string caption, MessageBoxButton button, MessageBoxImage image)
+ public WDMessageBox(string message, string caption, MessageBoxButton button, MessageBoxImage image)
{
_titleString = caption;
_messageString = message;
@@ -117,6 +125,19 @@ public override void OnApplyTemplate()
_buttonOK.Click += ButtonOK_Click;
}
+ _buttonYes = GetTemplateChild(ButtonYesTemplateName) as Button;
+ if (_buttonYes != null)
+ {
+ _buttonYes.Visibility = _yesVisibility;
+ _buttonYes.Click += ButtonYes_Click;
+ }
+
+ _buttonNo = GetTemplateChild(ButtonNoTemplateName) as Button;
+ if (_buttonNo != null)
+ {
+ _buttonNo.Visibility = _noVisibility;
+ _buttonNo.Click += ButtonNo_Click;
+ }
if (Owner == null)
{
BorderThickness = new Thickness(1);
@@ -143,6 +164,18 @@ public override void OnApplyTemplate()
#endif
}
+ private void ButtonNo_Click(object sender, RoutedEventArgs e)
+ {
+ Result = MessageBoxResult.No;
+ Close();
+ }
+
+ private void ButtonYes_Click(object sender, RoutedEventArgs e)
+ {
+ Result = MessageBoxResult.Yes;
+ Close();
+ }
+
private void ButtonOK_Click(object sender, RoutedEventArgs e)
{
Result = MessageBoxResult.OK;
@@ -165,10 +198,18 @@ private void DisplayButtons(MessageBoxButton button)
switch (button)
{
case MessageBoxButton.OKCancel:
- case MessageBoxButton.YesNo:
_cancelVisibility = Visibility.Visible;
_okVisibility = Visibility.Visible;
break;
+ case MessageBoxButton.YesNo:
+ _yesVisibility = Visibility.Visible;
+ _noVisibility = Visibility.Visible;
+ break;
+ case MessageBoxButton.YesNoCancel:
+ _yesVisibility = Visibility.Visible;
+ _noVisibility = Visibility.Visible;
+ _cancelVisibility = Visibility.Visible;
+ break;
default:
_okVisibility = Visibility.Visible;
break;
diff --git a/src/WPFDevelopers.Shared/Controls/Pagination/Pagination.cs b/src/WPFDevelopers.Shared/Controls/Pagination/Pagination.cs
index 4bab85a8..de9104a6 100644
--- a/src/WPFDevelopers.Shared/Controls/Pagination/Pagination.cs
+++ b/src/WPFDevelopers.Shared/Controls/Pagination/Pagination.cs
@@ -272,7 +272,10 @@ private void UnsubscribeEvents()
_jumpPageNumericBox.ValueChanged -= OnJumpPageTextBoxChanged;
if (_listBox != null)
+ {
+ _listBox.PreviewMouseMove -= ListBox_PreviewMouseMove;
_listBox.SelectionChanged -= OnSelectionChanged;
+ }
}
private void SubscribeEvents()
@@ -284,7 +287,15 @@ private void SubscribeEvents()
_jumpPageNumericBox.ValueChanged += OnJumpPageTextBoxChanged;
if (_listBox != null)
+ {
+ _listBox.PreviewMouseMove += ListBox_PreviewMouseMove;
_listBox.SelectionChanged += OnSelectionChanged;
+ }
+ }
+
+ private void ListBox_PreviewMouseMove(object sender, MouseEventArgs e)
+ {
+ e.Handled = true;
}
private void UpdatePages()
diff --git a/src/WPFDevelopers.Shared/Controls/RadarChart/RadarModel.cs b/src/WPFDevelopers.Shared/Controls/RadarChart/RadarModel.cs
deleted file mode 100644
index 23e59835..00000000
--- a/src/WPFDevelopers.Shared/Controls/RadarChart/RadarModel.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Windows;
-using WPFDevelopers.Helpers;
-
-namespace WPFDevelopers.Controls
-{
- public class RadarModel : ViewModelBase
- {
- private Point _pointValue;
-
- private int _valueMax;
- public string Text { get; set; }
-
- public int ValueMax
- {
- get => _valueMax;
- set
- {
- _valueMax = value;
- NotifyPropertyChange("ValueMax");
- }
- }
-
- public Point PointValue
- {
- get => _pointValue;
- set
- {
- _pointValue = value;
- NotifyPropertyChange("PointValue");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCaptureExt.cs b/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCaptureExt.cs
index cd3966aa..543ff78e 100644
--- a/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCaptureExt.cs
+++ b/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCaptureExt.cs
@@ -9,8 +9,7 @@ namespace WPFDevelopers.Controls
{
public class ScreenCaptureExt : Window
{
- const int WM_USER = 0x03FC;
- const int MY_MESSAGE = WM_USER + 1;
+
///
/// 截图完成委托
///
@@ -53,11 +52,11 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
{
switch (msg)
{
- case WM_USER:
+ case Helper.WM_USER:
GetClipboard();
Close();
break;
- case MY_MESSAGE:
+ case Helper.MY_MESSAGE:
if (SnapCanceled != null)
SnapCanceled();
Close();
diff --git a/src/WPFDevelopers.Shared/Core/Converts/CornerRadiusToSurroundConverter.cs b/src/WPFDevelopers.Shared/Core/Converts/CornerRadiusToSurroundConverter.cs
new file mode 100644
index 00000000..aff165bc
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Core/Converts/CornerRadiusToSurroundConverter.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+using WPFDevelopers.Controls;
+
+namespace WPFDevelopers.Converts
+{
+ public class CornerRadiusToSurroundConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is CornerRadius cornerRadius && parameter != null)
+ {
+ if (cornerRadius != new CornerRadius(0))
+ {
+ CornerRadius _cornerRadius = cornerRadius;
+ RadiusOrientation _radiusOrientation;
+ if (Enum.TryParse(parameter.ToString(), out _radiusOrientation))
+ {
+ switch (_radiusOrientation)
+ {
+ case RadiusOrientation.Down:
+ _cornerRadius.BottomRight = 0;
+ _cornerRadius.BottomLeft = 0;
+ break;
+ case RadiusOrientation.Up:
+ _cornerRadius.TopLeft = 0;
+ _cornerRadius.TopRight = 0;
+ break;
+ case RadiusOrientation.Left:
+ _cornerRadius.TopLeft = 0;
+ _cornerRadius.BottomLeft = 0;
+ break;
+ case RadiusOrientation.Right:
+ _cornerRadius.TopRight = 0;
+ _cornerRadius.BottomRight = 0;
+ break;
+ case RadiusOrientation.TopLeft:
+ _cornerRadius.TopRight = 0;
+ _cornerRadius.BottomRight = 0;
+ _cornerRadius.BottomLeft = 0;
+ break;
+ case RadiusOrientation.TopRight:
+ _cornerRadius.TopLeft = 0;
+ _cornerRadius.BottomRight = 0;
+ _cornerRadius.BottomLeft = 0;
+ break;
+ }
+ }
+ return _cornerRadius;
+ }
+ }
+ return DependencyProperty.UnsetValue;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+}
diff --git a/src/WPFDevelopers.Shared/Core/Converts/WidthHeightToRectConverter.cs b/src/WPFDevelopers.Shared/Core/Converts/WidthHeightToRectConverter.cs
new file mode 100644
index 00000000..cca9f677
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Core/Converts/WidthHeightToRectConverter.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace WPFDevelopers.Converts
+{
+ public class WidthHeightToRectConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (values.Length == 2 && values[0] is double width && values[1] is double height)
+ return new System.Windows.Rect(0, 0, width, height);
+ return Binding.DoNothing;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs
index 524012af..601604c4 100644
--- a/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs
+++ b/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs
@@ -8,9 +8,11 @@
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Interop;
+using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
+using System.Xml;
namespace WPFDevelopers.Helpers
{
@@ -215,6 +217,24 @@ public static T FindVisualChild(DependencyObject parent) where T : Dependency
return null;
}
+ public static object GetXmlReader(object Content)
+ {
+ var originalContent = Content as UIElement;
+ string contentXaml = XamlWriter.Save(originalContent);
+ using (StringReader stringReader = new StringReader(contentXaml))
+ {
+ using (XmlReader xmlReader = XmlReader.Create(stringReader))
+ {
+ object clonedContent = XamlReader.Load(xmlReader);
+
+ if (clonedContent is UIElement clonedElement)
+ {
+ return clonedElement;
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs
index 78192910..d257ee26 100644
--- a/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs
+++ b/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs
@@ -1,4 +1,6 @@
-using System.Windows;
+using System;
+using System.Windows;
+using System.Windows.Controls;
namespace WPFDevelopers.Helpers
{
@@ -20,6 +22,10 @@ public class ElementHelper : DependencyObject
DependencyProperty.RegisterAttached("IsRound", typeof(bool), typeof(ElementHelper),
new PropertyMetadata(false));
+ public static readonly DependencyProperty IsClearProperty =
+ DependencyProperty.RegisterAttached("IsClear", typeof(bool), typeof(ElementHelper),
+ new PropertyMetadata(false, OnIsClearChanged));
+
public static CornerRadius GetCornerRadius(DependencyObject obj)
{
return (CornerRadius) obj.GetValue(CornerRadiusProperty);
@@ -58,5 +64,41 @@ public static void SetIsRound(DependencyObject obj, bool value)
{
obj.SetValue(IsRoundProperty, value);
}
+ public static void SetIsClear(UIElement element, bool value)
+ {
+ element.SetValue(IsClearProperty, value);
+ }
+
+ public static bool GetIsClear(UIElement element)
+ {
+ return (bool)element.GetValue(IsClearProperty);
+ }
+
+ private static void OnIsClearChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var button = d as Button;
+ if (button != null)
+ {
+ if ((bool)e.NewValue)
+ button.Click += ButtonClear_Click;
+ else
+ button.Click -= ButtonClear_Click;
+ }
+ }
+
+ private static void ButtonClear_Click(object sender, RoutedEventArgs e)
+ {
+ if (sender is Button button)
+ {
+ if (button.TemplatedParent is TextBox textBox)
+ {
+ textBox.Clear();
+ }
+ else if (button.TemplatedParent is PasswordBox passwordBox)
+ {
+ passwordBox.Clear();
+ }
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Core/Helpers/GeometryHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/GeometryHelper.cs
new file mode 100644
index 00000000..3e60c28f
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Core/Helpers/GeometryHelper.cs
@@ -0,0 +1,156 @@
+using System.Windows.Media;
+using System.Windows;
+using WPFDevelopers.Utilities;
+using System;
+
+namespace WPFDevelopers.Helpers
+{
+ public static class GeometryHelper
+ {
+ public static void GenerateGeometry(StreamGeometryContext ctx, Rect rect, Radii radii)
+ {
+ var point = new Point(radii.LeftTop, 0.0);
+ var point2 = new Point(rect.Width - radii.RightTop, 0.0);
+ var point3 = new Point(rect.Width, radii.TopRight);
+ var point4 = new Point(rect.Width, rect.Height - radii.BottomRight);
+ var point5 = new Point(rect.Width - radii.RightBottom, rect.Height);
+ var point6 = new Point(radii.LeftBottom, rect.Height);
+ var point7 = new Point(0.0, rect.Height - radii.BottomLeft);
+ var point8 = new Point(0.0, radii.TopLeft);
+ if (point.X > point2.X)
+ {
+ var x = radii.LeftTop / (radii.LeftTop + radii.RightTop) * rect.Width;
+ point.X = x;
+ point2.X = x;
+ }
+ if (point3.Y > point4.Y)
+ {
+ var y = radii.TopRight / (radii.TopRight + radii.BottomRight) * rect.Height;
+ point3.Y = y;
+ point4.Y = y;
+ }
+ if (point5.X < point6.X)
+ {
+ var x2 = radii.LeftBottom / (radii.LeftBottom + radii.RightBottom) * rect.Width;
+ point5.X = x2;
+ point6.X = x2;
+ }
+ if (point7.Y < point8.Y)
+ {
+ var y2 = radii.TopLeft / (radii.TopLeft + radii.BottomLeft) * rect.Height;
+ point7.Y = y2;
+ point8.Y = y2;
+ }
+ var vector = new Vector(rect.TopLeft.X, rect.TopLeft.Y);
+ point += vector;
+ point2 += vector;
+ point3 += vector;
+ point4 += vector;
+ point5 += vector;
+ point6 += vector;
+ point7 += vector;
+ point8 += vector;
+ ctx.BeginFigure(point, true, true);
+ ctx.LineTo(point2, true, false);
+ var width = rect.TopRight.X - point2.X;
+ var height = point3.Y - rect.TopRight.Y;
+ if (!DoubleUtil.IsZero(width) || !DoubleUtil.IsZero(height))
+ {
+ ctx.ArcTo(point3, new Size(width, height), 0.0, false, SweepDirection.Clockwise, true, false);
+ }
+ ctx.LineTo(point4, true, false);
+ width = rect.BottomRight.X - point5.X;
+ height = rect.BottomRight.Y - point4.Y;
+ if (!DoubleUtil.IsZero(width) || !DoubleUtil.IsZero(height))
+ {
+ ctx.ArcTo(point5, new Size(width, height), 0.0, false, SweepDirection.Clockwise, true, false);
+ }
+ ctx.LineTo(point6, true, false);
+ width = point6.X - rect.BottomLeft.X;
+ height = rect.BottomLeft.Y - point7.Y;
+ if (!DoubleUtil.IsZero(width) || !DoubleUtil.IsZero(height))
+ {
+ ctx.ArcTo(point7, new Size(width, height), 0.0, false, SweepDirection.Clockwise, true, false);
+ }
+ ctx.LineTo(point8, true, false);
+ width = point.X - rect.TopLeft.X;
+ height = point8.Y - rect.TopLeft.Y;
+ if (!DoubleUtil.IsZero(width) || !DoubleUtil.IsZero(height))
+ {
+ ctx.ArcTo(point, new Size(width, height), 0.0, false, SweepDirection.Clockwise, true, false);
+ }
+ }
+ public struct Radii
+ {
+ internal Radii(CornerRadius radii, Thickness borders, bool outer)
+ {
+ var left = 0.5 * borders.Left;
+ var top = 0.5 * borders.Top;
+ var right = 0.5 * borders.Right;
+ var bottom = 0.5 * borders.Bottom;
+ if (!outer)
+ {
+ LeftTop = Math.Max(0.0, radii.TopLeft - left);
+ TopLeft = Math.Max(0.0, radii.TopLeft - top);
+ TopRight = Math.Max(0.0, radii.TopRight - top);
+ RightTop = Math.Max(0.0, radii.TopRight - right);
+ RightBottom = Math.Max(0.0, radii.BottomRight - right);
+ BottomRight = Math.Max(0.0, radii.BottomRight - bottom);
+ BottomLeft = Math.Max(0.0, radii.BottomLeft - bottom);
+ LeftBottom = Math.Max(0.0, radii.BottomLeft - left);
+ return;
+ }
+ if (DoubleUtil.IsZero(radii.TopLeft))
+ {
+ LeftTop = (TopLeft = 0.0);
+ }
+ else
+ {
+ LeftTop = radii.TopLeft + left;
+ TopLeft = radii.TopLeft + top;
+ }
+ if (DoubleUtil.IsZero(radii.TopRight))
+ {
+ TopRight = (RightTop = 0.0);
+ }
+ else
+ {
+ TopRight = radii.TopRight + top;
+ RightTop = radii.TopRight + right;
+ }
+ if (DoubleUtil.IsZero(radii.BottomRight))
+ {
+ RightBottom = (BottomRight = 0.0);
+ }
+ else
+ {
+ RightBottom = radii.BottomRight + right;
+ BottomRight = radii.BottomRight + bottom;
+ }
+ if (DoubleUtil.IsZero(radii.BottomLeft))
+ {
+ BottomLeft = (LeftBottom = 0.0);
+ return;
+ }
+ BottomLeft = radii.BottomLeft + bottom;
+ LeftBottom = radii.BottomLeft + left;
+ }
+
+ internal double LeftTop;
+
+ internal double TopLeft;
+
+ internal double TopRight;
+
+ internal double RightTop;
+
+ internal double RightBottom;
+
+ internal double BottomRight;
+
+ internal double BottomLeft;
+
+ internal double LeftBottom;
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Core/Helpers/Helper.cs b/src/WPFDevelopers.Shared/Core/Helpers/Helper.cs
index 94aaa148..9f14935a 100644
--- a/src/WPFDevelopers.Shared/Core/Helpers/Helper.cs
+++ b/src/WPFDevelopers.Shared/Core/Helpers/Helper.cs
@@ -11,11 +11,8 @@ namespace WPFDevelopers
{
public class Helper
{
- //public static string GetTempPath = Path.Combine(Path.GetTempPath(), Assembly.GetEntryAssembly().GetName().Name);
- //public static string GetTempPathVersion = Path.Combine(GetTempPath, Assembly.GetExecutingAssembly().GetName().Version.ToString());
- //public const string GetExtName = "WPFDevelopersExt.exe";
- //public static string GetTempPathVersionExt = Path.Combine(GetTempPathVersion, GetExtName);
-
+ public const int WM_USER = 0x03FC;
+ public const int MY_MESSAGE = WM_USER + 1;
public static string GetTempPath = Path.Combine(Path.GetTempPath(), Assembly.GetExecutingAssembly().GetName().Name);
public static string GetTempPathVersion = Path.Combine(GetTempPath, GetMD5Hash(GetCurrentDllPath()));
public const string GetExtName = "WPFDevelopersExt.exe";
diff --git a/src/WPFDevelopers.Shared/Core/Helpers/Win32.cs b/src/WPFDevelopers.Shared/Core/Helpers/Win32.cs
index 4c7030b7..a2fa2d72 100644
--- a/src/WPFDevelopers.Shared/Core/Helpers/Win32.cs
+++ b/src/WPFDevelopers.Shared/Core/Helpers/Win32.cs
@@ -17,8 +17,8 @@ public const string
DwmApi = "dwmapi.dll",
Winmm = "winmm.dll",
Shcore = "Shcore.dll";
- //查找窗口的委托 查找逻辑
- public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
+ //查找窗口的委托 查找逻辑
+ public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
[DllImport(User32)]
public static extern IntPtr FindWindow(string className, string winName);
@@ -46,6 +46,12 @@ public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfte
[DllImport(User32)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
+ [DllImport(User32)]
+ public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport(User32)]
+ public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
+
[DllImport(Winmm)]
public static extern long mciSendString(string strCommand, StringBuilder strReturn,
int iReturnLength, IntPtr hwndCallback);
diff --git a/src/WPFDevelopers.Shared/LanguageManager.cs b/src/WPFDevelopers.Shared/LanguageManager.cs
new file mode 100644
index 00000000..a14e863a
--- /dev/null
+++ b/src/WPFDevelopers.Shared/LanguageManager.cs
@@ -0,0 +1,44 @@
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Resources;
+using System.Threading;
+
+namespace WPFDevelopers
+{
+ public class LanguageManager : INotifyPropertyChanged
+ {
+ private readonly ResourceManager _resourceManager;
+ private static readonly Lazy _lazy = new Lazy(() => new LanguageManager());
+ public static LanguageManager Instance => _lazy.Value;
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public LanguageManager()
+ {
+ _resourceManager = new ResourceManager("WPFDevelopers.Languages.Language", typeof(LanguageManager).Assembly);
+ }
+
+ public string this[string name]
+ {
+ get
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+ return _resourceManager.GetString(name);
+ }
+ }
+
+ public void ChangeLanguage(CultureInfo cultureInfo)
+ {
+ Thread.CurrentThread.CurrentCulture = cultureInfo;
+ Thread.CurrentThread.CurrentUICulture = cultureInfo;
+ OnPropertyChanged("Item[]");
+ }
+ protected virtual void OnPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Languages/Language.Designer.cs b/src/WPFDevelopers.Shared/Languages/Language.Designer.cs
new file mode 100644
index 00000000..c594edf2
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Languages/Language.Designer.cs
@@ -0,0 +1,111 @@
+
+
+namespace WPFDevelopers.Languages
+{
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ public class Language {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Language() {
+ }
+
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFDevelopers.Languages.Language", typeof(Language).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// 查找类似 取消 的本地化字符串。
+ ///
+ public static string Cancel {
+ get {
+ return ResourceManager.GetString("Cancel", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 跳至 的本地化字符串。
+ ///
+ public static string Goto {
+ get {
+ return ResourceManager.GetString("Goto", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 条 的本地化字符串。
+ ///
+ public static string Items {
+ get {
+ return ResourceManager.GetString("Items", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 否 的本地化字符串。
+ ///
+ public static string No {
+ get {
+ return ResourceManager.GetString("No", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 确定 的本地化字符串。
+ ///
+ public static string OK {
+ get {
+ return ResourceManager.GetString("OK", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 页 的本地化字符串。
+ ///
+ public static string Page {
+ get {
+ return ResourceManager.GetString("Page", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 共 的本地化字符串。
+ ///
+ public static string Total {
+ get {
+ return ResourceManager.GetString("Total", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 是 的本地化字符串。
+ ///
+ public static string Yes {
+ get {
+ return ResourceManager.GetString("Yes", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Languages/Language.en-US.resx b/src/WPFDevelopers.Shared/Languages/Language.en-US.resx
new file mode 100644
index 00000000..4a9658df
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Languages/Language.en-US.resx
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ OK
+
+
+ Cancel
+
+
+ Yes
+
+
+ No
+
+
+ Go to
+
+
+ Page
+
+
+ Items
+
+
+ Total
+
+
+ Rectangle
+
+
+ Ellipse
+
+
+ Arrow
+
+
+ Ink
+
+
+ Text
+
+
+ Save
+
+
+ Complete
+
+
+ Close
+
+
+ Select
+
+
+ Replace
+
+
+ Clear
+
+
+ Minimize
+
+
+ Maximize
+
+
+ Restore
+
+
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Languages/Language.ko-KR.resx b/src/WPFDevelopers.Shared/Languages/Language.ko-KR.resx
new file mode 100644
index 00000000..075244c7
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Languages/Language.ko-KR.resx
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 그래
+
+
+ 취소
+
+
+ 예
+
+
+ 아니오
+
+
+ 이동
+
+
+ 페이지
+
+
+ 바
+
+
+ 전부의
+
+
+ 직사각형
+
+
+ 타원
+
+
+ 화살표
+
+
+ 화필
+
+
+ 문자
+
+
+ 저장
+
+
+ 완료
+
+
+ 닫기
+
+
+ 선택
+
+
+ 교체
+
+
+ 비우기
+
+
+ 아래로 복원
+
+
+ 최소화
+
+
+ 최대화
+
+
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Languages/Language.resx b/src/WPFDevelopers.Shared/Languages/Language.resx
new file mode 100644
index 00000000..2c8474ab
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Languages/Language.resx
@@ -0,0 +1,166 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 确定
+
+
+ 取消
+
+
+ 是
+
+
+ 否
+
+
+ 跳至
+
+
+ 页
+
+
+ 条
+
+
+ 共
+
+
+ 方框
+
+
+ 椭圆
+
+
+ 箭头
+
+
+ 画笔
+
+
+ 文字
+
+
+ 保存
+
+
+ 完成
+
+
+ 关闭
+
+
+ 选择
+
+
+ 更换
+
+
+ 清空
+
+
+ 最小化
+
+
+ 最大化
+
+
+ 向下还原
+
+
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Styles/Styles.DataGrid.xaml b/src/WPFDevelopers.Shared/Styles/Styles.DataGrid.xaml
index 04e107c6..fe78678d 100644
--- a/src/WPFDevelopers.Shared/Styles/Styles.DataGrid.xaml
+++ b/src/WPFDevelopers.Shared/Styles/Styles.DataGrid.xaml
@@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Controls"
xmlns:converts="clr-namespace:WPFDevelopers.Converts"
+ xmlns:helpers="clr-namespace:WPFDevelopers.Helpers"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
@@ -38,14 +39,6 @@
-
-
-
-
-
-
-
-
@@ -62,7 +55,7 @@
BasedOn="{StaticResource WD.ControlBasicStyle}"
TargetType="{x:Type DataGrid}">
-
+
@@ -75,22 +68,32 @@
+
+
+
+
-
-
+
+
@@ -98,6 +101,7 @@
-
-
-
-
-
-
-
+
@@ -320,7 +318,12 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -423,11 +406,12 @@
+ BorderThickness="{TemplateBinding BorderThickness}"
+ SnapsToDevicePixels="True">
diff --git a/src/WPFDevelopers.Shared/Styles/Styles.DatePicker.xaml b/src/WPFDevelopers.Shared/Styles/Styles.DatePicker.xaml
index d6dba6cc..d10a6ad1 100644
--- a/src/WPFDevelopers.Shared/Styles/Styles.DatePicker.xaml
+++ b/src/WPFDevelopers.Shared/Styles/Styles.DatePicker.xaml
@@ -445,7 +445,7 @@
Background="{DynamicResource WD.BackgroundSolidColorBrush}"
BorderBrush="{DynamicResource WD.BaseSolidColorBrush}"
BorderThickness="1"
- CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
+ CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=Calendar}}"
SnapsToDevicePixels="True"
UseLayoutRounding="True">
diff --git a/src/WPFDevelopers.Shared/Styles/Styles.Expander.xaml b/src/WPFDevelopers.Shared/Styles/Styles.Expander.xaml
index acc3832c..bd248956 100644
--- a/src/WPFDevelopers.Shared/Styles/Styles.Expander.xaml
+++ b/src/WPFDevelopers.Shared/Styles/Styles.Expander.xaml
@@ -16,31 +16,43 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Styles/Styles.PasswordBox.xaml b/src/WPFDevelopers.Shared/Styles/Styles.PasswordBox.xaml
index ecacf83e..01758842 100644
--- a/src/WPFDevelopers.Shared/Styles/Styles.PasswordBox.xaml
+++ b/src/WPFDevelopers.Shared/Styles/Styles.PasswordBox.xaml
@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Controls"
xmlns:helpers="clr-namespace:WPFDevelopers.Helpers"
- xmlns:sys="clr-namespace:System;assembly=mscorlib">
+ xmlns:resx="clr-namespace:WPFDevelopers">
@@ -49,6 +49,23 @@
TextTrimming="CharacterEllipsis"
Visibility="Collapsed" />
+
+
+
@@ -58,6 +75,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/WPFDevelopers.Shared/Styles/Styles.ProgressBar.xaml b/src/WPFDevelopers.Shared/Styles/Styles.ProgressBar.xaml
index 27432e2f..9dbb3925 100644
--- a/src/WPFDevelopers.Shared/Styles/Styles.ProgressBar.xaml
+++ b/src/WPFDevelopers.Shared/Styles/Styles.ProgressBar.xaml
@@ -37,18 +37,18 @@
-
+
+ Clip="{Binding RelativeSource={RelativeSource AncestorType=controls:WDBorder}, Path=ContentClip}" />
+ Clip="{Binding RelativeSource={RelativeSource AncestorType=controls:WDBorder}, Path=ContentClip}" />
-
+
@@ -75,7 +75,6 @@
-
@@ -128,7 +127,6 @@
-
diff --git a/src/WPFDevelopers.Shared/Styles/Styles.Slider.xaml b/src/WPFDevelopers.Shared/Styles/Styles.Slider.xaml
index 43187fbe..d212016f 100644
--- a/src/WPFDevelopers.Shared/Styles/Styles.Slider.xaml
+++ b/src/WPFDevelopers.Shared/Styles/Styles.Slider.xaml
@@ -73,17 +73,32 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Themes/Pagination.xaml b/src/WPFDevelopers.Shared/Themes/Pagination.xaml
index 4b62f29d..de2a2c1a 100644
--- a/src/WPFDevelopers.Shared/Themes/Pagination.xaml
+++ b/src/WPFDevelopers.Shared/Themes/Pagination.xaml
@@ -2,7 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Controls"
- xmlns:helpers="clr-namespace:WPFDevelopers.Helpers">
+ xmlns:helpers="clr-namespace:WPFDevelopers.Helpers"
+ xmlns:resx="clr-namespace:WPFDevelopers">
@@ -102,7 +103,11 @@
-
+
+
+
+
+
-
+ Margin="3,0,0,0"
+ VerticalAlignment="Center">
+
+
+
+
-
+
+
+
+
+
-
+
-
+
-
+
-
+
diff --git a/src/WPFDevelopers.Shared/Themes/ScreenCut.xaml b/src/WPFDevelopers.Shared/Themes/ScreenCut.xaml
index 0cfe0a2d..29f60eda 100644
--- a/src/WPFDevelopers.Shared/Themes/ScreenCut.xaml
+++ b/src/WPFDevelopers.Shared/Themes/ScreenCut.xaml
@@ -2,7 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Controls"
- xmlns:helpers="clr-namespace:WPFDevelopers.Helpers">
+ xmlns:helpers="clr-namespace:WPFDevelopers.Helpers"
+ xmlns:resx="clr-namespace:WPFDevelopers">
@@ -79,7 +80,7 @@
x:Name="PART_RadioButtonRectangle"
Margin="4,0"
Style="{DynamicResource WD.PathRadioButton}"
- ToolTip="方框">
+ ToolTip="{Binding [Rectangle], Source={x:Static resx:LanguageManager.Instance}}">
+ ToolTip="{Binding [Ellipse], Source={x:Static resx:LanguageManager.Instance}}">
+ ToolTip="{Binding [Arrow], Source={x:Static resx:LanguageManager.Instance}}">
+ ToolTip="{Binding [Ink], Source={x:Static resx:LanguageManager.Instance}}">
+ ToolTip="{Binding [Text], Source={x:Static resx:LanguageManager.Instance}}">
+ ToolTip="{Binding [Save], Source={x:Static resx:LanguageManager.Instance}}">
+ ToolTip="{Binding [Cancel], Source={x:Static resx:LanguageManager.Instance}}">
+ ToolTip="{Binding [Complete], Source={x:Static resx:LanguageManager.Instance}}">
WPFDevelopers
+
+
+
+
+
+
@@ -37,13 +43,17 @@
+
+
+
+
@@ -54,7 +64,7 @@
-
+
@@ -81,10 +91,9 @@
-
+
-
@@ -113,8 +122,7 @@
-
-
+
@@ -149,6 +157,7 @@
+
@@ -523,10 +532,6 @@
MSBuild:Compile
Designer
-
- MSBuild:Compile
- Designer
-
MSBuild:Compile
Designer
@@ -561,6 +566,9 @@
+
+
+
diff --git a/src/WPFDevelopers.sln b/src/WPFDevelopers.sln
index 9bd16c28..4014fd8b 100644
--- a/src/WPFDevelopers.sln
+++ b/src/WPFDevelopers.sln
@@ -80,6 +80,8 @@ Global
{88DD2697-4DF1-40DC-B33B-DE1FD9846800} = {2C729CA5-1110-40DA-8EF4-2A7549072C53}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
+ RESX_SaveFilesImmediatelyUponChange = False
+ RESX_NeutralResourcesLanguage = zh-CN
SolutionGuid = {641F8D5D-5514-4C9A-9FAB-7FAF38D9C008}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution