用户头像显示

This commit is contained in:
Kaniu Tayou
2018-12-25 22:45:58 +08:00
parent 8ec162c5df
commit 96c128b295
13 changed files with 137 additions and 102 deletions
@@ -5,7 +5,7 @@ using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace StormChatWPF
namespace StormChatWPF.UI
{
/// <summary>
/// 聊天气泡
@@ -0,0 +1,17 @@
<UserControl x:Class="StormChatWPF.UI.Contacts"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:StormChatWPF.UI"
mc:Ignorable="d"
d:DesignHeight="40" d:DesignWidth="120">
<Grid>
<WrapPanel HorizontalAlignment="Left" Height="40" VerticalAlignment="Stretch" Width="120">
<Image x:Name="HeadPicture" HorizontalAlignment="Left" Height="40" Width="40"/>
<Label x:Name="text" Content="Label" Height="40" Width="80"/>
</WrapPanel>
</Grid>
</UserControl>
@@ -0,0 +1,27 @@
using System;
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 StormChatWPF.UI
{
/// <summary>
/// Contacts.xaml 的交互逻辑
/// </summary>
public partial class Contacts : UserControl
{
public Contacts()
{
InitializeComponent();
}
}
}
@@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Media;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
namespace StormChatWPF
{
class HeadPicture : Image
{
public HeadPicture(/*Stream imgstream*/)
{
FileStream fileStream = new FileStream(@"C:\Users\Administrator\Desktop\闪电.png", FileMode.Open);
Source = new BitmapImage()
{
StreamSource = fileStream
};
//border.Content = this;
}
private Label border = new Label()
{
};
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

@@ -1,30 +1,20 @@
using Interact;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;
using System.Windows.Media.Imaging;
using System.IO;
namespace StormChatWPF
namespace StormChatWPF.UI
{
class UserInfo:Label
internal class UserInfo : Contacts
{
public UserInfo(User user)
{
}
private Image headpicture = new Image
{
HorizontalAlignment = HorizontalAlignment.Left
};
private TextBlock UserNmae=new TextBlock
{
FontFamily = new FontFamily("Comic Sans MS"),
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment=VerticalAlignment.Top
};
image.BeginInit();
image.StreamSource = user.Photo;
User.DefaultPhoto.Seek(0, SeekOrigin.Begin);
image.EndInit();
HeadPicture.Source = image;
text.Content = user.NickName;
}
BitmapImage image = new BitmapImage();
}
}