add role property

This commit is contained in:
NaBian committed 2019-01-29 00:16:09 +08:00
1 parent 8c372510f5
commit 2c0889f64b
24 files changed
+284 -87

No files matched your search

+12 -5
View File
@@ -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);
}
}
+14 -7
View File
@@ -79,6 +79,16 @@ var windowList = new List<string>
"CommonWindow",
"CustomNonClientAreaWindow"
};
var messageList = new List<string>
{
"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);
}
<#}#>
}
}
@@ -0,0 +1,9 @@
namespace HandyControlDemo.Data
{
public class ChatInfoModel
{
public string Message { get; set; }
public string SenderId { get; set; }
}
}
+19 -8
View File
@@ -103,6 +103,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>MessageToken.tt</DependentUpon>
</Compile>
<Compile Include="Data\Model\ChatInfoModel.cs" />
<Compile Include="Data\Model\ContributorModel.cs" />
<Compile Include="Data\Model\DemoDataModel.cs" />
<Compile Include="Data\Model\StepBarDemoModel.cs" />
@@ -123,6 +124,9 @@
<Compile Include="UserControl\Basic\Avatar.xaml.cs">
<DependentUpon>Avatar.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Basic\ChatBox.xaml.cs">
<DependentUpon>ChatBox.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Controls\AnimationPathDemoCtl.xaml.cs">
<DependentUpon>AnimationPathDemoCtl.xaml</DependentUpon>
</Compile>
@@ -327,15 +331,16 @@
<Compile Include="UserControl\Styles\TreeViewDemoCtl.xaml.cs">
<DependentUpon>TreeViewDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModel\ComboBoxDemoViewModel.cs" />
<Compile Include="ViewModel\ContributorsViewModel.cs" />
<Compile Include="ViewModel\GrowlDemoViewModel.cs" />
<Compile Include="ViewModel\ImageBrowserDemoViewModel.cs" />
<Compile Include="ViewModel\MainViewModel.cs" />
<Compile Include="ViewModel\PaginationDemoViewModel.cs" />
<Compile Include="ViewModel\StepBarDemoViewModel.cs" />
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
<Compile Include="ViewModel\Main\ContributorsViewModel.cs" />
<Compile Include="ViewModel\Controls\GrowlDemoViewModel.cs" />
<Compile Include="ViewModel\Controls\ImageBrowserDemoViewModel.cs" />
<Compile Include="ViewModel\Main\MainViewModel.cs" />
<Compile Include="ViewModel\Controls\PaginationDemoViewModel.cs" />
<Compile Include="ViewModel\Controls\StepBarDemoViewModel.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
<Compile Include="ViewModel\WindowDemoViewModel.cs" />
<Compile Include="ViewModel\Controls\WindowDemoViewModel.cs" />
<Compile Include="Window\AboutWindow.xaml.cs">
<DependentUpon>AboutWindow.xaml</DependentUpon>
</Compile>
@@ -411,6 +416,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Basic\ChatBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Controls\AnimationPathDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -725,6 +734,8 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MessageToken.cs</LastGenOutput>
</Content>
<Resource Include="Resources\Img\Chat\chat_back1.jpg" />
<Resource Include="Resources\Img\Chat\chat_back2.jpg" />
<Resource Include="Resources\Img\LeftMainContent\Bubble_16xLG.png" />
<Resource Include="Resources\Img\LeftMainContent\Transfer_16x.png" />
<Resource Include="Resources\Img\LeftMainContent\ProgressButton_16x.png" />
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@@ -0,0 +1,48 @@
<UserControl x:Class="HandyControlDemo.UserControl.ChatBox"
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:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:command="http://www.galasoft.ch/mvvmlight"
mc:Ignorable="d"
Height="486"
Effect="{StaticResource EffectShadow5}"
Background="{DynamicResource RegionBrush}"
DataContext="{Binding ChatBox,Source={StaticResource Locator}}"
Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel>
<controls:ChatBubble Role="Receiver" Content="123123123123"/>
<controls:ChatBubble Content="123123123123"/>
<controls:ChatBubble Role="Receiver">
<Image Width="200" Source="/HandyControlDemo;component/Resources/Img/b1.jpg"/>
</controls:ChatBubble>
</StackPanel>
<Border Background="{DynamicResource DarkDefaultBrush}" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ToggleButton Name="ToggleButtonAudio" controls:BorderElement.CornerRadius="15" Width="30" Height="30" Padding="7" Margin="6" controls:IconSwitchElement.Geometry="{StaticResource AudioGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource KeyboardGeometry}" Style="{StaticResource ToggleButtonIcon}"/>
<Button Command="{Binding OpenImageCmd}" Grid.Column="2" Margin="6,0,6,0" controls:BorderElement.CornerRadius="15" Width="30" Height="30" Padding="7" controls:IconElement.Geometry="{StaticResource ImageGeometry}"/>
<TextBox Grid.Column="1" Text="{Binding ChatString}" Visibility="{Binding IsChecked,ElementName=ToggleButtonAudio,Converter={StaticResource Boolean2VisibilityReConverter}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyDown">
<command:EventToCommand Command="{Binding SendStringCmd}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<Button Grid.Column="1" Visibility="{Binding IsChecked,ElementName=ToggleButtonAudio,Converter={StaticResource Boolean2VisibilityConverter}}" Content="{x:Static langs:Lang.PushToTalk}" HorizontalAlignment="Stretch"/>
</Grid>
</Border>
</Grid>
</UserControl>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl
{
public partial class ChatBox
{
public ChatBox()
{
InitializeComponent();
}
}
}
@@ -1,54 +1,20 @@
<UserControl x:Class="HandyControlDemo.UserControl.ChatBubbleDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
Background="{DynamicResource RegionBrush}">
<ContentControl>
<UniformGrid Columns="2" Width="600" Height="486">
<Border BorderThickness="0,0,1,0" BorderBrush="{DynamicResource BorderBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Background="{DynamicResource DarkDefaultBrush}" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ToggleButton Name="ToggleButtonAudioLeft" controls:BorderElement.CornerRadius="15" Width="30" Height="30" Padding="7" Margin="6,6,0,6" controls:IconSwitchElement.Geometry="{StaticResource AudioGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource KeyboardGeometry}" Style="{StaticResource ToggleButtonIcon}"/>
<Button Grid.Column="1" Margin="6,6,0,6" controls:BorderElement.CornerRadius="15" Width="30" Height="30" Padding="7" controls:IconElement.Geometry="{StaticResource ImageGeometry}"/>
<TextBox Grid.Column="2" Margin="6,0,6,0" Visibility="{Binding IsChecked,ElementName=ToggleButtonAudioLeft,Converter={StaticResource Boolean2VisibilityReConverter}}"/>
<Button Grid.Column="2" Margin="6,0,6,0" Visibility="{Binding IsChecked,ElementName=ToggleButtonAudioLeft,Converter={StaticResource Boolean2VisibilityConverter}}" Content="{x:Static langs:Lang.PushToTalk}" Width="{x:Static system:Double.NaN}" HorizontalAlignment="Stretch"/>
</Grid>
</Border>
</Grid>
</Border>
<Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Background="{DynamicResource DarkDefaultBrush}" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ToggleButton Name="ToggleButtonAudioRight" controls:BorderElement.CornerRadius="15" Width="30" Height="30" Padding="7" Margin="6,6,0,6" controls:IconSwitchElement.Geometry="{StaticResource AudioGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource KeyboardGeometry}" Style="{StaticResource ToggleButtonIcon}"/>
<Button Grid.Column="1" Margin="6,6,0,6" controls:BorderElement.CornerRadius="15" Width="30" Height="30" Padding="7" controls:IconElement.Geometry="{StaticResource ImageGeometry}"/>
<TextBox Grid.Column="2" Margin="6,0,6,0" Visibility="{Binding IsChecked,ElementName=ToggleButtonAudioRight,Converter={StaticResource Boolean2VisibilityReConverter}}"/>
<Button Grid.Column="2" Margin="6,0,6,0" Visibility="{Binding IsChecked,ElementName=ToggleButtonAudioRight,Converter={StaticResource Boolean2VisibilityConverter}}" Content="{x:Static langs:Lang.PushToTalk}" Width="{x:Static system:Double.NaN}" HorizontalAlignment="Stretch"/>
</Grid>
</Border>
</Grid>
</Grid>
</UniformGrid>
<StackPanel Orientation="Horizontal" Margin="32">
<userControl:ChatBox>
<userControl:ChatBox.Background>
<ImageBrush ImageSource="/HandyControlDemo;component/Resources/Img/Chat/chat_back1.jpg" Stretch="Uniform"/>
</userControl:ChatBox.Background>
</userControl:ChatBox>
<userControl:ChatBox Margin="32,0,0,0">
<userControl:ChatBox.Background>
<ImageBrush ImageSource="/HandyControlDemo;component/Resources/Img/Chat/chat_back2.jpg" Stretch="Uniform"/>
</userControl:ChatBox.Background>
</userControl:ChatBox>
</StackPanel>
</ContentControl>
</UserControl>
@@ -0,0 +1,83 @@
using System;
using System.IO;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging;
using HandyControlDemo.Data;
using Microsoft.Win32;
namespace HandyControlDemo.ViewModel
{
public class ChatBoxViewModel : ViewModelBase
{
private readonly string _id = Guid.NewGuid().ToString();
public ChatBoxViewModel()
{
Messenger.Default.Register<ChatInfoModel>(this, MessageToken.SendChatString, ReceiveString);
Messenger.Default.Register<ChatInfoModel>(this, MessageToken.SendChatImage, ReceiveImage);
Messenger.Default.Register<ChatInfoModel>(this, MessageToken.SendChatAudio, ReceiveAudio);
}
private void ReceiveString(ChatInfoModel info)
{
if (!_id.Equals(info.SenderId)) return;
}
private void ReceiveImage(ChatInfoModel info)
{
if (!_id.Equals(info.SenderId)) return;
}
private void ReceiveAudio(ChatInfoModel info)
{
if (!_id.Equals(info.SenderId)) return;
}
private string _chatString;
public string ChatString
{
get => _chatString;
set => Set(ref _chatString, value);
}
public RelayCommand<KeyEventArgs> SendStringCmd => new Lazy<RelayCommand<KeyEventArgs>>(() =>
new RelayCommand<KeyEventArgs>(SendString)).Value;
private void SendString(KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
if (string.IsNullOrEmpty(ChatString)) return;
Messenger.Default.Send(new ChatInfoModel
{
Message = ChatString,
SenderId = _id
}, MessageToken.SendChatString);
ChatString = string.Empty;
}
}
public RelayCommand OpenImageCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(OpenImage)).Value;
private void OpenImage()
{
var dialog = new OpenFileDialog();
if (dialog.ShowDialog() == true)
{
var fileName = dialog.FileName;
if (File.Exists(fileName))
{
Messenger.Default.Send(new ChatInfoModel
{
Message = fileName,
SenderId = _id
}, MessageToken.SendChatImage);
}
}
}
}
}
@@ -22,6 +22,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register<ContributorsViewModel>();
SimpleIoc.Default.Register<StepBarDemoViewModel>();
SimpleIoc.Default.Register<PaginationDemoViewModel>();
SimpleIoc.Default.Register<ChatBoxViewModel>();
}
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
@@ -45,6 +46,8 @@ namespace HandyControlDemo.ViewModel
public PaginationDemoViewModel PaginationDemo => ServiceLocator.Current.GetInstance<PaginationDemoViewModel>();
public ChatBoxViewModel ChatBox => ServiceLocator.Current.GetInstance<ChatBoxViewModel>();
#endregion
}
}