-
Notifications
You must be signed in to change notification settings - Fork 1
/
SelectLuForm.cs
60 lines (52 loc) · 1.67 KB
/
SelectLuForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ArcSWAT3
{
public partial class SelectLuForm : Form
{
private GlobalVars _gv;
private string _luse;
public SelectLuForm(GlobalVars gv) {
InitializeComponent();
this._gv = gv;
this._luse = "";
}
// Run the dialog and return selected landuse.
public virtual string run() {
var luses = this._gv.db.populateAllLanduses();
this.listBox.DataSource = luses;
var result = this.ShowDialog();
if (result == DialogResult.OK) {
return this._luse;
} else {
return "";
}
}
//
// A selection has the form 'LUSE (Description)' or 'USE (Description)'.
// This function returns 'LUSE' or 'USE':
// namely the line up to the space before '('
//
public virtual void select(string selection) {
var length = selection.IndexOf("(");
this._luse = selection.Substring(0, length - 1);
}
private void listBox_SelectedValueChanged(object sender, EventArgs e) {
this.select(this.listBox.SelectedValue.ToString());
}
private void okButton_Click(object sender, EventArgs e) {
this.Close();
}
private void cancelButton_Click(object sender, EventArgs e) {
this.Close();
}
}
}