source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet.WinForm/Forms/RpmsServerConfigurationManagementDialog.cs@ 1146

Last change on this file since 1146 was 1146, checked in by Sam Habiel, 13 years ago

Initial Import of BMX4

File size: 6.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using IndianHealthService.BMXNet.WinForm.Configuration;
9
10namespace IndianHealthService.BMXNet.WinForm.Forms
11{
12 internal partial class RpmsServerConfigurationManagementDialog : Form
13 {
14 public RpmsServerConfigurationManagementDialog()
15 {
16 InitializeComponent();
17 }
18
19 private RpmsConnectionSettings _settings = null;
20
21 public RpmsConnectionSettings Settings
22 {
23 get { return _settings; }
24 set { _settings = value; }
25 }
26
27
28 public void UpdateListView(RpmsConnectionSpec aSpec)
29 {
30 this.specListView.BeginUpdate();
31 this.specListView.Items.Clear();
32 this.specListView.Columns.Clear();
33
34 this.specListView.Columns.Add("Connection", 140);
35 this.specListView.Columns.Add("Server:Port", 100);
36 this.specListView.Columns.Add("Namespace", 120);
37 this.specListView.Columns.Add("Authenication", 120);
38
39 foreach (RpmsConnectionSpec each in this.Settings.ManagedConnectionSpecs)
40 {
41 ListViewItem item = new ListViewItem(each.Name);
42 item.UseItemStyleForSubItems=false;
43 if (each.IsDefault) {
44 item.Font = new Font(this.specListView.Font, FontStyle.Bold);
45 item.Text = item.Text + " (default)";
46 }
47 item.SubItems.Add(each.Server + ":" + each.Port.ToString());
48 item.SubItems.Add(each.HasNameSpace ? each.NameSpace : "(RPMS default)");
49 item.SubItems.Add(each.UseWindowsAuthentication ? "RPMS/Windows" : "RPMS");
50 item.Tag = each;
51 item.Selected = each==aSpec;
52
53 this.specListView.Items.Add(item);
54 }
55
56 this.specListView.EndUpdate();
57
58 this.UpdateCues();
59 }
60
61 private void RpmsServerConfigurationManagementDialog_Load(object sender, EventArgs e)
62 {
63 this.Icon = this.Owner.Icon;
64 this.UpdateListView(null);
65 }
66
67 private void newButton_Click(object sender, EventArgs e)
68 {
69 RpmsServerConnectionPropertiesDialog dialog = new RpmsServerConnectionPropertiesDialog();
70 dialog.Model = new RpmsConnectionSpec();
71 dialog.ShowDialog(this);
72 if (dialog.Model == null)
73 return;
74
75 this.Settings.AddConnectionSpec(dialog.Model);
76 this.UpdateListView(dialog.Model);
77
78 }
79
80 private void saveButton_Click(object sender, EventArgs e)
81 {
82 this.Settings.Save();
83 this.Close();
84 }
85
86 private void specListView_SelectedIndexChanged(object sender, EventArgs e)
87 {
88 this.UpdateCues();
89 }
90
91 public RpmsConnectionSpec SelectedSpec
92 {
93 get
94 {
95 if (this.specListView.SelectedItems.Count > 0)
96 {
97 return (RpmsConnectionSpec)this.specListView.SelectedItems[0].Tag;
98 }
99 else
100 {
101 return null;
102 }
103 }
104 }
105
106 protected void UpdateCues()
107 {
108 bool hasSelection = this.SelectedSpec != null;
109
110 this.deleteButton.Enabled = hasSelection;
111 this.editButton.Enabled = hasSelection;
112 this.moveDownButton.Enabled = hasSelection;
113 this.moveUpButton.Enabled = hasSelection;
114 this.beDefaultButton.Enabled = hasSelection;
115 this.testButton.Enabled = hasSelection;
116 }
117
118 private void cancelButton_Click(object sender, EventArgs e)
119 {
120 this.Settings.Revert();
121 this.Close();
122 }
123
124 private void moveUpButton_Click(object sender, EventArgs e)
125 {
126 RpmsConnectionSpec spec = this.SelectedSpec;
127
128 if (spec != null)
129 {
130 if (this.Settings.MoveConnectionSpecUp(spec))
131 {
132 this.UpdateListView(spec);
133 }
134 }
135 }
136
137 private void moveDownButton_Click(object sender, EventArgs e)
138 {
139 RpmsConnectionSpec spec = this.SelectedSpec;
140
141 if (spec != null)
142 {
143 if (this.Settings.MoveConnectionSpecDown(spec))
144 {
145 this.UpdateListView(spec);
146 }
147 }
148 }
149
150 private void beDefaultButton_Click(object sender, EventArgs e)
151 {
152 RpmsConnectionSpec spec = this.SelectedSpec;
153
154 if (spec != null)
155 {
156 this.Settings.SetConnectionSpecAsDefault(spec);
157 this.UpdateListView(spec);
158 }
159 }
160
161 private void deleteButton_Click(object sender, EventArgs e)
162 {
163 RpmsConnectionSpec spec = this.SelectedSpec;
164
165 if (spec != null)
166 {
167 this.Settings.RemoveConnectionSpec(spec);
168 this.UpdateListView(null);
169 }
170 }
171
172 private void editButton_Click(object sender, EventArgs e)
173 {
174 RpmsConnectionSpec spec = this.SelectedSpec;
175
176 if (spec != null)
177 {
178 RpmsServerConnectionPropertiesDialog dialog = new RpmsServerConnectionPropertiesDialog();
179 dialog.Model = spec;
180 dialog.ShowDialog();
181 if (dialog.Model == null)
182 return;
183
184 if (dialog.Model.IsDefault)
185 {
186 this.Settings.SetConnectionSpecAsDefault(dialog.Model);
187 }
188 this.UpdateListView(dialog.Model);
189 }
190 }
191
192 private void testButton_Click(object sender, EventArgs e)
193 {
194 RpmsConnectionSpec selectedSpec = this.SelectedSpec;
195
196 if (selectedSpec == null)
197 return;
198
199 RpmsConnectionSpec testSpec = new RpmsConnectionSpec();
200 testSpec.Name = selectedSpec.Name;
201 testSpec.Server = selectedSpec.Server;
202 testSpec.Port = selectedSpec.Port;
203 testSpec.NameSpace = selectedSpec.NameSpace;
204 testSpec.IsDefault = true; //This is so auth will work
205 testSpec.UseWindowsAuthentication = selectedSpec.UseWindowsAuthentication;
206
207 ConnectionTest test = new ConnectionTest();
208 test.UiOwner = this;
209
210 test.Test(testSpec);
211
212 }
213
214
215 }
216}
Note: See TracBrowser for help on using the repository browser.