Expose CurrentDirectory bindable for consumption

This commit is contained in:
Dean Herbert 2020-05-13 22:57:31 +09:00
parent 75777d22d2
commit 6bb06e9d61
1 changed files with 6 additions and 7 deletions

View File

@ -28,11 +28,11 @@ public class DirectorySelector : CompositeDrawable
private GameHost host { get; set; }
[Cached]
private readonly Bindable<DirectoryInfo> currentDirectory = new Bindable<DirectoryInfo>();
public readonly Bindable<DirectoryInfo> CurrentDirectory = new Bindable<DirectoryInfo>();
public DirectorySelector(string initialPath = null)
{
currentDirectory.Value = new DirectoryInfo(initialPath ?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
CurrentDirectory.Value = new DirectoryInfo(initialPath ?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
}
[BackgroundDependencyLoader]
@ -68,7 +68,7 @@ private void load()
},
};
currentDirectory.BindValueChanged(updateDisplay, true);
CurrentDirectory.BindValueChanged(updateDisplay, true);
}
private void updateDisplay(ValueChangedEvent<DirectoryInfo> directory)
@ -86,9 +86,9 @@ private void updateDisplay(ValueChangedEvent<DirectoryInfo> directory)
}
else
{
directoryFlow.Add(new ParentDirectoryPiece(currentDirectory.Value.Parent));
directoryFlow.Add(new ParentDirectoryPiece(CurrentDirectory.Value.Parent));
foreach (var dir in currentDirectory.Value.GetDirectories().OrderBy(d => d.Name))
foreach (var dir in CurrentDirectory.Value.GetDirectories().OrderBy(d => d.Name))
{
if ((dir.Attributes & FileAttributes.Hidden) == 0)
directoryFlow.Add(new DirectoryPiece(dir));
@ -97,8 +97,7 @@ private void updateDisplay(ValueChangedEvent<DirectoryInfo> directory)
}
catch (Exception)
{
currentDirectory.Value = directory.OldValue;
CurrentDirectory.Value = directory.OldValue;
this.FlashColour(Color4.Red, 300);
}
}