mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
source code checkin
This commit is contained in:
parent
5f8fb2c825
commit
7e57b72e35
675 changed files with 168433 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Common.Converters
|
||||
{
|
||||
public class SecondsToTimeValueConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
// Value is seconds since midnight.
|
||||
var seconds = (int)value;
|
||||
var hours = Math.Min(Math.Max(seconds / 3600, 0), 23);
|
||||
var minutes = Math.Min(Math.Max((seconds % 3600) / 60, 0), 59);
|
||||
return String.Format("{0:00}:{1:00}", hours, minutes);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var strTime = (string)value;
|
||||
var split = strTime.Split(':');
|
||||
if(split.Length != 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hours;
|
||||
Int32.TryParse(split[0], out hours);
|
||||
|
||||
int minutes;
|
||||
Int32.TryParse(split[1], out minutes);
|
||||
|
||||
return hours * 3600 + minutes * 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue