annotate Widgets/TransformXmlWidget.cs @ 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
children cff58ea990c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
127
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (TransformXmlWidget.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2011 IBBoard
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // 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.
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System.IO;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.Collections.Generic;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.GtkSharp;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.WarFoundry.GUI.GTK
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 [System.ComponentModel.ToolboxItem(true)]
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public partial class TransformXmlWidget : Gtk.Bin
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public event EventHandler TransformChanged;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public TransformXmlWidget()
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 this.Build();
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 FillXsltList();
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 private void FillXsltList()
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 DirectoryInfo dir = new DirectoryInfo(System.IO.Path.Combine(Constants.ExecutablePath, "xsl"));
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 List<FileInfo> files = new List<FileInfo>(dir.GetFiles("*.xsl"));
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 ComboBoxUtils.FillCombo(transformList, files, delegate(FileInfo file) { return file.Name; });
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 public bool IsValid
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 get { return !doTransformWidget.Active || ComboBoxUtils.GetSelectedItem<FileInfo>(transformList) != null; }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 public bool TransformEnabled
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 get { return doTransformWidget.Active; }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 public string GetXsltPath()
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 return ComboBoxUtils.GetSelectedItem<FileInfo>(transformList).FullName;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 protected void OnDoTransformWidgetToggled(object sender, System.EventArgs e)
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 bool enabled = doTransformWidget.Active;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 lblTransform.Sensitive = enabled;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 transformList.Sensitive = enabled;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 FireTransformChanged();
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 protected void OnTransformListChanged(object sender, System.EventArgs e)
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 FireTransformChanged();
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 private void FireTransformChanged()
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 if (TransformChanged!= null)
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 TransformChanged(this, EventArgs.Empty);
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66