, Visual C#

       


Imports System.Math ' .

Imports System.Drawing ' .

Imports System.Drawing.Drawing2D ' .

6. Class1 , , .

43.1. .

Public Class Class1

Public Function myFunction1() As Object

' myArrayVB(i, j):

Dim i, j As Integer

' myArrayVB(i, j):

Dim N_x As Integer = 2000

Dim N_y As Integer = 1

' Single myArrayVB(i, j),

' i = 0,1,2,3,...,N_x; j = 0,1,2,3,...,N_y:

Dim myArrayVB(N_x, N_y) As Single

' 10 :

For i = 0 To N_x

For j = 0 To N_y

myArrayVB(i, j) = 10

Next

Next

' 4- :

myArrayVB(0, 0) = 100

myArrayVB(0, 1) = 50

myArrayVB(1, 0) = 200

myArrayVB(1, 1) = 75

myArrayVB(2, 0) = 300

myArrayVB(2, 1) = 150

myArrayVB(3, 0) = 400

myArrayVB(3, 1) = 300

Return myArrayVB

End Function

End Class

43.2. PictureBox1_Paint .

Private Sub PictureBox1_Paint(ByVal sender As Object, _

ByVal e As System.Windows.Forms.PaintEventArgs) _

Handles PictureBox1.Paint

' myObject Class1 VB:

Dim myObject As New ComponentVB.Class1

' myArrayVC(i, j):

Dim i, j As Integer

' myArrayVC(i, j):

Dim N_x As Integer = 2000

Dim N_y As Integer = 1

' myArrayVC(i, j) float,

' i = 0,1,2,3,...,(N_x - 1);


' j = 0,1,2,3,...,(N_y - 1):
Dim myArrayVB_Client(N_x, N_y) As Single
' myArrayVB(i, j) VB
' myArrayVB_Client(i, j) VB:
For i = 0 To N_x
For j = 0 To N_y
myArrayVB_Client(i, j) = myObject.myFunction1(i, j)
Next
Next
' .
' :
Dim x1, y1, x2, y2 As Single
' myPen 3:
Dim myPen As New Pen(Color.Black, 3)
' , myArrayVB_Client(i, j):
x1 = myArrayVB_Client(0, 0)
y1 = myArrayVB_Client(0, 1)
x2 = myArrayVB_Client(1, 0)
y2 = myArrayVB_Client(1, 1)
e.Graphics.DrawLine(myPen, x1, y1, x2, y2)
x1 = x2
y1 = y2
x2 = myArrayVB_Client(2, 0)
y2 = myArrayVB_Client(2, 1)
e.Graphics.DrawLine(myPen, x1, y1, x2, y2)
x1 = x2
y1 = y2
x2 = myArrayVB_Client(3, 0)
y2 = myArrayVB_Client(3, 1)
e.Graphics.DrawLine(myPen, x1, y1, x2, y2)
End Sub
43.3. pictureBox1_Paint .
private void pictureBox1_Paint(object sender,
PaintEventArgs e)
{
// myObject . Class1 VB:
ComponentVB.Class1 myObject =
new ComponentVB.Class1();
// myArrayVC(i, j):
int i, j;
// myArrayVC(i, j):
int N_x = 2001; int N_y = 2;
// myArrayVC[i, j] - float,
// i = 0,1,2,3,...,(N_x - 1);
// j = 0,1,2,3,...,(N_y - 1):
float[,] myArrayVC = new float[N_x, N_y];
// myArray Array
// myFunction1,
// myArrayVB(i, j) VB:
Array myArray = (Array)myObject.myFunction1();


// myArrayVB(i, j) VB
// myArrayVC[i, j] VC:
for (i = 0; i <= N_x - 1; i++)
for (j = 0; j <= N_y - 1; j++)
myArrayVC[i, j] =
Convert.ToSingle(myArray.GetValue(i,j));
// .
// :
float x1, y1, x2, y2;
// myPen 3:
Pen myPen = new Pen(Color.Black, 3);
// , myArrayVC[i, j]:
x1 = myArrayVC[0, 0];
y1 = myArrayVC[0, 1];
x2 = myArrayVC[1, 0];
y2 = myArrayVC[1, 1];
e.Graphics.DrawLine(myPen, x1, y1, x2, y2);
x1 = x2; y1 = y2;
x2 = myArrayVC[2, 0]; y2 = myArrayVC[2, 1];
e.Graphics.DrawLine(myPen, x1, y1, x2, y2);
x1 = x2; y1 = y2;
x2 = myArrayVC[3, 0]; y2 = myArrayVC[3, 1];
e.Graphics.DrawLine(myPen, x1, y1, x2, y2);
}
43.4.
pictureBox1_Paint .
private:
System::Void pictureBox1_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e)
{
// myObject Class1 VB:
ComponentVB::Class1^ myObject =
gcnew ComponentVB::Class1();
// myArrayVC(i, j):
int i, j;
// myArrayVC(i, j):
int N_x = 2001; int N_y = 2;
// myArrayVC[i, j] float,
// i = 0,1,2,3,...,(N_x - 1);
// j = 0,1,2,3,...,(N_y - 1):
array<float,2>^ myArrayVC =
gcnew array<float,2>(N_x, N_y);
// myArray Array
// myFunction1,
// myArrayVB[i, j] VB:
Array^ myArray = (Array^)myObject->myFunction1();
// myArrayVB(i, j) VB
// myArrayVC[i, j] VC:
for (i = 0 ; i <= N_x - 1; i++)
for (j = 0 ; j <= N_y - 1; j++)
myArrayVC[i, j] =
Convert::ToSingle(myArray->GetValue(i,j));
// .
// :
float x1, y1, x2, y2;
// myPen 3:
Pen^ myPen = gcnew Pen(Color::Black, 3);
// , myArrayVC[i, j]:
x1 = myArrayVC[0, 0];
y1 = myArrayVC[0, 1];
x2 = myArrayVC[1, 0];
y2 = myArrayVC[1, 1];
e->Graphics->DrawLine(myPen, x1, y1, x2, y2);
x1 = x2; y1 = y2;
x2 = myArrayVC[2, 0]; y2 = myArrayVC[2, 1];
e->Graphics->DrawLine(myPen, x1, y1, x2, y2);
x1 = x2; y1 = y2;
x2 = myArrayVC[3, 0]; y2 = myArrayVC[3, 1];
e->Graphics->DrawLine(myPen, x1, y1, x2, y2);
}









Forekc.ru
, , , , , , , , , ,