<Compile Include="src\GraphicObjects\Combobox.cs" />\r
<Compile Include="src\SelectionChangeEventArgs.cs" />\r
<Compile Include="src\ValueChangeEventArgs.cs" />\r
+ <Compile Include="src\GraphicObjects\FileDialog.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Reference Include="System" />\r
<EmbeddedResource Include="Templates\Groupbox.goml" />\r
<EmbeddedResource Include="Templates\Combobox.goml" />\r
<EmbeddedResource Include="Templates\ComboboxOverlay.goml" />\r
+ <EmbeddedResource Include="Templates\FileDialog.goml" />\r
+ <EmbeddedResource Include="Templates\tmpDirItem.goml" />\r
+ <EmbeddedResource Include="Templates\ScrollingListBox.goml" />\r
+ <EmbeddedResource Include="Templates\imgItemTemplate.goml" />\r
</ItemGroup>\r
<ItemGroup>\r
<None Include="Images\Icons\Cursors\hand" />\r
--- /dev/null
+<?xml version="1.0"?>
+<Window Title="OpenFile" Height="300" Width="500">
+ <VerticalStack Margin="5">
+ <TextBoxWidget Margin="1" Width="0" Height="-1" Text="{CurrentPath}"/>
+ <HorizontalStack >
+ <ListBox Data="{Directories}" Width="-1" Height="0"
+ Background="0,5;0,5;0,5;0,5"
+ SelectedItemChanged="OnSelectedItemChanged"
+ Template="#go.Templates.ScrollingListBox.goml"
+ ItemTemplate="#go.Templates.tmpDirItem.goml" >
+ </ListBox>
+ <ListBox Data="{Files}" Width="0" Height="0"
+ Background="0,5;0,5;0,5;0,5"
+ SelectedItemChanged="onFileListItemChanged"
+ Template="#go.Templates.ScrollingListBox.goml"
+ ItemTemplate="#go.Templates.imgItemTemplate.goml">
+ </ListBox>
+ </HorizontalStack>
+ <HorizontalStack Fit="true" HorizontalAlignment="Right">
+ <Button Text="Ok" MouseClick="onFileSelect"/>
+ <Button Text="Cancel"/>
+ </HorizontalStack>
+ </VerticalStack>
+</Window>
--- /dev/null
+<?xml version="1.0"?>
+<Border BorderWidth="1" MinimumSize="20;20" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}">
+ <HorizontalStack Margin="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">
+ <Scroller Name="scroller1" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"
+ Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">
+ <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1"
+ Name="List" Margin="0" VerticalAlignment="Top" />
+ </Scroller>
+ <Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}"
+ MaximumScroll="{../scroller1.MaximumScroll}" Orientation="Vertical"
+ Width="10" Height="{../../../TemplatedHeight}" />
+ </HorizontalStack>
+</Border>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>\r
+ <VerticalStack Width="0" Height="-1" Focusable="true" \r
+ MouseEnter="{Background=BlueCrayola}"\r
+ MouseLeave="{Background=Transparent}">\r
+ <Image Width="-1" Height="-1" Path="{FullName}" MaximumSize="80;80"/>\r
+ <Label Text="{Name}" Width="-1" Height="-1" Margin="0" MaximumSize="100;0"/>\r
+ </VerticalStack>\r
+\r
--- /dev/null
+<?xml version="1.0"?>\r
+ <HorizontalStack Width="-1" Height="-1" Focusable="true"\r
+ HorizontalAlignment="Left"\r
+ MouseEnter="{Background=BlueCrayola}"\r
+ MouseLeave="{Background=Transparent}">\r
+ <Image Width="16" Height="16" Path="#Tests.image.folder1.svg" SvgSub="{Attributes}"/>\r
+ <Label Text="{Name}" Width="-1" Height="-1" Margin="0"/>\r
+<!-- <Label Text="{Attributes}" Width="-1" Height="-1" Margin="0"/>\r
+ <Label Text="{Extension}" Width="-1" Height="-1" Margin="0"/>-->\r
+ </HorizontalStack>\r
+\r
{}\r
\r
public DirContainer CurDir;\r
+ FileDialog dialog;\r
\r
protected override void OnLoad (EventArgs e)\r
{\r
\r
CurDir = new DirContainer(new DirectoryInfo ("/home/jp/"));\r
\r
- GraphicObject dv = Interface.Load ("Interfaces/testDirViewer.goml");\r
- this.AddWidget(dv);\r
- dv.DataSource = CurDir;\r
+// GraphicObject dv = Interface.Load ("Interfaces/testDirViewer.goml");\r
+// this.AddWidget(dv);\r
+// dv.DataSource = CurDir;\r
+ dialog = new FileDialog();\r
+ dialog.SearchPattern = ".png|.jpg|.jpeg|.gif|.svg";\r
+ dialog.Show ();\r
\r
//LoadInterface("Interfaces/testTypeViewer.goml", out g);\r
}\r
}\r
protected override void OnKeyDown (KeyboardKeyEventArgs e)\r
{\r
- base.OnKeyDown (e);\r
+ if (FocusedWidget != null) {\r
+ base.OnKeyDown (e);\r
+ return;\r
+ }\r
if (e.Key == Key.Escape) {\r
this.Quit ();\r
return;\r
Background="0,5;0,5;0,5;0,5"
SelectedItemChanged="OnSelectedItemChanged"
ItemTemplate="Interfaces/tmpDirItem.goml" >
-<!-- <Template>
- <Border Width="0" Height="0" BorderWidth="1" Margin="1" MinimumSize="0;100" >
- <HorizontalStack Width="0" Height="0">
- <Scroller Name="scroller1" Height="0" Width="0"
- Margin="10" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">
- <VerticalStack Width="0" Height="-1" Name="List" Margin="0" VerticalAlignment="Top"/>
+ <Template>
+ <Border BorderWidth="1" MinimumSize="20;20" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}">
+ <HorizontalStack Margin="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">
+ <Scroller Name="scroller1" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"
+ Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">
+ <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1" Name="List" Margin="0" VerticalAlignment="Top"/>
</Scroller>
<Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}"
- Orientation="Vertical" Width="10" />
+ Orientation="Vertical" Width="10" Height="{../../../TemplatedHeight}" />
</HorizontalStack>
</Border>
- </Template>-->
+ </Template>
</ListBox>
</VerticalStack>
--- /dev/null
+<?xml version="1.0"?>
+<FileDialog Width="500" Height="300"/>
+
<?xml version="1.0"?>\r
-<!--<Group>-->\r
<Window Name="window1" Left="10" Top="10" Title="Test window" \r
Width="250" Height="300" >\r
<VerticalStack Name="contentVSStack" Margin="10" Spacing="10">\r
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTests</StartupObject>
+ <StartupObject>test2.GOLIBTest_DirViewer</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
<None Include="Interfaces\testCombobox.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\testFileDialog.goml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
--- /dev/null
+//
+// FileDialog.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2015 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using System.IO;
+using System.Collections.Generic;
+using System.Diagnostics;
+using OpenTK.Input;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace go
+{
+ public class FileDialog: IValueChange
+ {
+ #region IValueChange implementation
+ public event EventHandler<ValueChangeEventArgs> ValueChanged;
+ public virtual void NotifyValueChanged(string MemberName, object _value)
+ {
+ ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
+ }
+ #endregion
+
+ Window window;
+ DirectoryInfo currentDir;
+ FileInfo selectedFile;
+ string searchPattern = "*";
+
+ #region CTOR
+ public FileDialog ()
+ {
+ currentDir = new DirectoryInfo (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
+ window = Interface.Load("#go.Templates.FileDialog.goml") as Window;
+ window.DataSource = this;
+ }
+ #endregion
+
+ public string CurrentPath {
+ get { return currentDir.FullName; }
+ set {
+ currentDir = new DirectoryInfo (value);
+ NotifyValueChanged ("CurrentPath", CurrentPath);
+ }
+ }
+ public string SearchPattern {
+ get { return searchPattern; }
+ set {
+ searchPattern = value;
+ NotifyValueChanged ("Files", Files);
+ }
+ }
+
+ public DirectoryInfo[] Directories
+ {
+ get {
+ //currentDir.GetDirectories
+ List<DirectoryInfo> tmp = currentDir.GetDirectories ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList();
+ if (currentDir.Parent != null)
+ tmp.Insert (0, currentDir.Parent);
+ return tmp.ToArray ();
+ }
+ }
+ public FileInfo[] Files
+ {
+ get {
+ string[] exts = searchPattern.Replace("*","").Split ('|');
+ //return currentDir.GetFiles (searchPattern).Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray();
+ return currentDir.GetFiles().Where(f => exts.Any
+ (x => f.Name.EndsWith (x, StringComparison.InvariantCultureIgnoreCase))).ToArray();
+ }
+ }
+
+ public void Show(){
+ OpenTKGameWindow.currentWindow.AddWidget(window);
+ }
+
+ void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
+ {
+ currentDir = e.NewValue as DirectoryInfo;
+ NotifyValueChanged ("CurrentPath", CurrentPath);
+ NotifyValueChanged ("Directories", Directories);
+ NotifyValueChanged ("Files", Files);
+
+ }
+ void onFileListItemChanged (object sender, SelectionChangeEventArgs e)
+ {
+ selectedFile = e.NewValue as FileInfo;
+ }
+ void onFileSelect(object sender, OpenTK.Input.MouseButtonEventArgs e){
+ OpenTKGameWindow.currentWindow.DeleteWidget(window);
+ }
+ }
+ 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; }
+ }
+
+ void onDirUp(object sender, MouseButtonEventArgs e)
+ {
+
+ }
+ public void onMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ Debug.WriteLine (sender.ToString ());
+ }
+
+ }
+}
+
_pic = new BmpPicture ();\r
\r
_pic.LoadImage (path);\r
+ registerForGraphicUpdate ();\r
}\r
#endregion\r
\r
bool _scrollbarVisible;\r
double _scrollX = 0.0;\r
double _scrollY = 0.0;\r
+ int scrollSpeed;\r
+\r
\r
\r
#region public properties\r
}\r
}\r
\r
- public static int ScrollSpeed = 10;\r
+ [XmlAttributeAttribute][DefaultValue(30)]\r
+ public int ScrollSpeed {\r
+ get { return scrollSpeed; }\r
+ set {\r
+ scrollSpeed = value;\r
+ ValueChanged.Raise(this, new ValueChangeEventArgs("ScrollSpeed", scrollSpeed));\r
+ }\r
+ }\r
\r
#endregion\r
\r
#region Mouse handling\r
public override bool MouseIsIn (Point m)\r
{ \r
+ Debug.WriteLine ("Mouse in scroller: {0} scr coord:{1} mouse:{2}",\r
+ base.ScreenCoordinates (Slot).ContainsOrIsEqual (m),\r
+ base.ScreenCoordinates (Slot), m);\r
+\r
return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false; \r
}\r
public override void checkHoverWidget (MouseMoveEventArgs e)\r
// : base(_width, _height, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), _title)\r
{\r
//VSync = VSyncMode.On;\r
-\r
+ currentWindow = this;\r
//Load cursors\r
XCursor.Cross = XCursorFile.Load("#go.Images.Icons.Cursors.cross").Cursors[0];\r
XCursor.Default = XCursorFile.Load("#go.Images.Icons.Cursors.arrow").Cursors[0];\r