Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: Pascal to C# Convert Pin
Pavlex413-Dec-16 8:12
Pavlex413-Dec-16 8:12 
AnswerRe: Pascal to C# Convert Pin
OriginalGriff13-Dec-16 8:12
mveOriginalGriff13-Dec-16 8:12 
GeneralRe: Pascal to C# Convert Pin
PIEBALDconsult13-Dec-16 9:06
mvePIEBALDconsult13-Dec-16 9:06 
GeneralRe: Pascal to C# Convert Pin
NotPolitcallyCorrect13-Dec-16 9:26
NotPolitcallyCorrect13-Dec-16 9:26 
GeneralRe: Pascal to C# Convert Pin
Daniel Pfeffer13-Dec-16 20:24
professionalDaniel Pfeffer13-Dec-16 20:24 
GeneralRe: Pascal to C# Convert Pin
OriginalGriff13-Dec-16 21:41
mveOriginalGriff13-Dec-16 21:41 
QuestionRe: Pascal to C# Convert Pin
Gerry Schmitz13-Dec-16 22:27
mveGerry Schmitz13-Dec-16 22:27 
QuestionHow to Draw tracking Line of plane in Radar - C# Pin
Khant Nyar Kyaw13-Dec-16 7:51
Khant Nyar Kyaw13-Dec-16 7:51 
I draw a radar screen with C#. In radar screen, planes(PictureBox) can move from start point to end Point. Scanning Line can also run. Although, I cannot code tracking line behind the planes for my poor knowledge. May you help me?

C#
<pre lang="c#">
private void timer1_Tick(object sender, EventArgs e)
{
if (i > 361)
{
i = 0;
rotate = true;
}
else
{


i += 1;
angle = i;
foreach (Control con in this.picRadarRing.Controls)
{
if (con is PictureBox)
{
PictureBox pb = con as PictureBox;


if (angle > s)
{

rotate = true;
}
degg = 90 - (int)Angle(pb.Location, new Point((picRadarRing.Width / 2), (picRadarRing.Height / 2)));

startX = pb.Location.X;
startY = pb.Location.Y;


double dis = Math.Sqrt(Math.Pow(endX - startX, 2) + Math.Pow(endY - startY, 2));
double directionX = (endX - startX) / dis;
double directionY = (endY - startY) / dis;
if (degg == 0)
{
degg = 1;
}
if (degg < 0)
{
degg += 360;
}

if (angle == degg)
{
if (rotate)
{
x1 = pb.Location.X;
y1 = pb.Location.Y;
x1 += directionX * speed * elapsed;
y1 += directionY * speed * elapsed;

pb.Location = new Point((int)x1, (int)y1);

}
rotate = false;
s = (90 - (int)Angle(pb.Location, new Point((picRadarRing.Width / 2), (picRadarRing.Height / 2))));
if (s < 0)
{
s += 360;
}
}
}



private void picRadarRing_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.ResetTransform();
g.TranslateTransform(picRadarRing.Width / 2, picRadarRing.Height / 2);
g.RotateTransform(angle);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.DrawImage(hand, 0.00f, 0.00f, 5, (picRadarRing.Width / 2) - 4);

SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);


}


private void btnAdd_Click(object sender, EventArgs e)
{
if ((txtSy.Text == "") || (txtSx.Text == "") || (txtEndY.Text == "") || (txtEndX.Text == ""))
{
MessageBox.Show("Enter Point");
}
else
{

count += 1;



endX = Convert.ToDouble(txtEndX.Text);
endY = Convert.ToDouble(txtEndY.Text);
Tx = Convert.ToInt32(txtSx.Text);
Ty = Convert.ToInt32(txtSy.Text);
Airplane(Tx, Ty);
timer1.Start();
}
}

private double Angle(Point start, Point end)
{
return Math.Atan2(start.Y - end.Y, end.X - start.X) * Rad2Deg;
}

private void Airplane(int TX, int TY) // to Create air thread picturebox
{


PictureBox pic = new PictureBox();
foreach (Control con in this.picRadarRing.Controls)
{
if (con is PictureBox)
{
if (con.Name == "airplane")
{
this.picRadarRing.Controls.Remove(con);
}
}
}
this.picRadarRing.Controls.Add(pic);
pic.BackColor = Color.Red;
pic.Location = new Point(TX, TY);
pic.Size = new Size(7, 7);
pic.Name = "airplane-" + count;


}

modified 13-Dec-16 14:23pm.

AnswerRe: How to Draw tracking Line of plane in Radar - C# Pin
OriginalGriff13-Dec-16 8:06
mveOriginalGriff13-Dec-16 8:06 
AnswerRe: How to Draw tracking Line of plane in Radar - C# Pin
Dave Kreskowiak13-Dec-16 9:00
mveDave Kreskowiak13-Dec-16 9:00 
AnswerRe: How to Draw tracking Line of plane in Radar - C# Pin
V.13-Dec-16 19:01
professionalV.13-Dec-16 19:01 
AnswerRe: How to Draw tracking Line of plane in Radar - C# Pin
Gerry Schmitz13-Dec-16 22:20
mveGerry Schmitz13-Dec-16 22:20 
Questionfingerprint transaction system Pin
Member 1290211313-Dec-16 2:45
Member 1290211313-Dec-16 2:45 
AnswerRe: fingerprint transaction system Pin
OriginalGriff13-Dec-16 2:46
mveOriginalGriff13-Dec-16 2:46 
AnswerRe: fingerprint transaction system Pin
Pete O'Hanlon13-Dec-16 2:50
mvePete O'Hanlon13-Dec-16 2:50 
AnswerRe: fingerprint transaction system Pin
Simon_Whale13-Dec-16 3:14
Simon_Whale13-Dec-16 3:14 
AnswerRe: fingerprint transaction system Pin
Dave Kreskowiak13-Dec-16 4:35
mveDave Kreskowiak13-Dec-16 4:35 
AnswerRe: fingerprint transaction system Pin
Gerry Schmitz13-Dec-16 6:47
mveGerry Schmitz13-Dec-16 6:47 
AnswerRe: fingerprint transaction system Pin
Patrice T14-Dec-16 12:50
mvePatrice T14-Dec-16 12:50 
QuestionHow to Invoke Function from Form through Controls event? Pin
manju 312-Dec-16 20:03
manju 312-Dec-16 20:03 
AnswerRe: How to Invoke Function from Form through Controls event? Pin
Richard MacCutchan12-Dec-16 21:53
mveRichard MacCutchan12-Dec-16 21:53 
AnswerRe: How to Invoke Function from Form through Controls event? Pin
Dave Kreskowiak13-Dec-16 2:15
mveDave Kreskowiak13-Dec-16 2:15 
AnswerRe: How to Invoke Function from Form through Controls event? Pin
Gerry Schmitz13-Dec-16 7:16
mveGerry Schmitz13-Dec-16 7:16 
QuestionWCF multiple bindings and prevent external user to use my tcp binding Pin
Tridip Bhattacharjee12-Dec-16 3:21
professionalTridip Bhattacharjee12-Dec-16 3:21 
AnswerRe: WCF multiple bindings and prevent external user to use my tcp binding Pin
Wastedtalent12-Dec-16 4:40
professionalWastedtalent12-Dec-16 4:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.