1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Data;
|
---|
5 | using System.Drawing;
|
---|
6 | using System.Text;
|
---|
7 | using System.Windows.Forms;
|
---|
8 | using IndianHealthService.BMXNet.WinForm.Configuration;
|
---|
9 | using IndianHealthService.BMXNet.WinForm.Forms;
|
---|
10 |
|
---|
11 | namespace IndianHealthService.BMXNet.WinForm.Forms
|
---|
12 | {
|
---|
13 | internal partial class RpmsServerConnectionPropertiesDialog : Form
|
---|
14 | {
|
---|
15 | public RpmsServerConnectionPropertiesDialog()
|
---|
16 | {
|
---|
17 | InitializeComponent();
|
---|
18 | }
|
---|
19 |
|
---|
20 | private void entry_TextChanged(object sender, EventArgs e)
|
---|
21 | {
|
---|
22 | this.UpdateCues();
|
---|
23 | }
|
---|
24 |
|
---|
25 | private void UpdateCues()
|
---|
26 | {
|
---|
27 | this.okButton.Enabled = this.ValidateInput();
|
---|
28 | this.testButton.Enabled = this.okButton.Enabled;
|
---|
29 | }
|
---|
30 |
|
---|
31 | private void txtNamespace_TextChanged(object sender, EventArgs e)
|
---|
32 | {
|
---|
33 | this.useDefaultNameSpaceCheck.Checked = this.txtNamespace.Text.Length == 0;
|
---|
34 | }
|
---|
35 |
|
---|
36 | private void useDefaultNameSpaceCheck_CheckedChanged(object sender, EventArgs e)
|
---|
37 | {
|
---|
38 | if (this.useDefaultNameSpaceCheck.Checked)
|
---|
39 | {
|
---|
40 | this.txtNamespace.Text = "";
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | private void RpmsServerConnectionPropertiesDialog_Load(object sender, EventArgs e)
|
---|
45 | {
|
---|
46 | this.Icon = this.Owner==null ? null : this.Owner.Icon;
|
---|
47 |
|
---|
48 | this.connectionNameEntry.Text = this.Model.Name;
|
---|
49 | this.serverEntry.Text = this.Model.Server;
|
---|
50 | this.portEntry.Text=this.Model.Port.ToString();
|
---|
51 | this.txtNamespace.Text = this.Model.NameSpace;
|
---|
52 | this.defaultConnectionCheckbox.Checked = this.Model.IsDefault;
|
---|
53 | this.useWindowsCheckbox.Checked = this.Model.UseWindowsAuthentication;
|
---|
54 | this.useDefaultNameSpaceCheck.Checked = this.Model.UseDefaultNamespace;
|
---|
55 |
|
---|
56 | this.UpdateCues();
|
---|
57 | }
|
---|
58 |
|
---|
59 | public bool ValidateInput()
|
---|
60 | {
|
---|
61 | int port = 0;
|
---|
62 |
|
---|
63 | return
|
---|
64 | (this.connectionNameEntry.Text.Length > 0)
|
---|
65 | &&
|
---|
66 | (this.serverEntry.Text.Length > 0 )
|
---|
67 | &&
|
---|
68 | (int.TryParse(this.portEntry.Text,out port));
|
---|
69 |
|
---|
70 | }
|
---|
71 |
|
---|
72 | private RpmsConnectionSpec _model = null;
|
---|
73 |
|
---|
74 | public RpmsConnectionSpec Model
|
---|
75 | {
|
---|
76 | get { return _model; }
|
---|
77 | set { _model = value; }
|
---|
78 | }
|
---|
79 |
|
---|
80 | private void okButton_Click(object sender, EventArgs e)
|
---|
81 | {
|
---|
82 | if (this.ValidateInput())
|
---|
83 | {
|
---|
84 |
|
---|
85 | this.Model.Name = this.connectionNameEntry.Text.Trim();
|
---|
86 | this.Model.Server = this.serverEntry.Text.Trim();
|
---|
87 | this.Model.Port = int.Parse(this.portEntry.Text.Trim());
|
---|
88 | this.Model.NameSpace = this.txtNamespace.Text.Trim();
|
---|
89 | this.Model.IsDefault = this.defaultConnectionCheckbox.Checked;
|
---|
90 | this.Model.UseWindowsAuthentication = this.useWindowsCheckbox.Checked;
|
---|
91 | this.Model.UseDefaultNamespace = this.useDefaultNameSpaceCheck.Checked;
|
---|
92 |
|
---|
93 | this.Close();
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 |
|
---|
99 | private void cancelButton_Click(object sender, EventArgs e)
|
---|
100 | {
|
---|
101 | this.Model = null;
|
---|
102 | this.Close();
|
---|
103 | }
|
---|
104 |
|
---|
105 | private void testButton_Click(object sender, EventArgs e)
|
---|
106 | {
|
---|
107 | ConnectionTest test = new ConnectionTest();
|
---|
108 | test.UiOwner = this;
|
---|
109 |
|
---|
110 | RpmsConnectionSpec testSpec = new RpmsConnectionSpec();
|
---|
111 | testSpec.Name = this.connectionNameEntry.Text.Trim();
|
---|
112 | testSpec.Server = this.serverEntry.Text.Trim();
|
---|
113 | testSpec.Port = int.Parse(this.portEntry.Text.Trim());
|
---|
114 | testSpec.NameSpace = this.txtNamespace.Text.Trim();
|
---|
115 | testSpec.IsDefault = true; //This is so auth will work
|
---|
116 | testSpec.UseWindowsAuthentication = this.useWindowsCheckbox.Checked;
|
---|
117 |
|
---|
118 | test.Test(testSpec);
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 | }
|
---|
123 | }
|
---|