Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68be369e39 | ||
|
|
ae050cb425 | ||
|
|
e6a76ddc69 | ||
|
|
55cb903d1b | ||
|
|
c9d18b31bf | ||
|
|
c80e895d4a | ||
|
|
f4062dc5a6 | ||
|
|
2293d207c5 | ||
|
|
b9988cbe4c | ||
|
|
d3a281e10a | ||
|
|
6926e2d268 | ||
|
|
e36db2dec9 | ||
|
|
94b068ec40 | ||
|
|
c54e096162 | ||
|
|
6dda41d62e | ||
|
|
2bcfbd1726 | ||
|
|
5c910aaed7 | ||
|
|
1a3b89bdf7 | ||
|
|
972da36877 | ||
|
|
bf46dc5622 | ||
|
|
ee308d245d | ||
|
|
d0d5d9bfd5 | ||
|
|
85ff350339 | ||
|
|
0646b49a62 | ||
|
|
b449231adc | ||
|
|
6caae160a1 | ||
|
|
bbd3476670 | ||
|
|
0931cb9434 |
No files matched your search
@@ -4,4 +4,5 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FileManager_UWP">
|
||||
|
||||
|
||||
</Application>
|
||||
@@ -1,4 +1,5 @@
|
||||
using FileManager_UWP.Server;
|
||||
using FileManager_UWP.Service;
|
||||
using FileManager_UWP.View;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -68,13 +69,13 @@ namespace FileManager_UWP
|
||||
// 当导航堆栈尚未还原时,导航到第一页,
|
||||
// 并通过将所需信息作为导航参数传入来配置
|
||||
// 参数
|
||||
rootFrame.Navigate(typeof(MainPage), e.Arguments);
|
||||
rootFrame.Navigate(typeof(TestLabelView), e.Arguments);
|
||||
}
|
||||
// 确保当前窗口处于活动状态
|
||||
Window.Current.Activate();
|
||||
}
|
||||
|
||||
SimpleIoc.Default.Register<FileServer>();
|
||||
SimpleIoc.Default.Register<FileService>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
using FileManager_UWP.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Documents;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Markup;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
|
||||
// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235
|
||||
|
||||
namespace FileManager_UWP.Controls {
|
||||
|
||||
public class LabelListControl: ItemsControl {
|
||||
|
||||
//private int _collpse_distance = 22;
|
||||
//private List<int> _expanded_position = new List<int>();
|
||||
private Storyboard _collpse_story_board = new Storyboard();
|
||||
private Storyboard _expand_story_board = new Storyboard();
|
||||
private Duration _animate_during = new Duration(TimeSpan.FromMilliseconds(500));
|
||||
private int _status = 0; // 0 展开, 1 动画, 2 折叠
|
||||
private double _width, _height;
|
||||
private Canvas labelListCanvas;
|
||||
|
||||
|
||||
private ResourceDictionary genericResourceDictionary;
|
||||
public LabelListControl() {
|
||||
this.DefaultStyleKey = typeof(LabelListControl);
|
||||
var uri = new Uri("ms-appx:///Controls/LabelListControl.xaml");
|
||||
genericResourceDictionary = new ResourceDictionary();
|
||||
Application.LoadComponent(genericResourceDictionary, uri);
|
||||
}
|
||||
|
||||
private void ItemsSource_CollectionChanged(object sender,
|
||||
System.Collections.Specialized.NotifyCollectionChangedEventArgs e) {
|
||||
update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
//TextBlock textBlock = (TextBlock)GetTemplateChild("LabelTextBlock");
|
||||
//textBlock.Text = "测试自定义控件\n";
|
||||
//listView.ItemsSource = ItemsSource;
|
||||
var itemsSource = ItemsSource as ObservableCollection<LabelItem>;
|
||||
//textBlock.Text += itemsSource.Count().ToString();
|
||||
|
||||
//labelListCanvas.Children.Count;
|
||||
labelListCanvas.Children.Clear();
|
||||
_collpse_story_board.Stop();
|
||||
_collpse_story_board.Children.Clear();
|
||||
_expand_story_board.Stop();
|
||||
_expand_story_board.Children.Clear();
|
||||
int expanded_position = 0;
|
||||
foreach (LabelItem label in itemsSource) {
|
||||
Button b = new Button();
|
||||
b.Content = label.tag;
|
||||
b.Background = new SolidColorBrush(label.color);
|
||||
b.SetValue(Canvas.LeftProperty, expanded_position);
|
||||
b.Style = (Style)genericResourceDictionary["LabelButtonStyle"];
|
||||
b.Click += B_Click;
|
||||
|
||||
DoubleAnimation collpse_animate = new DoubleAnimation();
|
||||
collpse_animate.From = null; // labelListCanvas.Children.Count * 22;
|
||||
collpse_animate.To = expanded_position;
|
||||
collpse_animate.Duration = _animate_during;
|
||||
collpse_animate.Completed += Animate_Completed;
|
||||
_collpse_story_board.Children.Add(collpse_animate);
|
||||
Storyboard.SetTarget(collpse_animate, b);
|
||||
Storyboard.SetTargetProperty(collpse_animate, "(Canvas.Left)");
|
||||
|
||||
DoubleAnimation expand_animate = new DoubleAnimation();
|
||||
expand_animate.From = null; // expanded_position;
|
||||
expand_animate.To = labelListCanvas.Children.Count * 22;
|
||||
expand_animate.Duration = _animate_during;
|
||||
expand_animate.Completed += Animate_Completed;
|
||||
_expand_story_board.Children.Add(expand_animate);
|
||||
Storyboard.SetTarget(expand_animate, b);
|
||||
Storyboard.SetTargetProperty(expand_animate, "(Canvas.Left)");
|
||||
|
||||
expanded_position += label.tag.Count() * 14 + 20;
|
||||
labelListCanvas.Children.Add(b);
|
||||
}
|
||||
measure();
|
||||
LabelListCanvas_PointerExited(null, null);
|
||||
}
|
||||
|
||||
private void B_Click(object sender, RoutedEventArgs e) {
|
||||
Button b = sender as Button;
|
||||
Debug.WriteLine(b.Content);
|
||||
}
|
||||
|
||||
private void Animate_Completed(object sender, object e) {
|
||||
measure();
|
||||
}
|
||||
|
||||
private void measure() {
|
||||
Button lb = labelListCanvas.Children.Last() as Button;
|
||||
labelListCanvas.Height = lb.ActualHeight;
|
||||
double left = (double)lb.GetValue(Canvas.LeftProperty);
|
||||
labelListCanvas.Width = left + lb.ActualHeight;
|
||||
}
|
||||
|
||||
private void LabelListCanvas_PointerExited(object sender, PointerRoutedEventArgs e) {
|
||||
_expand_story_board.Begin();
|
||||
}
|
||||
|
||||
private void LabelListCanvas_PointerEntered(object sender, PointerRoutedEventArgs e) {
|
||||
_collpse_story_board.Begin();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
var itemsSource = ItemsSource as ObservableCollection<LabelItem>;
|
||||
itemsSource.CollectionChanged += ItemsSource_CollectionChanged;
|
||||
Button labelListButton = (Button)GetTemplateChild("LabelListPresenter");
|
||||
labelListButton.PointerEntered += LabelListCanvas_PointerEntered;
|
||||
labelListButton.PointerExited += LabelListCanvas_PointerExited;
|
||||
labelListCanvas = (Canvas)GetTemplateChild("LabelListCanvas");
|
||||
|
||||
//TextBlock textBlock = (TextBlock)GetTemplateChild("LabelTextBlock");
|
||||
//textBlock.Text = "测试自定义控件\nINIT";
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate() {
|
||||
init();
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FileManager_UWP.Controls">
|
||||
|
||||
<Style TargetType="Button" x:Key="LabelButtonStyle">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid x:Name="RootGrid"
|
||||
CornerRadius="10"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="1"
|
||||
BorderBrush="Blue">
|
||||
<ContentPresenter
|
||||
x:Name="ContentPresenter"
|
||||
Padding="4 4 4 4"
|
||||
/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="local:LabelListControl">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="local:LabelListControl">
|
||||
<Button Name="LabelListPresenter">
|
||||
<Button.Resources>
|
||||
<ResourceDictionary>
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="Transparent"/>
|
||||
</ResourceDictionary>
|
||||
</Button.Resources>
|
||||
<Canvas Name="LabelListCanvas"></Canvas>
|
||||
</Button>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -18,7 +18,7 @@
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
|
||||
<PackageCertificateKeyFile>FileManager_UWP_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<PackageCertificateThumbprint>5058C24840B066026EEA46E892616A9B0CF9D282</PackageCertificateThumbprint>
|
||||
<PackageCertificateThumbprint>3345EE1782F80611CAB226C70864DC55EDEBBCEE</PackageCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -120,7 +120,17 @@
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Server\FileServer.cs" />
|
||||
<Compile Include="Controls\LabelListControl.cs" />
|
||||
<Compile Include="Model\DisplayableDisk.cs" />
|
||||
<Compile Include="Model\DisplayableFile.cs" />
|
||||
<Compile Include="Model\DisplayableFolder.cs" />
|
||||
<Compile Include="Model\DisplayableSpecial.cs" />
|
||||
<Compile Include="Model\Displayable.cs" />
|
||||
<Compile Include="Model\FolderSetting.cs" />
|
||||
<Compile Include="Model\LabelItem.cs" />
|
||||
<Compile Include="Model\VirtualFolder.cs" />
|
||||
<Compile Include="Service\FileService.cs" />
|
||||
<Compile Include="Service\IconServer.cs" />
|
||||
<Compile Include="ViewModel\FileListViewModel.cs" />
|
||||
<Compile Include="ViewModel\MainPageViewModel.cs" />
|
||||
<Compile Include="View\FileListView.xaml.cs">
|
||||
@@ -133,6 +143,9 @@
|
||||
<Compile Include="View\PreviewView.xaml.cs">
|
||||
<DependentUpon>PreviewView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\TestLabelView.xaml.cs">
|
||||
<DependentUpon>TestLabelView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
@@ -155,6 +168,14 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Controls\LabelListControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Generic.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="View\FileListView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -167,18 +188,38 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="View\TestLabelView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.2.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
|
||||
<Version>2.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MvvmLight">
|
||||
<Version>5.4.1.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MvvmLightLibs">
|
||||
<Version>5.4.1.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="sqlite-net-pcl">
|
||||
<Version>1.5.231</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.IO">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.IO.FileSystem">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Model\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace FileManager_UWP.Model {
|
||||
public enum Type{
|
||||
Folder = 0, VirtualFolder, Disk, File
|
||||
}
|
||||
public abstract class Displayable : IComparable {
|
||||
public abstract string Name { get; }
|
||||
public abstract string Path { get; }
|
||||
public abstract Type Type { get; }
|
||||
public abstract BitmapImage Icon { get; }
|
||||
public abstract List<String> Labels { get; }
|
||||
|
||||
public int CompareTo(object obj) {
|
||||
|
||||
if (this.Type != (obj as Displayable).Type)
|
||||
return this.Type - (obj as Displayable).Type;
|
||||
if (obj is Displayable another) {
|
||||
return Name.CompareTo(another.Name);
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Foundation;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.FileProperties;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace FileManager_UWP.Model
|
||||
{
|
||||
public class DisplayableDisk: Displayable {
|
||||
private readonly DriveInfo _drive;
|
||||
private readonly BitmapImage _icon = new BitmapImage();
|
||||
private readonly List<String> _labels = new List<String>();
|
||||
|
||||
private DisplayableDisk(DriveInfo d) {
|
||||
_drive = d;
|
||||
}
|
||||
|
||||
public static async Task<DisplayableDisk> GetInstance(DriveInfo d) {
|
||||
var obj = new DisplayableDisk(d);
|
||||
StorageFolder f = await StorageFolder.GetFolderFromPathAsync(d.Name);
|
||||
var thumbnail = await f.GetThumbnailAsync(ThumbnailMode.ListView, 32);
|
||||
await obj._icon.SetSourceAsync(thumbnail).AsTask();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public override string Name => _drive.Name;
|
||||
public override string Path => _drive.Name;
|
||||
public override BitmapImage Icon => _icon;
|
||||
public override Type Type => Type.Disk;
|
||||
public override List<String> Labels => _labels;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.FileProperties;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace FileManager_UWP.Model
|
||||
{
|
||||
public class DisplayableFile: Displayable {
|
||||
private readonly StorageFile _file;
|
||||
private readonly BitmapImage _icon;
|
||||
private readonly List<String> _labels;
|
||||
|
||||
private DisplayableFile(StorageFile f) {
|
||||
_file = f;
|
||||
_icon = new BitmapImage();
|
||||
_labels = new List<string> { "喵喵喵" };
|
||||
}
|
||||
|
||||
public static async Task<DisplayableFile> GetInstanceAsync(StorageFile f) {
|
||||
DisplayableFile obj = new DisplayableFile(f);
|
||||
var thumbnail = await f.GetThumbnailAsync(ThumbnailMode.SingleItem, 32);
|
||||
await obj._icon.SetSourceAsync(thumbnail).AsTask();
|
||||
return obj;
|
||||
}
|
||||
|
||||
public override string Name => _file.Name;
|
||||
public override string Path => _file.Path;
|
||||
public override Type Type => Type.File;
|
||||
public override BitmapImage Icon => _icon;
|
||||
public override List<String> Labels => _labels;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.FileProperties;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace FileManager_UWP.Model
|
||||
{
|
||||
public class DisplayableFolder: Displayable {
|
||||
private readonly StorageFolder _folder;
|
||||
private readonly BitmapImage _icon;
|
||||
private readonly List<String> _labels;
|
||||
|
||||
private DisplayableFolder(StorageFolder f) {
|
||||
_folder = f;
|
||||
_icon = new BitmapImage();
|
||||
_labels = new List<string>();
|
||||
}
|
||||
|
||||
public static async Task<DisplayableFolder> GetInstanceAsync(StorageFolder f)
|
||||
{
|
||||
DisplayableFolder obj = new DisplayableFolder(f);
|
||||
var thumbnail = await f.GetThumbnailAsync(ThumbnailMode.ListView, 32);
|
||||
await obj._icon.SetSourceAsync(thumbnail).AsTask();
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static async Task<Displayable> GetParentAsync(StorageFolder f) {
|
||||
string path = System.IO.Path.GetDirectoryName(f.Path);
|
||||
BitmapImage img = new BitmapImage();
|
||||
if (path != null) {
|
||||
path = f.Path.Substring(0, f.Path.LastIndexOf('\\'));
|
||||
StorageFolder file = await StorageFolder.GetFolderFromPathAsync(path);
|
||||
var thumbnail = await file.GetThumbnailAsync(ThumbnailMode.ListView, 32);
|
||||
await img.SetSourceAsync(thumbnail).AsTask();
|
||||
return new DisplayableSpecial("..", file.Path, Model.Type.Folder, img);
|
||||
}
|
||||
else {
|
||||
var thumbnail = await f.GetThumbnailAsync(ThumbnailMode.ListView, 32);
|
||||
await img.SetSourceAsync(thumbnail).AsTask();
|
||||
return new DisplayableSpecial("..", "/", Model.Type.Folder, img);
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name => _folder.Name;
|
||||
public override string Path => _folder.Path;
|
||||
public override Type Type => Type.Folder;
|
||||
public override BitmapImage Icon => _icon;
|
||||
public override List<String> Labels => _labels;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace FileManager_UWP.Model
|
||||
{
|
||||
public class DisplayableSpecial: Displayable {
|
||||
public DisplayableSpecial(string name, string path, Type type, BitmapImage icon)
|
||||
{
|
||||
Name = name;
|
||||
Path = path;
|
||||
Type = type;
|
||||
Icon = icon;
|
||||
Labels = new List<String>();
|
||||
}
|
||||
public override string Name { get; }
|
||||
public override string Path { get; }
|
||||
public override Type Type { get; }
|
||||
public override BitmapImage Icon { get; }
|
||||
public override List<String> Labels { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Data.Json;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace FileManager_UWP.Model
|
||||
{
|
||||
public class FolderSetting {
|
||||
public List<VirtualFolder> VirtualFolders { get; set; }
|
||||
|
||||
public FolderSetting() {
|
||||
VirtualFolders = new List<VirtualFolder>();
|
||||
}
|
||||
|
||||
static public async Task<FolderSetting> GetInstance(StorageFolder folder) {
|
||||
var confPath = folder.Path;
|
||||
if (confPath.EndsWith('\\'))
|
||||
confPath += ".awesomefilemanager";
|
||||
else
|
||||
confPath += "\\.awesomefilemanager";
|
||||
FolderSetting folderSetting;
|
||||
try {
|
||||
var confFile = await StorageFile.GetFileFromPathAsync(confPath);
|
||||
var jsonString = await FileIO.ReadTextAsync(confFile);
|
||||
folderSetting = JsonConvert.DeserializeObject<FolderSetting>(jsonString);
|
||||
} catch (FileNotFoundException) {
|
||||
Debug.WriteLine("no configure file in " + confPath);
|
||||
folderSetting = new FolderSetting();
|
||||
}
|
||||
return folderSetting;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.UI;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FileManager_UWP.Model {
|
||||
public class LabelItem {
|
||||
public string tag;
|
||||
public Color color = Color.FromArgb(0xf0, 0xC6, 0xE2, 0xFF);
|
||||
public LabelItem(string tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Data.Json;
|
||||
using Windows.UI.StartScreen;
|
||||
|
||||
namespace FileManager_UWP.Model
|
||||
{
|
||||
public class VirtualFolder {
|
||||
public string Name { get; set; }
|
||||
public List<string> Includes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:wincap="https://schemas.microsoft.com/appx/manifest/foundation/windows10/windowscapabilities" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
|
||||
<Identity Name="c339ceaf-658a-4c74-9c4b-5b956758df7c" Publisher="CN=MingjianW" Version="1.0.0.0" />
|
||||
<Identity Name="c339ceaf-658a-4c74-9c4b-5b956758df7c" Publisher="CN=wming" Version="1.0.0.0" />
|
||||
<mp:PhoneIdentity PhoneProductId="c339ceaf-658a-4c74-9c4b-5b956758df7c" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>FileManager_UWP</DisplayName>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -26,4 +27,6 @@ using System.Runtime.InteropServices;
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: NeutralResourcesLanguage("zh")]
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace FileManager_UWP.Server {
|
||||
/// <summary>
|
||||
/// 负责提供本地文件及文件夹访问服务
|
||||
/// </summary>
|
||||
class FileServer {
|
||||
public async Task<IReadOnlyList<StorageFile>> getFileList() {
|
||||
StorageFolder picturesFolder = KnownFolders.DocumentsLibrary;
|
||||
IReadOnlyList<StorageFile> fileList = await picturesFolder.GetFilesAsync();
|
||||
return fileList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
using FileManager_UWP.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Data.Json;
|
||||
using Windows.Devices.Custom;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.FileProperties;
|
||||
using Windows.Web.Http.Headers;
|
||||
using Newtonsoft.Json;
|
||||
using Type = FileManager_UWP.Model.Type;
|
||||
|
||||
namespace FileManager_UWP.Service {
|
||||
internal interface IFileService {
|
||||
/// <summary>
|
||||
/// 获得可显示的目录
|
||||
/// </summary>
|
||||
/// <param name="path">路径</param>
|
||||
/// <returns>文件和文件夹列表</returns>
|
||||
Task<List<Displayable>> GetDisplayFileFolderList(string path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 负责提供本地文件及文件夹访问服务
|
||||
/// </summary>
|
||||
internal class FileService: IFileService {
|
||||
private async Task<List<Displayable>> GetVirtualFolderAsync(string path) {
|
||||
// var splitList = path.Split('\\');
|
||||
//var virtualFolderName = path.Substring(0, path.LastIndexOf('\\'));
|
||||
//path = path.Substring(path.LastIndexOf('\\'));
|
||||
var directoryName = Path.GetDirectoryName(path);
|
||||
var virtualFolderName = path.Substring(path.LastIndexOf('\\'));
|
||||
|
||||
if (directoryName == null)
|
||||
throw new FileNotFoundException();
|
||||
|
||||
|
||||
StorageFolder folder;
|
||||
folder = await StorageFolder.GetFolderFromPathAsync(directoryName);
|
||||
FolderSetting folderSetting = await FolderSetting.GetInstance(folder);
|
||||
VirtualFolder virtualFolder = folderSetting.VirtualFolders.Find(x => x.Name == virtualFolderName);
|
||||
if (virtualFolder == null)
|
||||
throw new FileNotFoundException();
|
||||
var displayFileFolderItems = new List<Displayable>
|
||||
{
|
||||
new DisplayableSpecial(
|
||||
"..",
|
||||
directoryName,
|
||||
Type.Folder,
|
||||
await IconServer.GetFolderIcon(ThumbnailMode.ListView, 32)
|
||||
)
|
||||
};
|
||||
|
||||
foreach (var virtualFilderItem in virtualFolder.Includes) {
|
||||
displayFileFolderItems.AddRange(
|
||||
await GetRegularFilesAsync(virtualFilderItem, false)
|
||||
);
|
||||
}
|
||||
return displayFileFolderItems;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得普通文件夹中的文件
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="withParent"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<Displayable>> GetRegularFilesAsync(string path, bool withParent = true) {
|
||||
StorageFolder folder = null;
|
||||
try {
|
||||
folder = await StorageFolder.GetFolderFromPathAsync(path);
|
||||
} catch (System.UnauthorizedAccessException) {
|
||||
throw;
|
||||
} catch (Exception e) {
|
||||
Debug.WriteLine(e.Message + " " + path + " try to get Virtual Folder");
|
||||
try {
|
||||
return await GetVirtualFolderAsync(path);
|
||||
} catch (Exception) {
|
||||
Debug.WriteLine(e.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// 打开文件夹
|
||||
var displayFileFolderItems = new List<Displayable>();
|
||||
if (withParent)
|
||||
displayFileFolderItems.Add(await DisplayableFolder.GetParentAsync(folder));
|
||||
|
||||
// 读取配置文件
|
||||
|
||||
FolderSetting folderSetting = await FolderSetting.GetInstance(folder);
|
||||
foreach (var virtualFolder in folderSetting.VirtualFolders) {
|
||||
displayFileFolderItems.Add(new DisplayableSpecial(
|
||||
virtualFolder.Name,
|
||||
folder.Path + "//" + virtualFolder.Name,
|
||||
Type.VirtualFolder,
|
||||
await IconServer.GetFolderIcon(ThumbnailMode.ListView, 32)));
|
||||
}
|
||||
|
||||
IReadOnlyList<StorageFolder> folders = await folder.GetFoldersAsync();
|
||||
IReadOnlyList<StorageFile> files = await folder.GetFilesAsync();
|
||||
//displayFileFolderItems.AddRange(folders
|
||||
// .Select(async i => await DisplayFileFolderItem.GetInstance(i))
|
||||
// .Select(i => i.Result)
|
||||
//);
|
||||
//displayFileFolderItems.AddRange(files
|
||||
// .Select(async i => await DisplayFileFolderItem.GetInstance(i))
|
||||
// .Select(i => i.Result)
|
||||
//);
|
||||
try {
|
||||
foreach (var file in folders)
|
||||
displayFileFolderItems.Add(
|
||||
await DisplayableFolder.GetInstanceAsync(file));
|
||||
|
||||
foreach (var file in files)
|
||||
displayFileFolderItems.Add(
|
||||
await DisplayableFile.GetInstanceAsync(file));
|
||||
} catch (Exception e) {
|
||||
Debug.WriteLine("Exception at appending dispalyFileFolder " + e.Message);
|
||||
}
|
||||
|
||||
return displayFileFolderItems;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得磁盘驱动器列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<List<Displayable>> GetDiskDrivesAsync() {
|
||||
var drives = DriveInfo.GetDrives();
|
||||
var ans = new List<Displayable>();
|
||||
foreach (var d in drives) ans.Add(await DisplayableDisk.GetInstance(d));
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得可显示的目录
|
||||
/// </summary>
|
||||
/// <param name="path">路径</param>
|
||||
/// <returns>文件和文件夹列表</returns>
|
||||
public async Task<List<Displayable>> GetDisplayFileFolderList(string path) {
|
||||
try {
|
||||
List<Displayable> ans;
|
||||
if (path == "/")
|
||||
ans = await GetDiskDrivesAsync();
|
||||
else
|
||||
ans = await GetRegularFilesAsync(path);
|
||||
ans.Sort();
|
||||
return ans;
|
||||
|
||||
} catch (Exception) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.FileProperties;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace FileManager_UWP.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 管理文件和文件夹图标的静态类
|
||||
/// </summary>
|
||||
public class IconServer
|
||||
{
|
||||
private IconServer() {
|
||||
}
|
||||
|
||||
public static async Task<BitmapImage> GetFolderIcon(ThumbnailMode mode, uint size) {
|
||||
StorageFolder f = await StorageFolder.GetFolderFromPathAsync("C:\\Windows");
|
||||
BitmapImage img = new BitmapImage();
|
||||
StorageItemThumbnail thumbnail = await f.GetThumbnailAsync(mode, size);
|
||||
await img.SetSourceAsync(thumbnail).AsTask();
|
||||
|
||||
return img;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FileManager_UWP.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Controls/LabelListControl.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<Page
|
||||
x:Class="FileManager_UWP.View.FileListView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FileManager_UWP.View"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:storage="using:Windows.Storage"
|
||||
xmlns:Custom="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:Custom1="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:model="using:FileManager_UWP.Model"
|
||||
x:Class="FileManager_UWP.View.FileListView"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
@@ -23,56 +24,78 @@
|
||||
<Button
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Name="getFileList"
|
||||
Click="GetFileList_Click"
|
||||
Content="获得文件列表"
|
||||
Command="{Binding RefreshCommand}"
|
||||
Content="刷新文件列表"
|
||||
FontSize="20"/>
|
||||
<TextBox
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Width="Auto"
|
||||
Text="C:\"
|
||||
Name="pathText"/>
|
||||
Text="{Binding Path}"
|
||||
/>
|
||||
<ListView
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
ItemsSource="{x:Bind Files}"
|
||||
ItemsSource="{Binding DisplayFileFolderItems}"
|
||||
CanDragItems="False"
|
||||
CanReorderItems="True"
|
||||
AllowDrop="True"
|
||||
AllowDrop="False"
|
||||
SelectionMode="Single"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="ListView_ItemClick"
|
||||
SelectedItem="{Binding ListSelectedItem, Mode=TwoWay}"
|
||||
|
||||
IsDoubleTapEnabled="True"
|
||||
IsTapEnabled="True"
|
||||
|
||||
>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate
|
||||
x:Name="SingleLineDataTemplate"
|
||||
x:DataType="local:DisplayFileFolderItem">
|
||||
<DataTemplate>
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Height="44"
|
||||
Padding="12"
|
||||
AutomationProperties.Name="{x:Bind Name}">
|
||||
<Image Source="Placeholder.png"
|
||||
>
|
||||
<Image Source="{Binding Icon}"
|
||||
Height="16"
|
||||
Width="16"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock
|
||||
Text="{x:Bind Name}"
|
||||
Text="{Binding Name}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource BaseTextBlockStyle}"
|
||||
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
||||
Margin="12,0,0,0"/>
|
||||
<ListView
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.VerticalScrollMode="Disabled"
|
||||
ItemsSource="{Binding Labels}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<TextBlock Text="{Binding}"></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
||||
<Custom:Interaction.Behaviors>
|
||||
<Custom1:EventTriggerBehavior EventName="DoubleTapped">
|
||||
<Custom1:InvokeCommandAction Command="{Binding DoubleTappedCommand}"/>
|
||||
</Custom1:EventTriggerBehavior>
|
||||
</Custom:Interaction.Behaviors>
|
||||
|
||||
</ListView>
|
||||
|
||||
<TextBlock
|
||||
Name="DebugPanel"
|
||||
Grid.Row="2">
|
||||
</TextBlock>
|
||||
Text="{Binding DebugText}"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -1,93 +1,15 @@
|
||||
using FileManager_UWP.Server;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using FileManager_UWP.ViewModel;
|
||||
|
||||
namespace FileManager_UWP.View {
|
||||
public class DisplayFileFolderItem {
|
||||
public string Name { get; set; }
|
||||
public string Path { get; set; }
|
||||
public bool IsFolder { get; set; }
|
||||
public DisplayFileFolderItem(StorageFolder f) {
|
||||
Name = f.Name;
|
||||
Path = f.Path;
|
||||
IsFolder = true;
|
||||
}
|
||||
public DisplayFileFolderItem(StorageFile f) {
|
||||
Name = f.Name;
|
||||
Path = f.Path;
|
||||
IsFolder = false;
|
||||
}
|
||||
public DisplayFileFolderItem() { }
|
||||
|
||||
public static DisplayFileFolderItem parent(string current) {
|
||||
DisplayFileFolderItem d = new DisplayFileFolderItem();
|
||||
d.Name = "..";
|
||||
d.IsFolder = true;
|
||||
d.Path = current.Substring(0, current.LastIndexOf('\\'));
|
||||
if (d.Path.Length == 2)
|
||||
d.Path += "\\";
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class FileListView : Page {
|
||||
ObservableCollection<DisplayFileFolderItem> Files =
|
||||
new ObservableCollection<DisplayFileFolderItem>();
|
||||
private FileListViewModel vm;
|
||||
public FileListView() {
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private async void UpdateFileList(string path) {
|
||||
StorageFolder folder = null;
|
||||
try {
|
||||
folder = await StorageFolder.GetFolderFromPathAsync(path);
|
||||
} catch (Exception ex) {
|
||||
DebugPanel.Text = ex.Message;
|
||||
}
|
||||
|
||||
if (null != folder) {
|
||||
TreeViewNode rootNode = new TreeViewNode() { Content = folder.Name };
|
||||
IReadOnlyList<StorageFolder> folders = await folder.GetFoldersAsync();
|
||||
IReadOnlyList<StorageFile> files = await folder.GetFilesAsync();
|
||||
Files.Clear();
|
||||
Files.Add(DisplayFileFolderItem.parent(path));
|
||||
foreach (StorageFolder f in folders) {
|
||||
// DebugPanel.Children.Add(new TextBlock { Text = f.Name });
|
||||
Files.Add(new DisplayFileFolderItem(f));
|
||||
}
|
||||
foreach (StorageFile f in files) {
|
||||
// DebugPanel.Children.Add(new TextBlock { Text = f.Name });
|
||||
Files.Add(new DisplayFileFolderItem(f));
|
||||
// Files.Add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GetFileList_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) {
|
||||
//StorageFolder picturesFolder = KnownFolders.DocumentsLibrary;
|
||||
//IReadOnlyList<StorageFile> fileList = await picturesFolder.GetFilesAsync();
|
||||
//foreach (StorageFile file in fileList) {
|
||||
// DebugPanel.Children.Add(new TextBlock { Text = file.Name });
|
||||
// Debug.WriteLine(file.Name);
|
||||
//}
|
||||
|
||||
string path = pathText.Text;
|
||||
UpdateFileList(path);
|
||||
}
|
||||
|
||||
private void ListView_ItemClick(object sender, ItemClickEventArgs e) {
|
||||
DisplayFileFolderItem i = e.ClickedItem as DisplayFileFolderItem;
|
||||
if (i.IsFolder) {
|
||||
pathText.Text = i.Path;
|
||||
UpdateFileList(i.Path);
|
||||
}
|
||||
vm = new FileListViewModel();
|
||||
DataContext = vm;
|
||||
vm.RefreshCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<NavigationView PaneDisplayMode="LeftCompact" IsBackButtonVisible="Auto"
|
||||
<NavigationView PaneDisplayMode="LeftCompact" IsBackButtonVisible="Collapsed"
|
||||
>
|
||||
<NavigationView.Header>
|
||||
<RelativePanel Margin="0,5,10,0">
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<Page
|
||||
x:Class="FileManager_UWP.View.TestLabelView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FileManager_UWP.View"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="using:FileManager_UWP.Controls"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
FontSize="50"
|
||||
Text="Test Label View" />
|
||||
<Button FontSize="20" Content="加" Click="Button_Click"></Button>
|
||||
<!--<ListView ItemsSource="{x:Bind Labels}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}"></TextBlock>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>-->
|
||||
|
||||
<controls:LabelListControl ItemsSource="{x:Bind Labels}"></controls:LabelListControl>
|
||||
</StackPanel>
|
||||
</Page>
|
||||
@@ -0,0 +1,62 @@
|
||||
using FileManager_UWP.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace FileManager_UWP.View {
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class TestLabelView: Page {
|
||||
public ObservableCollection<LabelItem> Labels =
|
||||
new ObservableCollection<LabelItem>{
|
||||
new LabelItem("照片"),
|
||||
new LabelItem("土耳其摔跤"),
|
||||
new LabelItem("李若明"),
|
||||
new LabelItem("鸢晓曼"),
|
||||
new LabelItem("才明洋与吴岳江进行土耳其摔跤"),
|
||||
new LabelItem("真正的瑜伽大师")
|
||||
};
|
||||
|
||||
public TestLabelView() {
|
||||
this.InitializeComponent();
|
||||
Debug.WriteLine(Labels.ToString());
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e) {
|
||||
switch (Labels.Count) {
|
||||
case 0:
|
||||
Labels.Add(new LabelItem("照片"));
|
||||
break;
|
||||
case 1:
|
||||
Labels.Add(new LabelItem("土耳其摔跤"));
|
||||
break;
|
||||
case 2:
|
||||
Labels.Add(new LabelItem("李若明"));
|
||||
break;
|
||||
case 3:
|
||||
Labels.Add(new LabelItem("鸢晓曼"));
|
||||
break;
|
||||
default:
|
||||
Labels.Add(new LabelItem("才明洋与吴岳江摔跤"));
|
||||
break;
|
||||
}
|
||||
Debug.WriteLine(Labels.Count.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,94 @@
|
||||
using System;
|
||||
using FileManager_UWP.Model;
|
||||
using FileManager_UWP.Service;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Type = FileManager_UWP.Model.Type;
|
||||
|
||||
namespace FileManager_UWP.ViewModel {
|
||||
class FileListViewModel {
|
||||
public class FileListViewModel: ViewModelBase {
|
||||
/// <summary>
|
||||
/// 当前路径
|
||||
/// </summary>
|
||||
private string _path = "C:\\";
|
||||
|
||||
public string Path {
|
||||
get => _path;
|
||||
set => Set(nameof(Path), ref _path, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件和文件夹列表
|
||||
/// </summary>
|
||||
private IEnumerable<Displayable> _displayFileFolderItems;
|
||||
|
||||
public IEnumerable<Displayable> DisplayFileFolderItems {
|
||||
get => _displayFileFolderItems;
|
||||
set => Set(nameof(DisplayFileFolderItems), ref _displayFileFolderItems, value);
|
||||
}
|
||||
|
||||
private string _debugText;
|
||||
|
||||
public string DebugText {
|
||||
get => _debugText;
|
||||
set => Set(nameof(DebugText), ref _debugText, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新命令
|
||||
/// </summary>
|
||||
private RelayCommand _refreshCommand;
|
||||
|
||||
public RelayCommand RefreshCommand =>
|
||||
_refreshCommand ?? (_refreshCommand = new RelayCommand(async () => {
|
||||
try {
|
||||
var fileService = new FileService();
|
||||
var fileList = await fileService.GetDisplayFileFolderList(Path);
|
||||
DisplayFileFolderItems = fileList;
|
||||
} catch (System.UnauthorizedAccessException) {
|
||||
ContentDialog noWifiDialog = new ContentDialog {
|
||||
Title = "无文件系统访问权限",
|
||||
Content = "请在设置->隐私->文件系统中为FileManager_UWP开启文件系统访问权限。",
|
||||
CloseButtonText = "行"
|
||||
};
|
||||
ContentDialogResult result = await noWifiDialog.ShowAsync();
|
||||
} catch (Exception e) {
|
||||
Debug.WriteLine(e.Message);
|
||||
}
|
||||
}));
|
||||
|
||||
private object _listSelectedItem;
|
||||
|
||||
public object ListSelectedItem {
|
||||
get => _listSelectedItem;
|
||||
set => Set(nameof(ListSelectedItem), ref _listSelectedItem, value);
|
||||
}
|
||||
|
||||
private List<object> _listSelectedItems;
|
||||
|
||||
public List<object> ListSelectedItems {
|
||||
get => _listSelectedItems;
|
||||
set => Set(nameof(ListSelectedItems), ref _listSelectedItems, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新命令
|
||||
/// </summary>
|
||||
private RelayCommand _doubleTappedCommand;
|
||||
|
||||
public RelayCommand DoubleTappedCommand =>
|
||||
_doubleTappedCommand ?? (_doubleTappedCommand = new RelayCommand(
|
||||
() => {
|
||||
Displayable i = ListSelectedItem as Displayable;
|
||||
Debug.WriteLine("Double tapped");
|
||||
if (i != null && (i.Type != Type.File)) {
|
||||
Path = i.Path;
|
||||
RefreshCommand.Execute(null);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user