Ejemplo n.º 1
0
        private void cb_custom_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                sp_sliders.Children.Clear();
            }
            catch
            {
            }

            helper.Save("levels", (sender as ComboBox).SelectedIndex);

            int x     = 0;
            int y     = 0;
            int level = 0;

            if (helper.Read <double[]>("sliderValues") != null)
            {
                do
                {
                    y++;
                    Slider s = new Slider();
                    s.Header    = "Level " + y;
                    s.Maximum   = 100;
                    s.MinHeight = 0;
                    s.Value     = 10;
                    sp_sliders.Children.Add(s);
                    x++;
                }while (x < (sender as ComboBox).SelectedIndex + 3);
            }
            else
            {
                do
                {
                    y++;
                    Slider s = new Slider();
                    s.Header    = "Level " + y;
                    s.Maximum   = 100;
                    s.MinHeight = 0;
                    s.Value     = level;
                    sp_sliders.Children.Add(s);
                    level = level + 15;
                    x++;
                }while (x < (sender as ComboBox).SelectedIndex + 3);
            }
        }
Ejemplo n.º 2
0
        private static void SaveRecentSamples()
        {
            if (_recentSamples == null)
            {
                return;
            }

            var str = string.Join(";", _recentSamples.Take(10).Select(s => s.Name).ToArray());

            _roamingObjectStorageHelper.Save <string>(_recentSamplesStorageKey, str);
        }
Ejemplo n.º 3
0
 public static void StoreRoamingObject(string key, object value)
 {
     try
     {
         _roamingObjectStorage.Save(key, value);
     }
     catch (Exception ex)
     {
         Analytics.TrackEvent(string.Format("{0} {1}", ex.Message, key));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            //IPropertySet roamingProperties = Application.Current.RoamingSettings.Values();
            RoamingObjectStorageHelper roamingProperties = new RoamingObjectStorageHelper();
            //IPropertySet roamingProperties = Windows.Storage.ApplicationData.Current.RoamingSettings.Values;
            Frame rootFrame = Window.Current.Content as Frame;

            Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            var k = roamingProperties.KeyExists("HasBeenHereBefore");

            if (roamingProperties.KeyExists("HasBeenHereBefore"))
            {
                try
                {
                    var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                    authToken = localSettings.Values["authToken"].ToString();
                }
                catch
                {
                    if (e.PrelaunchActivated == false)
                    {
                        if (rootFrame.Content == null)
                        {
                            // When the navigation stack isn't restored navigate to the first page,
                            // configuring the new page by passing required information as a navigation
                            // parameter
                            rootFrame.Navigate(typeof(MainPage), e.Arguments);
                        }
                        // Ensure the current window is active
                        Window.Current.Activate();
                    }
                }

                if (e.PrelaunchActivated == false)
                {
                    if (rootFrame.Content == null)
                    {
                        // When the navigation stack isn't restored navigate to the first page,
                        // configuring the new page by passing required information as a navigation
                        // parameter
                        DataManager.StatusCode res = await DataManager.LoginAsync(authToken);

                        if (res == DataManager.StatusCode.NoInternet)
                        {
                        }
                        if (res == DataManager.StatusCode.Success)
                        {
                            rootFrame.Navigate(typeof(Home), e.Arguments);
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(MainPage), e.Arguments);
                            MessageDialog dialog = new MessageDialog("No Pre-stored data found, please connect to the internet");
                            await dialog.ShowAsync();
                        }
                    }
                    // Ensure the current window is active
                    Window.Current.Activate();
                }
            }
            else
            {
                // The First Time App Starts Case
                //roamingProperties["HasBeenHereBefore"] = bool.TrueString;
                roamingProperties.Save("HasBeenHereBefore", true);
                rootFrame.Navigate(typeof(Welcome), e.Arguments);
                Window.Current.Activate();
            }
        }