Exemple #1
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        async protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.Navigated += OnNavigated;
                SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // 最开始的时候应用会通过这里进入主界面
                    // 如果在这里读入设置文件,就可以起到维护用户个人设置的功能。

                    var checkItem = await ApplicationData.Current.LocalFolder.TryGetItemAsync("dataFile.txt");

                    if (checkItem != null)
                    {
                        StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                        StorageFile   file        = await localFolder.GetFileAsync("dataFile.txt");

                        String format = await FileIO.ReadTextAsync(file);


                        var strAns     = format.Split(' ');
                        var parameters = new SettingParameterPassing();
                        parameters.pomotodoWorkInterval = Int32.Parse(strAns[0]);
                        parameters.pomotodoShortBreak   = Int32.Parse(strAns[1]);
                        parameters.pomotodoLongBreak    = Int32.Parse(strAns[2]);
                        parameters.pomotodoRestInterval = Int32.Parse(strAns[3]);

                        rootFrame.Navigate(typeof(MainPage), parameters);
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(MainPage), e.Arguments);
                    }
                }
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
            }
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     parameter = (SettingParameterPassing)e.Parameter;
     SettingWorkIntervalInput.Text      = parameter.pomotodoWorkInterval.ToString();
     SettingShortBreakInput.Text        = parameter.pomotodoShortBreak.ToString();
     SettingLongBreakInput.Text         = parameter.pomotodoLongBreak.ToString();
     SettingLongBreakIntervalInput.Text = parameter.pomotodoRestInterval.ToString();
 }
Exemple #3
0
        //前往设置页面
        private void AppBarSettingButton_Click(object sender, RoutedEventArgs e)
        {
            var parameters = new SettingParameterPassing();

            parameters.pomotodoLongBreak    = pomotodoLongBreak;
            parameters.pomotodoShortBreak   = pomotodoShortBreak;
            parameters.pomotodoWorkInterval = pomotodoWorkInterval;
            parameters.pomotodoRestInterval = pomotodoRestInterval;

            if (timer != null)
            {
                timeReaper.cacheBeginTime  = beginTime;
                timeReaper.cacheTimerState = timerState;
                timeReaper.cacheNeedPress  = needPress;
                timeReaper.cacheWork       = work;
            }


            Frame.Navigate(typeof(SettingPage), parameters);
        }