chatbubble封装
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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界面
|
||||
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace StormChatWPF.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap LogFormBackground {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("LogFormBackground", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 71 KiB |
@@ -64,6 +64,7 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ScrollViewer.cs" />
|
||||
<Compile Include="UI\ChatBubble.cs" />
|
||||
<Page Include="LogWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -85,11 +86,6 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
@@ -97,7 +93,7 @@
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
@@ -107,9 +103,6 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\LogFormBackground.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interact\Interact.csproj">
|
||||
<Project>{cef054af-95b7-4b88-934e-02705feea554}</Project>
|
||||
@@ -117,10 +110,13 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="UI\登录界面底.png" />
|
||||
<Resource Include="UI\Resources\登录界面底.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="UI\闪电.png" />
|
||||
<Resource Include="UI\Resources\闪电.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="UI\Resources\聊天气泡.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 聊天气泡
|
||||
/// </summary>
|
||||
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
|
||||
};
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="msg">传入消息体</param>
|
||||
/// <param name="alignment">设置水平对齐方式,参数为HorizontalAlignment枚举类型</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Reference in New Issue
Block a user