diff --git a/src/Package.props b/src/Package.props new file mode 100644 index 00000000..683b1e3c --- /dev/null +++ b/src/Package.props @@ -0,0 +1,16 @@ + + + WPFDevelopers + WPFDevelopers + true + WPFDevelopers + true + snupkg + Copyright © WPFDevelopersOrg 2024 + 1.1.0.2 + 1.1.0.2 + 1.1.0.2 + https://github.com/WPFDevelopersOrg/WPFDevelopers + Debug;Release;Debug-.NET40;Release-.NET40 + + \ No newline at end of file diff --git a/src/Resources.props b/src/Resources.props new file mode 100644 index 00000000..419ade94 --- /dev/null +++ b/src/Resources.props @@ -0,0 +1,170 @@ + + + WPFDevelopers.Samples + WPFDevelopers.Samples + WinExe + true + true + false + Debug;Release;Debug-.NET40;Release-.NET40 + ..\WPFDevelopers.Samples.Shared\WPFDevelopers.ico + + + + False + ..\..\Reference\ICSharpCode.AvalonEdit.dll + + + False + ..\..\Reference\Microsoft.Maps.MapControl.WPF.dll + + + ..\..\Reference\System.Windows.Interactivity.dll + + + + + WPFDevelopers.ico + + + Resources\emoji\发烧.png + + + Resources\emoji\大笑.png + + + Resources\emoji\得意.png + + + Resources\emoji\思考.png + + + Resources\emoji\生病.png + + + Resources\emoji\破涕为笑.png + + + Resources\Assets\Lock.png + + + Resources\Assets\Mail.png + + + Resources\Assets\User.png + + + Resources\Assets\Clear.png + + + Resources\Assets\Background.png + + + Resources\Assets\Logo.png + + + Resources\Fonts\fixedsys.ttf + + + Resources\Images\AMap\Car2.png + + + Resources\Images\AnimationNavigationBar3D\background.png + + + Resources\Images\Breathe\0.jpg + + + Resources\Images\Breathe\1.jpg + + + Resources\Images\Breathe\2.jpg + + + Resources\Images\Chat\Left.jpg + + + Resources\Images\Chat\Right.jpg + + + Resources\Images\Chat\UserImages\jingtao.png + + + Resources\Images\Chat\UserImages\yanjinhua.png + + + Resources\Images\CircularMenu\1.png + + + Resources\Images\CircularMenu\2.png + + + Resources\Images\CircularMenu\3.png + + + Resources\Images\CircularMenu\4.png + + + Resources\Images\CircularMenu\5.png + + + Resources\Images\CircularMenu\6.png + + + Resources\Images\CircularMenu\7.png + + + Resources\Images\CircularMenu\8.png + + + Resources\Images\Craouse\0.jpg + + + Resources\Images\Craouse\1.jpg + + + Resources\Images\Craouse\2.jpg + + + Resources\Images\Craouse\3.jpg + + + Resources\Images\Craouse\4.jpg + + + Resources\Images\Crop\0.jpg + + + Resources\Images\Passwrod\Eye_50px.png + + + Resources\Images\Passwrod\Invisible_50px.png + + + Resources\Images\Passwrod\Lock_48px.png + + + Resources\Images\Snow\SnowTree.png + + + Resources\Images\SpeedRockets\飞机.png + + + Resources\Images\ZooSemy\0.png + + + Resources\Images\ZooSemy\1.png + + + Resources\Audio\HelloWPFDevelopes_en.mp3 + + + Resources\Audio\HelloWPFDevelopes_zh.mp3 + + + + WPFDevelopers.Samples + WPFDevelopers.Samples + + + \ No newline at end of file diff --git a/src/TargetFrameworks.props b/src/TargetFrameworks.props new file mode 100644 index 00000000..675ca381 --- /dev/null +++ b/src/TargetFrameworks.props @@ -0,0 +1,5 @@ + + + net45;net46;net47;net48;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows;netcoreapp3.0 + + \ No newline at end of file diff --git a/src/WPFDevelopers.Net40/AssemblyInfo.cs b/src/WPFDevelopers.Net40/Properties/AssemblyInfo.cs similarity index 100% rename from src/WPFDevelopers.Net40/AssemblyInfo.cs rename to src/WPFDevelopers.Net40/Properties/AssemblyInfo.cs diff --git a/src/WPFDevelopers.Net40/WPFDevelopers.Net40.csproj b/src/WPFDevelopers.Net40/WPFDevelopers.Net40.csproj index 1a6adf1c..2257a905 100644 --- a/src/WPFDevelopers.Net40/WPFDevelopers.Net40.csproj +++ b/src/WPFDevelopers.Net40/WPFDevelopers.Net40.csproj @@ -1,18 +1,7 @@  + - WPFDevelopers - WPFDevelopers net40 - true - WPFDevelopers - true - snupkg - Copyright © WPFDevelopersOrg 2022 - 1.1.0.2 - 1.1.0.2 - 1.1.0.2 - https://github.com/WPFDevelopersOrg/WPFDevelopers - Debug;Release;Debug-.NET40;Release-.NET40 diff --git a/src/WPFDevelopers.Net45x/Themes/Generic.xaml b/src/WPFDevelopers.Net45x/Themes/Generic.xaml index 809d1ad2..8a45c79e 100644 --- a/src/WPFDevelopers.Net45x/Themes/Generic.xaml +++ b/src/WPFDevelopers.Net45x/Themes/Generic.xaml @@ -190,5 +190,4 @@ - \ No newline at end of file diff --git a/src/WPFDevelopers.Net45x/WPFDevelopers.Net45x.csproj b/src/WPFDevelopers.Net45x/WPFDevelopers.Net45x.csproj index ef75a287..4a1256a3 100644 --- a/src/WPFDevelopers.Net45x/WPFDevelopers.Net45x.csproj +++ b/src/WPFDevelopers.Net45x/WPFDevelopers.Net45x.csproj @@ -1,22 +1,12 @@ - + + + - WPFDevelopers - WPFDevelopers - net45;net46;net47;net48;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows;netcoreapp3.0 - true true - WPFDevelopers - true - snupkg - Copyright © WPFDevelopersOrg 2022 - 1.1.0.2 - 1.1.0.2 - 1.1.0.2 - https://github.com/WPFDevelopersOrg/WPFDevelopers - false - Debug;Release;Debug-.NET40;Release-.NET40 + false + @@ -48,6 +38,16 @@ 7.0.0 + + + 7.0.0 + + + + + 7.0.0 + + 7.0.0 diff --git a/src/WPFDevelopers.Samples.Shared/App.xaml b/src/WPFDevelopers.Samples.Shared/App.xaml index a8a341b3..a4eba48e 100644 --- a/src/WPFDevelopers.Samples.Shared/App.xaml +++ b/src/WPFDevelopers.Samples.Shared/App.xaml @@ -28,7 +28,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/WaterfallPanelExample.xaml.cs similarity index 55% rename from src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml.cs rename to src/WPFDevelopers.Samples.Shared/ExampleViews/WaterfallPanelExample.xaml.cs index 82a762eb..c649bcfb 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml.cs +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/WaterfallPanelExample.xaml.cs @@ -3,11 +3,11 @@ namespace WPFDevelopers.Samples.ExampleViews { /// - /// TransformThumbExample.xaml 的交互逻辑 + /// WaterfallPanelExample.xaml 的交互逻辑 /// - public partial class TransformThumbExample : UserControl + public partial class WaterfallPanelExample : UserControl { - public TransformThumbExample() + public WaterfallPanelExample() { InitializeComponent(); } diff --git a/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs b/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs index 457063ab..a05067e1 100644 --- a/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs +++ b/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs @@ -19,7 +19,7 @@ public enum MenuEnum CropAvatar, AnimationAudio, AMap, - TransformThumb, + TransformLayout, VerifyCode, CircularMenu, ChatEmoji, @@ -79,6 +79,7 @@ public enum MenuEnum ColorPicker, IPEditBox, TimePicker, + WaterfallPanel, VirtualizingWrapPanel, AcrylicBlur, TaskbarInfo diff --git a/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs b/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs index 95e5ceaf..00ff9811 100644 --- a/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs +++ b/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs @@ -126,8 +126,8 @@ void MenuItemSelection(string _menuName) case MenuEnum.AMap: ControlPanel = new BingAMapExample(); break; - case MenuEnum.TransformThumb: - ControlPanel = new TransformThumbExample(); + case MenuEnum.TransformLayout: + ControlPanel = new TransformLayoutExample(); break; case MenuEnum.VerifyCode: ControlPanel = new VerifyCodeExample(); @@ -315,6 +315,9 @@ void MenuItemSelection(string _menuName) case MenuEnum.TimePicker: ControlPanel = new TimePickerExample(); break; + case MenuEnum.WaterfallPanel: + ControlPanel = new WaterfallPanelExample(); + break; case MenuEnum.VirtualizingWrapPanel: ControlPanel = new VirtualizingWrapPanel(); new VirtualizingWrapPanelExample().MaskShowDialog(); diff --git a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems index 8739ef24..86ad8dcf 100644 --- a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems +++ b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems @@ -25,9 +25,9 @@ - - - + + + @@ -397,9 +397,9 @@ TimePickerExample.xaml - + Code - TransformThumbExample.xaml + TransformLayoutExample.xaml Code @@ -421,6 +421,9 @@ Code VirtualizingWrapPanelExample.xaml + + WaterfallPanelExample.xaml + Code VolumeControl.xaml @@ -470,7 +473,7 @@ MSBuild:Compile Designer - + MSBuild:Compile Designer @@ -875,7 +878,7 @@ MSBuild:Compile Designer - + MSBuild:Compile Designer @@ -899,6 +902,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj b/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj index 176330f8..6b43b722 100644 --- a/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj +++ b/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj @@ -1,29 +1,8 @@  - WPFDevelopers.Samples - WPFDevelopers.Samples - WinExe net40 - true - false - Debug;Release;Debug-.NET40;Release-.NET40 - - ..\WPFDevelopers.Samples.Shared\WPFDevelopers.ico - - - - False - ..\..\Reference\ICSharpCode.AvalonEdit.dll - - - False - ..\..\Reference\Microsoft.Maps.MapControl.WPF.dll - - - ..\..\Reference\System.Windows.Interactivity.dll - - + False @@ -32,155 +11,11 @@ - - - - - WPFDevelopers.ico - - - Resources\emoji\发烧.png - - - Resources\emoji\大笑.png - - - Resources\emoji\得意.png - - - Resources\emoji\思考.png - - - Resources\emoji\生病.png - - - Resources\emoji\破涕为笑.png - - - Resources\Assets\Lock.png - - - Resources\Assets\Mail.png - - - Resources\Assets\User.png - - - Resources\Assets\Clear.png - - - Resources\Assets\Background.png - - - Resources\Assets\Logo.png - - - Resources\Fonts\fixedsys.ttf - - - Resources\Images\AMap\Car2.png - - - Resources\Images\AnimationNavigationBar3D\background.png - - - Resources\Images\Breathe\0.jpg - - - Resources\Images\Breathe\1.jpg - - - Resources\Images\Breathe\2.jpg - - - Resources\Images\Chat\Left.jpg - - - Resources\Images\Chat\Right.jpg - - - Resources\Images\Chat\UserImages\jingtao.png - - - Resources\Images\Chat\UserImages\yanjinhua.png - - - Resources\Images\CircularMenu\1.png - - - Resources\Images\CircularMenu\2.png - - - Resources\Images\CircularMenu\3.png - - - Resources\Images\CircularMenu\4.png - - - Resources\Images\CircularMenu\5.png - - - Resources\Images\CircularMenu\6.png - - - Resources\Images\CircularMenu\7.png - - - Resources\Images\CircularMenu\8.png - - - Resources\Images\Craouse\0.jpg - - - Resources\Images\Craouse\1.jpg - - - Resources\Images\Craouse\2.jpg - - - Resources\Images\Craouse\3.jpg - - - Resources\Images\Craouse\4.jpg - - - Resources\Images\Crop\0.jpg - - - Resources\Images\Passwrod\Eye_50px.png - - - Resources\Images\Passwrod\Invisible_50px.png - - - Resources\Images\Passwrod\Lock_48px.png - - - Resources\Images\Snow\SnowTree.png - - - Resources\Images\SpeedRockets\飞机.png - - - Resources\Images\ZooSemy\0.png - - - Resources\Images\ZooSemy\1.png - - - Resources\Audio\HelloWPFDevelopes_en.mp3 - - - Resources\Audio\HelloWPFDevelopes_zh.mp3 - + - - WPFDevelopers.Samples - WPFDevelopers.Samples - 1701;1702;CS0067 diff --git a/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40_k0iwbism_wpftmp.csproj b/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40_k0iwbism_wpftmp.csproj deleted file mode 100644 index cd2bd368..00000000 --- a/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40_k0iwbism_wpftmp.csproj +++ /dev/null @@ -1,172 +0,0 @@ - - - WPFDevelopers.Samples - E:\Code\git\WPFDevelopers\WPFDevelopersMultiple\WPFDevelopers\src\.vs\WPFDevelopers\Intermediate\WPFDevelopers.Samples40\Debug-.NET40\ - E:\Code\git\WPFDevelopers\WPFDevelopersMultiple\WPFDevelopers\src\.vs\WPFDevelopers\Intermediate\WPFDevelopers.Samples40\ - E:\Code\git\WPFDevelopers\WPFDevelopersMultiple\WPFDevelopers\src\.vs\WPFDevelopers\Intermediate\WPFDevelopers.Samples40\ - <_TargetAssemblyProjectName>WPFDevelopers.Samples40 - - - - WPFDevelopers.Samples - WPFDevelopers.Samples - WinExe - net40 - true - false - Debug;Release;Debug-.NET40;Release-.NET40 - - - ..\WPFDevelopers.Samples.Shared\WPFDevelopers.ico - - - - - - False - .NET Framework 3.5 SP1 - false - - - - - - - - - - WPFDevelopers.Samples - WPFDevelopers.Samples - - - 1701;1702;CS0067 - - - 1701;1702;CS0067 - - - 1701;1702;CS0067 - - - 1701;1702;CS0067 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj b/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj index 5d34aa5e..8077602b 100644 --- a/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj +++ b/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj @@ -1,185 +1,13 @@  - - WPFDevelopers.Samples - WPFDevelopers.Samples - WinExe - net45;net46;net47;net48;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows;netcoreapp3.0 - true - true - false - Debug;Release;Debug-.NET40;Release-.NET40 - - - ..\WPFDevelopers.Samples.Shared\WPFDevelopers.ico - + + - - - - - False - ..\..\Reference\ICSharpCode.AvalonEdit.dll - - - False - ..\..\Reference\Microsoft.Maps.MapControl.WPF.dll - - - ..\..\Reference\System.Windows.Interactivity.dll - - - - - WPFDevelopers.ico - - - Resources\emoji\发烧.png - - - Resources\emoji\大笑.png - - - Resources\emoji\得意.png - - - Resources\emoji\思考.png - - - Resources\emoji\生病.png - - - Resources\emoji\破涕为笑.png - - - Resources\Assets\Lock.png - - - Resources\Assets\Mail.png - - - Resources\Assets\User.png - - - Resources\Assets\Clear.png - - - Resources\Assets\Background.png - - - Resources\Assets\Logo.png - - - Resources\Fonts\fixedsys.ttf - - - Resources\Images\AMap\Car2.png - - - Resources\Images\AnimationNavigationBar3D\background.png - - - Resources\Images\Breathe\0.jpg - - - Resources\Images\Breathe\1.jpg - - - Resources\Images\Breathe\2.jpg - - - Resources\Images\Chat\Left.jpg - - - Resources\Images\Chat\Right.jpg - - - Resources\Images\Chat\UserImages\jingtao.png - - - Resources\Images\Chat\UserImages\yanjinhua.png - - - Resources\Images\CircularMenu\1.png - - - Resources\Images\CircularMenu\2.png - - - Resources\Images\CircularMenu\3.png - - - Resources\Images\CircularMenu\4.png - - - Resources\Images\CircularMenu\5.png - - - Resources\Images\CircularMenu\6.png - - - Resources\Images\CircularMenu\7.png - - - Resources\Images\CircularMenu\8.png - - - Resources\Images\Craouse\0.jpg - - - Resources\Images\Craouse\1.jpg - - - Resources\Images\Craouse\2.jpg - - - Resources\Images\Craouse\3.jpg - - - Resources\Images\Craouse\4.jpg - - - Resources\Images\Crop\0.jpg - - - Resources\Images\Passwrod\Eye_50px.png - - - Resources\Images\Passwrod\Invisible_50px.png - - - Resources\Images\Passwrod\Lock_48px.png - - - Resources\Images\Snow\SnowTree.png - - - Resources\Images\SpeedRockets\飞机.png - - - Resources\Images\ZooSemy\0.png - - - Resources\Images\ZooSemy\1.png - - - Resources\Audio\HelloWPFDevelopes_en.mp3 - - - Resources\Audio\HelloWPFDevelopes_zh.mp3 - + - - WPFDevelopers.Samples - WPFDevelopers.Samples - - - - - diff --git a/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj b/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj index eaf45a4c..85717037 100644 --- a/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj +++ b/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj @@ -127,9 +127,9 @@ - - - + + + @@ -140,8 +140,9 @@ - + + @@ -361,8 +362,8 @@ ExampleViews\ThermometerExample.xaml - - ExampleViews\TransformThumbExample.xaml + + ExampleViews\TransformLayoutExample.xaml ExampleViews\TimeLineExample.xaml @@ -420,8 +421,8 @@ Controls\Others\OtherControl.xaml - - Controls\ElementAdorner\TransformThumb.xaml + + Controls\TransformLayout\TransformLayout.xaml Controls\ChatEmoji\ChatEmoji.xaml @@ -480,5 +481,8 @@ ExampleViews\TimePickerExample.xaml + + ExampleViews\WaterfallPanelExample.xaml + diff --git a/src/WPFDevelopers.Shared/Controls/IPEditBox/IPEditBox.cs b/src/WPFDevelopers.Shared/Controls/IPEditBox/IPEditBox.cs index a3f81977..a4312177 100644 --- a/src/WPFDevelopers.Shared/Controls/IPEditBox/IPEditBox.cs +++ b/src/WPFDevelopers.Shared/Controls/IPEditBox/IPEditBox.cs @@ -27,7 +27,7 @@ public string Text private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var ctrl = d as IPEditBox; - if (e.NewValue is string text && !ctrl._isChangingText) + if (e.NewValue is string text && !ctrl._isChangingText && ctrl.IsLoaded) ctrl.PasteTextIPTextBox(text); } @@ -74,7 +74,8 @@ public override void OnApplyTemplate() _textBox4.PreviewKeyDown += TextBox_PreviewKeyDown; _textBox4.Loaded -= TextBox_Loaded; _textBox4.Loaded += TextBox_Loaded; - + if (!string.IsNullOrWhiteSpace(Text)) + PasteTextIPTextBox(Text); } private void TextBox1_TextChanged(object sender, TextChangedEventArgs e) @@ -130,12 +131,39 @@ void ClipboardHandle() void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) { + var textBox = sender as TextBox; if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) && e.Key == Key.V) { ClipboardHandle(); _isChangingText = false; e.Handled = true; } + else if(e.Key == Key.Left) + { + if (textBox.CaretIndex == 0 && !IsFirstTextBox(textBox)) + { + GetPreviousTextBox(textBox).Focus(); + } + } + else if (e.Key == Key.Right) + { + if (textBox.CaretIndex == textBox.Text.Length && !IsLastTextBox(textBox)) + { + GetNextTextBox(textBox).Focus(); + } + } + else if (e.Key == Key.Back) + { + if (textBox.CaretIndex == 0 && !IsFirstTextBox(textBox)) + { + var previousTextBox = GetPreviousTextBox(textBox); + if (previousTextBox.Text.Length > 0) + previousTextBox.Text = previousTextBox.Text.Remove(previousTextBox.Text.Length - 1); + previousTextBox.Focus(); + previousTextBox.CaretIndex = previousTextBox.Text.Length; + e.Handled = true; + } + } else if (e.Key == Key.Delete || e.Key == Key.Back) { _isChangingText = true; @@ -144,6 +172,37 @@ void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) _isChangingText = false; } + bool IsFirstTextBox(TextBox textBox) + { + return textBox == _textBox1; + } + + bool IsLastTextBox(TextBox textBox) + { + return textBox == _textBox4; + } + TextBox GetPreviousTextBox(TextBox textBox) + { + if (textBox == _textBox2) + return _textBox1; + else if (textBox == _textBox3) + return _textBox2; + else if (textBox == _textBox4) + return _textBox3; + return textBox; + } + + TextBox GetNextTextBox(TextBox textBox) + { + if (textBox == _textBox1) + return _textBox2; + else if (textBox == _textBox2) + return _textBox3; + else if (textBox == _textBox3) + return _textBox4; + return textBox; + } + void PasteTextIPTextBox(string text) { _textBox1.TextChanged -= TextBox1_TextChanged; diff --git a/src/WPFDevelopers.Shared/Controls/Loading/NormalLoading.cs b/src/WPFDevelopers.Shared/Controls/Loading/NormalLoading.cs index 690101ae..c5ce0a69 100644 --- a/src/WPFDevelopers.Shared/Controls/Loading/NormalLoading.cs +++ b/src/WPFDevelopers.Shared/Controls/Loading/NormalLoading.cs @@ -1,73 +1,61 @@ using System; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; +using Microsoft.Expression.Drawing.Media; +using Microsoft.Expression.Drawing.Shapes; namespace WPFDevelopers.Controls { - [TemplatePart(Name = PART_EillipseTemplateName, Type = typeof(Ellipse))] - public class NormalLoading : Control + [TemplatePart(Name = IndicatorTemplateName, Type = typeof(Arc))] + public class NormalLoading : RangeBase { - private const string PART_EillipseTemplateName = "PART_Ellipse"; + private const string IndicatorTemplateName = "PART_Indicator"; - public static readonly DependencyProperty StrokeValueProperty = - DependencyProperty.Register("StrokeValue", typeof(double), typeof(NormalLoading) - , new PropertyMetadata(0.0, OnStrokeValueChanged)); + public static readonly DependencyProperty ArcThicknessProperty = + DependencyProperty.Register("ArcThickness", typeof(double), typeof(NormalLoading), + new PropertyMetadata(0d)); - public static readonly DependencyProperty StrokeArrayProperty = - DependencyProperty.Register("StrokeArray", typeof(DoubleCollection), typeof(NormalLoading) - , new PropertyMetadata(new DoubleCollection {10, 100})); + public static readonly DependencyProperty IsIndeterminateProperty = + ProgressBar.IsIndeterminateProperty.AddOwner(typeof(NormalLoading), + new FrameworkPropertyMetadata(true)); - private Ellipse _ellipse; + private Arc _indicator; - private Storyboard _storyboard; - - public NormalLoading() + public double ArcThickness { - Loaded += LoadingNew_Loaded; - Unloaded += LoadingNew_Unloaded; + get => (double)GetValue(ArcThicknessProperty); + set => SetValue(ArcThicknessProperty, value); } - - public double StrokeValue + public bool IsIndeterminate { - get => (double) GetValue(StrokeValueProperty); - set => SetValue(StrokeValueProperty, value); - } - - - public DoubleCollection StrokeArray - { - get => (DoubleCollection) GetValue(StrokeArrayProperty); - set => SetValue(StrokeArrayProperty, value); - } - - private static void OnStrokeValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - (d as NormalLoading).StrokeArray = new DoubleCollection {(double) e.NewValue, 100}; - } - - private void LoadingNew_Loaded(object sender, RoutedEventArgs e) - { - _storyboard = new Storyboard(); - _storyboard.RepeatBehavior = RepeatBehavior.Forever; - var animation = new DoubleAnimation(0, Width + 20, new Duration(TimeSpan.FromSeconds(1.0))); - _storyboard.Children.Add(animation); - Storyboard.SetTarget(animation, this); - Storyboard.SetTargetProperty(animation, new PropertyPath(StrokeValueProperty)); - _storyboard.Begin(); + get => (bool)GetValue(IsIndeterminateProperty); + set => SetValue(IsIndeterminateProperty, value); } public override void OnApplyTemplate() { base.OnApplyTemplate(); + _indicator = GetTemplateChild(IndicatorTemplateName) as Arc; + if (_indicator != null) + { + _indicator.StartAngle = 0; + _indicator.EndAngle = 0; + } + SetProgressBarIndicatorAngle(); } - private void LoadingNew_Unloaded(object sender, RoutedEventArgs e) + private void SetProgressBarIndicatorAngle() { - if (_storyboard != null) - _storyboard.Stop(); + if (_indicator == null) return; + var minimum = Minimum; + var maximum = Maximum; + var num = Value; + _indicator.EndAngle = (maximum <= minimum ? 0 : (num - minimum) / (maximum - minimum)) * 360; } } + } \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Controls/Panel/WaterfallPanel.cs b/src/WPFDevelopers.Shared/Controls/Panel/WaterfallPanel.cs new file mode 100644 index 00000000..1f12fb26 --- /dev/null +++ b/src/WPFDevelopers.Shared/Controls/Panel/WaterfallPanel.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Controls; +using System.Windows; + +namespace WPFDevelopers.Controls +{ + public class WaterfallPanel : VirtualizingPanel + { + private List columnHeights = new List(); + protected override Size MeasureOverride(Size availableSize) + { + columnHeights.Clear(); + var panelDesiredSize = new Size(0, 0); + columnHeights = new double[Columns].ToList(); + double currentX = 0; + var width = availableSize.Width / Columns - (Columns * Spacing); + for (int i = 0; i < InternalChildren.Count; i++) + { + var child = InternalChildren[i] as FrameworkElement; + if (child == null) + continue; + child.Measure(availableSize); + child.Width = width; + int columnIndex = i % Columns; + double x = columnIndex != 0 ? currentX + Spacing : 0; + double y = columnHeights[columnIndex]; + if (i >= Columns) + y = y + Spacing; + var size = new Size(width, child.DesiredSize.Height); + child.Arrange(new Rect(new Point(x, y), size)); + panelDesiredSize.Width = Math.Max(panelDesiredSize.Width, x + child.DesiredSize.Width); + panelDesiredSize.Height = Math.Max(panelDesiredSize.Height, y + child.DesiredSize.Height); + currentX = x + size.Width; + if (currentX >= Width) + currentX = 0; + columnHeights[columnIndex] += child.DesiredSize.Height + (i >= Columns ? Spacing : 0); + } + return panelDesiredSize; + } + + public void AddChild(UIElement element) + { + Children.Add(element); + } + + public int Columns + { + get { return (int)GetValue(ColumnsProperty); } + set { SetValue(ColumnsProperty, value); } + } + + public static readonly DependencyProperty ColumnsProperty = + DependencyProperty.Register("Columns", typeof(int), typeof(WaterfallPanel), new PropertyMetadata(3)); + + public double Spacing + { + get { return (double)GetValue(SpacingProperty); } + set { SetValue(SpacingProperty, value); } + } + + public static readonly DependencyProperty SpacingProperty = + DependencyProperty.Register("Spacing", typeof(double), typeof(WaterfallPanel), new PropertyMetadata(5.0)); + } +} diff --git a/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCut.cs b/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCut.cs index 758161c6..62c58ee8 100644 --- a/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCut.cs +++ b/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCut.cs @@ -28,6 +28,8 @@ using Brushes = System.Windows.Media.Brushes; using System.Runtime.InteropServices; using System.Runtime.Versioning; +using System.Drawing.Imaging; +using System.Windows.Threading; namespace WPFDevelopers.Controls { @@ -248,7 +250,7 @@ public override void OnApplyTemplate() _canvas.Width = Screen.AllScreens[ScreenIndex].Bounds.Width; _canvas.Height = Screen.AllScreens[ScreenIndex].Bounds.Height; //_canvas.Background = new ImageBrush(ControlsHelper.Capture()); - _canvas.Background = new ImageBrush(ConvertBitmap(CopyScreen())); + _canvas.Background = new ImageBrush(ImagingHelper.CreateBitmapSourceFromBitmap(CopyScreen())); _rectangleLeft.Width = _canvas.Width; _rectangleLeft.Height = _canvas.Height; _border.Opacity = 0; @@ -289,19 +291,7 @@ private void ScreenCut_Loaded(object sender, RoutedEventArgs e) { } - private BitmapSource ConvertBitmap(Bitmap bitmap) - { - BitmapSource img; - IntPtr hBitmap; - hBitmap = bitmap.GetHbitmap(); - img = Imaging.CreateBitmapSourceFromHBitmap( - hBitmap, - IntPtr.Zero, - Int32Rect.Empty, - BitmapSizeOptions.FromEmptyOptions()); - img.Freeze(); - return img; - } + private ScreenDPI GetScreenDPI(int screenIndex) { ScreenDPI dpi = new ScreenDPI(); diff --git a/src/WPFDevelopers.Shared/Controls/Step/Step.cs b/src/WPFDevelopers.Shared/Controls/Step/Step.cs index 00f11c67..495302b3 100644 --- a/src/WPFDevelopers.Shared/Controls/Step/Step.cs +++ b/src/WPFDevelopers.Shared/Controls/Step/Step.cs @@ -11,6 +11,17 @@ public class Step : ItemsControl { private const string ProgressBarTemplateName = "PART_ProgressBar"; private ProgressBar _progressBar; + + public Orientation Orientation + { + get { return (Orientation)GetValue(OrientationProperty); } + set { SetValue(OrientationProperty, value); } + } + + public static readonly DependencyProperty OrientationProperty = + DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Step), new PropertyMetadata(Orientation.Horizontal)); + + public int StepIndex { get => (int)GetValue(StepIndexProperty); @@ -66,9 +77,10 @@ protected override void OnRender(DrawingContext drawingContext) if (_progressBar == null || count <= 0) return; _progressBar.Maximum = count - 1; _progressBar.Value = StepIndex; - _progressBar.Width = (ActualWidth / count) * (count - 1); - - + if (Orientation == Orientation.Horizontal) + _progressBar.Width = (ActualWidth / count) * (count - 1); + else + _progressBar.Height = (ActualHeight / count) * (count - 1); } protected override bool IsItemItsOwnContainerOverride(object item) { diff --git a/src/WPFDevelopers.Shared/Core/Converts/OrientationConverter.cs b/src/WPFDevelopers.Shared/Core/Converts/OrientationConverter.cs new file mode 100644 index 00000000..11ce80db --- /dev/null +++ b/src/WPFDevelopers.Shared/Core/Converts/OrientationConverter.cs @@ -0,0 +1,23 @@ +using System; +using System.Globalization; +using System.Windows.Controls; +using System.Windows.Data; + +namespace WPFDevelopers.Converts +{ + public class OrientationConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is Orientation orientation) + return (orientation == Orientation.Horizontal) ? Orientation.Vertical : Orientation.Horizontal; + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + +} diff --git a/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs index 4a47cfca..78192910 100644 --- a/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs +++ b/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs @@ -6,7 +6,7 @@ public class ElementHelper : DependencyObject { public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached("CornerRadius", typeof(CornerRadius), typeof(ElementHelper), - new PropertyMetadata(new CornerRadius(3))); + new PropertyMetadata(new CornerRadius(0))); public static readonly DependencyProperty WatermarkProperty = DependencyProperty.RegisterAttached("Watermark", typeof(string), typeof(ElementHelper), diff --git a/src/WPFDevelopers.Shared/Core/Helpers/ImagingHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/ImagingHelper.cs new file mode 100644 index 00000000..43895953 --- /dev/null +++ b/src/WPFDevelopers.Shared/Core/Helpers/ImagingHelper.cs @@ -0,0 +1,58 @@ +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Windows; +using System.Windows.Media.Imaging; +using System.Windows.Threading; + +namespace WPFDevelopers +{ + public static class ImagingHelper + { + public static BitmapSource CreateBitmapSourceFromBitmap(Bitmap bitmap) + { + if (bitmap == null) + throw new ArgumentNullException("bitmap"); + + if (Application.Current.Dispatcher == null) + return null; + try + { + using (MemoryStream memoryStream = new MemoryStream()) + { + bitmap.Save(memoryStream, ImageFormat.Png); + memoryStream.Seek(0, SeekOrigin.Begin); + if (InvokeRequired) + return (BitmapSource)Application.Current.Dispatcher.Invoke( + new Func(CreateBitmapSourceFromBitmap), + DispatcherPriority.Normal, + memoryStream); + return CreateBitmapSourceFromBitmap(memoryStream); + } + } + catch (Exception) + { + return null; + } + } + + private static bool InvokeRequired + { + get { return Dispatcher.CurrentDispatcher != Application.Current.Dispatcher; } + } + + private static BitmapSource CreateBitmapSourceFromBitmap(Stream stream) + { + var bitmapDecoder = BitmapDecoder.Create( + stream, + BitmapCreateOptions.PreservePixelFormat, + BitmapCacheOption.OnLoad); + + var writable = new WriteableBitmap(bitmapDecoder.Frames.Single()); + writable.Freeze(); + return writable; + } + } +} diff --git a/src/WPFDevelopers.Shared/GZ/WPFDevelopersExt.exe.gz b/src/WPFDevelopers.Shared/GZ/WPFDevelopersExt.exe.gz index 3a33babf..797662bf 100644 Binary files a/src/WPFDevelopers.Shared/GZ/WPFDevelopersExt.exe.gz and b/src/WPFDevelopers.Shared/GZ/WPFDevelopersExt.exe.gz differ diff --git a/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml b/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml index ab5fcfeb..42239c33 100644 --- a/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml +++ b/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml @@ -21,7 +21,7 @@ - + diff --git a/src/WPFDevelopers.Shared/Styles/Styles.CheckBox.xaml b/src/WPFDevelopers.Shared/Styles/Styles.CheckBox.xaml index ef6a1ace..02c38767 100644 --- a/src/WPFDevelopers.Shared/Styles/Styles.CheckBox.xaml +++ b/src/WPFDevelopers.Shared/Styles/Styles.CheckBox.xaml @@ -2,6 +2,7 @@ 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:sys="clr-namespace:System;assembly=mscorlib"> @@ -16,6 +17,7 @@ + @@ -32,8 +34,8 @@ Height="16" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" - BorderThickness="1" - CornerRadius="3"> + BorderThickness="{TemplateBinding BorderThickness}" + CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"> @@ -199,9 +200,13 @@ BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" + Effect="{StaticResource WD.PopupShadowDepth}" SnapsToDevicePixels="True" UseLayoutRounding="True" /> - + @@ -261,7 +266,7 @@ - + diff --git a/src/WPFDevelopers.Shared/Styles/Styles.DatePicker.xaml b/src/WPFDevelopers.Shared/Styles/Styles.DatePicker.xaml index 64b0604e..d6dba6cc 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="3" + CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" SnapsToDevicePixels="True" UseLayoutRounding="True"> @@ -453,7 +453,7 @@ BlurRadius="12" Opacity="0.1" ShadowDepth="2" - Color="Black" /> + Color="{DynamicResource WD.BlackColor}" /> diff --git a/src/WPFDevelopers.Shared/Styles/Styles.Expander.xaml b/src/WPFDevelopers.Shared/Styles/Styles.Expander.xaml index 52b9b9b8..acc3832c 100644 --- a/src/WPFDevelopers.Shared/Styles/Styles.Expander.xaml +++ b/src/WPFDevelopers.Shared/Styles/Styles.Expander.xaml @@ -2,6 +2,7 @@ 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:sys="clr-namespace:System;assembly=mscorlib"> @@ -36,7 +37,7 @@ @@ -54,7 +55,7 @@ Height="10" Data="{StaticResource WD.NextGeometry}" RenderTransformOrigin=".5,.5" - Stretch="Fill"> + Stretch="Uniform"> @@ -107,7 +108,12 @@ BorderBrush="{DynamicResource WD.BaseSolidColorBrush}" BorderThickness="0" DockPanel.Dock="Bottom" - SnapsToDevicePixels="True"> + RenderTransformOrigin=".5,0" + SnapsToDevicePixels="True" + Visibility="Collapsed"> + + + + Focusable="False" /> + - + + + + + + + + - - - - - - - - - - - - - - - - - + + + @@ -185,42 +120,26 @@ Fill="{TemplateBinding Foreground}" Placement="Bottom" Visibility="Collapsed" /> - - - - - + + Style="{DynamicResource WD.SliderRepeatButtonStyle}" /> + Style="{StaticResource WD.SliderRepeatButtonStyle}" /> - + @@ -228,166 +147,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -411,41 +190,23 @@ Fill="{TemplateBinding Foreground}" Placement="Right" Visibility="Collapsed" /> - - - - - + Style="{StaticResource WD.SliderRepeatButtonStyle}" /> + Style="{StaticResource WD.SliderRepeatButtonStyle}" /> - + @@ -453,38 +214,33 @@ - - - - - - - + -