view Widgets/TransformXmlWidget.cs @ 167:9808adf2d566 default tip

Re #419: Remove assumptions of a file-based install * Update GTK# GUI to use Streams version of XSLT export
author IBBoard <dev@ibboard.co.uk>
date Wed, 28 Nov 2012 20:25:53 +0000
parents cff58ea990c4
children
line wrap: on
line source

// 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;
using IBBoard.GtkSharp.Translatable;
using IBBoard.WarFoundry.API.Exporters;
using IBBoard.IO;

namespace IBBoard.WarFoundry.GUI.GTK
{
	[System.ComponentModel.ToolboxItem(true)]
	public partial class TransformXmlWidget : Gtk.Bin
	{
		public event EventHandler TransformChanged;

		public TransformXmlWidget()
		{
			this.Build();
			FillXsltList();
			ControlTranslator.TranslateWidget(this);
		}

		private void FillXsltList()
		{
			NamedStream[] streams = WarFoundryXmlWithXslExporter.GetDefault().GetXsltStreams();
			ComboBoxUtils.FillCombo(transformList, streams, delegate(NamedStream xslStream) { return xslStream.Name; });
		}

		public bool IsValid
		{
			get { return !doTransformWidget.Active || ComboBoxUtils.GetSelectedItem<Stream>(transformList) != null; }
		}

		public bool TransformEnabled
		{
			get { return doTransformWidget.Active; }
		}

		public Stream GetXsltStream()
		{
			return ComboBoxUtils.GetSelectedItem<Stream>(transformList);
		}

		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);
			}
		}
	}
}