123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Xamarin.Forms;
- namespace comal.timesheets
- {
- public class SetoutPacketGrid : Frame
- {
- public SetoutShell Shell;
- Dictionary<string, Guid> fileNameIDS = new Dictionary<string, Guid>();
- public SetoutPacketGrid(SetoutShell shell)
- {
- Margin = 0;
- Padding = 0;
- BorderColor = Color.Gray;
- HasShadow = false;
- Shell = shell;
- Grid mainGrid = new Grid();
- mainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
- mainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) });
- mainGrid.Children.Add(SetupSetoutColumn(shell));
- mainGrid.Children.Add(SetupPacketsColumn(shell));
- Content = mainGrid;
- GestureRecognizers.Add(OpenPDFCommand(shell));
- }
- private View SetupPacketsColumn(SetoutShell shell)
- {
- StackLayout layout = new StackLayout
- {
- Orientation = StackOrientation.Vertical
- };
- layout.SetValue(Grid.ColumnProperty, 1);
- foreach (var packet in shell.Packets)
- {
- layout.Children.Add(CreatePacketView(packet));
- }
- return layout;
- }
- private View CreatePacketView(MiniManufacturingPacket packet)
- {
- Frame frame = new Frame();
- frame.Margin = 1;
- frame.Padding = 0;
- frame.BorderColor = Color.Gray;
- frame.HasShadow = false;
- frame.Content = new Label
- {
- Text = packet.Serial + " / " + packet.Location,
- Margin = new Thickness(5, 0, 0, 0)
- };
- frame.GestureRecognizers.Add(OpenPacketCommand(packet));
- return frame;
- }
- private IGestureRecognizer OpenPacketCommand(MiniManufacturingPacket packet)
- {
- var tapped = new TapGestureRecognizer();
- tapped.Tapped += async (s, e) =>
- {
- ManufacturingPacketPopup popup = new ManufacturingPacketPopup(packet.ID, packet.OrderID);
- Navigation.PushAsync(popup);
- };
- return tapped;
- }
- private IGestureRecognizer OpenPDFCommand(SetoutShell shell)
- {
- var tapped = new TapGestureRecognizer();
- tapped.Tapped += async (s, e) =>
- {
- fileNameIDS.Clear();
- CoreTable table = new Client<SetoutDocument>().Query
- (
- new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(shell.ID),
- new Columns<SetoutDocument>(x => x.DocumentLink.ID, x => x.DocumentLink.FileName)
- );
- if (table.Rows.Any())
- {
- foreach (CoreRow row in table.Rows)
- {
- if (!fileNameIDS.ContainsKey(row.Get<string>("DocumentLink.FileName")))
- fileNameIDS.Add(row.Get<string>("DocumentLink.FileName"), row.Get<Guid>("DocumentLink.ID"));
- }
- PDFList list = new PDFList(fileNameIDS);
- Navigation.PushAsync(list);
- }
- };
- return tapped;
- }
- #region Setup Setout column
- private Grid SetupSetoutColumn(SetoutShell shell)
- {
- Grid grid = new Grid();
- grid.SetValue(Grid.ColumnProperty, 0);
- grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
- grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
- Label label = new Label
- {
- Text = shell.Number,
- LineBreakMode = LineBreakMode.WordWrap,
- Margin = new Thickness(5, 0, 0, 0)
- };
- label.SetValue(Grid.RowProperty, 0);
- Label label1 = new Label
- {
- Text = shell.Description,
- LineBreakMode = LineBreakMode.WordWrap,
- Margin = new Thickness(5, 0, 0, 0)
- };
- label1.SetValue(Grid.RowProperty, 1);
- grid.Children.Add(label);
- grid.Children.Add(label1);
- return grid;
- }
- private View CreateLabel(string text, double rownumber)
- {
- Label label = new Label
- {
- Text = text,
- LineBreakMode = LineBreakMode.WordWrap
- };
- label.SetValue(Grid.RowProperty, rownumber);
- return label;
- }
- #endregion
- }
- }
|