Пример #1
0
        private void listMO_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }

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

                // If this is not the current marketplace, inform of a change
                if (!selected.storeID.Equals(MarketWorker.getMOStore(), StringComparison.InvariantCultureIgnoreCase))
                {
                    textRestart.Visibility = System.Windows.Visibility.Visible;
                }
            }
            catch (InvalidCastException)
            {
                // This will happen when changing the lists
            }
            catch (Exception ex)
            {
                errorPrompt(ex);
            }
        }
Пример #2
0
        void MainPage_UpdateComplete(object sender, EventArgs e)
        {
            populateLists();

            // If this is an unknown store, ask to submit it
            if (!UpdateManager.getInstance().knownStore(MarketWorker.getMOStore()) &&
                !(bool)SettingsManager.getInstance().loadValue("submitasked"))
            {
                SettingsManager.getInstance().saveValue("submitasked", true);
                if (MessageBox.Show(MarketWorker.getMOStore() + " is a new market not yet known by the developer. " +
                                    "Would you care to submit it to improve this app?\n\n(You can review what will be sent before submitting)",
                                    "Unknown market", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    MOStore          submit = MarketWorker.generateMOStore();
                    EmailComposeTask email  = new EmailComposeTask();
                    email.To      = "*****@*****.**";
                    email.Subject = submit.storeID;
                    email.Body    = Store.saveStore(submit.toStore());
                    email.Show();
                }
            }
        }
Пример #3
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Test for unlock status
            if (!WP7RootToolsSDK.Environment.HasRootAccess())
            {
                // Disable everything since nothing will work right anyway
                listMO.IsEnabled            = false;
                listOEM.IsEnabled           = false;
                sliderMaxDownload.IsEnabled = false;

                // Inform the user
                messageQueue.Enqueue("This app requires root access. Please mark this app as 'Trusted' in WP7 Root Tools and restart the app.");
                return;
            }

            // Update the lists
            populateLists();

            // Run a backup
            if (MarketWorker.createBackup())
            {
                messageQueue.Enqueue("Your current configuration was backed up. If you ever need to restore it, " +
                                     "you can do so from the settings.");
            }

            // Listen for list changing events
            listOEM.SelectionChanged += new SelectionChangedEventHandler(listOEM_SelectionChanged);
            listMO.SelectionChanged  += new SelectionChangedEventHandler(listMO_SelectionChanged);

            // Update if auto-update is enabled
            UpdateManager.getInstance().UpdateComplete += new EventHandler(MainPage_UpdateComplete);
            if ((bool)SettingsManager.getInstance().loadValue("autoupdate"))
            {
                UpdateManager.getInstance().startUpdate();
            }
        }
Пример #4
0
        private void menuSave_Click(object sender, EventArgs e)
        {
            // Disable the elements to prevent the user from messing about while things save
            listOEM.IsEnabled           = false;
            listMO.IsEnabled            = false;
            listRegion.IsEnabled        = false;
            sliderMaxDownload.IsEnabled = false;
            ApplicationBar.IsVisible    = false;

            try
            {
                MarketWorker.setOEMStore((Store)listOEM.SelectedItem);
                MarketWorker.setMOStore(new MOStore((Store)listMO.SelectedItem));
                //MarketWorker.setMarketRegion((Region)listRegion.SelectedItem);
                MarketWorker.setMaxDownload(sliderMaxDownload.Value);
            }
            catch (Exception ex)
            {
                errorPrompt(ex);
            }

            // An ugly way to 'close' the app, but it works
            throw new Exception("Exiting");
        }
Пример #5
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);
            }
        }
Пример #6
0
        private SettingsManager()
        {
            // Generate default values
            defaults.Add("autoupdate", true);
            defaults.Add("permanent", false);
            defaults.Add("autoregion", true);
            defaults.Add("hideforeign", true);
            defaults.Add("submitasked", false);

            List <Store> emptyOEMs = new List <Store>();

            emptyOEMs.Add(Store.loadStore(new Uri("Resources/Stores/alloems.dat", UriKind.Relative), true));
            defaults.Add("emptyoems", emptyOEMs);

            List <MOStore> emptyMOs = new List <MOStore>();

            emptyMOs.Add(new MOStore(Store.loadStore(new Uri("Resources/Stores/unlocked.dat", UriKind.Relative), true)));
            defaults.Add("emptymos", emptyMOs);

            // OEM list
            if (!valueExists("oems"))
            {
                List <Store> oems = new List <Store>();
                oems.Add(Store.loadStore(new Uri("Resources/Stores/alloems.dat", UriKind.Relative), true));
                oems.Add(Store.loadStore(new Uri("Resources/Stores/acer.dat", UriKind.Relative), true));
                oems.Add(Store.loadStore(new Uri("Resources/Stores/dell.dat", UriKind.Relative), true));
                oems.Add(Store.loadStore(new Uri("Resources/Stores/fujitsu.dat", UriKind.Relative), true));
                oems.Add(Store.loadStore(new Uri("Resources/Stores/htc.dat", UriKind.Relative), true));
                oems.Add(Store.loadStore(new Uri("Resources/Stores/lge.dat", UriKind.Relative), true));
                oems.Add(Store.loadStore(new Uri("Resources/Stores/nokia.dat", UriKind.Relative), true));
                oems.Add(Store.loadStore(new Uri("Resources/Stores/samsung.dat", UriKind.Relative), true));
                oems.Add(Store.loadStore(new Uri("Resources/Stores/zte.dat", UriKind.Relative), true));
                defaults.Add("oems", oems);
            }

            // MO list
            if (!valueExists("mos"))
            {
                List <Store> mos = new List <Store>();
                mos.Add(Store.loadStore(new Uri("Resources/Stores/unlocked.dat", UriKind.Relative), true));
                try
                {
                    mos.Add(MarketWorker.generateMOStore().toStore());
                }
                catch (Exception)
                {
                    // LKG_MOStoreConfig.xml doesn't exists. Oddly, it happens. Don't crash, just carry on.
                }
                defaults.Add("mos", mos);
            }

            // Region list
            List <string> regions = new List <string>();

            // Original markets
            regions.Add("en-US");   regions.Add("es-US");   regions.Add("en-GB");   regions.Add("de-DE");
            regions.Add("it-IT");   regions.Add("fr-FR");   regions.Add("es-ES");   regions.Add("en-CA");
            regions.Add("fr-CA");   regions.Add("en-AU");   regions.Add("fr-BE");   regions.Add("es-MX");
            regions.Add("en-SG");   regions.Add("de-CH");   regions.Add("fr-CH");   regions.Add("it-CH");
            regions.Add("de-AT");   regions.Add("en-NZ");   regions.Add("en-IE");   regions.Add("en-HK");
            regions.Add("zh-HK");
            // New mango markets

            /*regions.Add("nl-BE"); regions.Add("ja-JP"); regions.Add("pt-BR"); regions.Add("ko-KR");
             * regions.Add("nl-NL"); regions.Add("pl-PL"); regions.Add("en-ZA"); regions.Add("sv-SE");
             * regions.Add("pt-PT"); regions.Add("da-DK"); regions.Add("nb-NO"); regions.Add("fi-FI");
             * regions.Add("cs-CZ"); regions.Add("es-CL"); regions.Add("hu-HU"); regions.Add("el-GR");
             * regions.Add("es-CO"); regions.Add("ru-RU"); regions.Add("en-IN"); regions.Add("zh-TW");
             * regions.Add("id-ID"); regions.Add("es-AR"); regions.Add("ms-MY"); regions.Add("en-PH");
             * regions.Add("es-PE");
             * // New tango markets
             * regions.Add("zh-CN"); regions.Add("bg-BG"); regions.Add("es-CR"); regions.Add("hr-HR");
             * regions.Add("et-EE"); regions.Add("is-IS"); regions.Add("lv-LV"); regions.Add("lt-LT");
             * regions.Add("ro-RO"); regions.Add("sk-SK"); regions.Add("sl-SI"); regions.Add("tr-TR");
             * regions.Add("uk-UA"); regions.Add("es-VE");
             * // Second round of new tango markets
             * /*regions.Add("ar-BH"); regions.Add("ar-IQ"); regions.Add("he-IL"); regions.Add("kk-KZ");
             * regions.Add("ar-QA"); regions.Add("ar-SA"); regions.Add("th-TH"); regions.Add("ar-AE");
             * regions.Add("vi-VN");*/// Not supported by CultureInfo on WP7? (weird)*/

            defaults.Add("regions", regions);
        }