PgFlowTable.xaml.cs 5.01 KB
Newer Older
1 2 3 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 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
using FLY.OBJComponents.Client;
using FLY.OBJComponents.IService;
using FLY.Thick.Base.UI;
using FLY.Weight2.Common;
using FLY.Weight2.IService;
using FLY.Weight2.Server.Model;
using Misc;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Unity;

namespace FLY.Weight2.UI.Client
{
    /// <summary>
    /// Page_Flow.xaml 的交互逻辑
    /// </summary>
    public partial class PgFlowTable : Page
    {
        IUnityContainer container;
        IWeightSystemService weightSystemService;
        IBuffer<Lc_Flow> flowList;
        ParamDictionary paramDictionary;

        BufferWindow<Lc_Flow> mWindow;


        public PgFlowTable()
        {
            InitializeComponent();
        }

        [InjectionMethod]
        public void Init(
            IUnityContainer container,
            IWeightSystemService weightSystemService,
            IBuffer<Lc_Flow> flowList,
            ParamDictionary paramDictionary)
        {
            this.container = container;
            this.weightSystemService = weightSystemService;
            this.flowList = flowList;
            this.paramDictionary = paramDictionary;

            //itemsControl.DataContext = this.weightSystemService;

            //窗口显示数据条数
            int windowSize = this.paramDictionary.GetValue<int>(ParamDistItemKeys.WindowSize, 30);
            mWindow = new BufferWindow<Lc_Flow>(flowList, windowSize);
            mWindow.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Size")
                {
                    this.paramDictionary.SetValue(ParamDistItemKeys.WindowSize, mWindow.Size);
                    this.paramDictionary.Save();
                }
            };
            //界面........................................

            InitDataGrid();

            grid_window.DataContext = mWindow;
            stackpanel_weight.DataContext = this.weightSystemService;
        }
        void InitDataGrid()
        {
            DataGridTextColumn c = new DataGridTextColumn()
            {
                CanUserSort = false,
                CanUserReorder = false,

                Header = "时间",
                Binding = new Binding("Time") { StringFormat = "{0:MM/dd HH:mm}" }
            };
            gridFlows.Columns.Add(c);

            c = new DataGridTextColumn()
            {
                CanUserSort = false,
                CanUserReorder = false,
                Header = "总流量 kg/h",
                Binding = new Binding("Total") { StringFormat = "{0:F1}" }
            };
            gridFlows.Columns.Add(c);

            for (int i = 0; i < weightSystemService.ItemsCnt; i++)
            {
                string name = (char)('A' + i) + "层";
                c = new DataGridTextColumn()
                {
                    CanUserSort = false,
                    CanUserReorder = false,
                    Header = name + "流量 kg/h",
                    Binding = new Binding($"Items[{i}].Flow") { StringFormat = "{0:F1}" }
                };
                gridFlows.Columns.Add(c);

                c = new DataGridTextColumn()
                {
                    CanUserSort = false,
                    CanUserReorder = false,
                    Header = name + "比例 %",
                    Binding = new Binding($"Items[{i}].ScrewPDisp") { StringFormat = "{0:F1}" }
                };
                gridFlows.Columns.Add(c);

                c = new DataGridTextColumn()
                {
                    CanUserSort = false,
                    CanUserReorder = false,
                    Header = name + "频率 Hz",
                    Binding = new Binding($"Items[{i}].ScrewMotorFreq") { StringFormat = "{0:F1}" }
                };
                gridFlows.Columns.Add(c);
            }
        }
        private void button_back_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.GoBack();
            mWindow.Dispose();
        }


        private void button_clear_click(object sender, RoutedEventArgs e)
        {
            if (FLY.ControlLibrary.MyMessageBox.Show("确定是否清空全部历史数据?") == true)
            {
                mWindow.Buffer.Reset();

                FLY.ControlLibrary.Window_Tip.Show("成功", "清除完毕!", TimeSpan.FromSeconds(2));
            }
        }

        private void button_prepage_Click(object sender, RoutedEventArgs e)
        {
            mWindow.MovePrePage();
        }

        private void button_nextpage_Click(object sender, RoutedEventArgs e)
        {
            mWindow.MoveNextPage();
        }

        private void button_newest_Click(object sender, RoutedEventArgs e)
        {
            mWindow.MoveNewest();
        }
    }
}