Vue sur les fichiers distants

main
Paul Schneider 9 years ago
parent fa7ab0e525
commit e4e58b1512
15 changed files with 280 additions and 146 deletions

@ -25,6 +25,7 @@ namespace BookAStar
using ViewModels.UserProfile; using ViewModels.UserProfile;
using Pages.UserProfile; using Pages.UserProfile;
using ViewModels.EstimateAndBilling; using ViewModels.EstimateAndBilling;
using System.Net;
public partial class App : Application // superclass new in 1.3 public partial class App : Application // superclass new in 1.3
{ {
@ -109,7 +110,7 @@ namespace BookAStar
BindingContext = page.BindingContext BindingContext = page.BindingContext
}); });
} }
DataManager.Current.AppState.SaveCollection(); DataManager.Current.AppState.SaveEntity();
} }
// called on app startup, after OnStartup, not on rotation // called on app startup, after OnStartup, not on rotation
@ -124,7 +125,7 @@ namespace BookAStar
pageType, true, pageState.BindingContext); pageType, true, pageState.BindingContext);
} }
DataManager.Current.AppState.Clear(); DataManager.Current.AppState.Clear();
DataManager.Current.AppState.SaveCollection(); DataManager.Current.AppState.SaveEntity();
} }
// FIXME Not called? // FIXME Not called?
@ -206,6 +207,7 @@ namespace BookAStar
masterDetail.Detail = new NavigationPage(home); masterDetail.Detail = new NavigationPage(home);
ToolbarItem tiSetts = new ToolbarItem() ToolbarItem tiSetts = new ToolbarItem()
{ {
Priority = 0,
Text = "Paramètres", Text = "Paramètres",
Icon = "ic_corp_icon.png", Icon = "ic_corp_icon.png",
Command = new Command( Command = new Command(
@ -215,6 +217,7 @@ namespace BookAStar
ToolbarItem tiHome = new ToolbarItem() ToolbarItem tiHome = new ToolbarItem()
{ {
Priority = -1,
Text = "Accueil", Text = "Accueil",
Icon = "icon.png", Icon = "icon.png",
Command = new Command( Command = new Command(
@ -224,6 +227,7 @@ namespace BookAStar
ToolbarItem tiPubChat= new ToolbarItem() ToolbarItem tiPubChat= new ToolbarItem()
{ {
Priority = 1,
Text = "Chat", Text = "Chat",
Icon = "chat_icon_s.png", Icon = "chat_icon_s.png",
Command = new Command( Command = new Command(
@ -233,6 +237,7 @@ namespace BookAStar
masterDetail.ToolbarItems.Add(tiHome); masterDetail.ToolbarItems.Add(tiHome);
masterDetail.ToolbarItems.Add(tiSetts); masterDetail.ToolbarItems.Add(tiSetts);
masterDetail.ToolbarItems.Add(tiPubChat); masterDetail.ToolbarItems.Add(tiPubChat);
this.MainPage = masterDetail; this.MainPage = masterDetail;
NavigationService = new NavigationService(masterDetail.Detail.Navigation); NavigationService = new NavigationService(masterDetail.Detail.Navigation);
} }
@ -290,7 +295,19 @@ namespace BookAStar
// Start the Hub connection // Start the Hub connection
public async void StartHubConnection () public async void StartHubConnection ()
{ {
await chatHubConnection.Start(); try
{
await chatHubConnection.Start();
}
catch (WebException webex )
{
// TODO use webex, set this cx down status somewhere,
// & display it & maybe try again later.
}
catch (Exception ex)
{
// TODO use ex
}
} }
public void SetupHubConnection() public void SetupHubConnection()

@ -78,7 +78,6 @@
<Compile Include="Extensions\ImageResourceExtension.cs" /> <Compile Include="Extensions\ImageResourceExtension.cs" />
<Compile Include="Factories\ViewFactory.cs" /> <Compile Include="Factories\ViewFactory.cs" />
<Compile Include="Data\DataManager.cs" /> <Compile Include="Data\DataManager.cs" />
<Compile Include="Helpers\ObservableString.cs" />
<Compile Include="Interfaces\ILocalEntity.cs" /> <Compile Include="Interfaces\ILocalEntity.cs" />
<Compile Include="Data\LocaLEntity.cs" /> <Compile Include="Data\LocaLEntity.cs" />
<Compile Include="Helpers\NotIdentifiedException.cs" /> <Compile Include="Helpers\NotIdentifiedException.cs" />

@ -7,6 +7,7 @@
using Model.Social.Messaging; using Model.Social.Messaging;
using Model.FileSystem; using Model.FileSystem;
using ViewModels.EstimateAndBilling; using ViewModels.EstimateAndBilling;
using NonCrUD;
public class DataManager public class DataManager
{ {
@ -14,7 +15,7 @@
public RemoteEntityRO<BookQueryData, long> BookQueries { get; set; } public RemoteEntityRO<BookQueryData, long> BookQueries { get; set; }
public RemoteEntity<Estimate, long> Estimates { get; set; } public RemoteEntity<Estimate, long> Estimates { get; set; }
public RemoteEntity<Blog, long> Blogspot { get; set; } public RemoteEntity<Blog, long> Blogspot { get; set; }
internal RemoteEntity<UserDirectoryInfo, string> RemoteFiles { get; set; } internal RemoteFilesEntity RemoteFiles { get; set; }
public LocalEntity<ClientProviderInfo,string> Contacts { get; set; } public LocalEntity<ClientProviderInfo,string> Contacts { get; set; }
internal LocalEntity<PageState, int> AppState { get; set; } internal LocalEntity<PageState, int> AppState { get; set; }
@ -48,7 +49,7 @@
EstimationCache = new LocalEntity<EditEstimateViewModel, long>(e => e.Query.Id); EstimationCache = new LocalEntity<EditEstimateViewModel, long>(e => e.Query.Id);
EstimateLinesTemplates = new LocalEntity<BillingLine, string>(l => l.Description); EstimateLinesTemplates = new LocalEntity<BillingLine, string>(l => l.Description);
PrivateMessages = new LocalEntity<ChatMessage, int>(m=> m.GetHashCode()); PrivateMessages = new LocalEntity<ChatMessage, int>(m=> m.GetHashCode());
RemoteFiles = new RemoteEntity<UserDirectoryInfo, string> ("fs", d => d.SubPath); RemoteFiles = new RemoteFilesEntity ();
PrivateMessages.Load(); PrivateMessages.Load();
BookQueries.Load(); BookQueries.Load();

@ -40,14 +40,24 @@ namespace BookAStar.Data
return CurrentItem; return CurrentItem;
} }
public void Load() public virtual bool Load()
{ {
this.Populate<V>(); return this.Populate<V,K>();
} }
public void Load(string subKey) public virtual bool Load(string subKey)
{ {
this.Populate<V>(subKey); return (this.Populate<V,K>(subKey));
}
public virtual bool Seek(int index)
{
if (this.Count>index && index >=0)
{
CurrentItem = this[index];
return true;
}
return false;
} }
} }

@ -6,10 +6,17 @@ namespace BookAStar.Data.NonCrUD
{ {
using Helpers; using Helpers;
using Model.FileSystem; using Model.FileSystem;
using System.Linq;
/*
public class DirectoryEntryChangingEvent : EventArgs
{
public UserDirectoryInfo OldItem { get; set; }
public UserDirectoryInfo NewItem { get; set; }
}*/
public class RemoteFiles : RemoteEntity<UserDirectoryInfo, FileAddress> public class RemoteFilesEntity : RemoteEntity<UserDirectoryInfo, FileAddress>
{ {
public RemoteFiles() : base("fs", d => d) public RemoteFilesEntity() : base("fs", d => d)
{ {
} }
@ -23,14 +30,15 @@ namespace BookAStar.Data.NonCrUD
try try
{ {
var subpath = parameter as string; var subpath = parameter as string;
string path = ControllerUri.AbsolutePath + ((subpath != null) ? "/" + subpath : null); string path = ControllerUri.AbsoluteUri + ((subpath != null) ? "/" + subpath : null);
using (var response = await client.GetAsync(ControllerUri)) using (var response = await client.GetAsync(path))
{ {
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var di = JsonConvert.DeserializeObject<UserDirectoryInfo>(content); var di = JsonConvert.DeserializeObject<UserDirectoryInfo>(content);
this.Merge(di); this.Merge(di);
this.SaveEntity();
} }
else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
throw new Exception("Bad request"); throw new Exception("Bad request");
@ -43,8 +51,32 @@ namespace BookAStar.Data.NonCrUD
throw new Exception("Remote call failed", ex); throw new Exception("Remote call failed", ex);
} }
} }
AfterExecuting();
}
/*
public override void Merge(UserDirectoryInfo item)
{
var key = GetKey(item);
DirectoryEntryChangingEvent itemChanged = null;
if (this.Any(x => GetKey(x).Equals(key)))
{
var old = LocalGet(key);
itemChanged = new DirectoryEntryChangingEvent
{
OldItem = old,
NewItem = item
};
Remove(old);
}
Add(item);
CurrentItem = item;
if (DirectoryEntryChanged != null && itemChanged != null)
DirectoryEntryChanged.Invoke(this, itemChanged);
} }
public event EventHandler<DirectoryEntryChangingEvent> DirectoryEntryChanged;
*/
} }
} }

@ -65,7 +65,7 @@ namespace BookAStar.Data
{ {
Merge(item); Merge(item);
} }
this.SaveCollection(); this.SaveEntity();
} }
} }
} }

@ -1,59 +0,0 @@
using System;
using System.Collections.Generic;
namespace BookAStar
{
public class ObservableString : IObservable<string>, IDisposable
{
public ObservableString(string data)
{
this.data = data;
}
private string data = null;
private List<IObserver<string>> observers = new List<IObserver<string>>();
public string Data
{
get
{
return data;
}
set
{
if (data != value)
{
data = value;
foreach (var obs in observers)
obs.OnCompleted();
}
}
}
public override string ToString()
{
return data;
}
public static explicit operator ObservableString (string data)
{
return new ObservableString(data);
}
public static explicit operator string (ObservableString observable)
{
return observable.ToString();
}
public void Dispose()
{
observers = null;
}
public IDisposable Subscribe(IObserver<string> observer)
{
observers.Add(observer);
return this;
}
}
}

@ -1,10 +1,11 @@
using System; using System;
using System.Collections;
namespace BookAStar namespace BookAStar
{ {
public interface ILoadable public interface ILoadable
{ {
void Load(); bool Load();
} }
public interface IPersistentOnDemand : ILoadable public interface IPersistentOnDemand : ILoadable
@ -12,7 +13,7 @@ namespace BookAStar
void Save(); void Save();
} }
public interface ILocalEntity<V, K> : ILoadable where K : IEquatable<K> public interface ILocalEntity<V, K> : IList, ILoadable where K : IEquatable<K>
{ {
V CurrentItem { get; } V CurrentItem { get; }
@ -22,5 +23,6 @@ namespace BookAStar
void Merge(V item); void Merge(V item);
bool Seek(int index);
} }
} }

@ -58,7 +58,7 @@ namespace BookAStar.Pages
private void OnEditEstimate(object sender, EventArgs ev) private void OnEditEstimate(object sender, EventArgs ev)
{ {
var bookQueryViewModel = (BookQueryViewModel)BindingContext; var bookQueryViewModel = (BookQueryViewModel) BindingContext;
var editEstimateViewModel = bookQueryViewModel.DraftEstimate; var editEstimateViewModel = bookQueryViewModel.DraftEstimate;
if (editEstimateViewModel == null) if (editEstimateViewModel == null)
@ -70,7 +70,7 @@ namespace BookAStar.Pages
if (estimateToEdit == null) if (estimateToEdit == null)
{ {
DataManager.Current.Contacts.Merge(BookQuery.Client); DataManager.Current.Contacts.Merge(BookQuery.Client);
DataManager.Current.Contacts.SaveCollection(); DataManager.Current.Contacts.SaveEntity();
estimateToEdit = new Estimate() estimateToEdit = new Estimate()
{ {
ClientId = BookQuery.Client.UserId, ClientId = BookQuery.Client.UserId,

@ -24,7 +24,7 @@ namespace BookAStar.Pages
private void EditEstimatePage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) private void EditEstimatePage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
DataManager.Current.EstimationCache.SaveCollection(); DataManager.Current.EstimationCache.SaveEntity();
} }
protected override void OnSizeAllocated(double width, double height) protected override void OnSizeAllocated(double width, double height)
@ -47,7 +47,7 @@ namespace BookAStar.Pages
var lineView = new BillingLineViewModel(com) var lineView = new BillingLineViewModel(com)
{ ValidateCommand = new Command(() => { { ValidateCommand = new Command(() => {
bill.Add(com); bill.Add(com);
bill.SaveCollection(); DataManager.Current.EstimationCache.SaveEntity();
})}; })};
App.NavigationService.NavigateTo<EditBillingLinePage>( App.NavigationService.NavigateTo<EditBillingLinePage>(
true, true,
@ -60,7 +60,7 @@ namespace BookAStar.Pages
var lineView = new BillingLineViewModel(line) var lineView = new BillingLineViewModel(line)
{ {
ValidateCommand = new Command(() => { ValidateCommand = new Command(() => {
bill.SaveCollection(); DataManager.Current.EstimationCache.SaveEntity();
}) })
}; };
lineView.PropertyChanged += LineView_PropertyChanged; lineView.PropertyChanged += LineView_PropertyChanged;
@ -71,7 +71,7 @@ namespace BookAStar.Pages
private void LineView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) private void LineView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
DataManager.Current.EstimationCache.SaveCollection(); DataManager.Current.EstimationCache.SaveEntity();
} }
protected void OnEstimateValidated(object sender, EventArgs e) protected void OnEstimateValidated(object sender, EventArgs e)
@ -88,9 +88,9 @@ namespace BookAStar.Pages
{ {
DataManager.Current.Estimates.Update(evm.Data); DataManager.Current.Estimates.Update(evm.Data);
} }
DataManager.Current.Estimates.SaveCollection(); DataManager.Current.Estimates.SaveEntity();
DataManager.Current.EstimationCache.Remove(evm); DataManager.Current.EstimationCache.Remove(evm);
DataManager.Current.EstimationCache.SaveCollection(); DataManager.Current.EstimationCache.SaveEntity();
Navigation.PopAsync(); Navigation.PopAsync();
} }
} }

@ -6,6 +6,7 @@ namespace BookAStar.Pages.UserProfile
{ {
using Data; using Data;
using ViewModels.UserProfile; using ViewModels.UserProfile;
public partial class DashboardPage : ContentPage public partial class DashboardPage : ContentPage
{ {
@ -23,10 +24,12 @@ namespace BookAStar.Pages.UserProfile
ShowPage<AccountChooserPage>(null, true); ShowPage<AccountChooserPage>(null, true);
}); });
} }
public void OnManageFiles(object sender, EventArgs e) public void OnManageFiles(object sender, EventArgs e)
{ {
ShowPage<UserFiles>(new object[] { new DirectoryInfoViewModel() }, true); ShowPage<UserFiles>(null, true);
} }
public void OnViewPerformerStatus(object sender, EventArgs e) public void OnViewPerformerStatus(object sender, EventArgs e)
{ {
ShowPage<AccountChooserPage>(null, true); ShowPage<AccountChooserPage>(null, true);

@ -1,35 +1,81 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.UserProfile.UserFiles"> x:Class="BookAStar.Pages.UserProfile.UserFiles"
<Label Text="{Binding SubPath}" VerticalOptions="Center" HorizontalOptions="Center" /> Style="{StaticResource PageStyle}">
<ListView x:Name="dirlist" ItemsSource="{Binding SubDirectories}" <ScrollView>
RefreshCommand="{Binding RefreshCommand}" > <StackLayout>
<ListView.ItemTemplate > <Label Text="Dossiers:" />
<DataTemplate> <ListView x:Name="filelist" ItemsSource="{Binding SubDirectories}"
<ViewCell> RefreshCommand="{Binding RefreshCommand}"
<ViewCell.View> SeparatorVisibility="Default"
<StackLayout Orientation="Horizontal"> VerticalOptions="Start">
<Label Text="{Binding Name}" /> <ListView.ItemTemplate >
<Label Text="{Binding Size}" /> <DataTemplate>
<Label Text="{Binding CreationTime, StringFormat='créé {0:dddd d MMMM à HH:mm}'}" /> <ViewCell>
<Label Text="{Binding LastModified, StringFormat='modifié {0:dddd d MMMM à HH:mm}'}" /> <ViewCell.View>
</StackLayout> <Label Text="{Binding .}" />
</ViewCell.View> </ViewCell.View>
</ViewCell> </ViewCell>
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView> </ListView>
<ListView x:Name="filelist" ItemsSource="{Binding FileInfo}" <ListView x:Name="dirlist" ItemsSource="{Binding FileInfo}"
RefreshCommand="{Binding RefreshCommand}"> RefreshCommand="{Binding RefreshCommand}"
<ListView.ItemTemplate > SeparatorVisibility="Default"
<DataTemplate> VerticalOptions="Start" >
<ViewCell> <ListView.ItemTemplate >
<ViewCell.View> <DataTemplate>
<Label Text="{Binding .}" /> <ViewCell>
</ViewCell.View> <ViewCell.View>
</ViewCell> <StackLayout Orientation="Horizontal">
</DataTemplate> <Label Text="{Binding Name}" />
</ListView.ItemTemplate> <Label Text="{Binding Size, StringFormat='{0}b'}" />
</ListView> <Label Text="{Binding CreationTime, StringFormat='créé {0:dddd d MMMM à HH:mm}'}" />
<Label Text="{Binding LastModified, StringFormat='modifié {0:dddd d MMMM à HH:mm}'}" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!--
<StackLayout Orientation="Horizontal">
<Label Text="{Binding UserName}" FontSize="{StaticResource LargeFontSize}" HorizontalOptions="Start"/>
<Label Text="{Binding SubPath}" VerticalOptions="Center" HorizontalOptions="Start" />
</StackLayout>
<ListView x:Name="filelist" ItemsSource="{Binding SubDirectories}"
RefreshCommand="{Binding RefreshCommand}">
<ListView.ItemTemplate >
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Label Text="{Binding .}" />
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView x:Name="dirlist" ItemsSource="{Binding FileInfo}"
RefreshCommand="{Binding RefreshCommand}" >
<ListView.ItemTemplate >
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding Name}" />
<Label Text="{Binding Size, StringFormat='{0}b'}" />
<Label Text="{Binding CreationTime, StringFormat='créé {0:dddd d MMMM à HH:mm}'}" />
<Label Text="{Binding LastModified, StringFormat='modifié {0:dddd d MMMM à HH:mm}'}" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
-->
</StackLayout>
</ScrollView>
</ContentPage> </ContentPage>

@ -4,31 +4,49 @@ namespace BookAStar.Pages.UserProfile
{ {
using ViewModels.UserProfile; using ViewModels.UserProfile;
using Data; using Data;
using System.Windows.Input;
public partial class UserFiles : ContentPage public partial class UserFiles : ContentPage
{ {
protected DirectoryInfoViewModel model; protected DirectoryInfoViewModel model;
public UserFiles() public UserFiles()
{ {
InitializeComponent(); InitializeComponent();
var current = DataManager.Current.RemoteFiles.CurrentItem;
var currentDir = DataManager.Current.RemoteFiles.CurrentItem; if (current != null)
BindingContext = new DirectoryInfoViewModel(current);
BindingContext = new DirectoryInfoViewModel(currentDir) else BindingContext = new DirectoryInfoViewModel
{ {
RefreshCommand = new Command(() => UserName = MainSettings.UserName
{
DataManager.Current.RemoteFiles.Execute(null);
this.dirlist.EndRefresh();
this.filelist.EndRefresh();
})
}; };
} }
public UserFiles(DirectoryInfoViewModel model)
{
InitializeComponent();
BindingContext = model;
}
protected override void OnBindingContextChanged() protected override void OnBindingContextChanged()
{ {
model = BindingContext as DirectoryInfoViewModel;
if (model != null)
model.RefreshCommand = new Command(() =>
{
DataManager.Current.RemoteFiles.Execute(null);
var item = DataManager.Current.RemoteFiles.CurrentItem;
if (item != null)
model.InnerModel = item;
// this.dirlist.EndRefresh();
// this.filelist.EndRefresh();
});
base.OnBindingContextChanged(); base.OnBindingContextChanged();
} }
protected override void OnAppearing()
{
base.OnAppearing();
model.RefreshCommand.Execute(model.SubPath);
}
} }
} }

@ -265,9 +265,9 @@ namespace BookAStar
/// <typeparam name="V"></typeparam> /// <typeparam name="V"></typeparam>
/// <param name="collection"></param> /// <param name="collection"></param>
/// <param name="subKey"></param> /// <param name="subKey"></param>
public static void Populate<V>(this IList<V> collection, string subKey = null) public static bool Populate<V,K>(this ILocalEntity<V, K> collection, string subKey = null) where K : IEquatable<K>
{ {
var key = $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}"; var key = GetCollectionKey<V>(subKey);
var data = AppSettings.GetValueOrDefault<string>(key, null); var data = AppSettings.GetValueOrDefault<string>(key, null);
if (!string.IsNullOrWhiteSpace(data)) if (!string.IsNullOrWhiteSpace(data))
{ {
@ -275,7 +275,15 @@ namespace BookAStar
if (items != null) if (items != null)
foreach (var item in items) foreach (var item in items)
collection.Add(item); collection.Add(item);
var cursorKey = GetCursorKey<V>(subKey);
var index = AppSettings.GetValueOrDefault<int>(cursorKey, -1);
if (index>=0)
{
collection.Seek(index);
}
return true;
} }
return false;
} }
/// <summary> /// <summary>
@ -284,11 +292,25 @@ namespace BookAStar
/// <typeparam name="V"></typeparam> /// <typeparam name="V"></typeparam>
/// <param name="collection"></param> /// <param name="collection"></param>
/// <param name="subKey"></param> /// <param name="subKey"></param>
public static void SaveCollection<V>(this IList<V> collection, string subKey=null) public static void SaveEntity<V,K>(this ILocalEntity<V, K> collection, string subKey=null) where K : IEquatable<K>
{ {
if (collection == null) return; if (collection == null) return;
var key = $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}"; var key = GetCollectionKey<V>(subKey);
var cursorKey = GetCursorKey<V>(subKey);
AppSettings.AddOrUpdateValue(key, JsonConvert.SerializeObject(collection)); AppSettings.AddOrUpdateValue(key, JsonConvert.SerializeObject(collection));
if (collection.CurrentItem!=null)
{
int index = collection.IndexOf(collection.CurrentItem) ;
AppSettings.AddOrUpdateValue<int>(cursorKey, index);
}
}
private static string GetCursorKey<V>(string subKey)
{
return $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}/c";
}
private static string GetCollectionKey<V>(string subKey)
{
return $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}";
} }
} }
} }

@ -5,28 +5,71 @@ using XLabs.Forms.Mvvm;
namespace BookAStar.ViewModels.UserProfile namespace BookAStar.ViewModels.UserProfile
{ {
using System.ComponentModel;
using Model.FileSystem; using Model.FileSystem;
public class DirectoryInfoViewModel : ViewModel public class DirectoryInfoViewModel : ViewModel
{ {
public ObservableString SubPath { get; set; } private string subPath;
public ObservableCollection<string> SubDirectories { get; set; } public string SubPath
public ObservableCollection<UserFileInfo> FileInfo { get; set; }
public ICommand RefreshCommand { get; set; }
public DirectoryInfoViewModel (UserDirectoryInfo model=null)
{ {
Data.DataManager.Current.RemoteFiles.CollectionChanged += RemoteFiles_CollectionChanged; get { return subPath; }
set { SetProperty<string>(ref subPath, value); }
}
private string userName;
public string UserName
{
get { return userName; }
set { SetProperty<string>(ref userName, value); }
}
private ObservableCollection<string> subDirectories;
public ObservableCollection<string> SubDirectories
{
get { return subDirectories; }
set { SetProperty< ObservableCollection < string >>( ref subDirectories, value) ; }
}
if (model == null) private ObservableCollection<UserFileInfo> fileInfo;
model = Data.DataManager.Current.RemoteFiles.CurrentItem; public ObservableCollection<UserFileInfo> FileInfo
SubDirectories = new ObservableCollection<string> (model.SubDirectories); {
SubPath = new ObservableString (model.SubPath); get { return fileInfo; }
FileInfo = new ObservableCollection<Model.FileSystem.UserFileInfo> (model.Files); set { SetProperty<ObservableCollection<UserFileInfo>> ( ref fileInfo, value ); }
}
UserDirectoryInfo model;
public UserDirectoryInfo InnerModel {
get { return model; }
set {
if (SetProperty<UserDirectoryInfo>(ref model, value))
if (model == null)
{
SubDirectories = new ObservableCollection<string>();
FileInfo = new ObservableCollection<UserFileInfo>();
SubPath = "<no path>";
UserName = "<no user>";
}
else
{
SubDirectories = new ObservableCollection<string>(model.SubDirectories);
FileInfo = new ObservableCollection<UserFileInfo>(model.Files);
SubPath = model.SubPath;
UserName = model.UserName;
}
}
}
public DirectoryInfoViewModel(UserDirectoryInfo model = null)
{
this.InnerModel = model;
} }
private void RemoteFiles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) private ICommand refreshCommand;
public ICommand RefreshCommand
{ {
throw new System.NotImplementedException(); get { return refreshCommand; }
set { SetProperty<ICommand>(ref refreshCommand, value); }
} }
} }
} }

Loading…