aboutsummaryrefslogtreecommitdiffstatsci
path: root/Tests/GOLIBTest_DirViewer.cs
blob: f17afb9b73714546916cf67b12a5cc149ebf2b40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#define MONO_CAIRO_DEBUG_DISPOSE


using System;
using System.Runtime.InteropServices;
using OpenTK;
using OpenTK.Graphics.OpenGL;

using System.Diagnostics;

//using GGL;
using Crow;
using System.Threading;
using System.Reflection;
using System.Linq;
using System.IO;
using System.Collections.Generic;


namespace test2
{
	class GOLIBTest_DirViewer : OpenTKGameWindow
	{
		public GOLIBTest_DirViewer ()
			: base(1024, 600,"test")
		{}

		public DirContainer CurDir;
		FileDialog dialog;

		protected override void OnLoad (EventArgs e)
		{
			base.OnLoad (e);

			CurDir = new DirContainer(new DirectoryInfo ("/home/jp/"));

//			GraphicObject dv = Interface.Load ("Interfaces/testDirViewer.goml");
//			this.AddWidget(dv);
//			dv.DataSource = CurDir;
			dialog = new FileDialog();
			dialog.SearchPattern = ".png|.jpg|.jpeg|.gif|.svg";
			dialog.Show ();

			//LoadInterface("Interfaces/testTypeViewer.goml", out g);
		}
			

		[STAThread]
		static void Main ()
		{
			Console.WriteLine ("starting example");

			using (GOLIBTest_DirViewer win = new GOLIBTest_DirViewer( )) {
				win.Run (30.0);
			}
		}
	}
	public class DirContainer: IValueChange
	{
		#region IValueChange implementation
		public event EventHandler<ValueChangeEventArgs> 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;
		}
		public string Name {
			get { return CurDir.Name; }
		}
		public FileSystemInfo[] GetFileSystemInfos
		{
			get {
				List<FileSystemInfo> 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)
		{
			
		}
		public void onMouseDown(object sender, MouseButtonEventArgs e)
		{
			Debug.WriteLine (sender.ToString ());
		}
		void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
		{
			CurDir = e.NewValue as DirectoryInfo;
			NotifyValueChanged ("GetFileSystemInfos", GetFileSystemInfos);
			NotifyValueChanged ("Name", Name);

		}
	}

}