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 diff
     1.1 --- a/FrmExportXml.cs	Sat Oct 01 20:45:31 2011 +0100
     1.2 +++ b/FrmExportXml.cs	Sat Oct 01 20:46:53 2011 +0100
     1.3 @@ -24,7 +24,7 @@
     1.4  			this.army = army;
     1.5  			AddButton(Gtk.Stock.Cancel, ResponseType.Cancel);
     1.6  			buttonOk = (Button)AddButton(Gtk.Stock.Save, ResponseType.Ok);
     1.7 -			buttonOk.Clicked+=OnButtonOkClicked;
     1.8 +			buttonOk.Clicked+= OnButtonOkClicked;
     1.9  			transformWidget = new TransformXmlWidget();
    1.10  			transformWidget.TransformChanged += HandleTransformWidgetTransformChanged;
    1.11  			ExtraWidget = transformWidget;
    1.12 @@ -37,9 +37,25 @@
    1.13  			SetOkayButtonSensitive();
    1.14  		}
    1.15  
    1.16 -		private bool IsValid ()
    1.17 +		private bool IsValid
    1.18  		{
    1.19 -			return Filename != null && Filename != "" && transformWidget.IsValid;
    1.20 +			get
    1.21 +			{
    1.22 +				return CheckFileCanExist() && transformWidget.IsValid;
    1.23 +			}
    1.24 +		}
    1.25 +
    1.26 +		private bool CheckFileCanExist()
    1.27 +		{
    1.28 +			bool canExist = false;
    1.29 +
    1.30 +			if (!String.IsNullOrEmpty(Filename))
    1.31 +			{
    1.32 +				FileInfo file = new FileInfo(Filename);
    1.33 +				canExist = file.Directory.Exists;
    1.34 +			}
    1.35 +
    1.36 +			return canExist;
    1.37  		}
    1.38  
    1.39  		private void SetOkayButtonSensitive()
    1.40 @@ -56,7 +72,7 @@
    1.41  
    1.42  		protected void OnButtonOkClicked (object sender, System.EventArgs e)
    1.43  		{
    1.44 -			if (IsValid())
    1.45 +			if (IsValid)
    1.46  			{
    1.47  				DoExport();
    1.48  			}