-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClusterSetup.cs
148 lines (134 loc) · 4.83 KB
/
ClusterSetup.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//=================================================================
// DXClusterSetup
//=================================================================
// Copyright (C) 2011,2012 S56A YT7PWR
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//=================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Collections;
using System.Runtime.InteropServices;
namespace CWExpert
{
public partial class ClusterSetup : Form
{
#region DLL imports
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr window, int message, int wparam, int lparam);
#endregion
const int WM_VSCROLL = 0x115;
const int SB_BOTTOM = 7;
DXClusterClient ParrentForm;
public ClusterSetup(DXClusterClient form)
{
this.AutoScaleMode = AutoScaleMode.Inherit;
InitializeComponent();
float dpi = this.CreateGraphics().DpiX;
float ratio = dpi / 96.0f;
string font_name = this.Font.Name;
float size = 8.25f / ratio;
System.Drawing.Font new_font = new System.Drawing.Font(font_name, size);
this.Font = new_font;
ParrentForm = form;
GetOptions();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
try
{
string[] vals = txtHosts.Text.Split('\n');
ParrentForm.UpdateHostsList(vals);
ParrentForm.UpdateButtonsText();
this.Close();
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
}
}
public void GetOptions()
{
try
{
ArrayList a = DB.GetVars("DXClusterOptions");
a.Sort();
foreach (string s in a)
{
string[] vals = s.Split('/');
string name = vals[0];
if (vals.Length > 2)
{
for (int i = 2; i < vals.Length; i++)
vals[1] += "/" + vals[i];
}
string val = vals[1];
if (s.StartsWith("Cluster"))
{
txtHosts.AppendText(val + "\n");
SendMessage(txtHosts.Handle, WM_VSCROLL, SB_BOTTOM, 0);
}
else if (s.StartsWith("btn1text"))
{
txtButton1.Text = vals[1];
}
else if (s.StartsWith("btn2text"))
{
txtButton2.Text = vals[1];
}
else if (s.StartsWith("btn3text"))
{
txtButton3.Text = vals[1];
}
else if (s.StartsWith("btn4text"))
{
txtButton4.Text = vals[1];
}
else if (s.StartsWith("btn1cmd"))
{
btn1cmd.Text = vals[1];
}
else if (s.StartsWith("btn2cmd"))
{
btn2cmd.Text = vals[1];
}
else if (s.StartsWith("btn3cmd"))
{
btn3cmd.Text = vals[1];
}
else if (s.StartsWith("btn4cmd"))
{
btn4cmd.Text = vals[1];
}
}
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
}
}
}
}