Skip to content

Commit 2714f37

Browse files
committed
Started to port xrEProps
Ported NumericVector control from VCL to Windows Forms (WIP, not tested) Yes. This is named xrECore. I think xrEProps should be merged into ECore
1 parent 68cbfb5 commit 2714f37

File tree

10 files changed

+604
-0
lines changed

10 files changed

+604
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#include "pch.hpp"
2+
#include "NumericVector.h"
3+
4+
namespace XRay
5+
{
6+
namespace ECore
7+
{
8+
bool NumericVector::Run(pcstr title, Fvector* data, int decimal, Fvector* resetValue, Fvector* min, Fvector* max, int* X, int* Y)
9+
{
10+
System::String^ str = gcnew System::String(title);
11+
this->Text = str;
12+
Value = data;
13+
ResetValue = resetValue;
14+
15+
if (min)
16+
{
17+
numX->Minimum = (Decimal)min->x;
18+
numY->Minimum = (Decimal)min->y;
19+
numZ->Minimum = (Decimal)min->z;
20+
}
21+
else
22+
{
23+
numX->Minimum = Decimal::MinValue;
24+
numY->Minimum = Decimal::MinValue;
25+
numZ->Minimum = Decimal::MinValue;
26+
27+
}
28+
29+
if (max)
30+
{
31+
numX->Maximum = (Decimal)max->x;
32+
numY->Maximum = (Decimal)max->y;
33+
numZ->Maximum = (Decimal)max->z;
34+
}
35+
else
36+
{
37+
numX->Maximum = Decimal::MaxValue;
38+
numY->Maximum = Decimal::MaxValue;
39+
numZ->Maximum = Decimal::MaxValue;
40+
41+
}
42+
43+
buttonReset_Click(nullptr, nullptr);
44+
45+
numX->ValueChanged += gcnew EventHandler(this, &NumericVector::OnValueChanged);
46+
47+
return ShowDialog() == Windows::Forms::DialogResult::OK;
48+
}
49+
50+
System::Void NumericVector::buttonApply_Click(System::Object^ sender, System::EventArgs^ e)
51+
{
52+
Value->set((float)numX->Value, (float)numY->Value, (float)numZ->Value);
53+
}
54+
55+
56+
System::Void NumericVector::buttonOk_Click(System::Object^ sender, System::EventArgs^ e)
57+
{
58+
buttonApply_Click(sender, e);
59+
this->Close();
60+
}
61+
62+
System::Void NumericVector::buttonCancel_Click(System::Object^ sender, System::EventArgs^ e)
63+
{
64+
this->Close();
65+
}
66+
67+
System::Void NumericVector::buttonReset_Click(System::Object^ sender, System::EventArgs^ e)
68+
{
69+
numX->Value = (Decimal)ResetValue->x;
70+
numY->Value = (Decimal)ResetValue->y;
71+
numZ->Value = (Decimal)ResetValue->z;
72+
}
73+
74+
System::Void NumericVector::buttonImmediate_Click(System::Object^ sender, System::EventArgs^ e)
75+
{
76+
checkImmediate->Checked = !checkImmediate->Checked;
77+
}
78+
79+
System::Void NumericVector::NumericVector_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e)
80+
{
81+
switch (e->KeyChar)
82+
{
83+
case (Char)Keys::Space:
84+
buttonApply_Click(sender, e);
85+
break;
86+
case (Char)Keys::Enter:
87+
buttonOk_Click(sender, e);
88+
break;
89+
case (Char)Keys::Escape:
90+
buttonCancel_Click(sender, e);
91+
break;
92+
}
93+
}
94+
95+
System::Void NumericVector::OnValueChanged(System::Object^ sender, System::EventArgs^ e)
96+
{
97+
if (checkImmediate->Checked)
98+
buttonApply_Click(sender, e);
99+
}
100+
101+
} // namespace ECore
102+
} // namespace XRay
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
#pragma once
2+
3+
namespace XRay
4+
{
5+
namespace ECore
6+
{
7+
ref class NumericVector;
8+
}
9+
}
10+
11+
template <class T>
12+
struct _vector3;
13+
using Fvector = _vector3<float>;
14+
15+
namespace XRay
16+
{
17+
namespace ECore
18+
{
19+
using namespace System;
20+
using namespace System::ComponentModel;
21+
using namespace System::Collections;
22+
using namespace System::Windows::Forms;
23+
using namespace System::Data;
24+
using namespace System::Drawing;
25+
26+
public ref class NumericVector : public System::Windows::Forms::Form
27+
{
28+
public:
29+
NumericVector()
30+
{
31+
InitializeComponent();
32+
}
33+
34+
bool Run(pcstr title, Fvector* data, int decimal, Fvector* reset_value, Fvector* min, Fvector* max, int* X, int* Y);
35+
36+
protected:
37+
~NumericVector()
38+
{
39+
if (components)
40+
{
41+
delete components;
42+
}
43+
}
44+
45+
private: Fvector* Value;
46+
private: Fvector* ResetValue;
47+
private: System::Windows::Forms::Button^ buttonOk;
48+
private: System::Windows::Forms::Button^ buttonCancel;
49+
private: System::Windows::Forms::Button^ buttonReset;
50+
private: XRay::SdkControls::NumericSpinner^ numX;
51+
private: XRay::SdkControls::NumericSpinner^ numY;
52+
private: XRay::SdkControls::NumericSpinner^ numZ;
53+
private: System::Windows::Forms::Label^ labelX;
54+
private: System::Windows::Forms::Label^ labelY;
55+
private: System::Windows::Forms::Label^ labelZ;
56+
private: System::Windows::Forms::Button^ button1;
57+
private: System::Windows::Forms::Button^ button2;
58+
private: System::Windows::Forms::CheckBox^ checkImmediate;
59+
60+
private: System::Windows::Forms::Button^ buttonApply;
61+
private: System::Windows::Forms::Button^ buttonImmediate;
62+
63+
private:
64+
System::ComponentModel::Container^ components;
65+
66+
#pragma region Windows Form Designer generated code
67+
void InitializeComponent(void)
68+
{
69+
this->buttonOk = (gcnew System::Windows::Forms::Button());
70+
this->buttonCancel = (gcnew System::Windows::Forms::Button());
71+
this->buttonReset = (gcnew System::Windows::Forms::Button());
72+
this->numX = (gcnew XRay::SdkControls::NumericSpinner());
73+
this->numY = (gcnew XRay::SdkControls::NumericSpinner());
74+
this->numZ = (gcnew XRay::SdkControls::NumericSpinner());
75+
this->labelX = (gcnew System::Windows::Forms::Label());
76+
this->labelY = (gcnew System::Windows::Forms::Label());
77+
this->labelZ = (gcnew System::Windows::Forms::Label());
78+
this->buttonApply = (gcnew System::Windows::Forms::Button());
79+
this->buttonImmediate = (gcnew System::Windows::Forms::Button());
80+
this->checkImmediate = (gcnew System::Windows::Forms::CheckBox());
81+
this->SuspendLayout();
82+
this->buttonOk->Location = System::Drawing::Point(136, 21);
83+
this->buttonOk->Name = L"buttonOk";
84+
this->buttonOk->Size = System::Drawing::Size(50, 22);
85+
this->buttonOk->TabIndex = 0;
86+
this->buttonOk->Text = L"Ok";
87+
this->buttonOk->UseVisualStyleBackColor = true;
88+
this->buttonOk->Click += gcnew System::EventHandler(this, &NumericVector::buttonOk_Click);
89+
this->buttonCancel->Location = System::Drawing::Point(136, 42);
90+
this->buttonCancel->Name = L"buttonCancel";
91+
this->buttonCancel->Size = System::Drawing::Size(50, 22);
92+
this->buttonCancel->TabIndex = 1;
93+
this->buttonCancel->Text = L"Cancel";
94+
this->buttonCancel->UseVisualStyleBackColor = true;
95+
this->buttonCancel->Click += gcnew System::EventHandler(this, &NumericVector::buttonCancel_Click);
96+
this->buttonReset->Location = System::Drawing::Point(136, 63);
97+
this->buttonReset->Name = L"buttonReset";
98+
this->buttonReset->Size = System::Drawing::Size(50, 22);
99+
this->buttonReset->TabIndex = 2;
100+
this->buttonReset->Text = L"Reset";
101+
this->buttonReset->UseVisualStyleBackColor = true;
102+
this->numX->DecimalPlaces = 3;
103+
this->numX->Hexadecimal = false;
104+
this->numX->Location = System::Drawing::Point(22, 1);
105+
this->numX->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 100, 0, 0, 0 });
106+
this->numX->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
107+
this->numX->MinimumSize = System::Drawing::Size(70, 22);
108+
this->numX->Name = L"numX";
109+
this->numX->Precision = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
110+
this->numX->Size = System::Drawing::Size(115, 22);
111+
this->numX->TabIndex = 3;
112+
this->numX->TextAlign = System::Windows::Forms::HorizontalAlignment::Left;
113+
this->numX->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
114+
this->numY->DecimalPlaces = 3;
115+
this->numY->Hexadecimal = false;
116+
this->numY->Location = System::Drawing::Point(22, 22);
117+
this->numY->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 100, 0, 0, 0 });
118+
this->numY->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
119+
this->numY->MinimumSize = System::Drawing::Size(70, 22);
120+
this->numY->Name = L"numY";
121+
this->numY->Precision = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
122+
this->numY->Size = System::Drawing::Size(115, 22);
123+
this->numY->TabIndex = 4;
124+
this->numY->TextAlign = System::Windows::Forms::HorizontalAlignment::Left;
125+
this->numY->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
126+
this->numZ->DecimalPlaces = 3;
127+
this->numZ->Hexadecimal = false;
128+
this->numZ->Location = System::Drawing::Point(22, 43);
129+
this->numZ->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 100, 0, 0, 0 });
130+
this->numZ->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
131+
this->numZ->MinimumSize = System::Drawing::Size(70, 22);
132+
this->numZ->Name = L"numZ";
133+
this->numZ->Precision = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
134+
this->numZ->Size = System::Drawing::Size(115, 22);
135+
this->numZ->TabIndex = 5;
136+
this->numZ->TextAlign = System::Windows::Forms::HorizontalAlignment::Left;
137+
this->numZ->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 0, 0, 0, 0 });
138+
this->labelX->AutoSize = true;
139+
this->labelX->Location = System::Drawing::Point(4, 4);
140+
this->labelX->Name = L"labelX";
141+
this->labelX->Size = System::Drawing::Size(14, 13);
142+
this->labelX->TabIndex = 6;
143+
this->labelX->Text = L"X";
144+
this->labelY->AutoSize = true;
145+
this->labelY->Location = System::Drawing::Point(4, 25);
146+
this->labelY->Name = L"labelY";
147+
this->labelY->Size = System::Drawing::Size(14, 13);
148+
this->labelY->TabIndex = 7;
149+
this->labelY->Text = L"Y";
150+
this->labelZ->AutoSize = true;
151+
this->labelZ->Location = System::Drawing::Point(4, 46);
152+
this->labelZ->Name = L"labelZ";
153+
this->labelZ->Size = System::Drawing::Size(14, 13);
154+
this->labelZ->TabIndex = 8;
155+
this->labelZ->Text = L"Z";
156+
this->buttonApply->Location = System::Drawing::Point(136, 0);
157+
this->buttonApply->Name = L"buttonApply";
158+
this->buttonApply->Size = System::Drawing::Size(50, 22);
159+
this->buttonApply->TabIndex = 9;
160+
this->buttonApply->Text = L"Apply";
161+
this->buttonApply->UseVisualStyleBackColor = true;
162+
this->buttonImmediate->Location = System::Drawing::Point(21, 63);
163+
this->buttonImmediate->Name = L"buttonImmediate";
164+
this->buttonImmediate->Size = System::Drawing::Size(116, 22);
165+
this->buttonImmediate->TabIndex = 10;
166+
this->buttonImmediate->Text = L"Immediate";
167+
this->buttonImmediate->UseVisualStyleBackColor = true;
168+
this->buttonImmediate->Click += gcnew System::EventHandler(this, &NumericVector::buttonImmediate_Click);
169+
this->checkImmediate->AutoSize = true;
170+
this->checkImmediate->Location = System::Drawing::Point(5, 67);
171+
this->checkImmediate->Name = L"checkImmediate";
172+
this->checkImmediate->Size = System::Drawing::Size(15, 14);
173+
this->checkImmediate->TabIndex = 11;
174+
this->checkImmediate->UseVisualStyleBackColor = true;
175+
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
176+
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
177+
this->ClientSize = System::Drawing::Size(186, 85);
178+
this->Controls->Add(this->checkImmediate);
179+
this->Controls->Add(this->buttonImmediate);
180+
this->Controls->Add(this->buttonApply);
181+
this->Controls->Add(this->labelZ);
182+
this->Controls->Add(this->labelY);
183+
this->Controls->Add(this->labelX);
184+
this->Controls->Add(this->numZ);
185+
this->Controls->Add(this->numY);
186+
this->Controls->Add(this->numX);
187+
this->Controls->Add(this->buttonReset);
188+
this->Controls->Add(this->buttonCancel);
189+
this->Controls->Add(this->buttonOk);
190+
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedToolWindow;
191+
this->Name = L"NumericVector";
192+
this->ShowInTaskbar = false;
193+
this->Text = L"NumericVector";
194+
this->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &NumericVector::NumericVector_KeyPress);
195+
this->ResumeLayout(false);
196+
this->PerformLayout();
197+
198+
}
199+
#pragma endregion
200+
private: System::Void buttonApply_Click(System::Object^ sender, System::EventArgs^ e);
201+
private: System::Void buttonOk_Click(System::Object^ sender, System::EventArgs^ e);
202+
private: System::Void buttonCancel_Click(System::Object^ sender, System::EventArgs^ e);
203+
private: System::Void buttonReset_Click(System::Object^ sender, System::EventArgs^ e);
204+
private: System::Void buttonImmediate_Click(System::Object^ sender, System::EventArgs^ e);
205+
private: System::Void NumericVector_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e);
206+
207+
private: System::Void OnValueChanged(System::Object^ sender, System::EventArgs^ e);
208+
};
209+
} // namespace ECore
210+
} // namespace XRay

0 commit comments

Comments
 (0)