Example #1
0
        private void listOEM_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }

            try
            {
                Store selected = (Store)listOEM.SelectedItem;

                // If this is not the current marketplace, inform of a change
                if (!selected.storeID.Equals(MarketWorker.getOEMStore(), StringComparison.InvariantCultureIgnoreCase))
                {
                    textRestart.Visibility = System.Windows.Visibility.Visible;
                }
            }
            catch (InvalidCastException)
            {
                // This will happen when changing the lists
            }
            catch (Exception ex)
            {
                errorPrompt(ex);
            }
        }
Example #2
0
        // TODO: Clean up this method. It's a mess and hacky.
        private void populateLists()
        {
            try
            {
                listOEM.IsEnabled = false;
                listMO.IsEnabled  = false;

                // This version of the silverlight toolkit is very picky. You can't set
                // the listpicker to an empty collection without it throwing exceptions,
                // so set them to 'non-empty' collection while prepping the real one
                List <Store> empty = new List <Store>();
                empty.Add(new Store("Error loading list", "", "", false,
                                    new Uri("http://winpho.foxingworth.com/marketplaceconfig/error.png"), "en-us"));
                listOEM.ItemsSource = empty;
                listMO.ItemsSource  = empty;

                // Get current market settings (for help with sorting, filtering, selecting items, etc)
                string currentOEM    = MarketWorker.getOEMStore();
                string currentMO     = MarketWorker.getMOStore();
                string currentRegion = MarketWorker.getMarketRegion();

                // Filter the sort the store lists
                IEnumerable <Store> oemList = from s in (List <Store>)SettingsManager.getInstance().loadValue("oems")
                                              orderby s.storeID
                                              select s;
                IEnumerable <MOStore> moList;
                if ((bool)SettingsManager.getInstance().loadValue("hideforeign"))
                {
                    moList = from s in (List <Store>)SettingsManager.getInstance().loadValue("mos")
                             where s.storeLocale.Equals(currentRegion, StringComparison.InvariantCultureIgnoreCase)
                             orderby s.storeName
                             select new MOStore(s); // Create MOStore from Store so they bind correctly in UI (show region)
                }
                else
                {
                    moList = from s in (List <Store>)SettingsManager.getInstance().loadValue("mos")
                             orderby s.storeName
                             select new MOStore(s);
                }

                // Populate and update the UI
                Store   selectedOEM = null;
                MOStore selectedMO  = null;

                oems.Clear();
                foreach (Store store in oemList)
                {
                    oems.Add(store);
                    if (store.Equals(currentOEM))
                    {
                        selectedOEM = store;
                    }
                }

                mos.Clear();
                foreach (MOStore store in moList)
                {
                    mos.Add(store);
                    if (store.Equals(currentMO))
                    {
                        selectedMO = store;
                    }
                }

                if (oems.Count() > 0)
                {
                    listOEM.ItemsSource = oems;
                }

                if (mos.Count() > 0)
                {
                    listMO.ItemsSource = mos;
                }

                if (selectedOEM != null)
                {
                    listOEM.SelectedItem = selectedOEM;
                }
                if (selectedMO != null)
                {
                    listMO.SelectedItem = selectedMO;
                }

                listOEM.IsEnabled = true;
                listMO.IsEnabled  = true;

                // This slider seems so easy in comparison :P
                sliderMaxDownload.Value = MarketWorker.getMaxDownload();

                textRestart.Visibility = System.Windows.Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                errorPrompt(ex);
            }
        }