PgBlowing.xaml.cs 2.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
using FLY.Thick.Base.Client;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.UI;
using FLY.Thick.Blowing.Client;
using FLY.Thick.Blowing.IService;
using FLY.Thick.BlowingScan.Client;
using FLY.Thick.BlowingScan.IService;
using FObjBase;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
13
using System.Globalization;
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
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.BlowingScan.UI.Client
{
    /// <summary>
    /// Page_Blowing.xaml 的交互逻辑
    /// </summary>
    public partial class PgBlowing : Page
    {
        IUnityContainer container;
        PgBlowingVm viewModel;

        public PgBlowing()
        {
            InitializeComponent();
        }

        [InjectionMethod]
        public void Init(
            IUnityContainer container,
            IBlowingService blowingScanService,
            IBlowingDetectService blowingDetectService,
            IInitParamService initParamService)
        {
            this.container = container;

            viewModel = new PgBlowingVm();

            viewModel.Init(
                (IBlowingScanService)blowingScanService,
                blowingDetectService,
                initParamService);
            this.DataContext = viewModel;
        }



        private void button_buflist_Click(object sender, RoutedEventArgs e)
        {
59 60 61 62 63
            //PgBufList p = new PgBufList();
            //container.BuildUp(p);
            //NavigationService.Navigate(p);

            PgBlowingExt p = new PgBlowingExt();
64 65 66 67
            container.BuildUp(p);
            NavigationService.Navigate(p);
        }
    }
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    public class OnOffConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool) {
                if ((bool)value)
                    return "On";
                else
                    return "Off";
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
    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;
        }

        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;
        }
    }
108
}