-
Notifications
You must be signed in to change notification settings - Fork 10
/
NumEntBox.h
186 lines (170 loc) · 5.83 KB
/
NumEntBox.h
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//
// Copyright 2004-2010, Thomas C. McDermott, N5EG
// This file is part of VNAR - the Vector Network Analyzer program.
//
// VNAR 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.
//
// VNAR 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 VNAR, if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace VNAR3
{
/// <summary>
/// Summary for NumEntBox
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
/// Numeric Entry dialogBox
public ref class NumEntBox : public System::Windows::Forms::Form
{
public:
NumEntBox(void)
{
InitializeComponent();
}
protected:
~NumEntBox()
{
if(components)
delete(components);
}
private: System::Windows::Forms::Button^ OKButton;
private: System::Windows::Forms::Button^ CancelButton;
private: System::Windows::Forms::TextBox^ NumberBox;
private: System::Windows::Forms::Label^ label1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container^ components;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(NumEntBox::typeid));
this->OKButton = (gcnew System::Windows::Forms::Button());
this->CancelButton = (gcnew System::Windows::Forms::Button());
this->NumberBox = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// OKButton
//
this->OKButton->DialogResult = System::Windows::Forms::DialogResult::OK;
this->OKButton->FlatStyle = System::Windows::Forms::FlatStyle::System;
this->OKButton->Location = System::Drawing::Point(48, 112);
this->OKButton->Name = L"OKButton";
this->OKButton->Size = System::Drawing::Size(75, 23);
this->OKButton->TabIndex = 1;
this->OKButton->Text = L"OK";
//
// CancelButton
//
this->CancelButton->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->CancelButton->FlatStyle = System::Windows::Forms::FlatStyle::System;
this->CancelButton->Location = System::Drawing::Point(168, 112);
this->CancelButton->Name = L"CancelButton";
this->CancelButton->Size = System::Drawing::Size(75, 23);
this->CancelButton->TabIndex = 2;
this->CancelButton->Text = L"Cancel";
//
// NumberBox
//
this->NumberBox->Location = System::Drawing::Point(72, 64);
this->NumberBox->Name = L"NumberBox";
this->NumberBox->Size = System::Drawing::Size(144, 20);
this->NumberBox->TabIndex = 0;
this->NumberBox->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;
//
// label1
//
this->label1->BackColor = System::Drawing::Color::Transparent;
this->label1->Location = System::Drawing::Point(96, 32);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(88, 16);
this->label1->TabIndex = 3;
this->label1->Text = L"Enter new value";
//
// NumEntBox
//
this->AcceptButton = this->OKButton;
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->ClientSize = System::Drawing::Size(292, 164);
this->Controls->Add(this->label1);
this->Controls->Add(this->NumberBox);
this->Controls->Add(this->CancelButton);
this->Controls->Add(this->OKButton);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"NumEntBox";
this->Text = L"Direct Value Entry";
this->ResumeLayout(false);
this->PerformLayout();
}
private: __int64 GetFreq(String ^t)
{
__int64 suff = 1;
if (t->Length > 1 && t[t->Length-1] > '9'){
switch(t[t->Length-1]) {
case 'g':
case 'G':
suff *= 1000;
case 'm':
case 'M':
suff *= 1000;
case 'k':
case 'K':
suff *= 1000;
default:;
}
}
if (suff > 1)
t = t->Remove(t->Length-1,1);
return((__int64)(Convert::ToInt64(t) * suff));
}
public:
void set_NumericValue(__int64 number) { NumberBox->Text = number.ToString(); } // display existing value
__int64 get_NumericValue() // retrieve value that user entered
{
__int64 n;
try // make sure it's an long number
{
n = GetFreq(NumberBox->Text);
}
catch (System::FormatException^ pe)
{
MessageBox::Show(pe->Message, "Error");
}
catch (System::OverflowException^ pe)
{
MessageBox::Show(pe->Message, "Error");
}
return n;
}
};
}