Example #1
0
        public bool Archive(Workday wd)
        {
            IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();

            try
            {
                if (!file.DirectoryExists("/history"))
                {
                    file.CreateDirectory("/history");
                }
            }
            catch
            {
                return(false);
            }
            try
            {
                String filename = Workday.StartTime.ToFileTime().ToString();
                IsolatedStorageHelper.ObjToFile(wd, typeof(Workday), "/history/" + filename + ".xml");
            }
            catch
            {
                return(false);
            }
            return(true);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            lastSeance         = new MainViewModel();
            lastSeance.Seances = IsolatedStorageHelper.GetObject <List <Seance> >("allSeances");

            if (lastSeance.Seances == null || lastSeance.Seances.Count == 0)
            {
                txtVitesse.Text  = "No Data";
                txtDuree.Text    = "No Data";
                txtDistance.Text = "No Data";
                txtCalories.Text = "No Data";
                txtDate.Text     = "No Data";
            }
            else
            {
                Seance lastOne = lastSeance.Seances.Last();
                txtCalories.Text = lastOne.Calories + " Kcal";
                txtDistance.Text = lastOne.Distance + " Km";
                txtDuree.Text    = lastOne.Duree + " min";
                txtVitesse.Text  = lastOne.Vitesse + " Km/h";
                txtDate.Text     = lastOne.DateSeance.ToString();
            }
            double bestStep = IsolatedStorageHelper.GetObject <double>("bestSteps");

            txtBestStep.Text = bestStep + "";

            double bestPush = IsolatedStorageHelper.GetObject <double>("bestPush");

            txtBestPush.Text = bestPush + "";
        }
Example #3
0
        public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args)
        {
            ObjFBHelper.ContinueAuthentication(args);
            if (ObjFBHelper.AccessToken != null)
            {
                IsolatedStorageHelper.SaveObject <String>("2", ObjFBHelper.AccessToken);

                fbclient = new Facebook.FacebookClient(ObjFBHelper.AccessToken);
                //Fetch facebook UserProfile:
                dynamic result = await fbclient.GetTaskAsync("me");

                id = result.id;
                string email = result.email;
                FBName = result.name;
                Debug.WriteLine("sssssssss");
                Debug.WriteLine(id);
                Debug.WriteLine(FBName);
                //Format UserProfile:
                GetUserProfilePicture(id);

                BtnLogin.Visibility  = Visibility.Collapsed;
                BtnLogout.Visibility = Visibility.Visible;


                TFname.Text = FBName;

                IsolatedStorageHelper.SaveObject("1", id);
            }
            else
            {
                String message = "No Internet Connection";
                var    dialog  = new MessageDialog(message);
                await dialog.ShowAsync();
            }
        }
Example #4
0
 private void OnAppBarSaveIconClick(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(ChildIdNumber.Text) && !String.IsNullOrWhiteSpace(ChildName.Text) && !String.IsNullOrWhiteSpace(ParentIdNumber.Text))
     {
         if (CurrentItem != null)
         {
             CurrentItem.ChildIdNumber  = ChildIdNumber.Text;
             CurrentItem.Name           = ChildName.Text;
             CurrentItem.ParentIdNumber = ParentIdNumber.Text;
             CurrentItem.ImagePath      = _imageFile;
             IsolatedStorageHelper.Save(CurrentItem);
         }
         else
         {
             var newChild = new Child
             {
                 Guid           = Convert.ToString(Guid.NewGuid()),
                 ChildIdNumber  = ChildIdNumber.Text,
                 Name           = ChildName.Text,
                 ParentIdNumber = ParentIdNumber.Text,
                 ImagePath      = _imageFile
             };
             IsolatedStorageHelper.Save(newChild);
         }
         Helper.NavigateToUrl(Globals.MainUri);
     }
     else
     {
         MessageBox.Show(Globals.ErrorMessageAdd, Globals.ErrorMessageCaptionAdd, MessageBoxButton.OK);
     }
 }
Example #5
0
        private string ReadContainerXml()
        {
            string path = _ePubViewer.Book.GetFilePath(ContainerXmlFile);

            if (path == null)
            {
                path = FileExists(MetaInfDirectory + "/" + ContainerXmlFile);
            }

            string content = IsolatedStorageHelper.ReadZipString(path);

            if (String.IsNullOrEmpty(content))
            {
                throw new EPubReaderException(String.Format(CultureInfo.InvariantCulture, "File \"{0}\" does not contain any content", path));
            }

            XElement xe = XDocument.Parse(content).
                          Elements(ContainerXmlNameSpace + "container").
                          Elements(ContainerXmlNameSpace + "rootfiles").
                          Elements(ContainerXmlNameSpace + "rootfile").
                          First();

            // read type
            string mediaType = xe.Attribute("media-type").Value.Trim();

            if (mediaType != "application/oebps-package+xml")
            {
                throw new EPubReaderException(String.Format(CultureInfo.InvariantCulture, "Container media-type \"{0}\" is not supported", mediaType));
            }

            // read content path
            return(xe.Attribute("full-path").Value.Trim());
        }
Example #6
0
        private void ExecuteLoginCommand()
        {
            Message = null;
            IsBusy  = true;

            Action act = () =>
            {
                if (RememberPassword || AutoLogin)
                {
                    IsolatedStorageHelper.Save(LocalData.Transfer(this));
                }
                else if (!RememberPassword)
                {
                    IsolatedStorageHelper.Delete <LocalData>();
                }

                CommunicateManager.Invoke <ILoginService>(p =>
                {
                    var token           = p.Login(Num, LoginName, LoginPwd);
                    LoginInfo.Token     = token;
                    LoginInfo.Code      = Num.Trim();
                    LoginInfo.Account   = LoginName.Trim();
                    LoginInfo.Guid      = Guid.NewGuid();
                    LoginInfo.IsLogined = true;
                    //登录成功
                    IsLogined = true;
                }, ShowErr);
            };

            Task.Factory.StartNew(act).ContinueWith(task =>
            {
                CommunicateManager.StartPushMessage();
                InvokeSetBusy(false);
            });
        }
Example #7
0
 private static void DeleteGallery(IEnumerable <string> images)
 {
     foreach (var image in images)
     {
         IsolatedStorageHelper.DeleteFile(image);
     }
 }
        private void CheckRemind()
        {
            var helper     = new IsolatedStorageHelper <RemindData>();
            var remindData = helper.ExistsInStorage() ? helper.RetrieveFromStorage() : new RemindData();

            if (!remindData.Reviewed && !remindData.Refused)
            {
                remindData.Starts++;
                if (remindData.Starts % RemindFrequency == 0)
                {
                    var result = MessageBox.Show(Message, Caption, MessageBoxButton.OKCancel);
                    if (result == MessageBoxResult.OK)
                    {
                        Review();
                        remindData.Reviewed = true;
                    }
                    else
                    {
                        if (remindData.Starts >= MaxReminders * RemindFrequency)
                        {
                            remindData.Refused = true;
                        }
                    }
                }
                helper.SaveToStorage(remindData);
            }
        }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LoginViewModel"/> class.
        /// </summary>
        public LoginViewModel()
        {
            //检查是否记住密码
            LocalData cacheData = null;

            try
            {
                cacheData = IsolatedStorageHelper.Get <LocalData>();
            }
            catch (Exception ex)
            {
                Logger.WriteLog(LogType.WARN, "读取本地配置错误", ex);
            }

            if (cacheData == null)
            {
                return;
            }
            Num              = cacheData.Num;
            LoginName        = cacheData.LoginName;
            LoginPwd         = cacheData.LoginPwd;
            AutoLogin        = cacheData.AutoLogin;
            RememberPassword = cacheData.RememberPassword;

            if (AutoLogin)
            {
                ExecuteLoginCommand();
            }
        }
Example #10
0
        private async void timing()
        {
            do
            {
                await Task.Delay(TimeSpan.FromSeconds(1));

                time--;
                TFtimer.DataContext = time;
            } while (time > 0);
            if (time <= 0)
            {
                testVibrationDevice.Vibrate(TimeSpan.FromSeconds(3));


                IMlife1.DataContext = dead; IMlife2.DataContext = dead; IMlife3.DataContext = dead;
                IMlife1.Visibility  = Visibility.Collapsed;
                IMlife2.Visibility  = Visibility.Collapsed;
                IMlife3.Visibility  = Visibility.Collapsed;
                RP1.Visibility      = Visibility.Collapsed;
                RP2.Visibility      = Visibility.Collapsed;
                RP3.Visibility      = Visibility.Collapsed;
                RP4.Visibility      = Visibility.Collapsed;
                //TFquestion.Visibility = Visibility.Collapsed;

                BTContinue.Visibility = Visibility.Visible;
                score = 2548 + RPVrais * 250 - RPFaux * 600;
                IsolatedStorageHelper.SaveObject(SharedInformation.sharedType, score);
                TFquestion.Text = "Game Over";
                TFaccuse.Text   = "Score = " + score;
            }
        }
Example #11
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     IsolatedStorageHelper.LoadFromUserStoreForDomain(this.Properties, _configFilename);
     Perspective.ResourceAssembly.Register();
     Perspective.View.MainWindow mw = new Perspective.View.MainWindow();
     mw.Show();
 }
Example #12
0
        public MainPageViewModel(INavigationService navigationService)
        {
            Tags               = new ObservableCollection <TagViewModel>();
            Accounts           = new ObservableCollection <AccountViewModel>();
            _navigationService = navigationService;

            var selectedDatastore = IsolatedStorageHelper.GetApplicationSetting("dataStore") as IDatastore;

            if (selectedDatastore == null)
            {
                var app = Application.Current as App;
                if (app != null)
                {
                    _dataStore = app.Datastores.GetSelectedDatastore();
                }
                else
                {
                    var init = new Init();
                    _dataStore = init.GetDatastores().GetSelectedDatastore();
                }
                var fakeData = new FakeDataGenerator();
                fakeData.GenerateFakeData(_dataStore);
            }
            else
            {
                _dataStore = selectedDatastore;
            }

            _accounts = new Accounts(_dataStore);

            UpdateUi();

            // _dataStore.OnSaved += RepositoryChanged;
        }
        public PushUpsPage()
        {
            this.InitializeComponent();

            bestPush = IsolatedStorageHelper.GetObject <double>("bestPush");
            Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
        }
        private void Stop_Button_Click(object sender, RoutedEventArgs e)
        {
            myTimer.Stop();


            if (txtSpeed.Text == "Wait")
            {
                speed = 0;
            }
            distance = (double)((int)(distance * 100)) / 100;
            speed    = (double)((int)(speed * 100)) / 100;

            Seance s = new Seance(DateTime.Now, speed, calories, distance, currentTimeMin);

            //All Seances
            if (IsolatedStorageHelper.GetObject <List <Seance> >("allSeances") == null)
            {
                listSeance.Seances.Add(s);
                IsolatedStorageHelper.SaveObject <List <Seance> >("allSeances", listSeance.Seances);
            }
            else
            {
                listSeance.Seances = IsolatedStorageHelper.GetObject <List <Seance> >("allSeances");
                listSeance.Seances.Add(s);
                IsolatedStorageHelper.SaveObject <List <Seance> >("allSeances", listSeance.Seances);
            }
            ///////////////////////////////////////////////////////////////////////////////////////////

            start = false;
            btnShare.Visibility = Visibility.Visible;
            btnStop.Visibility  = Visibility.Collapsed;

            //Frame.Navigate(typeof(MainPage));
        }
Example #15
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            IsolatedStorageHelper.LoadFromUserStoreForDomain(this.Properties, _filename);

            MainWindow mw = new MainWindow();

            mw.Show();
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (IsolatedStorageHelper.GetObject <List <Calendrier> >("Dates") != null)
     {
         s = IsolatedStorageHelper.GetObject <List <Calendrier> >("Dates");
     }
     lst.ItemsSource = s;
 }
Example #17
0
 public static void savePreferencesData()
 {
     IsolatedStorageHelper.SaveObject("PrefWorkHour", Paramaters.PrefWorkHour);
     IsolatedStorageHelper.SaveObject("PrefWorkMin", Paramaters.PrefWorkMin);
     IsolatedStorageHelper.SaveObject("PrefSnoozeHours", Paramaters.PrefSnoozeHours);
     IsolatedStorageHelper.SaveObject("PrefSnoozeMinutes", Paramaters.PrefSnoozeMinutes);
     IsolatedStorageHelper.SaveObject("initialized", Paramaters.initialized);
 }
Example #18
0
 private void button2_Copy1_Click(object sender, RoutedEventArgs e)
 {
     button2_Copy1.DataContext = 1;
     button2.DataContext       = 0.7;
     button2_Copy.DataContext  = 0.7;
     button2_Copy2.DataContext = 0.7;
     IsolatedStorageHelper.SaveObject("image", "4");
 }
Example #19
0
 public static void loadSessions()
 {
     try
     {
         myWorkSessions = IsolatedStorageHelper.GetObject <List <WorkSession> >("WorkSessions");
     }
     catch (Exception) { }
 }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            DataTransferManager.GetForCurrentView().DataRequested += OnShareDataRequested;
            accelerometer.ReadingChanged += accelerometer_ReadingChanged;
            bestSteps = IsolatedStorageHelper.GetObject <double>("bestSteps");

            MessageDialog msg = new MessageDialog("Put your phone in your pocket and walk to count your steps", "Instruction");
            await msg.ShowAsync();
        }
Example #21
0
 private void LoadChartContents()
 {
     listSeance = IsolatedStorageHelper.GetObject <List <Seance> >("allSeances");
     //(PieChart.Series[0] as PieSeries).ItemsSource = financialStuffList;
     //(ColumnChart.Series[0] as ColumnSeries).ItemsSource = financialStuffList;
     (LineChart.Series[0] as LineSeries).ItemsSource = listSeance;
     //(BarChart.Series[0] as BarSeries).ItemsSource = financialStuffList;
     //(BubbleChart.Series[0] as BubbleSeries).ItemsSource = financialStuffList;
 }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                string connectionProfileInfo = string.Empty;
                try
                {
                    ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
                    if (InternetConnectionProfile == null)
                    {
                        MessageDialog msg = new MessageDialog("Your phone seems to be disconnected", "Unavailable internet");
                        msg.Commands.Add(new UICommand("Wi-Fi Settings", new UICommandInvokedHandler(CommandHandlers)));
                        msg.Commands.Add(new UICommand("Cancel", new UICommandInvokedHandler(CommandHandlers)));
                    }
                }
                catch
                {
                }

                poids = IsolatedStorageHelper.GetObject <double>("poids");
                if (poids == 0)
                {
                    MessageDialog msg1 = new MessageDialog("Please check your info first!", "Ckeck Info");
                    msg1.Commands.Add(new UICommand("My infos", new UICommandInvokedHandler(CommandHandlers)));
                    await msg1.ShowAsync();
                }

                geolocator = new Geolocator();
                geolocator.DesiredAccuracy         = PositionAccuracy.High;
                geolocator.DesiredAccuracyInMeters = 1;
                geolocator.MovementThreshold       = 1; // The units are meters
                geolocator.PositionChanged        += geolocator_PositionChanged;



                // txttest.Text = MyMap.Center.Position.Longitude + "\n" + MyMap.Center.Position.Longitude;
                // txttest.Text = args.Position.Coordinate.Point.Position.Latitude + "\n" + args.Position.Coordinate.Point.Position.Longitude;

                //ENABLE THE LOCATION COMPATIBILITY
                position = await geolocator.GetGeopositionAsync();

                await MyMap.TrySetViewAsync(position.Coordinate.Point, 18D);

                MySlider.Value = MyMap.ZoomLevel;
                DataTransferManager.GetForCurrentView().DataRequested += OnShareDataRequested;
            }
            catch
            {
                popup = true;
            }
            if (popup)
            {
                MessageDialog msg = new MessageDialog("Your GPS seems to be desactivated, please activate it", "Error");
                await msg.ShowAsync();
            }
        }
Example #23
0
        private void PromptForMarketplaceReview()
        {
            string currentVersion = IsolatedStorageHelper.GetObject <string>("CurrentVersion");

            if (currentVersion == null)
            {
                currentVersion = App.VersionNumber;
            }

            DateTime installDate = IsolatedStorageHelper.GetObject <DateTime>("InstallDate");

            if (installDate == DateTime.MinValue)
            {
                installDate = DateTime.UtcNow;
            }

            if (currentVersion != App.VersionNumber) // override if this is a new version
            {
                installDate = DateTime.UtcNow;
            }

            if (DateTime.UtcNow.AddDays(-3) >= installDate) // prompt after 3 days
            {
                CustomMessageBox messageBox = new CustomMessageBox()
                {
                    Caption            = "Review Bootstrap",
                    Message            = "It's been a few days since you downloaded Bootstrap. Would you like to write a review for it in the Windows Phone Store?",
                    LeftButtonContent  = "yes",
                    RightButtonContent = "no",
                    IsFullScreen       = false
                };

                messageBox.Dismissed += (s1, e1) =>
                {
                    switch (e1.Result)
                    {
                    case CustomMessageBoxResult.LeftButton:
                        MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
                        marketplaceReviewTask.Show();

                        installDate = DateTime.MaxValue;     // they have rated, don't prompt again

                        break;

                    default:
                        installDate = DateTime.UtcNow;     // they did not rate, prompt again in 2 days
                        break;
                    }
                };

                messageBox.Show();
            }

            IsolatedStorageHelper.SaveObject <string>("CurrentVersion", App.VersionNumber); // save current version of application
            IsolatedStorageHelper.SaveObject <DateTime>("InstallDate", installDate);        // save install date
        }
Example #24
0
        private List <Workday> GetSelectedWorkdays()
        {
            List <Workday> workdays = new List <Workday>();

            foreach (ArchiveFile item in WorkdayList.SelectedItems)
            {
                workdays.Add((Workday)IsolatedStorageHelper.FileToObj(typeof(Workday), "/history/" + item.Filename));
            }
            return(workdays);
        }
Example #25
0
        public static void loadPreferencesData()
        {
            PrefWorkMin  = IsolatedStorageHelper.GetObject <int>("PrefWorkMin");
            PrefWorkHour = IsolatedStorageHelper.GetObject <int>("PrefWorkHour");

            PrefSnoozeMinutes = IsolatedStorageHelper.GetObject <int>("PrefSnoozeMinutes");
            PrefSnoozeHours   = IsolatedStorageHelper.GetObject <int>("PrefSnoozeHours");

            initialized = true;
        }
Example #26
0
        private void BtConnectDisconnect_Click(object sender, RoutedEventArgs e)
        {
            Room p = new Room()
            {
                channel = this.channel.Text, token = this.token.Text
            };

            IsolatedStorageHelper.SaveObject("100", p);
            this.Frame.Navigate(typeof(CameraPage));
        }
Example #27
0
        private async Task <int> AddMaterialData_SplitFile(ThemePack theme, string folder)
        {
            int materialCount = 0;

            //read theme pack materials file (xml)
            string xmlFilePath = Path.Combine(folder, "materials.xml");

            try
            {
                //MaterialGroup newMaterials = await XmlHelper.Deserialize<MaterialGroup>(path); /* the xml file is incomplete sometimes */
                List <Material> newMaterials = await LoadMaterialXML(xmlFilePath);

                materialCount = newMaterials.Count;

                //load my material file
                if (materialDataLoader == null)
                {
                    materialDataLoader = new DataLoader <MaterialGroup>();
                }

                string materialFilePath = Path.Combine(folder, Constants.MATERIAL_DATA_FILE);
                var    materialGroup    = await materialDataLoader.LoadLocalData(materialFilePath);

                if (materialGroup == null)
                {
                    materialGroup = new MaterialGroup();
                }

                //add new materials
                foreach (var m in newMaterials)
                {
                    m.themePackID = theme.id;

                    //image full path
                    string imagePath = Path.Combine(folder, m.image);
                    m.image = imagePath;

                    //thumbnail full path
                    string thumbnailPath = Path.Combine(folder, m.thumbnail);
                    m.thumbnail = thumbnailPath;

                    materialGroup.Materials.Add(m);
                }

                //save data
                string json = JsonSerializer.Serialize(materialGroup);
                await IsolatedStorageHelper.WriteToFileAsync(materialFilePath, json);
            }
            catch (Exception ex)
            {
                somethingWrong = true;
            }

            return(materialCount);
        }
        void ConnectionWebView_Loaded(object sender, RoutedEventArgs e)
        {
            object connectObj = IsolatedStorageHelper.ReadSaveObjectByKey("connecturl");

            if (connectObj == null)
            {
                return;
            }

            this.PhoneWebBrowser_WB.Navigate(new Uri(connectObj.ToString(), UriKind.RelativeOrAbsolute));
        }
 private void SetUICulture(string cultureString)
 {
     if (_loaded)
     {
         var cultureInfo = new CultureInfo(cultureString);
         Thread.CurrentThread.CurrentCulture   = cultureInfo;
         Thread.CurrentThread.CurrentUICulture = cultureInfo;
         _stringProvider.NotifyCultureChanged();
         IsolatedStorageHelper.SaveCultureSetting(cultureString);
     }
 }
Example #30
0
        private async void InitNeuralNetwork()
        {
            _trainingRows = new List <BackPropagationTrainingRow>();
            _network      = new Network(100, 60, 10);
            var weights = await IsolatedStorageHelper.Load <double[]>("weights.xml");

            if (weights != null)
            {
                _network.SetWeights(weights);
            }
        }