From f5f814e551005979e9e0c0003bde3d6bde67df01 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Mon, 19 Oct 2015 16:50:03 +0200 Subject: [PATCH] test Directory viewer --- Tests/GOLIBTest_DirViewer.cs | 40 +++- Tests/GOLIBTests.cs | 3 +- Tests/Interfaces/testDirViewer.goml | 13 +- Tests/Interfaces/tmpDirItem.goml | 10 +- Tests/Tests.csproj | 2 + Tests/image/folder1.svg | 341 +++++++++++++++++++++++----- src/GraphicObjects/ListBox.cs | 4 +- 7 files changed, 347 insertions(+), 66 deletions(-) diff --git a/Tests/GOLIBTest_DirViewer.cs b/Tests/GOLIBTest_DirViewer.cs index f5c31921..9632e665 100644 --- a/Tests/GOLIBTest_DirViewer.cs +++ b/Tests/GOLIBTest_DirViewer.cs @@ -15,12 +15,21 @@ using System.Threading; using System.Reflection; using System.Linq; using System.IO; +using System.Collections.Generic; namespace test2 { - class GOLIBTest_DirViewer : OpenTKGameWindow + class GOLIBTest_DirViewer : OpenTKGameWindow, IValueChange { + #region IValueChange implementation + public event EventHandler ValueChanged; + public void NotifyValueChanged(string name, object value) + { + ValueChanged.Raise (this, new ValueChangeEventArgs (name, value)); + } + #endregion + public GOLIBTest_DirViewer () : base(1024, 600,"test") {} @@ -30,11 +39,16 @@ namespace test2 protected override void OnLoad (EventArgs e) { base.OnLoad (e); + CurDir = new DirContainer(new DirectoryInfo ("/home/jp/")); - this.AddWidget(Interface.Load ("Interfaces/testDirViewer.goml", CurDir)); + GraphicObject dv = Interface.Load ("Interfaces/testDirViewer.goml"); + this.AddWidget(dv); + dv.DataSource = CurDir; + //LoadInterface("Interfaces/testTypeViewer.goml", out g); } + [STAThread] static void Main () @@ -46,8 +60,16 @@ namespace test2 } } } - public class DirContainer + public class DirContainer: IValueChange { + #region IValueChange implementation + public event EventHandler ValueChanged; + public void NotifyValueChanged(string name, object value) + { + ValueChanged.Raise (this, new ValueChangeEventArgs (name, value)); + } + #endregion + public DirectoryInfo CurDir; public DirContainer(DirectoryInfo _dir){ CurDir = _dir; @@ -58,7 +80,10 @@ namespace test2 public FileSystemInfo[] GetFileSystemInfos { get { - return CurDir.GetFileSystemInfos ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray(); + List tmp = CurDir.GetFileSystemInfos ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList(); + if (CurDir.Parent != null) + tmp.Insert (0, CurDir.Parent); + return tmp.ToArray (); } } void onDirUp(object sender, MouseButtonEventArgs e) @@ -69,6 +94,13 @@ namespace test2 { Debug.WriteLine (sender.ToString ()); } + void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e) + { + CurDir = e.NewValue as DirectoryInfo; + NotifyValueChanged ("GetFileSystemInfos", GetFileSystemInfos); + NotifyValueChanged ("Name", Name); + + } } } \ No newline at end of file diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs index 83fe00a1..e84c18fc 100644 --- a/Tests/GOLIBTests.cs +++ b/Tests/GOLIBTests.cs @@ -36,8 +36,8 @@ namespace test int frameCpt = 0; int idx = 0; string[] testFiles = { + "testSpinner.goml", "test_Listbox.goml", - "testCombobox.goml", "fps.goml", "testCheckbox.goml", "testExpandable.goml", @@ -53,6 +53,7 @@ namespace test "testGrid.goml", "testMeter.goml", // "test4.goml", +// "testCombobox.goml", }; #region FPS diff --git a/Tests/Interfaces/testDirViewer.goml b/Tests/Interfaces/testDirViewer.goml index 7383dc12..1c418126 100755 --- a/Tests/Interfaces/testDirViewer.goml +++ b/Tests/Interfaces/testDirViewer.goml @@ -1,11 +1,14 @@  - - + + - -