Exemple #1
0
 private void ExercisesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (e.AddedItems.Count > 0)
         {
             DBExercise selectedExercise = (e.AddedItems[0] as DBExercise);
             string     heading          = selectedExercise.ExerciseName;
             string     url = Utils.GetExerciseURL(selectedExercise.ExerciseName);
             NavigationService.Navigate(new Uri("/BrowserPage.xaml?heading=" + heading + "&url=" + url, UriKind.Relative));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("<kg12> Exception " + ex.Message);
     }
 }
Exemple #2
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            //Instantiate DB context
            App.WorkoutDB = new WorkoutContext("Data Source = 'appdata:/workout.sdf'; File Mode = read only;");

            //Retrieve settings
            try
            {
                App.IsProgramOn      = (bool)App.UserSettings["IsProgramOn"];
                App.ProgramStartDate = (DateTime)App.UserSettings["ProgramStartDate"];
            }
            catch (KeyNotFoundException ex)
            {
                App.IsProgramOn      = false;
                App.ProgramStartDate = DateTime.Now;
                Console.WriteLine("<kg12> Exception : " + ex.Message);
            }

            //Cache Reference DB
            App.AllDayExercises = (from DayExercise de in App.WorkoutDB.DayExercises
                                   select de).ToList();
            App.AllExercises = (from Exercise e in App.WorkoutDB.Exercises
                                select e).ToList();


            App.AllDBExercises = new ObservableCollection <DBExercise>();

            // Load all DB exercises
            foreach (Exercise exercise in App.AllExercises)
            {
                DBExercise ex = new DBExercise()
                {
                    ExerciseName = exercise.Name,
                    WorkoutImage = "Media/" + Utils.GetImage(exercise, 0)
                };

                App.AllDBExercises.Add(ex);
            }

            App.AllDBExercises = new ObservableCollection <DBExercise>(App.AllDBExercises.OrderBy(e => e.ExerciseName));
        }