annotate Widgets/TransformXmlWidget.cs @ 135:fda46380dd68

Re #329: "Points" system should be used in UI * Replace fixed "pts" or "pt" with game system's text (May be fixed, but needs more testing)
author IBBoard <dev@ibboard.co.uk>
date Sun, 09 Oct 2011 21:03:09 +0100
parents cff58ea990c4
children 9808adf2d566
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;
132
cff58ea990c4 Fixes #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
8 using IBBoard.GtkSharp.Translatable;
127
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 namespace IBBoard.WarFoundry.GUI.GTK
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 [System.ComponentModel.ToolboxItem(true)]
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 public partial class TransformXmlWidget : Gtk.Bin
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 public event EventHandler TransformChanged;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 public TransformXmlWidget()
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 this.Build();
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 FillXsltList();
132
cff58ea990c4 Fixes #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
21 ControlTranslator.TranslateWidget(this);
127
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 }
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 private void FillXsltList()
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 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
27 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
28 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
29 }
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 public bool IsValid
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 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
34 }
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 public bool TransformEnabled
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 get { return doTransformWidget.Active; }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 }
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 public string GetXsltPath()
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 return ComboBoxUtils.GetSelectedItem<FileInfo>(transformList).FullName;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 }
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 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
47 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 bool enabled = doTransformWidget.Active;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 lblTransform.Sensitive = enabled;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 transformList.Sensitive = enabled;
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 FireTransformChanged();
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }
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 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
55 {
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 FireTransformChanged();
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 }
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 private void FireTransformChanged()
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 if (TransformChanged!= null)
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 TransformChanged(this, EventArgs.Empty);
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 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 }
786a3afb9240 Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68