Page_MixTable.xaml.cs 5.09 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3
using FLY.OBJComponents.Client;
using FLY.Weight.Client;
using FLY.Weight.Common;
4
using FLY.Weight.Server.Model;
潘栩锋's avatar
潘栩锋 committed
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
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;

namespace FLY.Weight.UI.Client
{
    /// <summary>
    /// Page_Flow.xaml 的交互逻辑
    /// </summary>
    public partial class Page_MixTable : Page
    {
        
        WeightSystemClient mWeighterCsService;
        WeighterC mWeighter;

32 33
        BufferServiceClient<Lc_Mix> mBufferServiceClient;
        BufferWindow<Lc_Mix> mWindow;
潘栩锋's avatar
潘栩锋 committed
34 35 36 37 38 39 40 41 42 43 44


        public Page_MixTable()
        {
            InitializeComponent();

        }

        public void Init(WeighterC w)
        {
            mWeighter = w;
45
            templateRoot.DataContext = w;
潘栩锋's avatar
潘栩锋 committed
46 47 48 49 50 51 52 53
            mWeighterCsService = TDGage.Current.mWeighterCsService;
            SysParam sysparam = SysParam.Current;

            
            int item_idx = mWeighterCsService.Items.IndexOf(w);
            


54 55 56 57 58 59 60
            mBufferServiceClient = new BufferServiceClient<Lc_Mix>(FLY.Weight.OBJ_INTERFACE.OBJ_INTERFACE.WEIGHTS_OBJ_MIX_ID(item_idx));

            Common.BindingWindowSize((windowSize) =>
            {
                mWindow = new BufferWindow<Lc_Mix>(mBufferServiceClient, windowSize);
                return mWindow;
            });
潘栩锋's avatar
潘栩锋 committed
61 62 63 64 65 66 67 68 69 70

            FObjBase.FObjSys.Current.Connect_to_Another_OBJSys(
                sysparam.ServerEP,
                mBufferServiceClient.ID);

            //界面........................................

            InitDataGrid();

            grid_window.DataContext = mWindow;
71
 
潘栩锋's avatar
潘栩锋 committed
72 73 74 75 76 77 78 79 80 81
        }

        void InitDataGrid()
        {
            DataGrid datagrid = gridFlows;
            for (int i = 0; i < mWeighter.Ingredients.Count(); i++)
            {
                // kg
                DataGridTextColumn dgtc = new DataGridTextColumn()
                {
82
                    Binding = new Binding() { Path = new PropertyPath($"Items[{i}].Disp"), StringFormat = "{0:F4}" }
潘栩锋's avatar
潘栩锋 committed
83 84 85 86 87 88
                };
                StackPanel sp = new StackPanel() { Orientation = Orientation.Horizontal };
                sp.Children.Add(
                    new TextBlock()
                    {
                        Style = this.FindResource("TextBlockStyle_FieldHeader") as Style,
89
                        Text = $"{mWeighter.Ingredients[i].Number}#"
潘栩锋's avatar
潘栩锋 committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103
                    });
                sp.Children.Add(
                    new TextBlock()
                    {
                        Style = this.FindResource("TextBlockStyle_FieldContent_mm") as Style,
                        Text = "kg",
                        Margin = new Thickness(10, 0, 10, 0)
                    });
                dgtc.Header = sp;
                datagrid.Columns.Add(dgtc);

                // %
                DataGridTextColumn dgtc2 = new DataGridTextColumn()
                {
潘栩锋's avatar
潘栩锋 committed
104
                    Binding = new Binding() { Path = new PropertyPath($"Items[{i}].PDisp"), StringFormat = "{0:F2}" }
潘栩锋's avatar
潘栩锋 committed
105 106 107 108 109 110
                };
                StackPanel sp2 = new StackPanel() { Orientation = Orientation.Horizontal };
                sp2.Children.Add(
                    new TextBlock()
                    {
                        Style = this.FindResource("TextBlockStyle_FieldHeader") as Style,
111
                        Text = $"{mWeighter.Ingredients[i].Number}#"
潘栩锋's avatar
潘栩锋 committed
112 113 114 115 116 117 118 119 120
                    });
                sp2.Children.Add(
                    new TextBlock()
                    {
                        Style = this.FindResource("TextBlockStyle_FieldContent_mm") as Style,
                        Text = "%",
                        Margin = new Thickness(10, 0, 10, 0)
                    });
                dgtc2.Header = sp2;
潘栩锋's avatar
潘栩锋 committed
121
                dgtc2.CellStyle = this.FindResource("DataGridCellStyle_Percent") as Style;
潘栩锋's avatar
潘栩锋 committed
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
                datagrid.Columns.Add(dgtc2);

            }
        }

        private void button_back_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.GoBack();
            mBufferServiceClient.Dispose();
            mWindow.Dispose();
        }

        private void button_clear_click(object sender, RoutedEventArgs e)
        {
            if (FLY.ControlLibrary.MyMessageBox.Show("确定是否清空全部历史数据?") == true)
            {
                mBufferServiceClient.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();
        }
    }
}