public async void EnableLoaclApi()
        {
            if (ApiUpdateInfo == "ApiUpdate" || !Directory.Exists(Api.ApiFilePath1) || !Directory.Exists(Api.ApiFilePath2))
            {
                IPendingHandler pb = PendingBox.Show("初始化信息接口中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
                {
                    MinHeight = 110,
                    MaxHeight = 110,
                    MinWidth  = 280,
                    MaxWidth  = 280
                });

                await Task.Run(() =>
                {
                    Api.ApiStart(music.apiver, music.zipurl);
                    while (!Api.ok)
                    {
                    }
                });

                if (!Api.SetCookie(music.qqcookie))
                {
                    AduMessageBox.Show("初始化错误", "提示");
                    Api.StopApi();
                    Environment.Exit(0);
                }
                pb.Close();
            }
            else
            {
                IPendingHandler pb = PendingBox.Show("启动服务中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
                {
                    MinHeight = 110,
                    MaxHeight = 110,
                    MinWidth  = 280,
                    MaxWidth  = 280
                });
                await Task.Run(() =>
                {
                    Api.ApiStart(music.apiver, music.zipurl);
                    while (!Api.ok)
                    {
                    }
                });

                if (!Api.SetCookie(music.qqcookie))
                {
                    AduMessageBox.Show("服务启动错误", "提示");
                    Api.StopApi();
                    Environment.Exit(0);
                }
                pb.Close();
            }
            music.NeteaseApiUrl = "http://127.0.0.1:" + Api.port1 + "/";
            music.QQApiUrl      = "http://127.0.0.1:" + Api.port2 + "/";
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 等待窗
 /// handler.UpdateMessage("新的提示信息");更新提示信息
 /// handler.Close()关闭窗口
 /// </summary>
 /// <param name="message"></param>
 public static IPendingHandler MessageBoxShowWaiting(string message)
 {
     return(PendingBox.Show(message, "等待", false, Application.Current.MainWindow, new PendingBoxConfigurations()
     {
         LoadingForeground = "#20A0FF".ToColor().ToBrush(),
         ButtonBrush = "#20A0FF".ToColor().ToBrush(),
         PendingBoxStyle = PendingBoxStyle.Classic,
         LoadingSize = 50,
     }));
 }
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="key"></param>
        private async void Search(string key)
        {
            var pb = PendingBox.Show("搜索中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
            {
                MaxHeight = 160,
                MinWidth  = 400
            });

            try
            {
                SearchListItem.Clear();
                musicinfo?.Clear();
                int api = apiComboBox.SelectedIndex + 1;
                await Task.Run(() =>
                {
                    musicinfo = music.Search(key, api);
                });

                //musicinfo = music.Search(key, apiComboBox.SelectedIndex + 1);
                if (musicinfo == null)
                {
                    pb.Close();
                    MessageBoxX.Show("搜索错误", "警告", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations()
                    {
                        MessageBoxIcon = MessageBoxIcon.Error
                    });
                    return;
                }
                foreach (MusicInfo m in musicinfo)
                {
                    SearchListItemModel mod = new SearchListItemModel()
                    {
                        Album      = m.Album,
                        Singer     = m.Singer,
                        IsSelected = false,
                        Title      = m.Title
                    };
                    SearchListItem.Add(mod);
                }
                List.ItemsSource = SearchListItem;
                List.Items.Refresh();
                List.ScrollIntoView(List?.Items[0]);
                pb.Close();
            }
            catch
            {
                pb.Close();
                MessageBoxX.Show("搜索错误", "警告", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations()
                {
                    MessageBoxIcon = MessageBoxIcon.Error
                });
            }
        }
Ejemplo n.º 4
0
        private void Analyse(object parameter)
        {
            if (backgroundWorker.IsBusy)
            {
                return;
            }
            plate      = Plate;//后台线程访问会有问题,赋值个临时字段解决
            deviceName = DeviceName;
            backgroundWorker.RunWorkerAsync();
            PendingBoxConfigurations configurations = new PendingBoxConfigurations();

            configurations.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            pendingHandler = PendingBox.Show(string.Format("正在分析日志文件...({0}%)", 0), "请等待", false, Application.Current.MainWindow, configurations);
        }
Ejemplo n.º 5
0
        private async void BtnStandard_Click(object sender, RoutedEventArgs e)
        {
            var handler = PendingBox.Show("Please wait (1/2)...", "Processing", false, Application.Current.MainWindow, new PendingBoxConfigurations()
            {
                LoadingForeground = "#5DBBEC".ToColor().ToBrush(),
                ButtonBrush       = "#5DBBEC".ToColor().ToBrush(),
            });
            await Task.Delay(2000);

            handler.UpdateMessage("Almost complete (2/2)...");
            await Task.Delay(2000);

            handler.Close();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 解析专辑
        /// </summary>
        /// <param name="id"></param>
        private async void GetAblum(string id)
        {
            var pb = PendingBox.Show("解析中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
            {
                MinHeight = 110,
                MaxHeight = 110,
                MinWidth  = 280,
                MaxWidth  = 280
            });

            try
            {
                SearchListItem.Clear();
                musicinfo?.Clear();
                int api = apiComboBox.SelectedIndex + 1;
                await Task.Run(() =>
                {
                    musicinfo = music.GetAlbum(id, api);
                });

                if (musicinfo == null)
                {
                    pb.Close();
                    AduMessageBox.Show("解析错误", "提示");
                    return;
                }
                foreach (MusicInfo m in musicinfo)
                {
                    SearchListItemModel mod = new SearchListItemModel()
                    {
                        Album      = m.Album,
                        Singer     = m.Singer,
                        IsSelected = false,
                        Title      = m.Title
                    };
                    SearchListItem.Add(mod);
                }
                List.ItemsSource = SearchListItem;
                List.Items.Refresh();
                List.ScrollIntoView(List?.Items[0]);
                pb.Close();
                UpdateUI_LoadingState("获得专辑" + SearchListItem.Count + "首");
            }
            catch
            {
                pb.Close();
                AduMessageBox.Show("专辑解析错误", "提示");
            }
        }
Ejemplo n.º 7
0
        private void AnalyseXmpp(object parameter)
        {
            if (backgroundWorkerXmpp.IsBusy)
            {
                return;
            }
            this.XmppResult = "";
            filterText      = FilterText;

            backgroundWorkerXmpp.RunWorkerAsync();
            PendingBoxConfigurations configurations = new PendingBoxConfigurations();

            configurations.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            pendingHandler = PendingBox.Show(string.Format("正在分析日志文件...({0}%)", 0), "请等待", false, Application.Current.MainWindow, configurations);
        }
Ejemplo n.º 8
0
        public static IPendingHandler ShowLoadingWindow(this ViewModelBase vm)
        {
            var handler = PendingBox.Show("请等待...", "等待窗", false, Application.Current.MainWindow, new PendingBoxConfigurations()
            {
                LoadingForeground     = "#5DBBEC".ToColor().ToBrush(),
                ButtonBrush           = "#5DBBEC".ToColor().ToBrush(),
                LoadingSize           = 50,
                PendingBoxStyle       = PendingBoxStyle.Classic,
                FontSize              = 14,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                InteractOwnerMask     = true
            });

            return(handler);
        }
        private async void DownloadNodejsButton_Click(object sender, RoutedEventArgs e)
        {
            IPendingHandler pb = PendingBox.Show("下载中......", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
            {
                MinHeight = 110,
                MaxHeight = 110,
                MinWidth  = 280,
                MaxWidth  = 280
            });
            await Task.Run(new Action(() =>
            {
                Api.DownloadNodejs();
                while (!Api.NodejsDownloadSuc)
                {
                }
            }));

            pb.Close();
        }
Ejemplo n.º 10
0
        private async void BtnClassicCancelable_Click(object sender, RoutedEventArgs e)
        {
            var handler = PendingBox.Show("Please wait (1/2)...", "Processing", true, Application.Current.MainWindow, new PendingBoxConfigurations()
            {
                LoadingForeground = "#5DBBEC".ToColor().ToBrush(),
                ButtonBrush       = "#5DBBEC".ToColor().ToBrush(),
                LoadingSize       = 50,
                PendingBoxStyle   = PendingBoxStyle.Classic,
                FontSize          = 14,
            });

            handler.Cancel += delegate
            {
                handler.Close();
            };

            await Task.Delay(2000);

            handler.UpdateMessage("Almost complete (2/2)...");
            await Task.Delay(2000);

            handler.Close();
        }
        private async void Download(bool ifonlydownloadlrc = false, bool ifonlydownloadpic = false)
        {
            List <DownloadList> dl = new List <DownloadList>();

            for (int i = 0; i < SearchListItem.Count; i++)
            {
                if (SearchListItem[i].IsSelected)
                {
                    if (ifonlydownloadlrc)
                    {
                        dl.Add(new DownloadList
                        {
                            Id              = musicinfo[i].Id.ToString(),
                            IfDownloadLrc   = true,
                            IfDownloadMusic = false,
                            IfDownloadPic   = false,
                            Album           = musicinfo[i].Album,
                            LrcUrl          = musicinfo[i].LrcUrl,
                            PicUrl          = musicinfo[i].PicUrl,
                            Quality         = setting.DownloadQuality,
                            Singer          = musicinfo[i].Singer,
                            Title           = musicinfo[i].Title,
                            Api             = musicinfo[i].Api,
                            strMediaMid     = musicinfo[i].strMediaMid
                        });
                    }
                    else if (ifonlydownloadpic)
                    {
                        dl.Add(new DownloadList
                        {
                            Id              = musicinfo[i].Id,
                            IfDownloadLrc   = false,
                            IfDownloadMusic = false,
                            IfDownloadPic   = true,
                            Album           = musicinfo[i].Album,
                            LrcUrl          = musicinfo[i].LrcUrl,
                            PicUrl          = musicinfo[i].PicUrl,
                            Quality         = setting.DownloadQuality,
                            Singer          = musicinfo[i].Singer,
                            Title           = musicinfo[i].Title,
                            Api             = musicinfo[i].Api,
                            strMediaMid     = musicinfo[i].strMediaMid
                        });
                    }
                    else
                    {
                        dl.Add(new DownloadList
                        {
                            Id              = musicinfo[i].Id,
                            IfDownloadLrc   = setting.IfDownloadLrc,
                            IfDownloadMusic = true,
                            IfDownloadPic   = setting.IfDownloadPic,
                            Album           = musicinfo[i].Album,
                            LrcUrl          = musicinfo[i].LrcUrl,
                            PicUrl          = musicinfo[i].PicUrl,
                            Quality         = setting.DownloadQuality,
                            Singer          = musicinfo[i].Singer,
                            Title           = musicinfo[i].Title,
                            Api             = musicinfo[i].Api,
                            strMediaMid     = musicinfo[i].strMediaMid
                        });
                    }
                }
            }
            if (dl.Count != 0)
            {
                int api = apiComboBox.SelectedIndex + 1;
                var pb  = PendingBox.Show("请求处理中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
                {
                    MaxHeight = 160,
                    MinWidth  = 400
                });
                await Task.Run(() =>
                {
                    music.Download(dl, api);
                });

                pb.Close();
            }
        }
        public async void EnableLoaclApi()
        {
            if (ApiUpdateInfo == "ApiUpdate" /*|| !Directory.Exists(Api.ApiFilePath1)*/ || !Directory.Exists(Api.ApiFilePath2))
            {
                IPendingHandler pb = PendingBox.Show("初始化信息接口中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
                {
                    MinHeight = 110,
                    MaxHeight = 110,
                    MinWidth  = 280,
                    MaxWidth  = 280
                });

                await Task.Run(() =>
                {
                    bool r = Api.ApiStart(music.apiver, music.zipurl);
                    if (!r)
                    {
                        Dispatcher.Invoke(new Action(() => { setting.EnableLoacApi = false; pb.Close(); AduMessageBox.Show("服务启动错误", "提示"); }));
                    }
                    while (!Api.ok)
                    {
                    }
                });

                if (!Api.SetCookie(music.qqcookie))
                {
                    AduMessageBox.Show("初始化错误", "提示");
                    Api.StopApi();
                    Environment.Exit(0);
                }
                pb.Close();
            }
            else
            {
                IPendingHandler pb = PendingBox.Show("启动服务中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
                {
                    MinHeight = 110,
                    MaxHeight = 110,
                    MinWidth  = 280,
                    MaxWidth  = 280
                });
                await Task.Run(() =>
                {
                    bool r = Api.ApiStart(music.apiver, music.zipurl);
                    Dispatcher.Invoke(new Action(() =>
                    {
                        if (!r)
                        {
                            AduMessageBox.Show("服务启动错误(调用错误)", "提示");
                        }
                    }));

                    while (!Api.ok)
                    {
                    }
                });

                System.Threading.Thread.Sleep(1000);
                if (!Api.SetCookie(music.qqcookie))
                {
                    AduMessageBox.Show("服务启动错误(Cookie设置错误)", "提示");
                    Api.StopApi();
                    Environment.Exit(0);
                }
                pb.Close();
            }
            //music.NeteaseApiUrl = "http://127.0.0.1:" + Api.port1 + "/";
            music.QQApiUrl = "http://127.0.0.1:" + Api.port2 + "/";
        }
Ejemplo n.º 13
0
 private void BtnTestPendingBox_Click(object sender, RoutedEventArgs e)
 {
     var handler = PendingBox.Show(this, "PendingBox style configuration is placed in App.xaml.", "Caption", true);
     //handler.Cancelling += ...
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="key"></param>
        private async void Search(string key)
        {
            var pb = PendingBox.Show("搜索中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
            {
                MinHeight = 110,
                MaxHeight = 110,
                MinWidth  = 280,
                MaxWidth  = 280
            });

            try
            {
                SearchListItem.Clear();
                musicinfo?.Clear();
                int api = apiComboBox.SelectedIndex + 1;
                await Task.Run(() =>
                {
                    musicinfo = music.Search(key, api);
                });

                //musicinfo = music.Search(key, apiComboBox.SelectedIndex + 1);
                if (musicinfo == null)
                {
                    pb.Close();
                    AduMessageBox.Show("搜索错误", "提示", MessageBoxButton.OK);
                    return;
                }

                if (setting.IfSearchResultFilter)
                {
                    Filter filter = new Filter(setting.SearchResultFilter, key);
                    musicinfo = filter.Filt(musicinfo);
                }

                if (musicinfo.Count < 1)
                {
                    pb.Close();
                    AduMessageBox.Show("搜索结果为0", "提示", MessageBoxButton.OK);
                    return;
                }

                foreach (MusicInfo m in musicinfo)
                {
                    SearchListItemModel mod = new SearchListItemModel()
                    {
                        Album      = m.Album,
                        Singer     = m.Singer,
                        IsSelected = false,
                        Title      = m.Title
                    };
                    SearchListItem.Add(mod);
                }
                List.ItemsSource = SearchListItem;
                List.Items.Refresh();
                List.ScrollIntoView(List?.Items[0]);
                pb.Close();
                UpdateUI_LoadingState("搜索结果" + SearchListItem.Count + "首");
            }
            catch
            {
                pb.Close();
                AduMessageBox.Show("搜索错误", "提示", MessageBoxButton.OK);
            }
        }