Listview完整显示用户头像及昵称信息
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
using Interact;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LogWindow : Window
|
||||
{
|
||||
public static LogWindow Instence;
|
||||
public LogWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
using Interact;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LogWindow : Window
|
||||
{
|
||||
public static LogWindow Instence;
|
||||
public LogWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Instence = this;
|
||||
}
|
||||
private void Login_button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Login_button.IsEnabled = false;
|
||||
Chat.Log(AccountBox.Text,passwordBox.Password);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Login_button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Login_button.IsEnabled = false;
|
||||
Chat.Log(AccountBox.Text,passwordBox.Password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
<ColumnDefinition Width="200*"/>
|
||||
<ColumnDefinition Width="200*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListView x:Name="UsersList" Margin="0,0,0,0" IsEnabled="True" SelectionChanged="UsersList_SelectionChanged" Grid.Row="1" Grid.RowSpan="2"/>
|
||||
<ListView x:Name="UsersList" Margin="0,0,0,0" IsEnabled="True" SelectionChanged="UsersList_SelectionChanged" Grid.Row="1" Grid.RowSpan="2">
|
||||
</ListView>
|
||||
<TextBox x:Name="InputBox" Margin="0,0,0,0" TextWrapping="Wrap" Text="" Grid.Row="2" Grid.ColumnSpan="3" Grid.Column="1" />
|
||||
<Button Content="Send" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Bottom" Width="75" Click="Button_Click" Height="20" Grid.Row="2" Grid.Column="3"/>
|
||||
<ScrollViewer Grid.ColumnSpan="3" Grid.Column="1" Margin="0,0,0,0" Grid.Row="1" >
|
||||
@@ -27,6 +28,6 @@
|
||||
<StackPanel x:Name="OutBox" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Column="1" Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Hidden"/>
|
||||
</ScrollViewer.Content>
|
||||
</ScrollViewer>
|
||||
<Button x:Name="button" Content="Button" Grid.Column="2" HorizontalAlignment="Left" Margin="73,31,0,0" Grid.Row="2" VerticalAlignment="Top" Width="75" Click="button_Click_1"/>
|
||||
<Button x:Name="button" Content="更改头像" Grid.Column="1" HorizontalAlignment="Left" Margin="0,64,0,-2" Grid.Row="2" VerticalAlignment="Top" Width="75" Click="button_Click_1"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -1,83 +1,89 @@
|
||||
using Interact;
|
||||
using Interact;
|
||||
using StormChatWPF.UI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace StormChatWPF
|
||||
{
|
||||
/// <summary>
|
||||
/// UserWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public static MainWindow Instence;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadContactsList();
|
||||
Instence = this;
|
||||
}
|
||||
private void LoadContactsList()
|
||||
{
|
||||
if (Chat.ContactsList.Any())
|
||||
{
|
||||
foreach (var user in Chat.ContactsList)
|
||||
{
|
||||
UsersList.Items.Add(user.NickName);
|
||||
}
|
||||
}
|
||||
}//向联系人列表listview中添加元素
|
||||
|
||||
private void UsersList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (UsersList.SelectedItem != null)
|
||||
{
|
||||
Chat.CurrentContact = Chat.ContactsList[UsersList.SelectedIndex];
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Chat.CurrentContact == null)
|
||||
{
|
||||
MessageBox.Show("请选择联系人!");
|
||||
return;
|
||||
}
|
||||
if (InputBox.Text!="")
|
||||
{
|
||||
Chat.chat.SendMessage(InputBox.Text, Chat.CurrentContact);
|
||||
InputBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
internal void ShowMessage(Message message)
|
||||
{
|
||||
if (message.To == User.Me)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(
|
||||
(Action)delegate()
|
||||
{
|
||||
OutBox.Children.Add(new StormChatWPF.UI.ChatBubble(message,HorizontalAlignment.Left));
|
||||
});
|
||||
}//接受到的的消息
|
||||
else
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(
|
||||
(Action)delegate()
|
||||
{
|
||||
OutBox.Children.Add(new StormChatWPF.UI.ChatBubble(message, HorizontalAlignment.Right));
|
||||
});
|
||||
}//发送的的消息
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace StormChatWPF
|
||||
{
|
||||
/// <summary>
|
||||
/// UserWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public static MainWindow Instence;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadContactsList();
|
||||
Instence = this;
|
||||
}
|
||||
private void LoadContactsList()
|
||||
{
|
||||
if (Chat.ContactsList.Any())
|
||||
{
|
||||
foreach (var user in Chat.ContactsList)
|
||||
{
|
||||
if (user.Name !=User.Me.Name)
|
||||
{
|
||||
UsersList.Items.Add(new UI.ContactsInfo(user)
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}//向联系人列表listview中添加元素
|
||||
|
||||
private void UsersList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (UsersList.SelectedItem != null)
|
||||
{
|
||||
Chat.CurrentContact = Chat.ContactsList[UsersList.SelectedIndex];
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Chat.CurrentContact == null)
|
||||
{
|
||||
MessageBox.Show("请选择联系人!");
|
||||
return;
|
||||
}
|
||||
if (InputBox.Text != "")
|
||||
{
|
||||
Chat.chat.SendMessage(InputBox.Text, Chat.CurrentContact);
|
||||
InputBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
internal void ShowMessage(Message message)
|
||||
{
|
||||
if (message.To == User.Me)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(
|
||||
(Action)delegate ()
|
||||
{
|
||||
OutBox.Children.Add(new StormChatWPF.UI.ChatBubble(message, HorizontalAlignment.Left));
|
||||
});
|
||||
}//接受到的的消息
|
||||
else
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(
|
||||
(Action)delegate ()
|
||||
{
|
||||
OutBox.Children.Add(new StormChatWPF.UI.ChatBubble(message, HorizontalAlignment.Right));
|
||||
});
|
||||
}//发送的的消息
|
||||
}//将消息展现于UI界面
|
||||
|
||||
private void button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(
|
||||
(Action)delegate ()
|
||||
App.Current.Dispatcher.Invoke(
|
||||
(Action)delegate ()
|
||||
{
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<Compile Include="UI\Contacts.xaml.cs">
|
||||
<DependentUpon>Contacts.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\UserInfo.cs" />
|
||||
<Compile Include="UI\ContactsInfo.cs" />
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
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">
|
||||
d:DesignHeight="40" d:DesignWidth="120" HorizontalAlignment="Stretch">
|
||||
<Grid>
|
||||
<WrapPanel Height="40" VerticalAlignment="Stretch">
|
||||
<Image x:Name="HeadPicture" HorizontalAlignment="Left" Height="40" Width="40"/>
|
||||
<Label x:Name="text" Content="Label" Height="40" Width="80"/>
|
||||
<Label x:Name="text" Content="Label" Height="40" FontSize="14" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</WrapPanel>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace StormChatWPF.UI
|
||||
{
|
||||
internal class UserInfo : Contacts
|
||||
internal class ContactsInfo : Contacts
|
||||
{
|
||||
public UserInfo(User user)
|
||||
public ContactsInfo(User user)
|
||||
{
|
||||
image.BeginInit();
|
||||
image.StreamSource = user.Photo;
|
||||
Reference in New Issue
Block a user