[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms FileDialog.cs, 1.2, 1
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms FileDialog.cs, 1.2, 1.3 OpenFileDialog.cs, 1.2, 1.3 SaveFileDialog.cs, 1.1, 1.2 |
Date: |
Fri, 14 Nov 2003 04:51:34 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv30592/System.Windows.Forms
Modified Files:
FileDialog.cs OpenFileDialog.cs SaveFileDialog.cs
Log Message:
Build the basic widget structure for file dialogs, but with no behaviour as yet.
Index: FileDialog.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/FileDialog.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FileDialog.cs 14 Nov 2003 03:47:21 -0000 1.2
--- FileDialog.cs 14 Nov 2003 04:51:32 -0000 1.3
***************
*** 23,26 ****
--- 23,27 ----
{
+ using System.Drawing;
using System.ComponentModel;
***************
*** 42,45 ****
--- 43,47 ----
private bool validateNames;
private String title;
+ private FileDialogForm form;
// Event identifier for the "FileOk" event.
***************
*** 222,226 ****
}
}
- [TODO]
public String Title
{
--- 224,227 ----
***************
*** 235,240 ****
set
{
- // TODO: update the dialog box to match.
title = value;
}
}
--- 236,251 ----
set
{
title = value;
+ if(form != null)
+ {
+ if(value == null)
+ {
+ form.Text =
String.Empty;
+ }
+ else
+ {
+ form.Text = value;
+ }
+ }
}
}
***************
*** 258,261 ****
--- 269,279 ----
}
}
+ internal virtual String OkButtonName
+ {
+ get
+ {
+ return S._("SWF_FileDialog_OpenButton",
"Open");
+ }
+ }
// Hook procedure - not used in this implementation.
***************
*** 302,310 ****
return false;
}
- [TODO]
internal override DialogResult RunDialog(IWin32Window owner)
{
! // TODO
! return DialogResult.None;
}
--- 320,346 ----
return false;
}
internal override DialogResult RunDialog(IWin32Window owner)
{
! // If the dialog is already visible, then bail
out.
! if(form != null)
! {
! return DialogResult.Cancel;
! }
!
! // Construct the file dialog form.
! form = new FileDialogForm(this);
!
! // Run the dialog and get its result.
! DialogResult result;
! try
! {
! result = form.ShowDialog(owner);
! }
! finally
! {
! form.DisposeDialog();
! form = null;
! }
! return result;
}
***************
*** 318,321 ****
--- 354,453 ----
// Event that is raised to check that a file is OK.
public event CancelEventHandler FileOk;
+
+ // Form that defines the UI of a file dialog.
+ private sealed class FileDialogForm : Form
+ {
+ // Internal state.
+ private FileDialog fileDialogParent;
+ private VBoxLayout vbox;
+ private HBoxLayout hbox1;
+ private HBoxLayout hbox2;
+ private HBoxLayout hbox3;
+ private ListBox listBox;
+ private ComboBox directory;
+ private Button upButton;
+ private Label nameLabel;
+ private TextBox name;
+ private Label typeLabel;
+ private ComboBox type;
+ private Button okButton;
+ private Button cancelButton;
+
+ // Constructor.
+ public FileDialogForm(FileDialog fileDialogParent)
+ {
+ // Record the parent for later access.
+ this.fileDialogParent =
fileDialogParent;
+
+ // Set the caption to that specified in
the parent.
+ Text = fileDialogParent.Title;
+
+ // Construct the layout boxes for the
file dialog.
+ vbox = new VBoxLayout();
+ vbox.Dock = DockStyle.Fill;
+ hbox1 = new HBoxLayout();
+ listBox = new ListBox();
+ hbox2 = new HBoxLayout();
+ hbox3 = new HBoxLayout();
+ vbox.Controls.Add(hbox1);
+ vbox.Controls.Add(listBox);
+ vbox.Controls.Add(hbox2);
+ vbox.Controls.Add(hbox3);
+ vbox.StretchControl = listBox;
+
+ // Add the top line (directory name and
up button).
+ directory = new ComboBox();
+ upButton = new Button();
+ upButton.FlatStyle = FlatStyle.Popup;
+ upButton.Text = "Up"; // TODO: change
to an image.
+ hbox1.StretchControl = directory;
+ hbox1.Controls.Add(directory);
+ hbox1.Controls.Add(upButton);
+
+ // The second line is "listBox",
already created above.
+
+ // Add the third line (file name
fields).
+ nameLabel = new Label();
+ nameLabel.Text = "File name:"; //
TODO: translate.
+ name = new TextBox();
+ okButton = new Button();
+ okButton.Text =
fileDialogParent.OkButtonName;
+ hbox2.StretchControl = name;
+ hbox2.Controls.Add(nameLabel);
+ hbox2.Controls.Add(name);
+ hbox2.Controls.Add(okButton);
+
+ // Add the fourth line (file type
fields).
+ typeLabel = new Label();
+ typeLabel.Text = "Files of type:";
// TODO: translate.
+ type = new ComboBox();
+ cancelButton = new Button();
+ cancelButton.Text =
S._("SWF_MessageBox_Cancel", "Cancel");
+ hbox3.StretchControl = type;
+ hbox3.Controls.Add(typeLabel);
+ hbox3.Controls.Add(type);
+ hbox3.Controls.Add(cancelButton);
+
+ // Add the top-level vbox to the dialog
and set the size.
+ Controls.Add(vbox);
+ Size size = vbox.RecommendedSize;
+ if(size.Width < 500)
+ {
+ size.Width = 500;
+ }
+ if(size.Height < 300)
+ {
+ size.Height = 300;
+ }
+ ClientSize = size;
+ }
+
+ // Dispose of this dialog.
+ public void DisposeDialog()
+ {
+ Dispose(true);
+ }
+
+ }; // class FileDialogForm
}; // class FileDialog
Index: OpenFileDialog.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/OpenFileDialog.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** OpenFileDialog.cs 14 Nov 2003 03:47:21 -0000 1.2
--- OpenFileDialog.cs 14 Nov 2003 04:51:32 -0000 1.3
***************
*** 82,92 ****
}
}
- [TODO]
internal override String DefaultTitle
{
get
{
! // TODO: make this translatable.
! return "Open";
}
}
--- 82,90 ----
}
}
internal override String DefaultTitle
{
get
{
! return S._("SWF_FileDialog_OpenTitle",
"Open");
}
}
Index: SaveFileDialog.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/SaveFileDialog.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SaveFileDialog.cs 14 Nov 2003 03:47:21 -0000 1.1
--- SaveFileDialog.cs 14 Nov 2003 04:51:32 -0000 1.2
***************
*** 57,67 ****
}
}
- [TODO]
internal override String DefaultTitle
{
get
{
! // TODO: make this translatable.
! return "Save As";
}
}
--- 57,72 ----
}
}
internal override String DefaultTitle
{
get
{
! return
S._("SWF_FileDialog_SaveAsTitle", "Save As");
! }
! }
! internal override String OkButtonName
! {
! get
! {
! return S._("SWF_MessageBox_SaveButton",
"Save");
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/System.Windows.Forms FileDialog.cs, 1.2, 1.3 OpenFileDialog.cs, 1.2, 1.3 SaveFileDialog.cs, 1.1, 1.2,
Rhys Weatherley <address@hidden> <=