//-----------------------------------------------------------------------------
// wx.NET - FileDialog.cs
//
// The wxFileDialog wrapper class.
//
// Written by Achim Breunig (achim.breunig@web.de)
// (C) 2003 Achim Breunig
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: FileDialog.cs,v 1.11 2007/11/11 14:14:46 harald_meyer Exp $
//-----------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace wx{
public class FileDialogStyle
{
public const int wxOPEN = 0x0001;
public const int wxSAVE = 0x0002;
public const int wxOVERWRITE_PROMPT = 0x0004;
public const int wxHIDE_READONLY = 0x0008;
public const int wxFILE_MUST_EXIST = 0x0010;
public const int wxMULTIPLE = 0x0020;
public const int wxCHANGE_DIR = 0x0040;
}
public class FileDialog : Dialog
{
[DllImport("wx-c")] static extern IntPtr wxFileDialog_ctor(IntPtr parent, IntPtr message, IntPtr defaultDir, IntPtr defaultFile, IntPtr wildcard, uint style, int posX, int posY);
[DllImport("wx-c")] static extern void wxFileDialog_dtor(IntPtr self);
[DllImport("wx-c")] static extern IntPtr wxFileDialog_GetDirectory(IntPtr self);
[DllImport("wx-c")] static extern void wxFileDialog_SetDirectory(IntPtr self, IntPtr dir);
[DllImport("wx-c")] static extern IntPtr wxFileDialog_GetFilename(IntPtr self);
[DllImport("wx-c")] static extern void wxFileDialog_SetFilename(IntPtr self, IntPtr filename);
[DllImport("wx-c")] static extern IntPtr wxFileDialog_GetPath(IntPtr self);
[DllImport("wx-c")] static extern void wxFileDialog_SetPath(IntPtr self, IntPtr path);
[DllImport("wx-c")] static extern void wxFileDialog_SetFilterIndex(IntPtr self, int filterIndex);
[DllImport("wx-c")] static extern int wxFileDialog_GetFilterIndex(IntPtr self);
[DllImport("wx-c")] static extern IntPtr wxFileDialog_GetWildcard(IntPtr self);
[DllImport("wx-c")] static extern void wxFileDialog_SetWildcard(IntPtr self, IntPtr wildcard);
[DllImport("wx-c")] static extern void wxFileDialog_SetMessage(IntPtr self, IntPtr message);
[DllImport("wx-c")] static extern IntPtr wxFileDialog_GetMessage(IntPtr self);
[DllImport("wx-c")] static extern int wxFileDialog_ShowModal(IntPtr self);
[DllImport("wx-c")] static extern uint wxFileDialog_GetStyle(IntPtr self);
[DllImport("wx-c")] static extern void wxFileDialog_SetStyle(IntPtr self, uint style);
[DllImport("wx-c")] static extern IntPtr wxFileDialog_GetPaths(IntPtr self);
[DllImport("wx-c")] static extern IntPtr wxFileDialog_GetFilenames(IntPtr self);
//---------------------------------------------------------------------
public FileDialog(IntPtr wxObject)
: base(wxObject) { }
public FileDialog(Window parent)
: this(parent, "Choose a file", "", "", "*.*", 0, wxDefaultPosition) { }
public FileDialog(Window parent, string message)
: this(parent, message, "", "", "*.*", 0, wxDefaultPosition) { }
public FileDialog(Window parent, string message, string defaultDir)
: this(parent, message, defaultDir, "", "*.*", 0, wxDefaultPosition) { }
public FileDialog(Window parent, string message, string defaultDir, string defaultFile)
: this(parent, message, defaultDir, defaultFile, "*.*", 0, wxDefaultPosition) { }
public FileDialog(Window parent, string message, string defaultDir, string defaultFile, string wildcard)
: this(parent, message, defaultDir, defaultFile, wildcard, 0, wxDefaultPosition) { }
public FileDialog(Window parent, string message, string defaultDir, string defaultFile, string wildcard, uint style)
: this(parent, message, defaultDir, defaultFile, wildcard, style, wxDefaultPosition) { }
public FileDialog(Window parent, string message, string defaultDir, string defaultFile, string wildcard, uint style, Point pos)
: this(parent, wxString.SafeNew(message), wxString.SafeNew(defaultDir), wxString.SafeNew(defaultFile), wxString.SafeNew(wildcard), (uint)style, pos.X, pos.Y) { }
public FileDialog(Window parent, wxString message, wxString defaultDir, wxString defaultFile, wxString wildcard, uint style, int posX, int posY)
: this(wxFileDialog_ctor(Object.SafePtr(parent), Object.SafePtr(message), Object.SafePtr(defaultDir), Object.SafePtr(defaultFile), Object.SafePtr(wildcard), (uint)style, posX, posY)) { }
//---------------------------------------------------------------------
public string Directory
{
get { return new wxString(wxFileDialog_GetDirectory(wxObject), true); }
set
{
wxString wxValue = wxString.SafeNew(value);
wxFileDialog_SetDirectory(wxObject, Object.SafePtr(wxValue));
}
}
public string Filename
{
get { return new wxString(wxFileDialog_GetFilename(wxObject), true); }
set
{
wxString wxValue = wxString.SafeNew(value);
wxFileDialog_SetFilename(wxObject, Object.SafePtr(wxValue));
}
}
public string Path
{
get { return new wxString(wxFileDialog_GetPath(wxObject), true); }
set
{
wxString wxValue = wxString.SafeNew(value);
wxFileDialog_SetPath(wxObject, Object.SafePtr(wxValue));
}
}
public int FilterIndex
{
set
{
wxFileDialog_SetFilterIndex(wxObject, value);
}
get { return wxFileDialog_GetFilterIndex(wxObject); }
}
public string Message
{
set
{
wxString wxValue = wxString.SafeNew(value);
wxFileDialog_SetMessage(wxObject, Object.SafePtr(wxValue));
}
get { return new wxString(wxFileDialog_GetMessage(wxObject), true); }
}
//---------------------------------------------------------------------
public override int ShowModal()
{
return wxFileDialog_ShowModal(wxObject);
}
//---------------------------------------------------------------------
public string Wildcard
{
get { return new wxString(wxFileDialog_GetWildcard(wxObject), true); }
set
{
wxString wxValue = wxString.SafeNew(value);
wxFileDialog_SetWildcard(wxObject, Object.SafePtr(wxValue));
}
}
public uint style
{
get { return wxFileDialog_GetStyle(this.wxObject); }
set { wxFileDialog_SetStyle(wxObject, (uint)value); }
}
//---------------------------------------------------------------------
public string[] Paths
{
get { return new ArrayString(wxFileDialog_GetPaths(this.wxObject), true); }
}
public string[] Filenames
{
get { return new ArrayString(wxFileDialog_GetFilenames(this.wxObject), true); }
}
}
}
|