Answer the question
In order to leave comments, you need to log in
How to translate Delphi code to .NET?
The task is as follows, there is a code in Delphi, calculation of certain parameters and display of dependencies, graphics, in Delphi, you need to rewrite it in WinForms or WPF.
Maybe someone knows the means or services for this?
Code part:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Button1: TButton;
Chart1: TChart;
Series1: TLineSeries;
Series2: TLineSeries;
Series3: TLineSeries;
Series4: TLineSeries;
PogrechnostEdit: TEdit;
Label1: TLabel;
ApogrEdit: TEdit;
Label2: TLabel;
Label3: TLabel;
WpogrEdit: TEdit;
VpogrEdit: TEdit;
Label4: TLabel;
FoEdit: TEdit;
Label5: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
A,Fwsp,Fwo,Fp,d,Amax:extended;
V,N,W,M,R,R1,Rb,Rmax,R2:integer;
Wsp,Wo:array[0..100]of extended;
Wp0,Wp10,Wp1,Wp11,Wp2,Wp12,Wp3,Wp13,Wpb,Wpmax,Wpmin,Wp:array[0..1000]of extended;
minimumi,tochki,tochki1,tochki2,tochki3,tochkimin,tochkimax:TextFile;
implementation
{$R *.DFM}
Procedure FrequencyWSP;
var i:integer;
begin
V:=1;
Fwsp:=A/V;
N:=0; i:=0;
While Fwsp>=0.02499999999999 do
begin
if Fwsp<=0.035000000001 then begin
Wsp[i]:=Fwsp;
i:=i+1;
N:=N+1;
end;
V:=V+1;
Fwsp:=A/V;
end;
end;
Procedure FrequencyWO;
var i:integer;
begin
W:=1;
Fwo:=A/W;
i:=0;
M:=0;
While Fwo>=0.02999999999 do begin
Wo[i]:=Fwo;
i:=i+1;
M:=M+1;
W:=W+1;
Fwo:=A/W;
end;
end;
Procedure FrequencyP;
var i,j,k:integer;
begin
k:=0;
R:=0;
for i:=0 to (M-1)do begin
for j:=0 to (N-1)do begin
Fp:=Wo[i]+Wsp[j];
if Fp>=0.06999999999 then
begin
Wp[k]:=Fp;
k:=k+1;
R:=R+1;
end;
Fp:=Wo[i]-Wsp[j];
if Fp>=0.06999999999 then
begin
Wp[k]:=Fp;
k:=k+1;
R:=R+1;
end;
end;
end;
end;
Procedure OdEl;
var i,j:integer;
de:extended;
begin
for i:=0 to R-1 do begin
if Wp[i]>0 then begin
for j:=i+1 to R-1 do begin
if Wp[i]=Wp[j] then Wp[j]:=0;
de:=Wp[i]-Wp[j];
if de<0 then de:=-de;
if de<0.000000001 then Wp[j]:=0;
end;
end;
end;
R1:=0;
j:=0;
for i:=0 to R-1 do begin
if Wp[i]>0 then begin
Wp1[j]:=Wp[i];
j:=j+1;
R1:=R1+1;
end;
end;
end;
procedure inclear;
var i,j:integer;
p,p1:extended;
begin
Wpb[0]:=Wp1[0];
for i:=1 to R1-1 do begin
if Wp1[i]<Wpb[0] then Wpb[0]:=Wp1[i];
end;
for i:=1 to R1-1 do begin
p1:=1;
for j:=0 to R1-1 do begin
p:=Wp1[j]-Wpb[i-1];
if p>0 then begin
if p<p1 then begin
p1:=p;
Wpb[i]:=Wp1[j];
end;
end;
end;
end;
Rb:=R1;
end;
Procedure inclear1;
var j,i:integer;
p,p1: extended;
begin
Wp2[0]:=Wp1[0];
for i:=1 to R1-1 do begin
if Wp1[i]<Wp2[0] then Wp2[0]:=Wp1[i];
end;
for i:=1 to R1-1 do begin
p1:=1;
for j:=0 to R1-1 do begin
p:=Wp1[j]-Wp2[i-1];
if p>0 then begin
if p<p1 then begin
p1:=p;
Wp2[i]:=Wp1[j];
end;
end;
end;
end;
R2:=R1;
end;
Procedure MAXMIN;
var i,j:integer;
dl,dl1,dp:extended;
begin
for i:=0 to Rb-1 do begin
dl:=1;
for j:=0 to R1-1 do begin
dl1:=Wpb[i]-Wp1[j];
if dl1<0 then
dl1:=-dl1;
if dl1<dl then begin
dl:=dl1;
dp:=Wp1[j];
end;
end;
if dl>=0.000000001 then begin
if dp<Wpb[i] then begin
if Wpmin[i]<>0 then if Wpmin[i]>dp then Wpmin[i]:=dp;
if Wpmin[i]=0 then Wpmin[i]:=dp;
end;
if dp>Wpb[i] then begin
if Wpmax[i]<>0 then if Wpmax[i]<dp then Wpmax[i]:=dp;
if Wpmax[i]=0 then Wpmax[i]:=dp;
end;
end;
if dl<0.000000001 then begin
if Wpmin[i]<>0 then if Wpmin[i]>dp then Wpmin[i]:=dp;
if Wpmin[i]=0 then Wpmin[i]:=dp;
end;
end;
{for i:=0 to R1-1 do begin
if Wp1[i]<Wpb[0]then begin
if Wpmin[0]>0 then begin
if Wp1[i]<Wpmin[0]then Wpmin[0]:=Wp1[i];
end;
if Wpmin[0]=0 then Wpmin[0]:=Wp1[i];
end;
if Wp1[i]>Wpb[Rb-1]then begin
if Wpmax[Rb-1]>0 then begin
if Wp1[i]>Wpmax[Rb-1]then Wpmax[Rb-1]:=Wp1[i];
end;
if Wpmax[Rb-1]=0 then Wpmax[Rb-1]:=Wp1[i];
end;
for j:=0 to Rb-2 do begin
if Wp1[i]>Wpb[j]then if Wp1[i]<Wpb[j+1]then begin
dl:=Wp1[i]-Wpb[j];
dp:=Wpb[j+1]-Wp1[i];
if dl<dp then begin
if Wpmax[j]>0 then begin
if Wp1[i]>Wpmax[j]then Wpmax[j]:=Wp1[i];
end;
if Wpmax[j]=0 then Wpmax[j]:=Wp1[i];
end;
if dl>dp then begin
if Wpmin[j+1]>0 then begin
if Wp1[i]<Wpmin[j+1]then Wpmin[j+1]:=Wp1[i];
end;
if Wpmin[j+1]=0 then Wpmin[j+1]:=Wp1[i];
end;
if dl=dp then begin
if Wpmax[j]>0 then begin
if Wp1[i]>Wpmax[j]then Wpmax[j]:=Wp1[i];
end;
if Wpmax[j]=0 then Wpmax[j]:=Wp1[i];
end;
end;
end;
end; }
end;
Procedure MAXMIN1;
var i:integer;
begin
for i:=0 to Rb-1 do begin
if Wpmax[i]=0 then Wpmax[i]:=Wpb[i];
if Wpmin[i]=0 then Wpmin[i]:=Wpb[i];
end;
end;
Answer the question
In order to leave comments, you need to log in
Delphi NET or Win32?
Compile to NET and decompile to a C# project, maybe this option will work.
.NET Reflector
dotPeek
The code is nonsense, you can translate everything with pens in 3 hours.
Delphi rocks :)
The code here is really simple. But the problem is in the TeeChart component, which actually does all the work of rendering graphics. Go to their site, it seems there is a version for .NET (possibly paid). If there is, then take it and, I think, you will not have problems with the transition.
You can write in Delphi for .Net: before it was Delphi 8, then Delphi XE Prism.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question