Ejemplo n.º 1
0
        private void cboRegion_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (IsPostInit)
                {
                    ListPicker         oPicker             = sender as ListPicker;
                    LottoRegionMapping oLottoRegionMapping = oPicker.SelectedItem as LottoRegionMapping;

                    // Load Lotto Game file for Selected State
                    string sLotteryGameFileName = "";
                    if (LotteryGameConfigFiles.ContainsKey(oLottoRegionMapping.Region))
                    {
                        sLotteryGameFileName = oLottoRegionMapping.FileName;
                    }
                    CurrentLotteryGameFileName = sLotteryGameFileName;

                    // Load games in to dictionary definitions
                    LottoGames = LottoAlgorithm.GetLotteryGames(sLotteryGameFileName);

                    // Add Lotto Game Names to List Picker
                    this.cboLottoGame.ItemsSource
                        = LottoGames.RegionLottoGameDict.Values.ToList <LotteryGameRec>();

                    // Set list picker to selected Lotto Game
                    cboLottoGame.SelectedIndex = 0;
                }
            }
            catch { }
        }
Ejemplo n.º 2
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            try
            {
                if (!IsPostNavigation)
                {
                    // Get Passed Parameters for Lottery Game name and Region
                    base.OnNavigatedTo(e);
                    string sLotteryGameName = NavigationContext.QueryString["StartLotteryGameName"];
                    string sLotteryRegion   = NavigationContext.QueryString["StartLotteryRegion"];
                    StartLotteryGameName = sLotteryGameName;
                    StartLotteryRegion   = sLotteryRegion;

                    // Add State names to List Picker
                    List <LottoRegionMapping> oRegionsList
                        = LotteryGameConfigFiles.Values.ToList <LottoRegionMapping>();
                    this.cboRegion.ItemsSource
                        = oRegionsList;

                    // Set List Picker to Selected State
                    // int iRegionIndex = cboRegion.Items.IndexOf(StartLotteryRegion);
                    int iRegionIndex
                        = cboRegion.Items.IndexOf(oRegionsList.Where(Reg => Reg.Region == StartLotteryRegion).First());

                    if (iRegionIndex > -1)
                    {
                        cboRegion.SelectedIndex = iRegionIndex;
                    }
                    else
                    {
                        cboRegion.SelectedIndex = 0;
                    }


                    // Load Lotto Game file for selected State
                    string sLotteryGameFileName = "";
                    if (LotteryGameConfigFiles.ContainsKey(StartLotteryRegion))
                    {
                        LottoRegionMapping oLottoRegionMappingSI = cboRegion.SelectedItem as LottoRegionMapping;
                        sLotteryGameFileName = oLottoRegionMappingSI.FileName;
                        // Load games in to dictionary definitions
                        LottoGames = LottoAlgorithm.GetLotteryGames(sLotteryGameFileName);
                    }
                    CurrentLotteryGameFileName = sLotteryGameFileName;


                    // Add Lotto Game Names to List Picker
                    List <LotteryGameRec> oRegionLottoGamesList
                        = LottoGames.RegionLottoGameDict.Values.ToList <LotteryGameRec>();
                    this.cboLottoGame.ItemsSource = oRegionLottoGamesList;

                    // Set list picker to selected Lotto Game
                    int iGameIndex
                        = cboLottoGame.Items.IndexOf(oRegionLottoGamesList.Where(RGames => RGames.GameName == StartLotteryGameName).First());

                    if (iGameIndex > -1)
                    {
                        cboLottoGame.SelectedIndex = iGameIndex;
                    }
                    else
                    {
                        cboLottoGame.SelectedIndex = 0;
                    }


                    // Populate LottorGame data on screen
                    if (cboLottoGame.Items.Count > 0)
                    {
                        LotteryGameRec oPickerRec
                            = cboLottoGame.SelectedItem as LotteryGameRec;

                        CurrentLotteryGame          = LottoGames.RegionLottoGameDict[oPickerRec.GameName];
                        txtRegBallUB.Text           = CurrentLotteryGame.LottoBallRegUB.ToString();
                        txtRegBallCount.Text        = CurrentLotteryGame.LottoBallRegCount.ToString();
                        txtSpecialBallUB.Text       = CurrentLotteryGame.LottoBallSpecialUB.ToString();
                        chkUseSpecialBall.IsChecked = CurrentLotteryGame.UseSpecialBall;
                        txtRegBallOrderH2L.Text     = CurrentLotteryGame.LottoBallRegOrderingH2LStr;
                        txtSpecialBallOrderH2L.Text = CurrentLotteryGame.LottoBallSpecialOrderingH2LStr;
                        btnUpdate.IsEnabled         = false;
                    }

                    IsPostNavigation = true;
                }
            }
            catch { }
        }