diff --git a/StormChat.sln b/StormChat.sln index 335c8d2..a6d4cca 100644 --- a/StormChat.sln +++ b/StormChat.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.28010.2041 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StormChat", "StormChat\StormChat.csproj", "{01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interact", "Interact\Interact.csproj", "{CEF054AF-95B7-4B88-934E-02705FEEA554}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StormChatWPF", "StormChatWPF\StormChatWPF.csproj", "{CF4D6BE0-A862-401F-A3A6-4FDAC32F5B70}" @@ -19,18 +17,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Debug|x64.ActiveCfg = Debug|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Debug|x64.Build.0 = Debug|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Debug|x86.ActiveCfg = Debug|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Debug|x86.Build.0 = Debug|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Release|Any CPU.Build.0 = Release|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Release|x64.ActiveCfg = Release|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Release|x64.Build.0 = Release|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Release|x86.ActiveCfg = Release|Any CPU - {01903AE6-FDB9-4FF4-8BE7-FDA238CEB5AD}.Release|x86.Build.0 = Release|Any CPU {CEF054AF-95B7-4B88-934E-02705FEEA554}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CEF054AF-95B7-4B88-934E-02705FEEA554}.Debug|Any CPU.Build.0 = Debug|Any CPU {CEF054AF-95B7-4B88-934E-02705FEEA554}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/StormChatWPF/MainWindow.xaml.cs b/StormChatWPF/MainWindow.xaml.cs index b512576..8dcbe1d 100644 --- a/StormChatWPF/MainWindow.xaml.cs +++ b/StormChatWPF/MainWindow.xaml.cs @@ -59,22 +59,7 @@ namespace StormChatWPF App.Current.Dispatcher.Invoke( delegate () { - TextBlock text = new TextBlock - { - MaxWidth = 400, - MinWidth = 10, - MinHeight = 30, - Text = message.Text, - TextWrapping = TextWrapping.Wrap, - FontFamily = new FontFamily("Comic Sans MS"), - HorizontalAlignment = HorizontalAlignment.Left - }; - Label label = new Label - { - HorizontalAlignment = HorizontalAlignment.Left, - Content = text - }; - OutBox.Children.Add(label); + OutBox.Children.Add(new ChatBubble(message,HorizontalAlignment.Left)); }); }//接受到的的消息 else @@ -82,23 +67,7 @@ namespace StormChatWPF App.Current.Dispatcher.Invoke( delegate () { - - TextBlock text = new TextBlock - { - MaxWidth = 400, - MinWidth = 10, - MinHeight = 30, - Text = message.Text, - TextWrapping = TextWrapping.Wrap, - FontFamily = new FontFamily("Comic Sans MS"), - HorizontalAlignment = HorizontalAlignment.Right - }; - Label label = new Label - { - HorizontalAlignment=HorizontalAlignment.Right, - Content=text - }; - OutBox.Children.Add(label); + OutBox.Children.Add(new ChatBubble(message,HorizontalAlignment.Right)); }); }//发送的的消息 }//将消息展现于UI界面 diff --git a/StormChatWPF/Properties/Resources.Designer.cs b/StormChatWPF/Properties/Resources.Designer.cs deleted file mode 100644 index f0f2a03..0000000 --- a/StormChatWPF/Properties/Resources.Designer.cs +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace StormChatWPF.Properties { - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StormChatWPF.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 重写当前线程的 CurrentUICulture 属性 - /// 重写当前线程的 CurrentUICulture 属性。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 - /// - internal static System.Drawing.Bitmap LogFormBackground { - get { - object obj = ResourceManager.GetObject("LogFormBackground", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/StormChatWPF/Resources/LogFormBackground.jpg b/StormChatWPF/Resources/LogFormBackground.jpg deleted file mode 100644 index ea8dcfe..0000000 Binary files a/StormChatWPF/Resources/LogFormBackground.jpg and /dev/null differ diff --git a/StormChatWPF/StormChatWPF.csproj b/StormChatWPF/StormChatWPF.csproj index ca29bee..c83f885 100644 --- a/StormChatWPF/StormChatWPF.csproj +++ b/StormChatWPF/StormChatWPF.csproj @@ -64,6 +64,7 @@ MainWindow.xaml + MSBuild:Compile Designer @@ -85,11 +86,6 @@ Code - - True - True - Resources.resx - True Settings.settings @@ -97,7 +93,7 @@ ResXFileCodeGenerator - Resources.Designer.cs + Designer SettingsSingleFileGenerator @@ -107,9 +103,6 @@ - - - {cef054af-95b7-4b88-934e-02705feea554} @@ -117,10 +110,13 @@ - + - + + + + \ No newline at end of file diff --git a/StormChatWPF/UI/ChatBubble.cs b/StormChatWPF/UI/ChatBubble.cs new file mode 100644 index 0000000..232dbee --- /dev/null +++ b/StormChatWPF/UI/ChatBubble.cs @@ -0,0 +1,41 @@ +using Interact; +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace StormChatWPF +{ + /// + /// 聊天气泡 + /// + class ChatBubble:Label + { + TextBlock text = new TextBlock() + { + MaxWidth = 400, + MinWidth = 10, + MinHeight = 20, + TextWrapping = TextWrapping.Wrap, + FontFamily = new FontFamily("Comic Sans MS"), + HorizontalAlignment = HorizontalAlignment.Right, + VerticalAlignment = VerticalAlignment.Bottom + }; + /// + /// + /// + /// 传入消息体 + /// 设置水平对齐方式,参数为HorizontalAlignment枚举类型 + public ChatBubble(Message msg,HorizontalAlignment alignment) + { + Background = new ImageBrush() + { + ImageSource=new BitmapImage(new Uri("pack://application..../UI/Resource/聊天气泡.png")) + }; + HorizontalAlignment = alignment; + text.Text = msg.Text; + Content = text; + } + } +} diff --git a/StormChatWPF/UI/登录界面底.png b/StormChatWPF/UI/Resources/登录界面底.png similarity index 100% rename from StormChatWPF/UI/登录界面底.png rename to StormChatWPF/UI/Resources/登录界面底.png diff --git a/StormChatWPF/UI/Resources/聊天气泡.png b/StormChatWPF/UI/Resources/聊天气泡.png new file mode 100644 index 0000000..65597c6 Binary files /dev/null and b/StormChatWPF/UI/Resources/聊天气泡.png differ diff --git a/StormChatWPF/UI/闪电.png b/StormChatWPF/UI/Resources/闪电.png similarity index 100% rename from StormChatWPF/UI/闪电.png rename to StormChatWPF/UI/Resources/闪电.png