123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606 |
- using GenericDisplayCommand;
- using GenericDisplayCommand.Controls;
- using GenericDisplayCommand.Controls.V1;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Xml.Serialization;
- using Wayne.FDCPOSInterface;
- using Wayne.FDCPOSLibrary;
- namespace FdcServerTest
- {
- [TestClass]
- public class FdcServerTcpHandler_GenericDisplayCommandV1Wrapper_Test
- {
- public static bool ValueEquals(IEnumerable<byte> array1, IEnumerable<byte> array2)
- {
- if (array1 == null && array2 == null)
- {
- return true;
- }
- if ((array1 == null) || (array2 == null))
- {
- return false;
- }
- if (array1.Count() != array2.Count())
- {
- return false;
- }
- if (array1.Equals(array2))
- {
- return true;
- }
- else
- {
- for (int Index = 0; Index < array1.Count(); Index++)
- {
- if (!Equals(array1.ElementAt(Index), array2.ElementAt(Index)))
- {
- return false;
- }
- }
- }
- return true;
- }
- public class Message
- {
- public string Content { get; set; }
- }
- [TestMethod]
- public void UTF8_content_xml_Serialize_Test0()
- {
- string msgStr = "hell";
- var msg_ASCII = new Message() { Content = msgStr };
- var xmlMsgBodyMemStream = new MemoryStream();
- XmlSerializer serializer = new XmlSerializer(typeof(Message));
-
- serializer.Serialize(xmlMsgBodyMemStream, msg_ASCII);
- byte[] xmlMsgBodyBytes_ascII = null;
- xmlMsgBodyMemStream.Position = 0;
- using (StreamReader _ = new StreamReader(xmlMsgBodyMemStream, Encoding.UTF8))
- xmlMsgBodyBytes_ascII = Encoding.UTF8.GetBytes(_.ReadToEnd());
-
- msgStr = "你好你好";
- xmlMsgBodyMemStream = new MemoryStream();
- var msg_UTF8 = new Message() { Content = msgStr };
- serializer.Serialize(xmlMsgBodyMemStream, msg_UTF8);
- byte[] xmlMsgBodyBytes_utf8 = null;
- xmlMsgBodyMemStream.Position = 0;
- using (StreamReader _ = new StreamReader(xmlMsgBodyMemStream, Encoding.UTF8))
- xmlMsgBodyBytes_utf8 = Encoding.UTF8.GetBytes(_.ReadToEnd());
- var byteLengthDiff = Encoding.UTF8.GetBytes(msg_UTF8.Content).Length - Encoding.UTF8.GetBytes(msg_ASCII.Content).Length;
- Assert.AreEqual(true, xmlMsgBodyBytes_utf8.Length > xmlMsgBodyBytes_ascII.Length);
- Assert.AreEqual(true, (xmlMsgBodyBytes_utf8.Length - byteLengthDiff) == xmlMsgBodyBytes_ascII.Length);
- }
- [TestMethod]
- public void SerializeFdcMessageToNetworkBytes_Test0()
- {
- string workStationId = "abcdef";
- string appSendId = "i'm doing a test";
- var innerMsg = this.PrepareGenericDisplayCommandWithChineseCharacterIn();
- MemoryStream ms = new MemoryStream();
- XmlSerializer xmlSerializer = new XmlSerializer(typeof(GenericDisplayCommandWrapper));
- xmlSerializer.Serialize(ms, innerMsg);
- ms.Position = 0;
- var innerMsgStr = new StreamReader(ms).ReadToEnd();
- var outerMsg = new FDCMessageGenericTypelessMessage()
- {
- WorkstationID = workStationId,
- ApplicationSender = appSendId,
- MessageID = "9999",
- FDCdata = new FDCMessageFDCdataGenericTypelessMessage[] {
- new FDCMessageFDCdataGenericTypelessMessage()
- {
- FDCTimeStamp=FDCConvert.ToString(DateTime.Now),
- Message = innerMsgStr
- }
- }
- };
- var raw = FdcServerTcpHandler.SerializeFdcMessageToNetworkBytes(outerMsg, true);
-
- var actual = raw.Item1.Skip(4 + 16).ToArray();
- ms = new MemoryStream();
- xmlSerializer = new XmlSerializer(typeof(FDCMessageGenericTypelessMessage));
- xmlSerializer.Serialize(ms, outerMsg);
- ms.Position = 0;
- var expect = Encoding.UTF8.GetBytes(new StreamReader(ms).ReadToEnd());
- Assert.AreEqual(true, raw.Item2.Length != raw.Item1.Length, "Chinese character contained string should have its (char length) > its (bytes length)");
- Assert.AreEqual(true, ValueEquals(actual, expect));
- }
- [TestMethod]
- public void SerializeFdcMessageToNetworkBytes_Test1()
- {
- string workStationId = "abcdef";
- string appSendId = "i'm doing a test";
- var innerMsg = this.PrepareGenericDisplayCommandWithOnlyAscIICharacterIn_Simple();
- MemoryStream ms = new MemoryStream();
- XmlSerializer xmlSerializer = new XmlSerializer(typeof(GenericDisplayCommandWrapper));
- xmlSerializer.Serialize(ms, innerMsg);
- ms.Position = 0;
- var innerMsgStr = new StreamReader(ms).ReadToEnd();
- var outerMsg = new FDCMessageGenericTypelessMessage()
- {
- WorkstationID = workStationId,
- ApplicationSender = appSendId,
- MessageID = "9999",
- FDCdata = new FDCMessageFDCdataGenericTypelessMessage[] {
- new FDCMessageFDCdataGenericTypelessMessage()
- {
- FDCTimeStamp=FDCConvert.ToString(DateTime.Now),
- Message = innerMsgStr
- }
- }
- };
- var raw = FdcServerTcpHandler.SerializeFdcMessageToNetworkBytes(outerMsg, true);
-
- var actual = raw.Item1.Skip(4 + 16).ToArray();
- ms = new MemoryStream();
- xmlSerializer = new XmlSerializer(typeof(FDCMessageGenericTypelessMessage));
- xmlSerializer.Serialize(ms, outerMsg);
- ms.Position = 0;
- var expect = Encoding.UTF8.GetBytes(new StreamReader(ms).ReadToEnd());
- Assert.AreEqual(true, (raw.Item2.Length + 4 + 16) == raw.Item1.Length, "Full AscII character contained string should have its (char length) == its (bytes length)");
- Assert.AreEqual(true, ValueEquals(actual, expect));
- }
- [TestMethod]
- public void SerializeFdcMessageToNetworkBytes_Test2()
- {
- string workStationId = "abcdef";
- string appSendId = "i'm doing a test";
- var innerMsg = this.PrepareGenericDisplayCommandWithOnlyAscIICharacterIn();
- MemoryStream ms = new MemoryStream();
- XmlSerializer xmlSerializer = new XmlSerializer(typeof(GenericDisplayCommandWrapper));
- xmlSerializer.Serialize(ms, innerMsg);
- ms.Position = 0;
- var innerMsgStr = new StreamReader(ms).ReadToEnd();
- var outerMsg = new FDCMessageGenericTypelessMessage()
- {
- WorkstationID = workStationId,
- ApplicationSender = appSendId,
- MessageID = "9999",
- FDCdata = new FDCMessageFDCdataGenericTypelessMessage[] {
- new FDCMessageFDCdataGenericTypelessMessage()
- {
- FDCTimeStamp=FDCConvert.ToString(DateTime.Now),
- Message = innerMsgStr
- }
- }
- };
- var raw = FdcServerTcpHandler.SerializeFdcMessageToNetworkBytes(outerMsg, true);
-
- var actual = raw.Item1.Skip(4 + 16).ToArray();
- ms = new MemoryStream();
- xmlSerializer = new XmlSerializer(typeof(FDCMessageGenericTypelessMessage));
- xmlSerializer.Serialize(ms, outerMsg);
- ms.Position = 0;
- var expect = Encoding.UTF8.GetBytes(new StreamReader(ms).ReadToEnd());
- Assert.AreEqual(true, (raw.Item2.Length + 4 + 16) == raw.Item1.Length, "Full AscII character contained string should have its (char length) == its (bytes length)");
- Assert.AreEqual(true, ValueEquals(actual, expect));
- }
- private GenericDisplayCommandWrapper PrepareGenericDisplayCommandWithOnlyAscIICharacterIn_Simple()
- {
- LinearLayout root = new LinearLayout();
- root.Orientation = "vertical";
- root.Height = "match_parent";
- root.Width = "match_parent";
- root.WeightSum = 10.ToString(CultureInfo.InvariantCulture);
- var genericDisplayCommand = new GenericDisplayCommandV1Wrapper() { Version = 1, Control = root };
- return genericDisplayCommand;
- }
- private GenericDisplayCommandWrapper PrepareGenericDisplayCommandWithOnlyAscIICharacterIn()
- {
- LinearLayout advLinearLayout = new LinearLayout();
- advLinearLayout.Views.Add(new VideoView() { Src = "mp4.avi" });
- advLinearLayout.Orientation = "vertical";
- advLinearLayout.Height = "0dp";
- advLinearLayout.WeightSum = 4.ToString(CultureInfo.InvariantCulture);
- advLinearLayout.Width = "match_parent";
- LinearLayout middleLinearLayout = new LinearLayout()
- {
- Orientation = "horizontal",
- Height = "0dp",
- Weight = 3.ToString(CultureInfo.InvariantCulture),
- Width = "match_parent",
- };
- #region middle_left
- LinearLayout middle_left_LinearLayout = new LinearLayout()
- {
- Height = "match_parent",
- Width = "0dp",
- Weight = 7.5f.ToString(CultureInfo.InvariantCulture),
- };
- var carPlatesGridView = new GridView() { NumColumns = 3 };
- List<Tuple<string, string>> carPlateLabels = new List<Tuple<string, string>>();
- carPlateLabels.Add(new Tuple<string, string>("ACD343", "11"));
- carPlateLabels.Add(new Tuple<string, string>("BCDFSADF", "22"));
- carPlateLabels.Add(new Tuple<string, string>("CDF23423DF", "33"));
- carPlateLabels.Add(new Tuple<string, string>("D232f23DF", "44"));
- carPlateLabels.Add(new Tuple<string, string>("Eadfvvhjk3DF", "55"));
- for (int i = 0; i < carPlateLabels.Count; i++)
- {
- carPlatesGridView.Views.Add(this.ConstuctCarPlateLabel(carPlateLabels[i].Item1,
- carPlateLabels[i].Item2, "Yellow"));
- }
- middle_left_LinearLayout.Views.Add(carPlatesGridView);
- #endregion
- #region middle right
- LinearLayout middle_right_LinearLayout = new LinearLayout()
- {
- Height = "match_parent",
- Width = "0dp",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- };
- var errorCarPlatesGridView = new GridView() { NumColumns = 1 };
- List<Tuple<string, string>> errorCarPlateLabels = new List<Tuple<string, string>>();
- errorCarPlateLabels.Add(new Tuple<string, string>("QCD343", "66"));
- errorCarPlateLabels.Add(new Tuple<string, string>("TCDFSADF", "77"));
- errorCarPlateLabels.Add(new Tuple<string, string>("XDF23423DF", "88"));
- errorCarPlateLabels.Add(new Tuple<string, string>("Y232f23DF", "99"));
- errorCarPlateLabels.Add(new Tuple<string, string>("Zadfvvhjk3DF", "00"));
- for (int i = 0; i < errorCarPlateLabels.Count; i++)
- {
- errorCarPlatesGridView.Views.Add(this.ConstuctCarPlateLabel(errorCarPlateLabels[i].Item1,
- errorCarPlateLabels[i].Item2, "Red"));
- }
- middle_right_LinearLayout.Views.Add(errorCarPlatesGridView);
- #endregion
- LinearLayout bottomLinearLayout = new LinearLayout()
- {
- Orientation = "horizontal",
- Height = "0dp",
- Weight = 3.ToString(CultureInfo.InvariantCulture),
- WeightSum = 10.ToString(CultureInfo.InvariantCulture),
- Width = "match_parent",
- };
- #region firstNozzleLinearLayout
- LinearLayout firstNozzleLinearLayout = new LinearLayout()
- {
- Orientation = "vertical",
- Height = "match_parent",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- Width = "0dp",
- };
- List<Tuple<string, string>> firstNozzleBoundCarPlateLabels = new List<Tuple<string, string>>();
- firstNozzleBoundCarPlateLabels.Add(new Tuple<string, string>("QCD343", "11"));
- for (int i = 0; i < firstNozzleBoundCarPlateLabels.Count; i++)
- {
- firstNozzleLinearLayout.Views.Add(this.ConstuctCarPlateLabel(firstNozzleBoundCarPlateLabels[i].Item1,
- firstNozzleBoundCarPlateLabels[i].Item2, "Blue"));
- }
- firstNozzleLinearLayout.Views.Add(new NozzleView() { PumpId = 3, NozzleId = 1 });
- #endregion
- bottomLinearLayout.Views.Add(firstNozzleLinearLayout);
- #region second NozzleLinearLayout
- LinearLayout secondNozzleLinearLayout = new LinearLayout()
- {
- Orientation = "vertical",
- Height = "match_parent",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- Width = "0dp",
- };
- List<Tuple<string, string>> secondNozzleBoundCarPlateLabels = new List<Tuple<string, string>>();
- secondNozzleBoundCarPlateLabels.Add(new Tuple<string, string>("QCD343", "aa"));
- for (int i = 0; i < secondNozzleBoundCarPlateLabels.Count; i++)
- {
- secondNozzleLinearLayout.Views.Add(this.ConstuctCarPlateLabel(secondNozzleBoundCarPlateLabels[i].Item1,
- secondNozzleBoundCarPlateLabels[i].Item2, "Blue"));
- }
- secondNozzleLinearLayout.Views.Add(new NozzleView() { PumpId = 3, NozzleId = 2 });
- #endregion
- bottomLinearLayout.Views.Add(secondNozzleLinearLayout);
- #region third NozzleLinearLayout
- LinearLayout thirdNozzleLinearLayout = new LinearLayout()
- {
- Orientation = "vertical",
- Height = "match_parent",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- Width = "0dp",
- };
- List<Tuple<string, string>> thirdNozzleBoundCarPlateLabels = new List<Tuple<string, string>>();
- thirdNozzleBoundCarPlateLabels.Add(new Tuple<string, string>("QCD343", "cc"));
- for (int i = 0; i < thirdNozzleBoundCarPlateLabels.Count; i++)
- {
- thirdNozzleLinearLayout.Views.Add(this.ConstuctCarPlateLabel(thirdNozzleBoundCarPlateLabels[i].Item1,
- thirdNozzleBoundCarPlateLabels[i].Item2, "Blue"));
- }
- thirdNozzleLinearLayout.Views.Add(new NozzleView() { PumpId = 3, NozzleId = 3 });
- #endregion
- bottomLinearLayout.Views.Add(thirdNozzleLinearLayout);
- #region fourth NozzleLinearLayout
- LinearLayout fourthNozzleLinearLayout = new LinearLayout()
- {
- Orientation = "vertical",
- Height = "match_parent",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- Width = "0dp",
- };
- List<Tuple<string, string>> fourthNozzleBoundCarPlateLabels = new List<Tuple<string, string>>();
- fourthNozzleBoundCarPlateLabels.Add(new Tuple<string, string>("QCD343", "1111"));
- for (int i = 0; i < fourthNozzleBoundCarPlateLabels.Count; i++)
- {
- fourthNozzleLinearLayout.Views.Add(this.ConstuctCarPlateLabel(fourthNozzleBoundCarPlateLabels[i].Item1,
- fourthNozzleBoundCarPlateLabels[i].Item2, "Blue"));
- }
- fourthNozzleLinearLayout.Views.Add(new NozzleView() { PumpId = 3, NozzleId = 4 });
- #endregion
- bottomLinearLayout.Views.Add(fourthNozzleLinearLayout);
- LinearLayout root = new LinearLayout();
- root.Orientation = "vertical";
- root.Height = "match_parent";
- root.Width = "match_parent";
- root.WeightSum = 10.ToString(CultureInfo.InvariantCulture);
- root.Views.Add(advLinearLayout);
- root.Views.Add(middleLinearLayout);
- root.Views.Add(bottomLinearLayout);
- var genericDisplayCommand = new GenericDisplayCommandV1Wrapper() { Version = 1, Control = root };
- return genericDisplayCommand;
- }
- private GenericDisplayCommandWrapper PrepareGenericDisplayCommandWithChineseCharacterIn()
- {
- LinearLayout advLinearLayout = new LinearLayout();
- advLinearLayout.Views.Add(new VideoView() { Src = "mp4.avi" });
- advLinearLayout.Orientation = "vertical";
- advLinearLayout.Height = "0dp";
- advLinearLayout.WeightSum = 4.ToString(CultureInfo.InvariantCulture);
- advLinearLayout.Width = "match_parent";
- LinearLayout middleLinearLayout = new LinearLayout()
- {
- Orientation = "horizontal",
- Height = "0dp",
- Weight = 3.ToString(CultureInfo.InvariantCulture),
- Width = "match_parent",
- };
- #region middle_left
- LinearLayout middle_left_LinearLayout = new LinearLayout()
- {
- Height = "match_parent",
- Width = "0dp",
- Weight = 7.5f.ToString(CultureInfo.InvariantCulture),
- };
- var carPlatesGridView = new GridView() { NumColumns = 3 };
- List<Tuple<string, string>> carPlateLabels = new List<Tuple<string, string>>();
- carPlateLabels.Add(new Tuple<string, string>("ACD343", "你好世界你好世界你好世界你好世界"));
- for (int i = 0; i < carPlateLabels.Count; i++)
- {
- carPlatesGridView.Views.Add(this.ConstuctCarPlateLabel(carPlateLabels[i].Item1,
- carPlateLabels[i].Item2, "Yellow"));
- }
- middle_left_LinearLayout.Views.Add(carPlatesGridView);
- #endregion
- #region middle right
- LinearLayout middle_right_LinearLayout = new LinearLayout()
- {
- Height = "match_parent",
- Width = "0dp",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- };
- var errorCarPlatesGridView = new GridView() { NumColumns = 1 };
- List<Tuple<string, string>> errorCarPlateLabels = new List<Tuple<string, string>>();
- errorCarPlateLabels.Add(new Tuple<string, string>("QCD343", "66"));
- errorCarPlateLabels.Add(new Tuple<string, string>("TCDFSADF", "77"));
- errorCarPlateLabels.Add(new Tuple<string, string>("XDF23423DF", "88"));
- errorCarPlateLabels.Add(new Tuple<string, string>("Y232f23DF", "99"));
- errorCarPlateLabels.Add(new Tuple<string, string>("Zadfvvhjk3DF", "00"));
- for (int i = 0; i < errorCarPlateLabels.Count; i++)
- {
- errorCarPlatesGridView.Views.Add(this.ConstuctCarPlateLabel(errorCarPlateLabels[i].Item1,
- errorCarPlateLabels[i].Item2, "Red"));
- }
- middle_right_LinearLayout.Views.Add(errorCarPlatesGridView);
- #endregion
- LinearLayout bottomLinearLayout = new LinearLayout()
- {
- Orientation = "horizontal",
- Height = "0dp",
- Weight = 3.ToString(CultureInfo.InvariantCulture),
- WeightSum = 10.ToString(CultureInfo.InvariantCulture),
- Width = "match_parent",
- };
- #region firstNozzleLinearLayout
- LinearLayout firstNozzleLinearLayout = new LinearLayout()
- {
- Orientation = "vertical",
- Height = "match_parent",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- Width = "0dp",
- };
- List<Tuple<string, string>> firstNozzleBoundCarPlateLabels = new List<Tuple<string, string>>();
- firstNozzleBoundCarPlateLabels.Add(new Tuple<string, string>("QCD343", "11"));
- for (int i = 0; i < firstNozzleBoundCarPlateLabels.Count; i++)
- {
- firstNozzleLinearLayout.Views.Add(this.ConstuctCarPlateLabel(firstNozzleBoundCarPlateLabels[i].Item1,
- firstNozzleBoundCarPlateLabels[i].Item2, "Blue"));
- }
- firstNozzleLinearLayout.Views.Add(new NozzleView() { PumpId = 3, NozzleId = 1 });
- #endregion
- bottomLinearLayout.Views.Add(firstNozzleLinearLayout);
- #region second NozzleLinearLayout
- LinearLayout secondNozzleLinearLayout = new LinearLayout()
- {
- Orientation = "vertical",
- Height = "match_parent",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- Width = "0dp",
- };
- List<Tuple<string, string>> secondNozzleBoundCarPlateLabels = new List<Tuple<string, string>>();
- secondNozzleBoundCarPlateLabels.Add(new Tuple<string, string>("QCD343", "aa"));
- for (int i = 0; i < secondNozzleBoundCarPlateLabels.Count; i++)
- {
- secondNozzleLinearLayout.Views.Add(this.ConstuctCarPlateLabel(secondNozzleBoundCarPlateLabels[i].Item1,
- secondNozzleBoundCarPlateLabels[i].Item2, "Blue"));
- }
- secondNozzleLinearLayout.Views.Add(new NozzleView() { PumpId = 3, NozzleId = 2 });
- #endregion
- bottomLinearLayout.Views.Add(secondNozzleLinearLayout);
- #region third NozzleLinearLayout
- LinearLayout thirdNozzleLinearLayout = new LinearLayout()
- {
- Orientation = "vertical",
- Height = "match_parent",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- Width = "0dp",
- };
- List<Tuple<string, string>> thirdNozzleBoundCarPlateLabels = new List<Tuple<string, string>>();
- thirdNozzleBoundCarPlateLabels.Add(new Tuple<string, string>("QCD343", "cc"));
- for (int i = 0; i < thirdNozzleBoundCarPlateLabels.Count; i++)
- {
- thirdNozzleLinearLayout.Views.Add(this.ConstuctCarPlateLabel(thirdNozzleBoundCarPlateLabels[i].Item1,
- thirdNozzleBoundCarPlateLabels[i].Item2, "Blue"));
- }
- thirdNozzleLinearLayout.Views.Add(new NozzleView() { PumpId = 3, NozzleId = 3 });
- #endregion
- bottomLinearLayout.Views.Add(thirdNozzleLinearLayout);
- #region fourth NozzleLinearLayout
- LinearLayout fourthNozzleLinearLayout = new LinearLayout()
- {
- Orientation = "vertical",
- Height = "match_parent",
- Weight = 2.5f.ToString(CultureInfo.InvariantCulture),
- Width = "0dp",
- };
- List<Tuple<string, string>> fourthNozzleBoundCarPlateLabels = new List<Tuple<string, string>>();
- fourthNozzleBoundCarPlateLabels.Add(new Tuple<string, string>("QCD343", "1111"));
- for (int i = 0; i < fourthNozzleBoundCarPlateLabels.Count; i++)
- {
- fourthNozzleLinearLayout.Views.Add(this.ConstuctCarPlateLabel(fourthNozzleBoundCarPlateLabels[i].Item1,
- fourthNozzleBoundCarPlateLabels[i].Item2, "Blue"));
- }
- fourthNozzleLinearLayout.Views.Add(new NozzleView() { PumpId = 3, NozzleId = 4 });
- #endregion
- bottomLinearLayout.Views.Add(fourthNozzleLinearLayout);
- LinearLayout root = new LinearLayout();
- root.Orientation = "vertical";
- root.Height = "match_parent";
- root.Width = "match_parent";
- root.WeightSum = 10.ToString(CultureInfo.InvariantCulture);
- root.Views.Add(advLinearLayout);
- root.Views.Add(middleLinearLayout);
- root.Views.Add(bottomLinearLayout);
- var genericDisplayCommand = new GenericDisplayCommandV1Wrapper() { Version = 1, Control = root };
- return genericDisplayCommand;
- }
- private LinearLayout ConstuctCarPlateLabel(string carPlate, string hint, string hintColor)
- {
- var label = new LinearLayout()
- {
- Id = carPlate,
- Height = "match_parent",
- Width = "match_parent",
- Orientation = "horizontal",
- AllowActions = new List<AllowAction>() { AllowAction.Select, AllowAction.Drag, AllowAction.Drop },
- };
- label.Views.Add(new TextView()
- {
- Text = carPlate,
- Background = "White",
- AllowActions = new List<AllowAction>() { AllowAction.Select, AllowAction.Drag }
- });
- label.Views.Add(new TextView() { Text = hint, Background = hintColor, PaddingLeft = "2dp" });
- return label;
- }
- }
- }
|