|
|
|
ขอสอบถามเรื่องเวลา ใน C# หน่อยครับ ในส่วนของเวลากับ เข็มนาฬิกาครับ |
|
|
|
|
|
|
|
นี่คือลิ้ง โปรแกรมนะครับ ทำด้วย visual c# 2010
http://www.upload-thai.com/download.php?id=9a86fc2d91ee70e812c1f0e9ce9d371c
|
|
|
|
|
Date :
2012-03-05 04:41:38 |
By :
คนดี |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รบกวหน่อยนะครับ
|
|
|
|
|
Date :
2012-03-05 16:10:58 |
By :
คนดี |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยหน่อยนะคับ
|
|
|
|
|
Date :
2012-03-05 20:32:16 |
By :
คนดี |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ส่วนนี่เป็น โคดครับ
Code (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
bool running;
int hours, minutes, score;
double angleRadians1, angleRadians2;
double angle1, angle2, time1, time2;
private void updateClockBigHand()
{
int lineLength = 60;
line1.X2 = line1.X1 + (lineLength * Math.Cos(angleRadians1));
line1.Y2 = line1.Y1 - (lineLength * Math.Sin(angleRadians1));
}
private void updateClockSmallHand()
{
int lineLength = 100;
line2.X2 = line1.X1 + (lineLength * Math.Cos(angleRadians2));
line2.Y2 = line1.Y1 - (lineLength * Math.Sin(angleRadians2));
}
//Randomtime
private void randomtime()
{
Random RandomNumber = new Random();
Random RandomString = new Random();
String[] timetype = { "A.M.", "P.M." };
hours = RandomNumber.Next(0, 11);
minutes = RandomNumber.Next(0, 11) * 5;
textBlock2.Text = timetype[RandomString.Next(0, timetype.Length)];
textBlock1.Text = hours.ToString() + ":" + (minutes < 10 ? "0" : "") + minutes.ToString();
//checkEventBigHand();
//updateClockBigHand();
//checkEventSmallHand();
//updateClockSmallHand();
// int lineLength = 60;
//int lineLength2 = 100;
//line1.X2 = line1.X1 + (lineLength * Math.Cos(angleRadians1));
//line1.Y2 = line1.Y1 - (lineLength * Math.Sin(angleRadians1));
// line2.X2 = line1.X1 + (lineLength2 * Math.Cos(angleRadians2));
// line2.Y2 = line1.Y1 - (lineLength2 * Math.Sin(angleRadians2));
}
//CheckEventGame
private void checkEventBigHand()
{
if ((angle1 <= 95.0) && (angle1 >= 68))
{
time1 = 0;
}
else if ((angle1 <= 67.9) && (angle1 >= 33.0))
{
time1 = 1;
}
else if ((angle1 <= 32.9) && (angle1 >= 0.9))
{
time1 = 2;
}
else if ((angle1 <= 0) && (angle1 >= -25.0))
{
time1 = 3;
}
else if ((angle1 <= -24.9) && (angle1 >= -55.0))
{
time1 = 4;
}
else if ((angle1 <= -54.9) && (angle1 >= -85))
{
time1 = 5;
}
else if ((angle1 <= -84.9) && (angle1 >= -115))
{
time1 = 6;
}
else if ((angle1 <= -114.9) && (angle1 >= -145))
{
time1 = 7;
}
else if ((angle1 <= -144.9) && (angle1 >= -175))
{
time1 = 8;
}
else if ((angle1 <= -174.9) && (angle1 >= -205))
{
time1 = 9;
}
else if ((angle1 <= -204.9) && (angle1 >= -235))
{
time1 = 10;
}
else if ((angle1 <= -234.9) && (angle1 >= -269))
{
time1 = 11;
}
else
{
Console.WriteLine("Not time");
}
}
private void checkEventSmallHand()
{
if ((angle2 <= 95.0) && (angle2 >= 68))
{
time2 = 0;
}
else if ((angle2 <= 67.9) && (angle2 >= 33.0))
{
time2 = 5;
}
else if ((angle2 <= 32.9) && (angle2 >= 0.9))
{
time2 = 10;
}
else if ((angle2 <= 0) && (angle2 >= -25.0))
{
time2 = 15;
}
else if ((angle2 <= -24.9) && (angle2 >= -55.0))
{
time2 = 20;
}
else if ((angle2 <= -54.9) && (angle2 >= -85))
{
time2 = 25;
}
else if ((angle2 <= -84.9) && (angle2 >= -115))
{
time2 = 30;
}
else if ((angle2 <= -114.9) && (angle2 >= -145))
{
time2 = 35;
}
else if ((angle2 <= -144.9) && (angle2 >= -175))
{
time2 = 40;
}
else if ((angle2 <= -174.9) && (angle2 >= -205))
{
time2 = 45;
}
else if ((angle2 <= -204.9) && (angle2 >= -235))
{
time2 = 50;
}
else if ((angle2 <= -234.9) && (angle2 >= -269))
{
time2 = 55;
}
else
{
Console.WriteLine("Not time");
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
randomtime();
}
}
}
|
|
|
|
|
Date :
2012-03-05 20:36:19 |
By :
คนดี |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|