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