添加完成文件列表显示,接下载准备实现文件删除和下载。
This commit is contained in:
@@ -163,6 +163,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<!--左侧的侧边栏预告-->
|
||||||
<Grid Width="180" DockPanel.Dock="Left">
|
<Grid Width="180" DockPanel.Dock="Left">
|
||||||
<GroupBox Header="系统信息" Margin="0,0,0,0">
|
<GroupBox Header="系统信息" Margin="0,0,0,0">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ namespace 软件系统客户端Wpf
|
|||||||
private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
//点击了文件查看
|
//点击了文件查看
|
||||||
MessageBox.Show("点击了文件");
|
SetShowRenderControl(UIControl_Files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -646,6 +646,7 @@ namespace 软件系统客户端Wpf
|
|||||||
|
|
||||||
private UserHome UIControl_Home { get; set; }
|
private UserHome UIControl_Home { get; set; }
|
||||||
|
|
||||||
|
private UserFileRender UIControl_Files { get; set; }
|
||||||
|
|
||||||
private UserPaletteSelector UIControl_Palette { get; set; }
|
private UserPaletteSelector UIControl_Palette { get; set; }
|
||||||
|
|
||||||
@@ -690,6 +691,8 @@ namespace 软件系统客户端Wpf
|
|||||||
UIControl_Palette = new UserPaletteSelector() { DataContext = new PaletteSelectorViewModel() };
|
UIControl_Palette = new UserPaletteSelector() { DataContext = new PaletteSelectorViewModel() };
|
||||||
all_main_render.Add(UIControl_Palette);
|
all_main_render.Add(UIControl_Palette);
|
||||||
|
|
||||||
|
UIControl_Files = new UserFileRender();
|
||||||
|
all_main_render.Add(UIControl_Files);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
45
软件系统客户端Wpf/Views/UserFileRender.xaml
Normal file
45
软件系统客户端Wpf/Views/UserFileRender.xaml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<UserControl x:Class="软件系统客户端Wpf.Views.UserFileRender"
|
||||||
|
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:软件系统客户端Wpf.Views"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="400" d:DesignWidth="800">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="*"></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Grid Grid.Row="0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="auto"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="auto"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="auto"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="auto"></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Button Style="{StaticResource MaterialDesignRaisedLightButton}" Margin="0,0, 5 5" Width="100"
|
||||||
|
x:Name="Button_FileUpload" Click="Button_FileUpload_Click">
|
||||||
|
上传
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Column="1" Style="{StaticResource MaterialDesignRaisedLightButton}" Margin="0,0, 5 5" Width="100"
|
||||||
|
x:Name="Button_FileRefresh" Click="Button_FileRefresh_Click">
|
||||||
|
刷新
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="3" VerticalAlignment="Center" FontSize="15">搜索:</TextBlock>
|
||||||
|
<TextBox Grid.Column="4" Width="200" x:Name="FileSearchFilter" TextChanged="FileSearchFilter_TextChanged"></TextBox>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Border Grid.Row="1" BorderThickness="0,1,0,0" Margin="0,5,0,0" BorderBrush="{DynamicResource MaterialDesignDivider}">
|
||||||
|
<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||||
|
<StackPanel Margin="0,5,5,0" x:Name="FileListControl" ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
124
软件系统客户端Wpf/Views/UserFileRender.xaml.cs
Normal file
124
软件系统客户端Wpf/Views/UserFileRender.xaml.cs
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
using ClientsLibrary;
|
||||||
|
using CommonLibrary;
|
||||||
|
using HslCommunication;
|
||||||
|
using HslCommunication.Enthernet;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
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 软件系统客户端Wpf.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UserFileRender.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class UserFileRender : UserControl
|
||||||
|
{
|
||||||
|
public UserFileRender()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FileSearchFilter_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
//搜索时触发的数据
|
||||||
|
if (!string.IsNullOrEmpty(FileSearchFilter.Text))
|
||||||
|
{
|
||||||
|
string pattern = FileSearchFilter.Text;
|
||||||
|
SetFilesShow(Cache_Files.Where(f =>
|
||||||
|
f.FileName.Contains(pattern) ||
|
||||||
|
f.FileNote.Contains(pattern) ||
|
||||||
|
f.UploadName.Contains(pattern)).ToList());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetFilesShow(Cache_Files);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_FileUpload_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
//上传数据,先对权限进行验证
|
||||||
|
if (UserClient.UserAccount.Grade < AccountGrade.Technology)
|
||||||
|
{
|
||||||
|
MessageBox.Show("权限不够!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (FormSimplyFileUpload upload = new FormSimplyFileUpload(
|
||||||
|
UserClient.ServerIp,
|
||||||
|
CommonLibrary.CommonLibrary.Port_Share_File,
|
||||||
|
UserClient.UserAccount.UserName))
|
||||||
|
{
|
||||||
|
upload.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_FileRefresh_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
//向服务器请求数据
|
||||||
|
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求文件);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
Cache_Files = JArray.Parse(result.Content).ToObject<List<HslSoftFile>>();
|
||||||
|
SetFilesShow(Cache_Files);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(result.ToMessageShowString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdateFiles()
|
||||||
|
{
|
||||||
|
Button_FileRefresh_Click(null, new RoutedEventArgs());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClearControls()
|
||||||
|
{
|
||||||
|
FileListControl.Children.Clear();
|
||||||
|
//while (FilesControls.Count > 0)
|
||||||
|
//{
|
||||||
|
// FilesControls.Pop().Dispose();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetFilesShow(List<HslSoftFile> files)
|
||||||
|
{
|
||||||
|
//清楚缓存
|
||||||
|
ClearControls();
|
||||||
|
if (files?.Count > 0 && FileListControl.ActualWidth > 20)
|
||||||
|
{
|
||||||
|
//添加子控件
|
||||||
|
foreach (var m in files)
|
||||||
|
{
|
||||||
|
UserFileRenderItem item = new UserFileRenderItem();
|
||||||
|
FileListControl.Children.Add(item);
|
||||||
|
item.SetFile(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所有文件信息的缓存,以支持直接的搜索
|
||||||
|
/// </summary>
|
||||||
|
private List<HslSoftFile> Cache_Files { get; set; } = new List<HslSoftFile>();
|
||||||
|
/// <summary>
|
||||||
|
/// 文件控件的缓存列表,方便清除垃圾
|
||||||
|
/// </summary>
|
||||||
|
private Stack<IDisposable> FilesControls = new Stack<IDisposable>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
37
软件系统客户端Wpf/Views/UserFileRenderItem.xaml
Normal file
37
软件系统客户端Wpf/Views/UserFileRenderItem.xaml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<UserControl x:Class="软件系统客户端Wpf.Views.UserFileRenderItem"
|
||||||
|
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:软件系统客户端Wpf.Views"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="100" d:DesignWidth="400" BorderThickness="1" BorderBrush="{DynamicResource PrimaryHueMidBrush}"
|
||||||
|
Margin="0,0,0,3" MinWidth="400">
|
||||||
|
<Grid Margin="3">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="auto"></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="30"></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="120"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="130"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="60"></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Image x:Name="FileIcon" Grid.RowSpan="2" Width="18" Height="18" VerticalAlignment="Top" Margin="3,6,3,3"></Image>
|
||||||
|
|
||||||
|
<TextBlock x:Name="FileName" Grid.Column="1" VerticalAlignment="Center">文件名称:</TextBlock>
|
||||||
|
<TextBlock x:Name="FileSize" Grid.Column="2" VerticalAlignment="Center">大小:</TextBlock>
|
||||||
|
<TextBlock x:Name="FileDate" Grid.Column="3" VerticalAlignment="Center">日期:</TextBlock>
|
||||||
|
|
||||||
|
<TextBlock x:Name="FileDeleteButton" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand"
|
||||||
|
Background="{DynamicResource PrimaryHueLightBrush}" Padding="6,3,6,3">删除</TextBlock>
|
||||||
|
|
||||||
|
<TextBlock x:Name="FileDescription" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">文件备注:</TextBlock>
|
||||||
|
<TextBlock x:Name="FilePeople" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center">上传人:</TextBlock>
|
||||||
|
<TextBlock x:Name="FileDownloadTimes" Grid.Row="1" Grid.Column="3" VerticalAlignment="Center">下载次数:</TextBlock>
|
||||||
|
<TextBlock x:Name="FileDownloadButton" Grid.Row="1" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand"
|
||||||
|
Background="{DynamicResource PrimaryHueLightBrush}" Padding="6,3,6,3">下载</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
74
软件系统客户端Wpf/Views/UserFileRenderItem.xaml.cs
Normal file
74
软件系统客户端Wpf/Views/UserFileRenderItem.xaml.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using ClientsLibrary;
|
||||||
|
using HslCommunication.Enthernet;
|
||||||
|
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 软件系统客户端Wpf.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UserFileRenderItem.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class UserFileRenderItem : UserControl
|
||||||
|
{
|
||||||
|
public UserFileRenderItem()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private BitmapImage BitmapToBitmapImage(System.Drawing.Bitmap bitmap)
|
||||||
|
{
|
||||||
|
BitmapImage bitmapImage = new BitmapImage();
|
||||||
|
|
||||||
|
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
|
||||||
|
{
|
||||||
|
bitmap.Save(ms, bitmap.RawFormat);
|
||||||
|
bitmapImage.BeginInit();
|
||||||
|
bitmapImage.StreamSource = ms;
|
||||||
|
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
|
bitmapImage.EndInit();
|
||||||
|
bitmapImage.Freeze();
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmapImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HslSoftFile Hufile { get; set; } = null;
|
||||||
|
/// <summary>
|
||||||
|
/// 设置文件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">文件的信息对象</param>
|
||||||
|
/// <param name="deleteEnable">删除控件的使能委托</param>
|
||||||
|
public void SetFile(HslSoftFile file)
|
||||||
|
{
|
||||||
|
Hufile = file;
|
||||||
|
//获取后缀名
|
||||||
|
int dotIndex = Hufile.FileName.LastIndexOf('.');
|
||||||
|
if (dotIndex >= 0)
|
||||||
|
{
|
||||||
|
FileIcon.Source = BitmapToBitmapImage(Hufile.GetFileIcon());
|
||||||
|
}
|
||||||
|
|
||||||
|
FileName.Text = "文件名称:" + file.FileName;
|
||||||
|
FileSize.Text = "大小:" + file.GetTextFromFileSize();
|
||||||
|
FileDate.Text = "日期:" + file.UploadDate.ToString("yyyy-MM-dd");
|
||||||
|
FileDescription.Text = "文件备注:" + file.FileNote;
|
||||||
|
FilePeople.Text = "上传人:" + file.UploadName;
|
||||||
|
FileDownloadTimes.Text = "下载数:" + file.FileDownloadTimes;
|
||||||
|
|
||||||
|
FileDeleteButton.IsEnabled = file.UploadName == UserClient.UserAccount.UserName;
|
||||||
|
FileDownloadButton.IsEnabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,6 +81,12 @@
|
|||||||
<Compile Include="Views\UserChat.xaml.cs">
|
<Compile Include="Views\UserChat.xaml.cs">
|
||||||
<DependentUpon>UserChat.xaml</DependentUpon>
|
<DependentUpon>UserChat.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\UserFileRender.xaml.cs">
|
||||||
|
<DependentUpon>UserFileRender.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Views\UserFileRenderItem.xaml.cs">
|
||||||
|
<DependentUpon>UserFileRenderItem.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\UserHome.xaml.cs">
|
<Compile Include="Views\UserHome.xaml.cs">
|
||||||
<DependentUpon>UserHome.xaml</DependentUpon>
|
<DependentUpon>UserHome.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -114,6 +120,14 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\UserFileRender.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Views\UserFileRenderItem.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\UserHome.xaml">
|
<Page Include="Views\UserHome.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
Reference in New Issue
Block a user