changeset 127:786a3afb9240

Re #361: Add XML export UI to GTK# * Add missing widget
author IBBoard <dev@ibboard.co.uk>
date Sat, 01 Oct 2011 16:49:35 +0100
parents d4e6bfeb1c61
children d5a631a8d288
files Widgets/TransformXmlWidget.cs
diffstat 1 files changed, 66 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Widgets/TransformXmlWidget.cs	Sat Oct 01 16:49:35 2011 +0100
@@ -0,0 +1,66 @@
+// This file (TransformXmlWidget.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2011 IBBoard
+// 
+// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
+using System;
+using System.IO;
+using System.Collections.Generic;
+using IBBoard.GtkSharp;
+
+namespace IBBoard.WarFoundry.GUI.GTK
+{
+	[System.ComponentModel.ToolboxItem(true)]
+	public partial class TransformXmlWidget : Gtk.Bin
+	{
+		public event EventHandler TransformChanged;
+
+		public TransformXmlWidget()
+		{
+			this.Build();
+			FillXsltList();
+		}
+
+		private void FillXsltList()
+		{
+			DirectoryInfo dir = new DirectoryInfo(System.IO.Path.Combine(Constants.ExecutablePath, "xsl"));
+			List<FileInfo> files = new List<FileInfo>(dir.GetFiles("*.xsl"));
+			ComboBoxUtils.FillCombo(transformList, files, delegate(FileInfo file) { return file.Name; });
+		}
+
+		public bool IsValid
+		{
+			get { return !doTransformWidget.Active || ComboBoxUtils.GetSelectedItem<FileInfo>(transformList) != null; }
+		}
+
+		public bool TransformEnabled
+		{
+			get { return doTransformWidget.Active; }
+		}
+
+		public string GetXsltPath()
+		{
+			return ComboBoxUtils.GetSelectedItem<FileInfo>(transformList).FullName;
+		}
+
+		protected void OnDoTransformWidgetToggled(object sender, System.EventArgs e)
+		{
+			bool enabled = doTransformWidget.Active;
+			lblTransform.Sensitive = enabled;
+			transformList.Sensitive = enabled;
+			FireTransformChanged();
+		}
+
+		protected void OnTransformListChanged(object sender, System.EventArgs e)
+		{
+			FireTransformChanged();
+		}
+
+		private void FireTransformChanged()
+		{
+			if (TransformChanged!= null)
+			{
+				TransformChanged(this, EventArgs.Empty);
+			}
+		}
+	}
+}
+