コード例 #1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            NotifyIcon.Create(this);
            Fetcher.BindWindow(this);

            textBoxAmount.Text = Default.FetchAmount.ToString();
            FetchAmount        = Default.FetchAmount;

            #region FetchSource
            //switch ( Default . FetchSource )
            //{
            //default:
            //case 0:
            //    sourceNewest . IsChecked = true;
            //    break;
            //case 1:
            //    sourceYesterday . IsChecked = true;
            //    break;
            //}
            #endregion

            randomCheckBox.IsChecked      = Default.RandomWallpaper;
            textBoxInterval.Text          = Default.WallpaperSetInterval.TotalMinutes.ToString();
            wallpaperMainSwitch.IsChecked = Default.WallpaperMainSwitch;

            if (!string.IsNullOrWhiteSpace(Default.DownloadPath))
            {
                setPath(Default.DownloadPath);
            }

            filterCheckBox.IsChecked = Default.FilterAspectRatio;
            ratio.Value    = Default.AspectRatioLimit;
            ratioText.Text = Default.AspectRatioLimit.ToString();

            foreach (TreeViewItem item in categoryTreeView.Items)
            {
                if (item.Tag != null && (string)item.Tag == Default.FetchSource)
                {
                    item.IsSelected = true;
                }
                foreach (TreeViewItem item2 in item.Items)
                {
                    if (item2.Tag != null && (string)item2.Tag == Default.FetchSource)
                    {
                        item2.IsSelected = true;
                    }
                }
            }

            autoRunCheckBox.IsChecked = AutoRun.IsEnabled;

            FetchInterval = TimeSpan.FromHours(6);
            if (!string.IsNullOrWhiteSpace(Default.DownloadPath))
            {
                await Fetcher.Fetch();
            }

            showWindowTimer.Interval = TimeSpan.FromSeconds(1);
            showWindowTimer.Tick    += (s2, e2) =>
            {
                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "Icarus_Show"))
                {
                    Show();
                    Activate();
                    File.Delete(AppDomain.CurrentDomain.BaseDirectory + "Icarus_Show");
                }
            };
            showWindowTimer.Start();
        }
コード例 #2
0
 private static async void FetchTimer_Tick(object sender, EventArgs e)
 {
     //fetchTimer . Stop (); // 为了调试方便,写了不该写的东西,导致 bug。。。留在这以作警示
     await Fetcher.Fetch();
 }
コード例 #3
0
        //private void test_Click ( object sender , RoutedEventArgs e )
        //{
        //    OpenFileDialog ofd = new OpenFileDialog ();
        //    ofd . InitialDirectory = Environment . GetFolderPath ( Environment . SpecialFolder . MyPictures );
        //    if ( ofd . ShowDialog ( this ) == true )
        //    {
        //        wallpaper . SetWallpaper ( null , ofd . FileName );
        //    }
        //}

        private async void buttonManualFetch_Click(object sender, RoutedEventArgs e)
        {
            ResetFetchTimer();
            await Fetcher.Fetch();
        }