Пример #1
0
        // Код для выполнения при активации приложения (переводится в основной режим)
        // Этот код не будет выполняться при первом запуске приложения
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (e.IsApplicationInstancePreserved)
            {
                return;
            }

            IsolatedStorageSettings iss = IsolatedStorageSettings.ApplicationSettings;

            if (PhoneApplicationService.Current.State.ContainsKey("Settings"))
            {
                Settings = PhoneApplicationService.Current.State["Settings"] as SettingsData;
            }
            else
            {
                if (!iss.TryGetValue("Settings", out settingsData))
                {
                    Settings = new SettingsData();
                }
            }

            Mogade = MogadeHelper.CreateInstance();
            Mogade.LogApplicationStart();
        }
Пример #2
0
        public static void RestoreCache(Dispatcher dispatcher)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            string name;

            if (!_appSettings.TryGetValue(KEY_DATABASE, out name) ||
                string.IsNullOrEmpty(name))
            {
                return;
            }

            var info = new DatabaseInfo(name);

            if (!info.HasPassword)
            {
                return;
            }

            info.Open(dispatcher);
        }
Пример #3
0
        /**
         * Gets value stored at key
         * @param key
         * @return
         */
        public static Object Get(String key)
        {
#if NETFX_CORE
            StorageSettings iss = Defines.GetStorageSettings();
#else
            IsolatedStorageSettings iss = IsolatedStorageSettings.ApplicationSettings;
#endif
            String value = "";
            if (iss.TryGetValue <String>(key, out value))
            {
                return(value);
            }
            else
            {
                if (iss.Contains(key))
                {
                    return(Convert.ToDouble(iss[key]));
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #4
0
        private void AutoSummarise()
        {
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            SetDic AutoSummariseSettings;

            if (!settings.TryGetValue <SetDic>("AutoSummariseSettings", out AutoSummariseSettings))
            {
                return;
            }
            String   temp;
            String   Frequency;
            DateTime dateNext;
            String   EmailAddr;

            if (!AutoSummariseSettings.TryGetValue("Frequency", out Frequency))
            {
                return;
            }
            if (!AutoSummariseSettings.TryGetValue("NextDate", out temp))
            {
                return;
            }
            dateNext = DateTime.ParseExact(temp, "d", null);
            if (!AutoSummariseSettings.TryGetValue("EmailAddr", out EmailAddr))
            {
                return;
            }

            if (DateTime.Today >= dateNext)
            {
                //update the next date to summarise.
                AutoSummariseSettings["NextDate"] = String2DateTimeDecrement(AutoSummariseSettings["Frequency"], dateNext).ToString("d");
                settings["AutoSummariseSettings"] = AutoSummariseSettings;
                settings.Save();
            }
        }
        public void fetch(string argsString)
        {
            AppPreferenceArgs preference;
            string            value;
            string            optionsString = JSON.JsonHelper.Deserialize <string[]> (argsString)[0];

            //BrowserOptions opts = JSON.JsonHelper.Deserialize<BrowserOptions>(options);

            try {
                preference = JSON.JsonHelper.Deserialize <AppPreferenceArgs> (optionsString);
                IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings;

                userSettings.TryGetValue <string> (preference.fullKey(), out value);
            } catch (NullReferenceException) {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
                return;
            }
            catch (Exception)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
                return;
            }
            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, value));
        }
        private void CheckTrialPeriodExpired()
        {
            // when the application is activated
            // show message to buy the full version if trial period has expired
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            DateTime firstLauchDate;

            if (settings.TryGetValue <DateTime>(FirstLauchDateKey, out firstLauchDate))
            {
                TimeSpan timeSinceFirstLauch = DateTime.UtcNow.Subtract(firstLauchDate);
                if (timeSinceFirstLauch > TrialPeriodLength)
                {
                    IsTrialOver = true;
                }
                else
                {
                    TimeSpan elapsed = TrialPeriodLength.Subtract(timeSinceFirstLauch);
                    if (elapsed != null)
                    {
                        DaysRemaining = (int)elapsed.TotalDays + 1;
                    }
                    IsTrialOver = false;
                }

                // subscribe to the Navigated event in order to show the popup
                // over the page after it has loaded
                RootFrame.Navigated += new NavigatedEventHandler(RootFrame_Navigated);
            }
            else
            {
                // if a value cannot be found for the first launch date
                // save the current date and time
                settings.Add(FirstLauchDateKey, DateTime.UtcNow);
                settings.Save();
            }
        }
Пример #7
0
        /// <summary>
        /// Gets the value for the specified field.  If the field does not exist
        /// it is created using the defaultValue and the defaultValue is returned.
        /// </summary>
        /// <param name="key">The name of the field whose value is being requested</param>
        /// <param name="defaultValue">The default value to return in the event that the field doesn't exist</param>
        /// <returns>The value of the specified field or the defaultValue, if the field does not exist</returns>
        public string GetPreference(string key, string defaultValue)
        {
            string value = null;

            // Validate the provided key
            if (string.IsNullOrEmpty(key))
            {
                // Add the new setting with the provided default value
                SetPreference(key, defaultValue);
                return(defaultValue);
            }

            // Try and get the setting from Isolated Storage
            if (isoSettings.TryGetValue(key, out value))
            {
                return(value);
            }
            else
            {
                // Add the new setting with the provided default value
                SetPreference(key, defaultValue);
                return(defaultValue);
            }
        }
Пример #8
0
        private async void InitializeMainPages()
        {
            string Current = "";

            UserSettings.TryGetValue("current_user", out Current);
            var tmp = await api.GetCustomersByEmail(Current);

            Currency = await api.GetCurrency();

            Customer          = tmp.First();
            CustomerName.Text = Customer.FullName;
            var Featured = await api.FeaturedProducts();

            FeaturedCount = Featured.Count();
            var FeaturedList = new List <ProductData>();
            int FeatCount    = Helper.GetSetting <int>("featured_count");
            int tmpCount     = 0;

            foreach (ProductDTO p in Featured)
            {
                if (tmpCount == FeatCount)
                {
                    break;
                }
                FeaturedList.Add(new ProductData {
                    Id = p.Id, ProductName = p.Name, Description = p.Description, Image = Helper.ConvertToBitmapImage(p.Image.First()), Value = p.Price.ToString("0") + " " + Currency
                });
                tmpCount++;
            }
            FeaturedProducts.ItemsSource = FeaturedList;
            var BestsellersA = await api.GetBestsellerByAmount();

            var BestsellersQ = await api.GetBestsellerByQuantity();

            var Bests     = new List <ProductData>();
            var BestCount = Helper.GetSetting <int>("bestsellers_count") / 2;

            for (int i = 0; i < BestCount; i++)
            {
                if (i < BestsellersA.Count())
                {
                    Bests.Add(new ProductData {
                        Id = BestsellersA[i].Product.Id, ProductName = BestsellersA[i].Product.Name, Value = BestsellersA[i].Product.Price.ToString("0.#") + " " + Currency, Image = Helper.ConvertToBitmapImage(BestsellersA[i].Product.Image.First())
                    });
                }
                if (i < BestsellersQ.Count())
                {
                    Bests.Add(new ProductData {
                        Id = BestsellersQ[i].Product.Id, ProductName = BestsellersQ[i].Product.Name, Value = BestsellersQ[i].Product.Price.ToString("0.#") + " " + Currency, Image = Helper.ConvertToBitmapImage(BestsellersQ[i].Product.Image.First())
                    });
                }
            }
            BestsellersList.ItemsSource = Bests;
            var Categories = await api.GetMainCategories();

            var CategoriesList = new List <CategoryData>();

            foreach (CategoryDTO c in Categories)
            {
                CategoriesList.Add(new CategoryData {
                    Id = c.Id, Name = c.Name, Image = Helper.ConvertToBitmapImage(c.Image)
                });
            }
            CategoriesListbox.ItemsSource = CategoriesList;
            HideLoading();
        }
        /*
         * Read username from isolated storage
         * */
        private bool ReadUsername(out string username)
        {
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

            return(settings.TryGetValue <string>("ovi_username", out username));
        }
Пример #10
0
        private async Task InitializeStore()
        {
            var Current = "";

            if (ChangeStore)
            {
                ResetValues();
                UserSettings.Remove("current_url");
                UserSettings.Add("current_url", StoreUrl);
                UserSettings.Remove("current_user");
                UserSettings.Add("current_user", UserName);
            }
            UserSettings.TryGetValue("current_user", out Current);
            SideMenu.Header = await api.GetStoreName();

            SideMenu.Header = SideMenu.Header.ToString().ToLower();
            AdminName.Text  = await api.GetFullName(Current);

            if (!ChangeStore)
            {
                foreach (KeyValuePair <string, object> url in UserSettings)
                {
                    if (url.Key.StartsWith("store_url_"))
                    {
                        var Name = url.Key.Substring(10);
                        UrlsMap.Add(new KeyValuePair <String, String>(Name, (string)url.Value));
                        urls.Add(Name);
                    }
                }
                MyStoresList.ItemsSource = urls;
            }
            var Currency = await api.GetCurrency();

            var SaleValuesIn = settings.GetValueOrDefault <int>(SaleValuesDash, 0);

            var PendingV = await api.GetStats(3);

            var CompleteV = await api.GetStats(2);

            var CancelledV = await api.GetStats(1);

            if (SaleValuesIn == 0)
            {
                PendingSales.Text   = PendingV + " " + Currency;;
                CompleteSales.Text  = CompleteV + " " + Currency;;
                CancelledSales.Text = CancelledV + " " + Currency;;
            }
            else
            {
                PendingSales.Text   = PendingV.ToString("0.0#") + " " + Currency;;
                CompleteSales.Text  = CompleteV.ToString("0.0#") + " " + Currency;;
                CancelledSales.Text = CancelledV.ToString("0.0#") + " " + Currency;;
            }

            var PendingOrdersCount = await api.GetPendingOrdersCount();

            var CartsCount = await api.GetCartsCount();

            var WishlistCount = await api.GetWishlistCount();

            PendingOrders.Text = PendingOrdersCount.ToString();
            Carts.Text         = CartsCount.ToString();
            Wishlists.Text     = WishlistCount.ToString();

            var VisitorsCount = await api.GetOnlineCount();

            var RegisteredCount = await api.GetRegisteredCustomersCount();

            var VendorsCount = await api.GetVendorsCount();

            Visitors.Text   = VisitorsCount.ToString();
            Registered.Text = RegisteredCount.ToString();
            Vendors.Text    = VendorsCount.ToString();

            var NPopWords = settings.GetValueOrDefault <int>(KeywordsInDash, 3);

            var PopularWords = await api.GetPopularKeywords(NPopWords);

            WordsHolder.Children.Clear();
            foreach (KeywordDTO word in PopularWords)
            {
                var Sp        = new StackPanel();
                var WordBlock = new TextBlock();
                WordBlock.Text     = word.Keyword;
                WordBlock.FontSize = 20;
                Sp.Background      = new SolidColorBrush(Colors.Gray);
                WordBlock.Margin   = new System.Windows.Thickness {
                    Left = 5, Right = 5
                };
                Sp.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                Sp.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                Sp.Margin = new System.Windows.Thickness {
                    Left = 5
                };
                Sp.Children.Add(WordBlock);
                WordsHolder.Children.Add(Sp);
            }
            var BestAmount = await api.GetBestsellerByAmount();

            BestsellerAmount.Text = BestAmount.First().Product.Name;
            var BestQuantity = await api.GetBestsellerByQuantity();

            BestsellerQuantity.Text = BestQuantity.First().Product.Name;

            var WeekCustomers = await api.GetCustomerCountByTime(7);

            var TwoWeeksCustomers = await api.GetCustomerCountByTime(14);

            var MonthCustomers = await api.GetCustomerCountByTime(30);

            var YearCustomers = await api.GetCustomerCountByTime(365);

            var registered = new int[4] {
                WeekCustomers, TwoWeeksCustomers, MonthCustomers, YearCustomers
            };

            RegisteredUsersGraph Graph = new RegisteredUsersGraph(registered, true);

            RegisteredPlot.Model = Graph.MyModel;

            ChangeStore = false;
        }
Пример #11
0
        private void toggleSwitch1_Loaded(object sender, RoutedEventArgs e)
        {
            settings.TryGetValue <bool>("gpsflag", out gpsFlag);

            toggleSwitch1.IsChecked = gpsFlag;
        }
        // Loads data when the application is initialized.
        public void LoadData()
        {
            // Try to get any stored count information.
            if (_totalCount == 0)
            {
                if (appSettings.TryGetValue("TotalCount", out _totalCount))
                {
                    // Update the pages loaded text.
                    NotifyPropertyChanged("PagesLoadedText");
                }
            }

            // Make sure we have a local DB to use, we can't place this in the
            // constructor because there might have been a previous DeleteDatabase call.
            if (!localDb.DatabaseExists())
            {
                // Create the database if it doesn't exist.
                localDb.CreateDatabase();
            }

            try
            {
                // Try to get entities from local database.
                var storedTitles = BuildCommonTitlesQuery(localDb.Titles);

                if (storedTitles != null && storedTitles.Count() < _pageSize)
                {
                    // Load the page from the data service.
                    var titlesFromService = new DataServiceCollection <Title>(this._context);

                    titlesFromService.LoadCompleted += this.OnTitlesLoaded;

                    var query = _context.Titles;

                    if (_totalCount == 0)
                    {
                        // If we don't yet have the total count, then request it now.
                        query = query.IncludeTotalCount();
                    }

                    // Load the data from the OData service.
                    titlesFromService.LoadAsync(BuildCommonTitlesQuery(query));
                }
                else
                {
                    // Bind to the data from the local database.
                    this.Titles = new ObservableCollection <Title>(storedTitles);

                    IsDataLoaded = true;

                    if (LoadCompleted != null)
                    {
                        LoadCompleted(this, new SourcesLoadCompletedEventArgs(null));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to load stored titles. " + ex.Message);

                if (LoadCompleted != null)
                {
                    LoadCompleted(this, new SourcesLoadCompletedEventArgs(ex));
                }
            }
        }
Пример #13
0
        private void AddToWishlist_Click(object sender, EventArgs e)
        {
            StackPanel     s        = new StackPanel();
            PhoneTextBox   Quantity = new PhoneTextBox();
            InputScope     scope    = new InputScope();
            InputScopeName number   = new InputScopeName();

            number.NameValue = InputScopeNameValue.Number;
            scope.Names.Add(number);
            Quantity.Hint       = "Quantity";
            Quantity.InputScope = scope;
            s.Children.Add(Quantity);
            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Caption            = "Select Quantity",
                Message            = "Select how many " + Product.Name + " do you want?",
                LeftButtonContent  = "Add To Cart",
                Content            = s,
                RightButtonContent = "Cancel"
            };

            messageBox.Show();
            messageBox.Dismissed += async(s1, e1) =>
            {
                switch (e1.Result)
                {
                case CustomMessageBoxResult.LeftButton:
                    var Current    = "";
                    var allChecked = true;
                    UserSettings.TryGetValue <string>("current_user", out Current);
                    var AttributesArray = new List <string>();
                    for (int i = 0; i < Product.Attributes.Count; i++)
                    {
                        switch (Product.Attributes[i].AttributeControl)
                        {
                        case AttributeControlType.TextBox:
                            var TmpText = (PhoneTextBox)Controls[i];
                            if (TmpText.Text.Equals("") && Product.Attributes[i].isRequired)
                            {
                                MessageBox.Show("You must fill " + Product.Attributes[i].Name);
                                allChecked = false;
                            }
                            AttributesArray.Add(TmpText.Text);
                            break;

                        case AttributeControlType.DropdownList:
                            var TmpDrop = (ListPicker)Controls[i];
                            if (TmpDrop.SelectedItem == null && Product.Attributes[i].isRequired)
                            {
                                MessageBox.Show("You must select " + Product.Attributes[i].Name);
                                allChecked = false;
                            }
                            AttributesArray.Add(TmpDrop.SelectedItem.ToString());
                            break;

                        case AttributeControlType.MultilineTextbox:
                            var TmpTextM = (PhoneTextBox)Controls[i];
                            if (TmpTextM.Text.Equals("") && Product.Attributes[i].isRequired)
                            {
                                MessageBox.Show("You must fill " + Product.Attributes[i].Name);
                                allChecked = false;
                            }
                            AttributesArray.Add(TmpTextM.Text);
                            break;

                        case AttributeControlType.RadioList:
                            var TmpRadio = (List <RadioButton>)Controls[i];
                            var Count    = 0;
                            foreach (RadioButton r in TmpRadio)
                            {
                                if ((bool)r.IsChecked)
                                {
                                    AttributesArray.Add(r.Content.ToString());
                                    Count++;
                                }
                            }
                            if (Count == 0 && Product.Attributes[i].isRequired)
                            {
                                MessageBox.Show("You must select " + Product.Attributes[i].Name);
                                allChecked = false;
                            }
                            break;

                        case AttributeControlType.Checkboxes:
                            var TmpCheck   = (List <CheckBox>)Controls[i];
                            var CountCheck = 0;
                            foreach (CheckBox r in TmpCheck)
                            {
                                if ((bool)r.IsChecked)
                                {
                                    AttributesArray.Add(r.Content.ToString());
                                    CountCheck++;
                                }
                            }
                            if (CountCheck == 0 && Product.Attributes[i].isRequired)
                            {
                                MessageBox.Show("You must select " + Product.Attributes[i].Name);
                                allChecked = false;
                            }
                            break;
                        }
                    }
                    if (allChecked)
                    {
                        if (Quantity.Text == "")
                        {
                            Quantity.Text = "1";
                        }
                        var AddResult = await api.AddToCart(Current, Product.Id, Int32.Parse(Quantity.Text), AttributesArray.ToArray(), ShoppingCartType.Wishlist);

                        if (AddResult)
                        {
                            RefreshCart = true;
                            CustomMessageBox SuccessToast = new CustomMessageBox()
                            {
                                Caption           = "Added Successfully",
                                Message           = "The product was added to your wishlist sucessfuly",
                                LeftButtonContent = "Dismiss"
                            };
                            SuccessToast.Show();
                            await Task.Delay(2500);

                            SuccessToast.Dismiss();
                        }
                    }
                    break;
                }
            };
        }
Пример #14
0
 private bool DoTryGetValue(string key, out object value)
 {
     return(_applicationSettings.TryGetValue <object>(key, out value));
 }
Пример #15
0
        private void InitializeAllComponents()
        {
            //DateTime now = DateTime.Now;
            MesTitulo.Text = Utils.formatarNomeMes(dateControlFlick);
            if (dateControlFlick.Month == DateTime.Now.Month &&
                dateControlFlick.Year == DateTime.Now.Year)
            {
                DiaTitulo.Text = "Dia: " + dateControlFlick.Day.ToString();
            }

            InitializeTextBoxFocus(InputMin, "", "00");
            InitializeTextBoxFocus(InputHora, "", "00");
            InitializeTextBoxFocus(InputRevisitas, "", "0");
            InitializeTextBoxFocus(InputRevistas, "", "0");
            InitializeTextBoxFocus(InputLivros, "", "0");
            InitializeTextBoxFocus(InputBrochuras, "", "0");
            InitializeTextBoxFocus(InputFolhetos, "", "0");
            InitializeMetasGrid(MetasGrid);

            Relatorio relatorio = relatorioRepository.GetRelatorioTotalMes(dateControlFlick);

            SomaLivros.Text    = Convert.ToString(relatorio.Livros);
            SomaRevisitas.Text = Convert.ToString(relatorio.Revisitas);
            SomaRevistas.Text  = Convert.ToString(relatorio.Revistas);
            SomaBrochuras.Text = Convert.ToString(relatorio.Brochuras);
            SomaFolhetos.Text  = Convert.ToString(relatorio.Folhetos);
            SomaHoras.Text     = relatorio.GetFormatedTime();

            Estudo estudosMes = estudoRepository.GetByDate(dateControlFlick);

            if (estudosMes != null)
            {
                SomaEstudos.Text = Convert.ToString(estudosMes.Qtd);
            }
            else
            {
                SomaEstudos.Text = "0";
            }


            IsolatedStorageSettings iso = IsolatedStorageSettings.ApplicationSettings;
            String alvo;

            if (iso.TryGetValue <string>("config.alvo", out alvo))
            {
                if (alvo.Equals("") || alvo.Contains(","))
                {
                    alvo = "00";
                }

                MetaTextBlock.Text = alvo + ":00" + " h";
            }

            CaulculeMeta(relatorio);

            if (Utils.GetIsoSettingsAsString(HORA_INI_TRABALHO_KEY) == "" || Utils.GetIsoSettingsAsString(HORA_INI_TRABALHO_KEY) == null)
            {
                ContadorTrabalho.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.ApplicationBar         = ((ApplicationBar)this.Resources["IniciadoContAppBar"]);
                ContadorTrabalho.Text       = "Trabalho Iniciado as: " + Utils.GetIsoSettingsAsString(HORA_INI_TRABALHO_KEY);
                ContadorTrabalho.Visibility = Visibility.Visible;
            }
        }
Пример #16
0
        private void haeVarastot()
        {
            if (varasto.TryGetValue <List <Lohko> >("lohkolista", out lohkolista))
            {
                DateTime last;
                if (varasto.TryGetValue <DateTime>("viimeksi_tallennettu", out last))
                {
                    DateTime now = DateTime.Now;
                    if (last.Date != now.Date)
                    {
                        LohkoHaku.nouda();
                    }
                }
            }
            else
            {
                bool tmp;
                if (varasto.TryGetValue <bool>("first_start", out tmp))
                {
                    LohkoHaku.nouda();
                }
                else
                {
                    LohkoHaku.noudaFirst();
                    varasto.Add("first_start", true);
                }
            }

            if (!varasto.TryGetValue <bool>("varina", out varina))
            {
                varina = true;
            }


            if (!varasto.TryGetValue <string>("lohko", out Lohko_))
            {
                Lohko_ = "B-nuorten SM-sarja";
            }

            if (!varasto.TryGetValue <string>("GameId", out GameId_))
            {
                GameId_ = "4456";
            }

            if (!varasto.TryGetValue <bool>("otteluPaattynyt", out otteluPaattynyt))
            {
                otteluPaattynyt = true;
            }

            /*
             * if (!varasto.TryGetValue<string>("viimeisinMaali", out viimeisin_maali))
             *  viimeisin_maali = null;
             */
            if (!varasto.TryGetValue <bool>("naytaKaikki", out naytaKaikki))
            {
                naytaKaikki = true;
            }

            if (!varasto.TryGetValue <bool>("alarmNoice", out alarmNoice))
            {
                alarmNoice = false;
            }

            IdleDetection(App.lockScreen);
        }
        public static TValue TryGetOrDefault <TValue>(this IsolatedStorageSettings settings, string key, TValue defaultValue = default(TValue))
        {
            TValue value;

            return(settings.TryGetValue(key, out value) ? value : defaultValue);
        }
Пример #18
0
        protected override void OnInvoke(ScheduledTask task)
        {
            // NOTE: determine if this needs to run.
            // maybe save the "number of days" in isostorage and check it to see if it has changed?

            IsolatedStorageSettings settings     = IsolatedStorageSettings.ApplicationSettings;
            DateTime dtDaysSinceDate             = DateTime.Now;
            bool     bWasSaveSelectedDateChecked = false;

            // only load a 'selected' date if gbSaveDate == true
            if (!settings.TryGetValue <bool>("saveSelectedDateIsChecked", out bWasSaveSelectedDateChecked))
            {
                NotifyComplete();
                return;
            }

            if (!settings.TryGetValue <DateTime>("selectdate", out dtDaysSinceDate))
            {
                NotifyComplete();
                return;
            }

            // We'll be using UIElements and WriteableBitmaps to build an image so we have to call BeginInvoke
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                // If the agent crashes twice WP7 will shut us down so let make sure if there's an error we catch it
                try
                {
                    ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
                    if (tile != null)
                    {
                        FormatResultsClass frc = new FormatResultsClass();

                        FlipTileData flipTile = new FlipTileData();
                        flipTile.Title        = LiveTileScheduledTaskAgentResources.AppTitle;
                        flipTile.BackTitle    = LiveTileScheduledTaskAgentResources.AppTitle;

                        flipTile.BackContent     = " ";
                        flipTile.WideBackContent = " ";

                        String strBackContent = "";
                        frc.FormatLiveTileText(dtDaysSinceDate, DateTime.Now, out strBackContent);

                        //Medium size Tile 336x336 px
                        //Create image for BackBackgroundImage in IsoStore
                        frc.RenderText(strBackContent, c_n336, c_n336, 28, "BackBackgroundImage");

                        flipTile.BackBackgroundImage = new Uri(@"isostore:/Shared/ShellContent/BackBackgroundImage.jpg", UriKind.Absolute); //Generated image for Back Background 336x336
                        flipTile.BackgroundImage     = new Uri("/Content/MediumBlankTileImage336x336.png", UriKind.Relative);               //Default image for Background Image Medium Tile 336x336 px
                        //End Medium size Tile 336x336 px

                        //Wide size Tile 691x336 px
                        //flipTile.WideBackgroundImage = new Uri("/Content/WideBlankTileIcon691x336.png", UriKind.Relative); // Default image for Background Image Wide Tile 691x336 px
                        flipTile.WideBackgroundImage = new Uri("/Content/WideBackBackgroundTileIcon691x336WithGlow.png", UriKind.Relative); // Default image for Background Image Wide Tile 691x336 px

                        //Crete image for WideBackBackgroundImage in IsoStore
                        frc.RenderText(strBackContent, 691, c_n336, 40, "WideBackBackgroundImage");
                        flipTile.WideBackBackgroundImage = new Uri(@"isostore:/Shared/ShellContent/WideBackBackgroundImage.jpg", UriKind.Absolute);

                        //End Wide size Tile 691x336 px

                        //Update Live Tile
                        tile.Update(flipTile);
                    }
                } // try

                // catch
                catch (Exception e)
                {
                    //MessageBox.Show( e.ToString() );
                }
                finally
                {
                    NotifyComplete();
                } // finally
            }); //Deployment.Current.Dispatcher.BeginInvoke(() =>
        }         // OnInvoke(ScheduledTask task)
Пример #19
0
        public void RestoreSettings()
        {
            Object article_is_image, article_size, article_font, crash_report, read_count, like_count, night_mode, touch_enable, quit_confirm, last_read, night_light, skydrive_login;

            if (settings.TryGetValue("article_is_image", out article_is_image) && article_is_image != null)
            {
                this.article_is_image = (Boolean)article_is_image;
            }
            else
            {
                this.article_is_image = true;
            }

            if (settings.TryGetValue("article_size", out article_size) && article_size != null)
            {
                this.article_size = article_size as String;
            }
            else
            {
                this.article_size = "22";
            }

            if (settings.TryGetValue("article_font", out article_font) && article_font != null)
            {
                this.article_font = article_font as String;
            }
            else
            {
                this.article_font = "Microsoft YaHei";
            }

            if (settings.TryGetValue("crash_report_2", out crash_report) && crash_report != null)
            {
                this.crash_report = (Boolean)crash_report;
            }
            else
            {
                this.crash_report = true;
            }

            if (settings.TryGetValue("read_count", out read_count) && read_count != null)
            {
                this.read_count = (UInt32)read_count;
            }
            else
            {
                this.read_count = 0;
            }

            if (settings.TryGetValue("like_count", out like_count) && like_count != null)
            {
                this.like_count = (UInt32)like_count;
            }
            else
            {
                this.like_count = 0;
            }

            if (settings.TryGetValue("night_mode", out night_mode) && night_mode != null)
            {
                this.night_mode = (Boolean)night_mode;
            }
            else
            {
                this.night_mode = false;
            }

            if (settings.TryGetValue("touch_enable", out touch_enable) && touch_enable != null)
            {
                this.touch_enable = (Boolean)touch_enable;
            }
            else
            {
                this.touch_enable = false;
            }

            if (settings.TryGetValue("quit_confirm", out quit_confirm) && quit_confirm != null)
            {
                this.quit_confirm = (Boolean)quit_confirm;
            }
            else
            {
                this.quit_confirm = true;
            }

            if (settings.TryGetValue("last_read", out last_read) && last_read != null)
            {
                this.last_read = (String)last_read;
            }
            else
            {
                this.last_read = "暂无";
            }

            if (settings.TryGetValue("night_light", out night_light) && night_light != null)
            {
                this.night_light = (String)night_light;
            }
            else
            {
                this.night_light = "50";
            }

            if (settings.TryGetValue("skydrive_login", out skydrive_login) && skydrive_login != null)
            {
                this.skydrive_login = (Boolean)skydrive_login;
            }
            else
            {
                this.skydrive_login = false;
            }
        }
Пример #20
0
        public ViewModel()
        {
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            string selectedScale;
            bool   settingExists = settings.TryGetValue("selectedScale", out selectedScale);

            if (!settingExists)
            {
                selectedScale = "standard";
            }

            _scaleName = selectedScale;
            switch (selectedScale)
            {
            case "fibonacci":
                _items = new List <ListItem>(new ListItem[] {
                    new ListItem(10, "0"),
                    new ListItem(11, "1"),
                    new ListItem(12, "2"),
                    new ListItem(13, "3"),
                    new ListItem(14, "5"),
                    new ListItem(15, "8"),
                    new ListItem(16, "13"),
                    new ListItem(17, "21"),
                    new ListItem(18, "34"),
                    new ListItem(19, "55"),
                    new ListItem(20, "89"),
                    new ListItem(21, "144"),
                    new ListItem(22, "?")
                });
                break;

            case "t-shirt":
                _items = new List <ListItem>(new ListItem[] {
                    new ListItem(10, "XS"),
                    new ListItem(11, "S"),
                    new ListItem(12, "M"),
                    new ListItem(13, "L"),
                    new ListItem(14, "XL"),
                    new ListItem(15, "XXL"),
                    new ListItem(16, "∞"),
                    new ListItem(17, "?")
                });
                break;

            case "doubling":
                _items = new List <ListItem>(new ListItem[] {
                    new ListItem(10, "0"),
                    new ListItem(11, "1/2"),
                    new ListItem(12, "1"),
                    new ListItem(13, "2"),
                    new ListItem(14, "4"),
                    new ListItem(15, "8"),
                    new ListItem(16, "16"),
                    new ListItem(17, "32"),
                    new ListItem(18, "64"),
                    new ListItem(19, "?")
                });
                break;

            default:
                _items = new List <ListItem>(new ListItem[] {
                    new ListItem(10, "0"),
                    new ListItem(11, "1/2"),
                    new ListItem(12, "1"),
                    new ListItem(13, "2"),
                    new ListItem(14, "3"),
                    new ListItem(15, "5"),
                    new ListItem(16, "8"),
                    new ListItem(17, "13"),
                    new ListItem(18, "20"),
                    new ListItem(19, "40"),
                    new ListItem(20, "100"),
                    new ListItem(21, "?")
                });
                break;
            }
        }