diff --git a/HandyControl/Controls/Input/SearchBar.cs b/HandyControl/Controls/Input/SearchBar.cs index d37ab5b1..6243b3c8 100644 --- a/HandyControl/Controls/Input/SearchBar.cs +++ b/HandyControl/Controls/Input/SearchBar.cs @@ -39,6 +39,7 @@ namespace HandyControl.Controls if (_textBox != null) { _textBox.TextChanged -= TextBox_TextChanged; + _textBox.KeyDown -= TextBox_KeyDown; } base.OnApplyTemplate(); diff --git a/HandyControl/Controls/Other/ChatBubble.cs b/HandyControl/Controls/Other/ChatBubble.cs index 497897d0..1ef28aa1 100644 --- a/HandyControl/Controls/Other/ChatBubble.cs +++ b/HandyControl/Controls/Other/ChatBubble.cs @@ -1,14 +1,18 @@ -using System.Windows.Controls; +using System.Windows; +using System.Windows.Controls; +using HandyControl.Data; namespace HandyControl.Controls { public class ChatBubble : ContentControl { + public static readonly DependencyProperty RoleProperty = DependencyProperty.Register( + "Role", typeof(ChatRoleType), typeof(ChatBubble), new PropertyMetadata(default(ChatRoleType))); - - //public ChatBubble(object message) - //{ - - //} + public ChatRoleType Role + { + get => (ChatRoleType) GetValue(RoleProperty); + set => SetValue(RoleProperty, value); + } } } \ No newline at end of file diff --git a/HandyControl/Data/Enum/ChatRoleType.cs b/HandyControl/Data/Enum/ChatRoleType.cs new file mode 100644 index 00000000..e9fadbfe --- /dev/null +++ b/HandyControl/Data/Enum/ChatRoleType.cs @@ -0,0 +1,8 @@ +namespace HandyControl.Data +{ + public enum ChatRoleType + { + Sender, + Receiver + } +} \ No newline at end of file diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index 01dcb6c7..24c5dc99 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -157,6 +157,7 @@ + diff --git a/HandyControl/Themes/Styles/Base/ChatBubbleBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ChatBubbleBaseStyle.xaml index 217d9b96..8b9853f7 100644 --- a/HandyControl/Themes/Styles/Base/ChatBubbleBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/ChatBubbleBaseStyle.xaml @@ -7,23 +7,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/Data/MessageToken.cs b/HandyControlDemo/Data/MessageToken.cs index ff8d59f7..5cebeecb 100644 --- a/HandyControlDemo/Data/MessageToken.cs +++ b/HandyControlDemo/Data/MessageToken.cs @@ -138,12 +138,19 @@ public static readonly string CustomNonClientAreaWindow = nameof(CustomNonClientAreaWindow); - public static readonly string LoadShowContent = nameof(LoadShowContent); + public static readonly string LoadShowContent = nameof(LoadShowContent); - public static readonly string FullSwitch = nameof(FullSwitch); + public static readonly string FullSwitch = nameof(FullSwitch); - public static readonly string ContributorsView = nameof(ContributorsView); + public static readonly string ContributorsView = nameof(ContributorsView); - public static readonly string ClearLeftSelected = nameof(ClearLeftSelected); - } + public static readonly string ClearLeftSelected = nameof(ClearLeftSelected); + + public static readonly string SendChatString = nameof(SendChatString); + + public static readonly string SendChatImage = nameof(SendChatImage); + + public static readonly string SendChatAudio = nameof(SendChatAudio); + + } } \ No newline at end of file diff --git a/HandyControlDemo/Data/MessageToken.tt b/HandyControlDemo/Data/MessageToken.tt index 4fcd0b93..7155e49d 100644 --- a/HandyControlDemo/Data/MessageToken.tt +++ b/HandyControlDemo/Data/MessageToken.tt @@ -79,6 +79,16 @@ var windowList = new List "CommonWindow", "CustomNonClientAreaWindow" }; +var messageList = new List +{ + "LoadShowContent", + "FullSwitch", + "ContributorsView", + "ClearLeftSelected", + "SendChatString", + "SendChatImage", + "SendChatAudio" +}; #> namespace HandyControlDemo.Data { @@ -96,12 +106,9 @@ namespace HandyControlDemo.Data public static readonly string <#=item#> = nameof(<#=item#>); <#}#> - public static readonly string LoadShowContent = nameof(LoadShowContent); +<#foreach(var item in messageList){#> + public static readonly string <#=item#> = nameof(<#=item#>); - public static readonly string FullSwitch = nameof(FullSwitch); - - public static readonly string ContributorsView = nameof(ContributorsView); - - public static readonly string ClearLeftSelected = nameof(ClearLeftSelected); - } + <#}#> +} } \ No newline at end of file diff --git a/HandyControlDemo/Data/Model/ChatInfoModel.cs b/HandyControlDemo/Data/Model/ChatInfoModel.cs new file mode 100644 index 00000000..9e3b795f --- /dev/null +++ b/HandyControlDemo/Data/Model/ChatInfoModel.cs @@ -0,0 +1,9 @@ +namespace HandyControlDemo.Data +{ + public class ChatInfoModel + { + public string Message { get; set; } + + public string SenderId { get; set; } + } +} \ No newline at end of file diff --git a/HandyControlDemo/HandyControlDemo.csproj b/HandyControlDemo/HandyControlDemo.csproj index 77747122..a26d040d 100644 --- a/HandyControlDemo/HandyControlDemo.csproj +++ b/HandyControlDemo/HandyControlDemo.csproj @@ -103,6 +103,7 @@ True MessageToken.tt + @@ -123,6 +124,9 @@ Avatar.xaml + + ChatBox.xaml + AnimationPathDemoCtl.xaml @@ -327,15 +331,16 @@ TreeViewDemoCtl.xaml - - - - - - - + + + + + + + + - + AboutWindow.xaml @@ -411,6 +416,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -725,6 +734,8 @@ TextTemplatingFileGenerator MessageToken.cs + + diff --git a/HandyControlDemo/Resources/Img/Chat/chat_back1.jpg b/HandyControlDemo/Resources/Img/Chat/chat_back1.jpg new file mode 100644 index 00000000..45672774 Binary files /dev/null and b/HandyControlDemo/Resources/Img/Chat/chat_back1.jpg differ diff --git a/HandyControlDemo/Resources/Img/Chat/chat_back2.jpg b/HandyControlDemo/Resources/Img/Chat/chat_back2.jpg new file mode 100644 index 00000000..f7120af2 Binary files /dev/null and b/HandyControlDemo/Resources/Img/Chat/chat_back2.jpg differ diff --git a/HandyControlDemo/UserControl/Basic/ChatBox.xaml b/HandyControlDemo/UserControl/Basic/ChatBox.xaml new file mode 100644 index 00000000..a9c78463 --- /dev/null +++ b/HandyControlDemo/UserControl/Basic/ChatBox.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + +