using FLY.OBJComponents.Client; using FLY.OBJComponents.IService; using FLY.Thick.Base.UI; using FLY.Weight.Client; using FLY.Weight.Common; using FLY.Weight.IService; using FLY.Weight.Server.Model; using GalaSoft.MvvmLight.Command; 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.Weight.UI.Client { /// <summary> /// Page_RollMixTable.xaml 的交互逻辑 /// </summary> public partial class PgRollMixTable : Page { IUnityContainer container; IWeightSystemService weightSystemService; WeighterC mWeighter; PgMixTableVm viewModel; public PgRollMixTable() { InitializeComponent(); } [InjectionMethod] public void Init( IUnityContainer container, WeighterC w, IWeightSystemService weightSystemService, MixBufferCollection mixBufferCollection, ParamDictionary paramDictionary) { this.container = container; this.weightSystemService = weightSystemService; mWeighter = w; int item_idx = this.weightSystemService.Items.IndexOf(w); var bulkDb = mixBufferCollection.GetRollMix(item_idx); viewModel = new PgMixTableVm(); viewModel.Init(bulkDb, paramDictionary, mWeighter); //界面........................................ InitDataGrid(); this.DataContext = viewModel; } void InitDataGrid() { DataGrid datagrid = gridFlows; for (int i = 0; i < mWeighter.Ingredients.Count(); i++) { // kg DataGridTextColumn dgtc = new DataGridTextColumn() { Binding = new Binding() { Path = new PropertyPath($"Items[{i}].Disp"), StringFormat = "{0:F1}" } }; StackPanel sp = new StackPanel() { Orientation = Orientation.Horizontal }; sp.Children.Add( new TextBlock() { Style = this.FindResource("TextBlockStyle_FieldHeader") as Style, Text = $"∑{mWeighter.Ingredients[i].Number}#" }); 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; gridFlows.Columns.Add(dgtc); // % DataGridTextColumn dgtc2 = new DataGridTextColumn() { Binding = new Binding() { Path = new PropertyPath($"Items[{i}].PDisp"), StringFormat = "{0:F1}" } }; StackPanel sp2 = new StackPanel() { Orientation = Orientation.Horizontal }; sp2.Children.Add( new TextBlock() { Style = this.FindResource("TextBlockStyle_FieldHeader") as Style, Text = $"∑{mWeighter.Ingredients[i].Number}#" }); sp2.Children.Add( new TextBlock() { Style = this.FindResource("TextBlockStyle_FieldContent_mm") as Style, Text = "%", Margin = new Thickness(10, 0, 10, 0) }); dgtc2.Header = sp2; dgtc2.CellStyle = this.FindResource("DataGridCellStyle_Percent") as Style; gridFlows.Columns.Add(dgtc2); } } } }