async private void WindowX_ContentRendered(object sender, EventArgs e)
        {
            notifyicon.Visible        = true;
            notifyicon.BalloonTipText = "Music Downloader UI";
            notifyicon.Icon           = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath);
            notifyicon.MouseClick    += Notifyicon_MouseClick;
            System.Windows.Forms.MenuItem menu1 = new System.Windows.Forms.MenuItem("关闭");
            menu1.Click           += Menu1_Click;
            notifyicon.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[] { menu1 });
            string result = "";

            NoticeManager.Initialize();
            await Task.Run(() =>
            {
                result = music.Update();
            });

            if (result == "Error")
            {
                NotifyError();
            }
            if (result == "Needupdate")
            {
                NotifyUpdate();
            }
        }
Exemple #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var splashScreen = new SplashScreen("Resources/aduskin.png");

            splashScreen.Show(true);
            base.OnStartup(e);
            //初始化通知弹框
            NoticeManager.Initialize();
        }
        private async void WindowX_ContentRendered(object sender, EventArgs e)
        {
            Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MusicDownloader/FirstRun.m");
            if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MusicDownloader/FirstRun.m"))
            {
                if (AduMessageBox.ShowYesNo("建议阅读帮助并启用本地API", "欢迎", "是", "否") == MessageBoxResult.Yes)
                {
                    Process.Start("https://www.nite07.com/music-downloader-ui-%e4%bd%bf%e7%94%a8%e5%b8%ae%e5%8a%a9/");
                }
                if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MusicDownloader/"))
                {
                    Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MusicDownloader/");
                }
                File.Create(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MusicDownloader/FirstRun.m").Close();
            }
            notifyicon.Visible        = true;
            notifyicon.BalloonTipText = "Music Downloader UI";
            notifyicon.Icon           = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath);
            notifyicon.MouseClick    += Notifyicon_MouseClick;
            System.Windows.Forms.MenuItem menu1 = new System.Windows.Forms.MenuItem("关闭");
            menu1.Click           += Menu1_Click;
            notifyicon.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[] { menu1 });
            string result = "";

            NoticeManager.Initialize();
            await Task.Run(() =>
            {
                result = music.Update();
            });

            if (result == "Error")
            {
                NotifyError();
            }
            if (result == "Needupdate")
            {
                NotifyUpdate();
            }
            ApiUpdateInfo = result;
            if (setting.EnableLoacApi)
            {
                EnableLoaclApi();
            }
        }