So I am currently working on a program in which I need to have a timer attached to each item inside of a list box, I have that working, but I can't select any of the items, is there a way to be able to select the items but also have a timer displayed to each item in the list box?
Update:
when adding the item to a new list box here is the code that I have:
private void btnSchedule_Click(object sender, EventArgs e)
{
try
{
string name = lsbScheduled.SelectedItem.ToString();// saves the selected item to a string
string newItem = (moveItem(name));//calls the method and passes the variable to it
tmrCheckedIn.Enabled = true;
tmrCheckedIn.Start();
newItem += " " + "00:00:00";
lsbScheduled.Items.Remove(name);// removes the item from the list
lsbCheckedIn.Items.Add(newItem); //adds the item to the list
}
catch (NullReferenceException)
{
}
}
here is my code for the tick event:
private void tmrCheckedIn_Tick(object sender, EventArgs e)
{
int count = lsbCheckedIn.Items.Count;
for (int i = 0; i < count; i++)
{
string item = lsbCheckedIn.Items[i].ToString();
string[] line = item.Split();
string time = line[8];
Time oldTime = new Time();
oldTime.StartTime = time;
lsbCheckedIn.Items.Remove(item);
string newTime = string.Format(line[0] + " " + line[1] + " " +line[2] + " " + "{0:c}", oldTime.EndTime);
lsbCheckedIn.Items.Add(newTime);
oldTime = null;
}
}
and here is my class that I use to increase the timer:
public class Time
{
private int seconds, minutes, hours;
string startTime, endTime;
public Time()
{
seconds = 00;
minutes = 00;
hours = 00;
startTime = " ";
endTime = "";
}
public string StartTime
{
set { startTime = value;
CalcNewTime();
}
get { return startTime; }
}
public string EndTime
{
set { endTime = value; }
get { return endTime; }
}
public int Hours
{
set { hours = value; }
get { return hours; }
}
public int Minutes
{
set { minutes = value; }
get { return minutes; }
}
public int Second
{
set { seconds = value; }
get { return seconds; }
}
private void CalcNewTime()
{
const int LIMIT = 6, CONVERT = 10;
string[] divisions = startTime.Split(':');
hours = Convert.ToInt32(divisions[0]);
minutes = Convert.ToInt32(divisions[1]);
seconds = Convert.ToInt32(divisions[2]);
int hoursTens = hours / CONVERT;
int hoursOnes = hours % CONVERT;
int minutesTens = minutes / CONVERT;
int minuteOnes = minutes % CONVERT;
seconds += 1;
int secondTens = seconds / CONVERT;
int secondOnes = seconds % CONVERT;
if (secondTens >= LIMIT)
{
secondTens = 0;
secondOnes = 0;
minutes += 1;
minutesTens = Minutes / CONVERT;
minuteOnes = minutes % CONVERT;
if (minutesTens >= LIMIT)
{
minutesTens = 0;
minuteOnes = 0;
hours += 1;
hoursTens = hours / CONVERT;
hoursOnes = Hours % CONVERT;
}
}
endTime = Convert.ToString(hoursTens + hoursOnes + ":" + minutesTens + minuteOnes + ":" + secondTens + secondOnes);
}
}
in programming a windows form application using visual studio 2010 im using the timer that you can select from the toolbox. I need to be able to select the items in the list box but right now i can because im constantly adding and removing items from the list box. I want the time that is displayed in the list box to go up, but i also need it so that i can select the item in the list box.
Your problem is that you're removing items from the listbox, and then adding new ones. This is why items do not remain selected. Instead, just replace the items.
lsbCheckedIn.Items[i] = newTime;
Related
I'm currently doing my current project and I had a problem. Here's what the project needs to do:
Find the maximum and the minimum temperature from a certain range of date. The range of the date will be inputted by the user.
So, I make a form as the main menu for inputting the items and finding the maximum and minimum value (both in the new form). I also make a class to store the items:
public class TempDate
{
public double Temp { get; set; }
public DateTime Date { get; set; }
}
In the first form, just call it FormAddData, from here items will be stored into the list using a textbox and here's the code:
private void buttonSubmit_Click(object sender, EventArgs e)
{
FormMenu formMenu = (FormMenu)this.Owner;
DateTime date = dateTimePickerDate.Value.Date;
double temp = double.Parse(textBoxTemp.Text);
TempDate tempDate = new TempDate();
tempDate.Date = date;
tempDate.Temp = temp;
formMenu.listOfTempDate.Add(tempDate);
listBoxInfo.Items.Add(date + "\t" + temp + "°C");
}
In the second form that called FormMaxMinRange. In this form, I use two DateTimePicker the first one for the starting date and the second for the ending date. From here I need to make a button that will select all the items from the range that I used from starting and ending date. Here's my code:
private void buttonMaxMin_Click(object sender, EventArgs e)
{
FormMenu formMenu = (FormMenu)this.Owner;
DateTime start = dateTimePickerStart.Value.Date;
DateTime end = dateTimePickerEnd.Value.Date;
int highest = 0;
double max = formMenu.listOfTempDate[0].Temp;
int lowest = 0;
double min = formMenu.listOfTempDate[0].Temp;
for (int i = 1; i < formMenu.listOfTempDate.Count; i++)
{
if (formMenu.listOfTempDate[i].Date >= start
&& formMenu.listOfTempDate[i].Date <= end)
{
if (formMenu.listOfTempDate[i].Temp > max)
{
highest = i;
max = formMenu.listOfTempDate[i].Temp;
}
if (formMenu.listOfTempDate[i].Temp < min)
{
lowest = i;
min = formMenu.listOfTempDate[i].Temp;
}
}
}
listBoxMaxMin.Items.Add("");
listBoxMaxMin.Items.Add("Lowest temp: " + min + ", on " + formMenu.listOfTempDate[lowest].Date);
listBoxMaxMin.Items.Add("Highest temp: " + max + ", on " + formMenu.listOfTempDate[highest].Date);
}
Here's the main form that i declared the class (which include the list):
public partial class FormMenu : Form
{
public List<TempDate> listOfTempDate = new List<TempDate>();
public FormMenu()
{
InitializeComponent();
}
private void fromCertainRangeToolStripMenuItem_Click(object sender, EventArgs e)
{
FormMaxMinRange formMaxMinRange = new FormMaxMinRange();
formMaxMinRange.Owner = this;
formMaxMinRange.ShowDialog();
}
}
But, the problem is, the minimum value was not selected inside the range of selection. Also I want the max and min value was printed in the listbox. Sorry for the long and weird question. I hope someone can understand what I means with this question to complete my project. Thank you.
See this code snippet.
You can use Linq to select the reduced list (with Start/Enddate) and order it by Temp. Now you can easy select the first (min) and the last (max) object.
List<TempDate> loTempDateList = new List<TempDate>()
{
new TempDate() {Date = DateTime.Now.AddDays(-10), Temp = 10.01 },
new TempDate() {Date = DateTime.Now.AddDays(-5), Temp = 20.01 },
new TempDate() {Date = DateTime.Now.AddDays(-3), Temp = 30.01 },
new TempDate() {Date = DateTime.Now, Temp = 40.01 }
};
DateTime ldStart = DateTime.Now.AddDays(-6);
DateTime ldEnd = DateTime.Now.AddDays(-1);
var loDateList = loTempDateList.Where(item => item.Date <= ldEnd && item.Date >= ldStart)
.OrderBy(item => item.Temp);
TempDate loMin = loDateList.First();
TempDate loMax = loDateList.Last();
Console.WriteLine("{0}: {1} with max temp", loMax.Date, loMax.Temp);
Console.WriteLine("{0}: {1} with min temp", loMin.Date, loMin.Temp);
Output (for today):
9/26/2017 3:17:09 PM: 30.01 with max temp
9/24/2017 3:17:09 PM: 20.01 with min temp
Update (with your variable names):
Copy this under DateTime end = dateTimePickerEnd.Value.Date;in your Form
var loDateList = listOfTempDate.Where(item => item.Date <= end && item.Date >= start)
.OrderBy(item => item.Temp);
TempDate loMin = loDateList.FirstOrDefault();
TempDate loMax = loDateList.LastOrDefault();
if (loMin != null && loMax != null)
{
listBoxMaxMin.Items.Add("");
listBoxMaxMin.Items.Add("Lowest temp: " + loMin.Temp + ", on " + loMin.Date);
listBoxMaxMin.Items.Add("Highest temp: " + loMax.Temp + ", on " + loMax.Date);
}
I would suggest you use Linq Max and Min methods.
// filter out only the dates in the range you need
var items = formMenu.listOfTempDateWhere(
item => ((TempDate)item).Date >= start && ((TempDate)item).Date <= end
);
// get the maximum value
var max = items.Max(item => item.Temp);
// get the minimum value
var min = items.Min(item => item.Temp);
Just remember to add using System.Linq on the top of your .cs file
try this online
If you don't like a LINQ approach (I never use LINQ, for some, possibly invalid reason, I think it's evil), you can override the List class and extend it with methods of your own.
public class TempDataList<T> : List<TempData>
{
public TempDataList() : base()
{
}
public TempDataList(IEnumerable<TempData> collection) : base(collection)
{
}
public TempData GetMaxTemp(DateTime startDate, DateTime endDate)
{
TempData highestTempData = null;
for (int i = 0; i < this.Count; i++)
{
if (this[i].Date >= startDate && this[i].Date <= endDate)
{
if (highestTempData == null || this[i].Temp > highestTempData.Temp)
{
highestTempData = this[i];
}
}
}
return highestTempData;
}
public TempData GetMinTemp(DateTime startDate, DateTime endDate)
{
TempData lowestTempData = null;
for (int i = 0; i < this.Count; i++)
{
if (this[i].Date >= startDate && this[i].Date <= endDate)
{
if (lowestTempData == null || this[i].Temp < lowestTempData.Temp)
{
lowestTempData = this[i];
}
}
}
return lowestTempData;
}
}
And fill the extended list and call the methods:
TempDataList<TempData> tempDataList = new TempDataList<TempData>();
tempDataList.Add(new TempData(10, DateTime.UtcNow));
tempDataList.Add(new TempData(20, DateTime.UtcNow));
tempDataList.Add(new TempData(15, DateTime.MinValue));
tempDataList.Add(new TempData(25, DateTime.MaxValue));
Console.WriteLine(tempDataList.GetMaxTemp(DateTime.UtcNow.AddDays(-1), DateTime.UtcNow.AddDays(1)).Temp);
Console.WriteLine(tempDataList.GetMinTemp(DateTime.UtcNow.AddDays(-1), DateTime.UtcNow.AddDays(1)).Temp);
can someone help me with my payroll system codes. I want a result where i will get the total number of hours of each employee and before proceeding to another employee it will be saved in a table in mysql. the problems im encountering are
1. it still counts the datetime even if it is null in database.
2. after changing the timeline it still counts the previous total hours
the variable does not reset.
enter image description here
public int IdFrom;
public int Idto;
public int TotalHours;
public int day;
public DateTime time1;
public DateTime time2;
public string testNull;
public string date;
public string testvariable;
string testdate1;
string testdate2;
TimeSpan totaltime;
TimeSpan ts;
private void btn_compute_Click(object sender, EventArgs e)
{
if (rb_all.Checked == true)
{
cls.Connection();
cls.connect.Open();
cls.command = new MySqlCommand("select ID from tbl_attendance order by ID asc limit 1", cls.connect);
cls.reader = cls.command.ExecuteReader();
while (cls.reader.Read())
{
IdFrom = cls.reader.GetInt16(0);
}
cls.reader.Close();
cls.Connection();
cls.connect.Open();
cls.command = new MySqlCommand("select ID from tbl_attendance order by ID desc limit 1", cls.connect);
cls.reader = cls.command.ExecuteReader();
while (cls.reader.Read())
{
Idto = cls.reader.GetInt16(0);
}
cls.reader.Close();
for(int x = IdFrom;x<=Idto;x++)
{
totaltime = TimeSpan.Zero;
ts = TimeSpan.Zero;
day = 0;
TotalHours = 0;
testNull = "";
date = "";
DateTime dt = DateTime.Parse(start_date.Text);
DateTime dt2 = DateTime.Parse(end_date.Text);
ts = dt2 - dt;
day = ts.Days;
for (int y = 0; y <= day; y++)
{
date = dt.AddDays(y).ToString("yyyy")
+ "-" + dt.AddDays(y).ToString("MM")
+ "-" + dt.AddDays(y).ToString("dd");
cls.Connection();
cls.connect.Open();
cls.command = new MySqlCommand("select Time_In,Time_Out from tbl_attendance where Date = '" + date + "' and ID = "+x+"", cls.connect);
cls.reader = cls.command.ExecuteReader();
while (cls.reader.Read())
{
time1 = DateTime.Parse(cls.reader.GetValue(0).ToString());
time2 = DateTime.Parse(cls.reader.GetValue(1).ToString());
}
cls.reader.Close();
MessageBox.Show(time1.ToString());
MessageBox.Show(time2.ToString());
totaltime = time2 - time1;
MessageBox.Show(totaltime.Hours.ToString());
if (totaltime.Hours == 0)
{
}
else
{
TotalHours = TotalHours + (int.Parse(totaltime.Hours.ToString()) - 1);
}
}//total hours computed
if (totaltime.Hours == 0)
{
break;
}
else
{
MessageBox.Show(TotalHours.ToString());
break;
}
}//end of for loop for total number of hours
}
private void DownloadFile() {
if (_downloadUrls.Any()) {
WebClient client = new WebClient();
client.DownloadProgressChanged += client_DownloadProgressChanged;
client.DownloadFileCompleted += client_DownloadFileCompleted;
var url = _downloadUrls.Dequeue();
string startTag = "animated/";
string endTag = "/infra";
int index = url.IndexOf(startTag);
int index1 = url.IndexOf(endTag);
string fname = url.Substring(index + 9, index1 - index - 9);
client.DownloadFileAsync(new Uri(url), #"C:\Temp\tempframes\" + fname + ".gif");
lastDownloadedFile = #"C:\Temp\tempframes\" + fname + ".gif";
label1.Text = url;
return;
}
// End of the download
btnStart.Text = "Download Complete";
}
private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) {
if (e.Error != null) {
// handle error scenario
throw e.Error;
}
if (e.Cancelled) {
// handle cancelled scenario
}
Image img = new Bitmap(lastDownloadedFile);
Image[] frames = GetFramesFromAnimatedGIF(img);
foreach(Image image in frames) {
countFrames++;
image.Save(#"C:\Temp\tempframes\" + countFrames + ".gif");
}
DownloadFile();
}
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) {
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
pBarFileProgress.Value = int.Parse(Math.Truncate(percentage).ToString());
label1.Text = e.BytesReceived.ToString() + "/" + e.TotalBytesToReceive.ToString();
}
Now I added this method
DateTime lastUpdate;
long lastBytes = 0;
private void progressChanged(long bytes) {
if (lastBytes == 0) {
lastUpdate = DateTime.Now;
lastBytes = bytes;
return;
}
var now = DateTime.Now;
var timeSpan = now - lastUpdate;
var bytesChange = bytes - lastBytes;
var bytesPerSecond = bytesChange / timeSpan.Seconds;
lastBytes = bytes;
lastUpdate = now;
}
And I want to use this method or another method to display the download speed in the progresschanged event on label2. But I'm not sure how to use this method.
Not sure how to use with it in the progresschanged event.
The call to your prepared method progressChanged would best fit into client_DownloadProgressChanged like this:
progressChanged(e.BytesReceived);
You must however use TotalSeconds instead of Seconds or the values will not be correct and also cause a division by zero exception
var bytesPerSecond = bytesChange / timeSpan.TotalSeconds;
This helper class will keep track of received chunks, timestamps and progress for you:
public class DownloadProgressTracker
{
private long _totalFileSize;
private readonly int _sampleSize;
private readonly TimeSpan _valueDelay;
private DateTime _lastUpdateCalculated;
private long _previousProgress;
private double _cachedSpeed;
private Queue<Tuple<DateTime, long>> _changes = new Queue<Tuple<DateTime, long>>();
public DownloadProgressTracker(int sampleSize, TimeSpan valueDelay)
{
_lastUpdateCalculated = DateTime.Now;
_sampleSize = sampleSize;
_valueDelay = valueDelay;
}
public void NewFile()
{
_previousProgress = 0;
}
public void SetProgress(long bytesReceived, long totalBytesToReceive)
{
_totalFileSize = totalBytesToReceive;
long diff = bytesReceived - _previousProgress;
if (diff <= 0)
return;
_previousProgress = bytesReceived;
_changes.Enqueue(new Tuple<DateTime, long>(DateTime.Now, diff));
while (_changes.Count > _sampleSize)
_changes.Dequeue();
}
public double GetProgress()
{
return _previousProgress / (double) _totalFileSize;
}
public string GetProgressString()
{
return String.Format("{0:P0}", GetProgress());
}
public string GetBytesPerSecondString()
{
double speed = GetBytesPerSecond();
var prefix = new[] { "", "K", "M", "G"};
int index = 0;
while (speed > 1024 && index < prefix.Length - 1)
{
speed /= 1024;
index++;
}
int intLen = ((int) speed).ToString().Length;
int decimals = 3 - intLen;
if (decimals < 0)
decimals = 0;
string format = String.Format("{{0:F{0}}}", decimals) + "{1}B/s";
return String.Format(format, speed, prefix[index]);
}
public double GetBytesPerSecond()
{
if (DateTime.Now >= _lastUpdateCalculated + _valueDelay)
{
_lastUpdateCalculated = DateTime.Now;
_cachedSpeed = GetRateInternal();
}
return _cachedSpeed;
}
private double GetRateInternal()
{
if (_changes.Count == 0)
return 0;
TimeSpan timespan = _changes.Last().Item1 - _changes.First().Item1;
long bytes = _changes.Sum(t => t.Item2);
double rate = bytes / timespan.TotalSeconds;
if (double.IsInfinity(rate) || double.IsNaN(rate))
return 0;
return rate;
}
}
In the following example, the progress tracker will give you the average download rate of the last 50 received Packets but only every 500 ms (so the UI doesn't flicker). You might need to tinker with the values a bit to find a good balance between accuracy and smoothness.
//Somewhere in your constructor / initializer:
tracker = new DownloadProgressTracker(50, TimeSpan.FromMilliseconds(500));
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
tracker.SetProgress(e.BytesReceived, e.TotalBytesToReceive);
pBarFileProgress.Value = tracker.GetProgress() * 100;
label1.Text = e.BytesReceived + "/" + e.TotalBytesToReceive;
label2.Text = tracker.GetBytesPerSecondString();
}
Keep in mind, that you have to reset the tracker before or after every new file:
tracker.NewFile();
In case you need some bigger files to test this with, I've found some here
I don't know how to explain this clearly but I will try my best.
I'm using a DispatcherTimer class in my windows phone 8 project. I've got some check boxes and when a check box is checked and the button is pressed the countdown from a bus schedule starts. Everything works perfectly here but when I uncheck the check box and when I check another one, the same bus time starts and it goes down(countdown) by 2 seconds now. If I uncheck the check box and check another again the same time starts to countdown and the countdown goes by 3 seconds... I don't understand how, because on the click_event there is always a new instance of the class.
The only thing that solves the problem is to reload my wp8 page and check something again and press the button for the countdown to start.
Note: I'm reading my times from a .txt file which are store on a folder within my project (using streamreader).
Any suggestions?
Here is some code:
CheckBox[] listchekbox;
DispatcherTimer timer;
private void Button_Click(object sender, RoutedEventArgs e)//BUTTON CLICK
{
timer = new DispatcherTimer();
listchekbox = new CheckBox[4] { Check1, Check2, Check3, Check4 };
if (Onlyoneclick(listchekbox, 0)) { Gettingbustime(path_names[0]); }
else if (Onlyoneclick(listchekbox, 1)) { Gettingbustime(path_names[1]); }
timer.Interval = new TimeSpan(0,0,1);
timer.Tick += onclick;
timer.Start();
}
private void onclick(object sender, EventArgs e) // TIMER EVENT COUNT
{
Countdown(bus1); // the parameter is the textbox where the result is displayed
Countdown(bus2);
}
private bool Onlyoneclick(CheckBox[] itemselected,int id) // this is not so important
{
int itemcounter = 0;
int falsecounter = 0;
for (int i = 0; i < listchekbox.Length; i++)
{
if (itemselected[i].IsChecked == true && id == i)
{
itemcounter++;
}
else if (itemselected[i].IsChecked == true) { falsecounter++; }
}
if (itemcounter == 1 && falsecounter==0) { return true; }
else { return false; }
}
public void Countdown(TextBlock tx)
{
string minute = tx.Text.Substring(0, 2);
string sekunde = tx.Text.Substring(3, 2);
int minute1 = Convert.ToInt32(minute);
int sekunde1 = Convert.ToInt32(sekunde);
sekunde1 = sekunde1 - 1;
if (sekunde1 < 0)
{
minute1 = minute1 - 1;
sekunde1 = 59;
}
if (minute1 < 0)
{
timer.Stop();
MessageBox.Show("Autobus left!");
}
if (sekunde1 < 10) { tx.Text = minute1.ToString() + ":0" + sekunde1.ToString(); }
else { tx.Text = minute1.ToString() + ":" + sekunde1.ToString(); }
if (minute1 < 10) { tx.Text = "0" + minute1.ToString() + ":" + sekunde1.ToString(); }
if (minute1 < 10 && sekunde1 < 10) { tx.Text = "0" + minute1.ToString() + ":0" + sekunde1.ToString(); }
}
Try removing this code from Button_Click:
timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0,0,1);
timer.Tick += onclick;
And add it instead to your constructor.
Now its only counting back as seconds like 8..7..6..5..etc the interval of Timer1 is set to 1000ms
I want that if the user change the numericupdown1 to 9 so instead counting seconds back like now it will count it as minutes and show it as: 01(minute):10(seconds)
This is the code of Timer1_Tick event:
private void timer1_Tick(object sender, EventArgs e)
{
try
{
numbers_radar = Convert.ToInt64(numericUpDown1.Value);
numbers_satellite = Convert.ToInt64(numericUpDown2.Value);
if (numbers_radar <= 0 || numbers_satellite <= 0)
{
timer1.Stop();
button1.Enabled = true;
numericUpDown1.Enabled = true;
numericUpDown2.Enabled = true;
MessageBox.Show("Value cannot be zero or below zero");
numericUpDown1.Text = "";
numericUpDown2.Text = "";
}
else
{
Numbers_Timer_radar = Numbers_Timer_radar + 1;
Numbers_Timer_satellite = Numbers_Timer_satellite + 1;
if (Numbers_Timer_radar >= numbers_radar)
{
try
{
filesdownload();
number_of_files_in_current_directory = Directory.GetFiles(sf, "radar*.png");
label13.Text = "Current Number Of Files In The Selected Directory Are: " + number_of_files_in_current_directory.Length;
button1.Enabled = false;
Numbers_Timer_radar = 0;
}
catch (Exception Local_Timer1_Exceptions)
{
Logger.Write("Timer1 Errors : " + Local_Timer1_Exceptions);
}
}
if (Numbers_Timer_satellite >= numbers_satellite)
{
satellite_downloads();
number_of_satellite_files_in_current_directory = Directory.GetFiles(satellite_dir, "satellite*.png");
label8.Text = "Current Number Of Files In The Selected Directory Are: " + number_of_satellite_files_in_current_directory.Length;
button1.Enabled = false;
Numbers_Timer_satellite = 0;
}
time_left_radar = numbers_radar - Numbers_Timer_radar;
time_left_satellite = numbers_satellite - Numbers_Timer_satellite;
//string t = GetTime((int)time_left_radar);
label21.Text = time_left_radar.ToString();
label22.Text = time_left_satellite.ToString();
label1.Text = "Next image radar will be download in: ";
label5.Text = "Next image satellite will be download in: ";
}
}
catch (Exception General_Exceptions)
{
Logger.Write("Show if numbers have wrong string input" + numbers_radar);
Logger.Write("Show if numbers have wrong string input" + numbers_satellite);
timer1.Stop();
Logger.Write("Exception: " + General_Exceptions + Environment.NewLine);
//numericUpDown1.Clear();
//numericUpDown2.Clear();
button1.Enabled = true;
numericUpDown1.Enabled = true;
numericUpDown2.Enabled = true;
Numbers_Timer_radar = 0;
Numbers_Timer_satellite = 0;
}
}
time_left_radar and time_left_satellite are both long variables
And in label21 and label22 instead see seconds backward counting 8..7..6..etc i want it to be like:
01(minutes):10(seconds)..01:9..01:8...or 01:09..01:08...
So it will count minutes and seconds.
I tried to use there in the timer1_tick event with GetTime method but it didnt work. The GetTime method code is:
public string GetTime(int Time)
{
//Seconds
Sec = Time % 60;
//Minutes
Min = ((Time - Sec) / 60) % 60;
//Hours
Hrs = ((Time - (Sec + (Min * 60))) / 3600) % 60;
return Hrs.ToString("00") + ":" +
Min.ToString("00") + ":" +
Sec.ToString("00");
}
Thanks for the help.