Files
BallanceTasEditor/Legacy/BallanceTASEditor/UI/StyleConverter.cs

48 lines
1.4 KiB
C#
Raw Normal View History

2021-05-13 15:49:26 +08:00
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
2021-05-21 22:37:25 +08:00
using System.Windows;
2021-05-13 15:49:26 +08:00
using System.Windows.Data;
using System.Windows.Media;
2021-05-13 22:18:51 +08:00
namespace BallanceTASEditor.UI {
2021-05-13 15:49:26 +08:00
2021-05-21 22:37:25 +08:00
public class AddItemConverter : IMultiValueConverter {
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
2021-05-13 15:49:26 +08:00
try {
2021-05-21 22:37:25 +08:00
var textCount = values[0] as string;
var textFps = values[1] as string;
var count = int.Parse(textCount);
var fps = float.Parse(textFps);
if (count <= 0 || fps <= 0) return false;
return true;
} catch {
return false;
2021-05-13 15:49:26 +08:00
}
}
2021-05-21 22:37:25 +08:00
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) {
2021-05-13 15:49:26 +08:00
return null;
}
}
2021-05-21 22:37:25 +08:00
public class FPS2DeltaTimeConverter : IValueConverter {
2021-05-13 15:49:26 +08:00
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
2021-05-21 22:37:25 +08:00
var text = value as string;
if (text == null) return "0";
2021-05-13 15:49:26 +08:00
2021-05-21 22:37:25 +08:00
float data;
if (!float.TryParse(text, out data)) return "0";
return (1000f / data).ToString();
2021-05-13 15:49:26 +08:00
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return null;
}
}
}