コード例 #1
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.NewCardVNames_Active)
            {
                View.Visibility = Visibility.Visible;
                #region Navigationbar Details
                VMReturnData.ViewTitle         = "New Card";
                VMReturnData.SubTitle          = "Vehicle Name details";
                VMReturnData.CurrentPageNumber = 3;
                VMReturnData.TotalPageNumber   = 4;
                VMReturnData.MenuButtonEnabled = Visibility.Collapsed;
                VMReturnData.HelpButtonEnabled = Visibility.Visible;
                //Only update this viewModel when this view is visible
                #endregion

                if (!OneTimeRead)
                {
                    VehicleInfoList    = new ObservableCollection <string>();
                    DisplayVehicleList = new ObservableCollection <string>();
                    OneTimeRead        = true;
                    VehicleName        = "";
                    index = 0;
                }

                if (Bypassed)
                {
                    DisplayVehicleList = new ObservableCollection <string> {
                        "All Vehicle Serials"
                    };
                    ByEnabled = BtnAddEnabled = false;
                    VMReturnData.VMCardDetails.VehicleNames = Enumerable.Repeat("", 15).ToArray();
                    VMReturnData.VMCardDetails.ByPassBits   = VMReturnData.VMCardDetails.ByPassBits | 0x04;
                    VMReturnData.NextButtonEnabled          = true;
                }
                else
                {
                    DisplayVehicleList = VehicleInfoList;
                    for (int i = 0; i < index; i++)
                    {
                        VMReturnData.VMCardDetails.VehicleNames[i] = VehicleInfoList[i];
                    }
                    if (VehicleInfoList.Count < 15 && VehicleName != "")
                    {
                        ByEnabled = BtnAddEnabled = true;
                    }
                    else
                    {
                        ByEnabled = BtnAddEnabled = false;
                    }
                    VMReturnData.NextButtonEnabled        = VehicleInfoList.Count() > 0 ? true : false;
                    VMReturnData.VMCardDetails.ByPassBits = (uint)(VMReturnData.VMCardDetails.ByPassBits & ~0b00000100);
                }


                if (AddbtnPressed)
                {
                    if (index < 15 && VehicleName != "")
                    {
                        VMReturnData.VMCardDetails.VehicleNames[index] = VehicleName;
                        VehicleInfoList.Add(VehicleName);
                        index++;
                    }
                    else
                    {
                        BtnAddEnabled = false;
                    }

                    for (int i = index; i < 15; i++)
                    {
                        VMReturnData.VMCardDetails.VehicleNames[index] = null;
                    }

                    VehicleName   = "";
                    AddbtnPressed = false;
                }

                if (RemovebtnPressed)
                {
                    RemovebtnPressed = false;
                    if (VehicleInfoList.Count() > 0)
                    {
                        BtnremoveEnabled = true;
                        index--;
                        VMReturnData.VMCardDetails.VehicleNames[index] = null;
                        VehicleInfoList.RemoveAt(VehicleInfoList.Count - 1);
                    }
                }

                if (VehicleInfoList.Count() > 0)
                {
                    BtnremoveEnabled = true;
                }
                else
                {
                    BtnremoveEnabled = false;
                }
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                View.Visibility = Visibility.Collapsed;
                OneTimeRead     = false;
            }
        }