Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
changeset 131:0d8004d6a4e5
Re #361: XML Export UI for GTK
* Be a bit more careful with path check - make sure it could exist
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 01 Oct 2011 20:46:53 +0100 |
parents | c0e646ed0147 |
children | cff58ea990c4 |
files | FrmExportXml.cs |
diffstat | 1 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmExportXml.cs Sat Oct 01 20:45:31 2011 +0100 +++ b/FrmExportXml.cs Sat Oct 01 20:46:53 2011 +0100 @@ -24,7 +24,7 @@ this.army = army; AddButton(Gtk.Stock.Cancel, ResponseType.Cancel); buttonOk = (Button)AddButton(Gtk.Stock.Save, ResponseType.Ok); - buttonOk.Clicked+=OnButtonOkClicked; + buttonOk.Clicked+= OnButtonOkClicked; transformWidget = new TransformXmlWidget(); transformWidget.TransformChanged += HandleTransformWidgetTransformChanged; ExtraWidget = transformWidget; @@ -37,9 +37,25 @@ SetOkayButtonSensitive(); } - private bool IsValid () + private bool IsValid + { + get + { + return CheckFileCanExist() && transformWidget.IsValid; + } + } + + private bool CheckFileCanExist() { - return Filename != null && Filename != "" && transformWidget.IsValid; + bool canExist = false; + + if (!String.IsNullOrEmpty(Filename)) + { + FileInfo file = new FileInfo(Filename); + canExist = file.Directory.Exists; + } + + return canExist; } private void SetOkayButtonSensitive() @@ -56,7 +72,7 @@ protected void OnButtonOkClicked (object sender, System.EventArgs e) { - if (IsValid()) + if (IsValid) { DoExport(); }