PgBlowing.xaml.cs 2.37 KB
Newer Older
1 2
using FLY.Thick.Blowing.IService;
using System;
潘栩锋's avatar
潘栩锋 committed
3
using System.Globalization;
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Navigation;
using Unity;

namespace FLY.Thick.Blowing360.UI
{
    /// <summary>
    /// Page_Blowing.xaml 的交互逻辑
    /// </summary>
    public partial class PgBlowing : Page
    {
        IUnityContainer container;
        PgBlowingVm viewModel;

        public PgBlowing()
        {
            InitializeComponent();
        }

        [InjectionMethod]
        public void Init(
            IUnityContainer container,
            IBlowingService blowingFixService,
潘栩锋's avatar
潘栩锋 committed
31
            IBlowingDetectService blowingDetectService)
32 33 34 35 36 37 38 39
        {

            viewModel = new PgBlowingVm();

            viewModel.Init((IBlowingFixService)blowingFixService, blowingDetectService);
            this.DataContext = viewModel;
        }

潘栩锋's avatar
潘栩锋 committed
40
        private void button_buflist_Click(object sender, RoutedEventArgs e)
潘栩锋's avatar
潘栩锋 committed
41 42 43 44 45 46
        {
            PgBlowingExt p = new PgBlowingExt();
            p.Init(viewModel.renZiJiaService, viewModel.bDetect);
            NavigationService.Navigate(p);
        }

47 48 49 50 51 52
    }





潘栩锋's avatar
潘栩锋 committed
53
    public class OnOffConverter : IValueConverter
54
    {
潘栩锋's avatar
潘栩锋 committed
55
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
56
        {
潘栩锋's avatar
潘栩锋 committed
57
            if (value is bool)
58
            {
潘栩锋's avatar
潘栩锋 committed
59 60 61 62
                if ((bool)value)
                    return "On";
                else
                    return "Off";
63 64 65 66
            }
            return null;
        }

潘栩锋's avatar
潘栩锋 committed
67
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
68 69 70 71
        {
            throw new NotImplementedException();
        }
    }
72 73 74 75 76 77 78 79 80 81
    public class InNoConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int)
            {
                return ((int)value + 1).ToString();
            }
            return null;
        }
82

83 84 85 86 87 88 89 90 91 92 93
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string)
            {
                if (!int.TryParse((string)value, out int no))
                    return null;
                return no - 1;
            }
            return null;
        }
    }
94

潘栩锋's avatar
潘栩锋 committed
95

96
}