Exemplo n.º 1
0
        private async void Update()
        {
            DateChangeable = false;
            Loading        = Visibility.Visible;

            ((App)Application.Current).AppData.Load(displayDate);
            MyDay today = ((App)Application.Current).AppData.AllDays[displayDate];

            Dictionary <string, Software> overView = today.GetOverView();

            DailyTime = await GenerateSumTime(overView);

            OverviewChart = await GenerateChart(today.GetTimeline());

            UpdateTime = LanguageHelper.InquireLocalizedWord("General_LastUpdate") + DateTime.Now.ToString("H:mm");

            Overview.Clear();
            foreach (OverViewItem item in await GenerateList(overView))
            {
                Overview.Add(item);
                MyDeviceHelper.DoEvents();
            }

            DateChangeable = true;
            Loading        = Visibility.Hidden;
        }
Exemplo n.º 2
0
        async void Update()
        {
            busy = true;

            DateTime firstDay = selectedDate.AddDays(-(int)selectedDate.DayOfWeek);

            SeriesCollection tmpChart = await GenerateChart(firstDay);

            List <SummaryListItem> tmpList = await generateList(firstDay);

            OverviewChartLables = generateChartLables(firstDay);
            AverageDailyTime    = generateAverageDailyTime((ChartValues <double>)tmpChart[0].Values);
            SummaryChart        = tmpChart;
            UpdateTime          = LanguageHelper.InquireLocalizedWord("General_LastUpdate") + DateTime.Now.ToString("H:mm");

            SummaryList.Clear();
            foreach (SummaryListItem listItem in tmpList)
            {
                SummaryList.Add(listItem);
                MyDeviceHelper.DoEvents();
            }

            busy = false;
        }
Exemplo n.º 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            //Launage switch
            ResourceDictionary dict = new ResourceDictionary();

            dict.Source = new Uri(@"Resources\Language\" + LanguageHelper.PreferenceLanguage + ".xaml", UriKind.Relative);
            ConfigHelper.Instance.SetLang(LanguageHelper.PreferenceLanguage == "zh-CN" ? "zh-cn" : "en");
            Current.Resources.MergedDictionaries.Add(dict);

            //theme switch
            ResourceDictionary themeDictionary = new ResourceDictionary();
            ResourceDictionary chartDictionary = new ResourceDictionary();

            switch (appData.ThemeSetting)
            {
            case 0:
                themeDictionary.Source = new Uri(@"pack://*****:*****@"Resources\Theme\DefaultTheme.xaml", UriKind.Relative);
                break;

            case 1:
                themeDictionary.Source = new Uri(@"pack://*****:*****@"Resources\Theme\DarkTheme.xaml", UriKind.Relative);
                break;

            default:     //bright default
                themeDictionary.Source = new Uri(@"pack://*****:*****@"Resources\Theme\DefaultTheme.xaml", UriKind.Relative);
                break;
            }
            Current.Resources.MergedDictionaries.Add(themeDictionary);
            Current.Resources.MergedDictionaries.Add(chartDictionary);

            //tray icon
            mutex = new Mutex(true, "FrogyMainProgram");
            string startupArg = e.Args.Count() > 0 ? e.Args[0] : null;

            //if frogy not running
            if (mutex.WaitOne(0, false) || startupArg == "restart")
            {
                //Promote permission if not Administrator
                var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
                if (!principal.IsInRole(WindowsBuiltInRole.Administrator))
                {
                    MyDeviceHelper.PromotePermission();
                }

                taskbarIcon = (TaskbarIcon)FindResource("icon");

                ShowNotification(
                    LanguageHelper.InquireLocalizedWord("TaskBar_AppName"),
                    LanguageHelper.InquireLocalizedWord("TaskBar_StartUp"),
                    BalloonIcon.Info);

                appData.InitializeMyAppData();
                appData.StartLogic();

                base.OnStartup(e);
            }
            else
            {
                MessageBox.Show(
                    LanguageHelper.InquireLocalizedWord("TaskBar_Overlap"),
                    LanguageHelper.InquireLocalizedWord("TaskBar_AppName"),
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);

                Environment.Exit(1);
            }
        }