/// <summary>
        /// Sets the provided marketplace as the current
        /// </summary>
        /// <param name="store">MO Marketplace to set</param>
        public static void setMOStore(MOStore store)
        {
            // Unlock the file if marked as read-only
            if (WP7RootToolsSDK.FileSystem.FileExists(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml"))
            {
                FileAttributes attributes = File.GetAttributes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml");
                if (attributes.ReadOnly)
                {
                    File.SetAttributes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml", new FileAttributes(FileAttributesEnum.Archive));
                }
            }

            // Overwrite the file with the desired market
            File.WriteAllBytes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.new",
                               System.Text.Encoding.UTF8.GetBytes(store.generateXML().ToString()));
            File.Copy(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.new", @"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml");
            File.Delete(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.new");

            // Set the correct attributes
            if ((bool)SettingsManager.getInstance().loadValue("permanent"))
            {
                File.SetAttributes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml", new FileAttributes(FileAttributesEnum.Archive | FileAttributesEnum.Readonly));
            }
            else
            {
                File.SetAttributes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml", new FileAttributes(FileAttributesEnum.Archive));
            }
        }
Example #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();
                }
            }
        }
Example #3
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);
            }
        }
        /// <summary>
        /// Sets the provided marketplace as the current
        /// </summary>
        /// <param name="store">MO Marketplace to set</param>
        public static void setMOStore(MOStore store)
        {
            // Unlock the file if marked as read-only
            if (WP7RootToolsSDK.FileSystem.FileExists(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml"))
            {
                FileAttributes attributes = File.GetAttributes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml");
                if (attributes.ReadOnly)
                    File.SetAttributes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml", new FileAttributes(FileAttributesEnum.Archive));
            }

            // Overwrite the file with the desired market
            File.WriteAllBytes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.new",
                System.Text.Encoding.UTF8.GetBytes(store.generateXML().ToString()));
            File.Copy(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.new", @"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml");
            File.Delete(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.new");

            // Set the correct attributes
            if ((bool)SettingsManager.getInstance().loadValue("permanent"))
                File.SetAttributes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml", new FileAttributes(FileAttributesEnum.Archive | FileAttributesEnum.Readonly));
            else
                File.SetAttributes(@"\My Documents\Zune\PimentoCache\Keepers\LKG_MOStoreConfig.xml", new FileAttributes(FileAttributesEnum.Archive));
        }