Пример #1
0
        private void 查看歌词ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.richTextBox1.Text = "正在查询...";

            if (!Pub_NetWork())
            {
                this.trackBar1.Enabled = false; this.richTextBox1.Text = "网络连接中断,请检查您的网络..."; return;
            }
            else
            {
                this.trackBar1.Enabled = true;
            }
            System.Threading.Thread.Sleep(20);

            int    rowIndex = dataGridView1.SelectedRows[0].Index;
            string ID       = dataGridView1.SelectedRows[0].Cells["ID"].Value + "";
            string SongName = dataGridView1.SelectedRows[0].Cells["SongName"].Value + "";
            string Singer   = dataGridView1.SelectedRows[0].Cells["Singer"].Value + "";

            var u = StAPIHelper.Ex_Kuwo_SearchLyrics(ID);

            this.richTextBox1.Text = string.Join("\r\n", u.Values.Select(i => i.StartTime + "," + i.Text));
            if (string.IsNullOrWhiteSpace(this.richTextBox1.Text))
            {
                this.richTextBox1.Text = "很抱歉,未能找到您要的歌词";
            }
        }
Пример #2
0
 //站点Title查询
 private void button5_Click(object sender, EventArgs e)
 {
     this.label11.ForeColor = Color.Black;
     SetControlValue(this.label11, "正在查询...");
     this.label11.Text = StAPIHelper.Ex_GetWebSiteTitle(this.textBox8.Text).Trim();
     if (label11.Text.IndexOf("div>") == label11.Text.Length - 4)
     {
         this.label11.Text      = "请输入正确的网址或查询失败";
         this.label11.ForeColor = Color.Red;
     }
 }
Пример #3
0
        //同IP域名查询
        private void button6_Click(object sender, EventArgs e)
        {
            this.textBox9.Text = "";
            int    totleCount;
            string msg;

            Dictionary <string, string> sss = StAPIHelper.Ex_GetUrlsByIP(this.textBox10.Text, out totleCount, out msg, 0, -1);

            string rel = string.Join("", sss.Select(i => "\r\n" + i.Key + "\t\t" + i.Value));

            this.textBox9.Text += "序号\t\t网址" + rel;
        }
Пример #4
0
        private void button8_Click(object sender, EventArgs e)
        {
            this.textBox14.Text = "";
            string mStr = this.textBox13.Text;

            decimal mDe = 0;

            if (!decimal.TryParse(mStr, out mDe))
            {
                MessageBox.Show("请输入数字");
                this.textBox13.Focus();
                return;
            }

            string form = this.comboBox3.SelectedValue + "";
            string to   = this.comboBox4.SelectedValue + "";

            if (form.Contains("otherCode"))
            {
                MessageBox.Show("请选择币种(form)");
                return;
            }
            if (to.Contains("otherCode"))
            {
                MessageBox.Show("请选择币种(to)");
                return;
            }
            if (form == to)
            {
                if (this.comboBox3.SelectedIndex == 0)
                {
                    this.comboBox4.SelectedIndex = 1;
                }
                else
                {
                    this.comboBox4.SelectedIndex = 0;
                }
            }

            to = this.comboBox4.SelectedValue + "";
            string  erroMsg;
            decimal?r = StAPIHelper.Ex_GetExchangeRate(form, to, out erroMsg);

            if (r.HasValue)
            {
                this.textBox14.Text = (r * mDe) + "";
            }
            else
            {
                this.textBox14.Text = erroMsg;
            }
        }
Пример #5
0
        private void  载MVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请先选择需要下载的MV");
                return;
            }

            if (!Pub_NetWork())
            {
                this.trackBar1.Enabled = false; return;
            }
            else
            {
                this.trackBar1.Enabled = true;
            }
            if (!Ve())
            {
                return;
            }


            string MV = dataGridView1.SelectedRows[0].Cells["ExistMV"].Value + "";

            if (string.IsNullOrWhiteSpace(MV))
            {
                MessageBox.Show("对不起您要下载的MV不存在");
                return;
            }
            string ID       = dataGridView1.SelectedRows[0].Cells["ID"].Value + "";
            string SongName = dataGridView1.SelectedRows[0].Cells["SongName"].Value + "";
            string Singer   = dataGridView1.SelectedRows[0].Cells["Singer"].Value + "";

            string u = StAPIHelper.Ex_Kuwo_GetMVDownUrl(ID);

            string filepath = StDirectory.CurrentAppDirectory + "\\" + this.textBox22.Text.Replace("/", "\\") + "\\" + Singer + " - " + SongName + u.Substring(u.LastIndexOf('.'));

            if (StFile.Exists(filepath, false, false))
            {
                MessageBox.Show("该MV已经被下载过啦");
                return;
            }

            Down(u, StDirectory.CurrentAppDirectory + "\\" + this.textBox22.Text.Replace("/", "\\"), Singer + " - " + SongName + u.Substring(u.LastIndexOf('.')));
            //MessageBox.Show("下载" + (re ? "成功" : "失败"));
        }
Пример #6
0
        private void 播放MVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.label20.Visible = false;
            if (dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请先选择需要播放的MV");
                return;
            }

            if (!Pub_NetWork())
            {
                this.trackBar1.Enabled = false; return;
            }
            else
            {
                this.trackBar1.Enabled = true;
            }
            //if (!Ve()) return;
            string MV = dataGridView1.SelectedRows[0].Cells["ExistMV"].Value + "";

            if (string.IsNullOrWhiteSpace(MV))
            {
                MessageBox.Show("对不起您要播放的MV不存在");
                return;
            }
            string ID       = dataGridView1.SelectedRows[0].Cells["ID"].Value + "";
            string SongName = dataGridView1.SelectedRows[0].Cells["SongName"].Value + "";
            string Singer   = dataGridView1.SelectedRows[0].Cells["Singer"].Value + "";

            //StAPIHelper.Kuwo_Song song = dataGridView1.SelectedRows[0] as StAPIHelper.Kuwo_Song;

            DateTime start = DateTime.Now;
            string   u     = StAPIHelper.Ex_Kuwo_GetMVDownUrl(ID);

            if (string.IsNullOrEmpty(u))
            {
                MessageBox.Show("资源不存在"); return;
            }
            CheckedMvOrLrc(2, true);
            SetSongName(SongName, Singer);
            axPlayer1.Open(u);
        }
Пример #7
0
        public void BingKuwoMusicList(string query, int type, int pageindex)
        {
            if (!this.button11.Enabled)
            {
                return;
            }

            this.button11.Enabled = false;
            if (string.IsNullOrWhiteSpace(query))
            {
                this.button11.Enabled = true;
                MessageBox.Show("请输入关键字");
                return;
            }
            switch (type)
            {
            case 1:
                this.radioButton1.Checked = true;
                break;

            case 2:
                this.radioButton2.Checked = true;
                break;

            default:
                break;
            }

            this.textBox19.Text     = query;
            kuwolist_totalPageCount = 0;
            kuwolist_Pageindex      = 0;
            Kuwo_Btn_Enabled(false);
            kuwolist_Pageindex = pageindex;
            bool mvShow = false;
            bool isErro = false;

            try
            {
                //不允许自动创建列
                dataGridView1.AutoGenerateColumns = false;

                List <StAPIHelper.Kuwo_Song> rel = null;
                if (this.radioButton1.Checked)
                {
                    kuwolist_current = 20;
                    rel = StAPIHelper.Ex_Kuwo_SearchSongBySinger(this.textBox19.Text, pageindex, kuwolist_current, out kuwolist_totalPageCount);
                }
                else
                {
                    rel = StAPIHelper.Ex_Kuwo_SearchSong(this.textBox19.Text, pageindex, out kuwolist_totalCount, out kuwolist_current, out kuwolist_totalPageCount);
                }
                dataGridView1.DataSource = rel;
                mvShow = rel.Where(i => !string.IsNullOrWhiteSpace(i.ExistMV)).Count() > 0;
            }
            catch (Exception)
            {
                MessageBox.Show("很抱歉 出错啦!"); isErro = true;
            }
            finally
            {
                Kuwo_Btn_Enabled(true);
            }
            this.button12.Enabled = pageindex > 0;
            this.button13.Enabled = pageindex < kuwolist_totalPageCount - 1;
            this.label16.Text     = "第 " + (pageindex + 1) + " 页,共 " + kuwolist_totalPageCount + " 页,每页 " + kuwolist_current + " 条";
            if (!isErro && dataGridView1.SelectedRows.Count < 1)
            {
                MessageBox.Show("很抱歉,没能找到您要的数据");
            }


            dataGridView1.Columns["ExistMV"].Visible = mvShow;
            dataGridView1.Columns["ID"].Width        = 77;
            this.button11.Enabled = true;
        }
Пример #8
0
        private void 播放ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.label20.Visible = false;
            if (dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请先选择需要播放的歌曲");
                return;
            }
            if (!Pub_NetWork())
            {
                this.trackBar1.Enabled = false; return;
            }
            else
            {
                this.trackBar1.Enabled = true;
            }

            //if (!Ve()) return;

            DateTime start    = DateTime.Now;
            int      rowIndex = dataGridView1.SelectedRows[0].Index;
            string   ID       = dataGridView1.SelectedRows[0].Cells["ID"].Value + "";
            string   SongName = dataGridView1.SelectedRows[0].Cells["SongName"].Value + "";
            string   Singer   = dataGridView1.SelectedRows[0].Cells["Singer"].Value + "";

            string u = StAPIHelper.Ex_Kuwo_GetSongDownUrl(ID);

            if (string.IsNullOrEmpty(u))
            {
                MessageBox.Show("资源不存在"); return;
            }
            SetSongName(SongName, Singer);
            axPlayer1.Open(u);
            CheckedMvOrLrc(1, true);



            kuwo_lrcs = StAPIHelper.Ex_Kuwo_SearchLyrics(ID);

            this.richTextBox1.Tag  = "0";
            this.richTextBox1.Text = string.Join("\r\n", kuwo_lrcs.Values.Select(i => i.TimeStr + "," + i.Text));
            if (!string.IsNullOrWhiteSpace(this.richTextBox1.Text))
            {
                this.richTextBox1.Text += "\r\n";
                this.richTextBox1.Tag   = "1";
                kuwo_lrcs_index         = 0;


                lrcPlay_Time = new Timer();
                int tttI = Kuwo_GetWainTime(kuwo_lrcs_index, out temp_i);
                kuwo_lrcs_index += temp_i - 1;

                int i = richTextBox1.GetFirstCharIndexFromLine(kuwo_lrcs_index);
                int j = richTextBox1.GetFirstCharIndexFromLine(kuwo_lrcs_index + temp_i);//注意如果要选取最后一行的时候,这里可能会出错,应当直接把j设置成为最后一个字符的位置+1
                richTextBox1.Select(i, j - i);

                this.richTextBox1.SelectionColor = Color.Red;
                this.richTextBox1.ScrollToCaret();
                lrcPlay_Time.Tick    += new EventHandler(t_Tick);
                lrcPlay_Time.Interval = tttI;
                lrcPlay_Time.Start();
            }

            if (string.IsNullOrWhiteSpace(this.richTextBox1.Text))
            {
                this.richTextBox1.Text = "很抱歉,未能找到您要的歌词";
            }
            //string filepath = StDirectory.CurrentAppDirectory + "\\" + this.textBox22.Text.Replace("/", "\\") + "\\" + Singer + " - " + SongName + u.Substring(u.LastIndexOf('.'));
            //if (StFile.Exists(filepath, false, false))
            //{
            //    MessageBox.Show("该歌曲已经被下载过啦");
            //    return;
            //}
            //bool re = StAPIHelper.DownLoad(u, StDirectory.CurrentAppDirectory + "\\" + this.textBox22.Text.Replace("/", "\\"), Singer + " - " + SongName);

            //this.label18.Text = "上次下载歌曲(" + SongName + ")共耗时 " + StPub.ToPrecision((DateTime.Now - start).TotalSeconds, 2) + " 秒";
            //MessageBox.Show("下载" + (re ? "成功" : "失败"));
        }
Пример #9
0
 //IP地址查询
 private void button4_Click(object sender, EventArgs e)
 {
     this.label10.Text = string.Join(",", StAPIHelper.Ex_GetIPAddress(this.textBox7.Text));
 }
Пример #10
0
        public void BaiDuFanYi()
        {
            this.textBox5.Text = "\r\n\r\n";

            string query = this.textBox6.Text;

            if (string.IsNullOrWhiteSpace(query))
            {
                return;
            }
            if (query == "sg give to bd")
            {
                StAPIHelper.Ex_BaiduFanYiDebuger = true;
            }
            else if (query == "sg give to bd.")
            {
                StAPIHelper.Ex_BaiduFanYiDebuger = false;
            }


            //语种
            int baidufanyi_len = 20;//这个是百度翻译获取语种的长度限制,在后面可能会考虑配置到文件

            string en_form  = this.comboBox2.Tag.ToString();
            int    cb2Index = this.comboBox2.SelectedIndex;

            this.comboBox2.Items.RemoveAt(0);
            if (en_form == BaiduFanyiAutoCheckText.Split('|')[1])
            {
                en_form = StAPIHelper.Ex_BaiduFanyiLangDetect(query.Length > baidufanyi_len ? query.Substring(0, baidufanyi_len) : query);
                string en_formText = BaidufanyiYuzhong[en_form];
                this.comboBox2.Items.Insert(0, "自动检测到 " + en_formText);
            }
            else
            {
                this.comboBox2.Items.Insert(0, "自动检测");
            }
            this.comboBox2.SelectedIndex = cb2Index;



            string en_to = this.comboBox1.SelectedValue.ToString();

            if (en_form == en_to)
            {
                if (this.comboBox1.SelectedIndex == 0)
                {
                    this.comboBox1.SelectedIndex = 1;
                }
                else
                {
                    this.comboBox1.SelectedIndex = 0;
                }
            }
            en_to = this.comboBox1.SelectedValue.ToString();
            this.comboBox1.Tag = en_to;

            string[] rel;

            rel = StAPIHelper.Ex_BaiduFanYi(query, en_form, en_to);



            if (rel == null)
            {
                this.textBox5.Text += "\r\n翻译失败";
                return;
            }


            this.textBox5.Text += string.Format("\r\n\r\n[{1} => {2}]\r\n\r\n{0}", query, en_form, en_to);
            this.textBox5.Text += "\r\n";


            rel = rel.Distinct().ToArray();
            if (query.IndexOf("\r\n") > -1)
            {
                this.textBox5.Text += string.Join("\r\n", rel);
            }
            else
            {
                this.textBox5.Text += this.checkBox2.Checked ? string.Format("[\"{0}\"]", string.Join("\",\"", rel)) : rel[0];
            }
            BaiDuFanYiPreStr = query;



            this.textBox5.Update();
            this.textBox5.Select(this.textBox5.Text.Length, 0);
            this.textBox5.ScrollToCaret();
        }