コード例 #1
0
ファイル: AlbumForm.cs プロジェクト: zyj0021/WinformSkin
        private void AlbumForm_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 100; i++)                   //添加列表项目
            {
                DuiPictureBox picBox = new DuiPictureBox(); //图片容器
                picBox.Size = new Size(120, 120);
                //picBox.BackColor = Color.Red;
                picBox.Location            = new Point(5, 5);
                picBox.MouseEnter         += picBox_MouseEnter;//绑定事件实现鼠标移入移出的边框变化效果
                picBox.MouseLeave         += picBox_MouseLeave;
                picBox.Borders.BottomWidth = 3;
                picBox.Borders.LeftWidth   = 3;
                picBox.Borders.RightWidth  = 3;
                picBox.Borders.TopWidth    = 3;
                picBox.Image    = pic;//设置图片
                picBox.SizeMode = PictureBoxSizeMode.StretchImage;

                DuiBaseControl item = new DuiBaseControl();//列表项目
                item.Size = new Size(130, 130);
                item.Top  = 10;
                item.Controls.Add(picBox);

                layeredListBox1.Items.Add(item);
            }
        }
コード例 #2
0
        public bool addIsNull()
        {
            try
            {
                this.BackColor = Color.White;
                DuiBaseControl abaseControl = new DuiBaseControl();
                abaseControl.Size     = new Size(this.Width - 5, this.Height);
                abaseControl.Location = new Point(0, 0);
                abaseControl.Name     = "imgListBaseControl_backnull";
                Items.Add(abaseControl);
                //更新列表
                RefreshList();
                GC.Collect();
                //背景图
                DuiPictureBox dp = new DuiPictureBox();
                dp.Size                  = new Size(510, 109);
                dp.BackgroundImage       = Properties.Resources.bnull;
                dp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                dp.Name                  = "back_pnull";
                dp.Location              = new Point((this.Width - 5 - 510) / 2, (this.Height - 2 - 109) / 2);
                abaseControl.Controls.Add(dp);

                Items.Add(abaseControl);
                //更新列表
                RefreshList();
                GC.Collect();
                return(true);
            }
            catch (Exception e)
            {
                throw new Exception("未搜索到内容,原因为:" + e.Message);
            }
        }
コード例 #3
0
ファイル: DirectUI.cs プロジェクト: zyj0021/WinformSkin
        private void layeredButton3_Click(object sender, EventArgs e)
        {
            DuiCheckBox   checkbox = new DuiCheckBox();
            DuiPictureBox pic      = new DuiPictureBox()
            {
                SizeMode = PictureBoxSizeMode.AutoSize, Image = smile
            };

            layeredBaseControl1.InnerDuiControl.FindControl("TextBox多行")[0].Controls.Add(checkbox);
            layeredBaseControl1.InnerDuiControl.FindControl("TextBox多行")[0].Controls.Add(pic);
            ((DuiTextBox)layeredBaseControl1.InnerDuiControl.FindControl("TextBox多行")[0]).LayoutContent();
        }
コード例 #4
0
 private void LoadingControl(bool isLoad)
 {
     if (this.Panel_load.InvokeRequired)
     {
         AsynUpdateUI au = new AsynUpdateUI(LoadingControl);
         this.Invoke(au, new object[] { isLoad });
     }
     else
     {
         Panel_load.Visible = isLoad;
         if (isLoad)
         {
             DuiPictureBox dp = Panel_load.DUIControls[0] as DuiPictureBox;
             dp.Images = new Image[] { Properties.Resources.video_loading_01, Properties.Resources.video_loading_02, Properties.Resources.video_loading_03, Properties.Resources.video_loading_04, Properties.Resources.video_loading_05, Properties.Resources.video_loading_06, Properties.Resources.video_loading_07, Properties.Resources.video_loading_08 };
             Panel_load.BringToFront();
         }
         else
         {
             Panel_load.SendToBack();
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// 图片点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Dp_MouseClick(object sender, DuiMouseEventArgs e)
        {
            DuiPictureBox dp            = sender as DuiPictureBox;
            string        ImageSavePath = "";

            if (string.IsNullOrEmpty(pes.CachePath))
            {
                ImageSavePath = AppDomain.CurrentDomain.BaseDirectory + @"\ImageWallpaper";
            }
            else
            {
                ImageSavePath = pes.CachePath + @"\ImageWallpaper";
            }

            //设置墙纸
            try
            {
                Bitmap      bmpWallpaper;
                WebRequest  webreq = WebRequest.Create(dp.Tag.ToString());
                WebResponse webres = webreq.GetResponse();
                Stream      stream = webres.GetResponseStream();
                if (!Directory.Exists(ImageSavePath))
                {
                    Directory.CreateDirectory(ImageSavePath);
                }
                bmpWallpaper  = (Bitmap)Image.FromStream(stream);
                ImageSavePath = ImageSavePath + "\\" + new Uri(dp.Tag.ToString()).Segments[new Uri(dp.Tag.ToString()).Segments.Length - 1];
                bmpWallpaper.Save(ImageSavePath, ImageFormat.Jpeg);
                stream.Close();
                PicDeal.setWallpaperApi(ImageSavePath);
            }
            catch (Exception ex)
            {
                throw new Exception("下载图片失败,原因为:" + ex.Message);
            }
        }
コード例 #6
0
        /// <summary>
        /// 添加图片列表
        /// </summary>
        /// <param name="imgInfos"></param>
        /// <returns></returns>
        public Boolean AddImgList(List <BridImg.ImageInfo> imgInfos)
        {
            if (imgInfos.Count == 0)
            {
                return(false);
            }
            int            thisWidth   = this.Width - 5;//减去滚动条宽度
            int            zWidth      = (int)(thisWidth / 3);
            int            zHeight     = (int)(thisWidth / 3 * 0.57);
            DuiBaseControl baseControl = new DuiBaseControl();

            baseControl.Size      = new Size(thisWidth, zHeight);
            baseControl.BackColor = Color.FromArgb(245, 245, 247);
            int    i      = 0;
            string baseID = "0";

            foreach (var imgInfo in imgInfos)
            {
                baseID = imgInfo.id.ToString();
                DuiBaseControl abaseControl = new DuiBaseControl();
                abaseControl.Size     = new Size(zWidth, zHeight);
                abaseControl.Location = new Point(i * zWidth, 0);
                abaseControl.Name     = "back_" + imgInfo.id.ToString();
                //背景图
                DuiPictureBox dp = new DuiPictureBox();
                dp.Size = new Size(zWidth - 4, zHeight - 4);
                int thisWidthScreen   = Screen.PrimaryScreen.Bounds.Width;
                int thisHeiightScreen = Screen.PrimaryScreen.Bounds.Height;
                dp.Tag = imgInfo.img_1280_1024;
                getImagePathByUIrlDelegate newg = new getImagePathByUIrlDelegate(PicDeal.DownloaImage);
                dp.BackgroundImage       = Image.FromFile(newg(imgInfo.url.Replace("__85", "300_161_100")));
                dp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                dp.Name     = "back_" + imgInfo.id.ToString();
                dp.Location = new Point(2, 2);
                //dp.Cursor = System.Windows.Forms.Cursors.Hand;
                dp.MouseEnter += Dp_MouseEnter;
                dp.MouseLeave += Dp_MouseLeave;
                //dp.MouseClick += Dp_MouseClick;
                //图片说明
                DuiLabel imgTag = new DuiLabel();
                imgTag.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                string ingTxt = (string.IsNullOrEmpty(imgInfo.utag) ? "" : imgInfo.utag);
                if (ingTxt.Length * 9 > zWidth)
                {
                    imgTag.Size     = new Size(zWidth - 4, 10 * 4);
                    imgTag.Location = new Point(2, zHeight - 43);
                }
                else
                {
                    imgTag.Size     = new Size(zWidth - 4, 10 * 2);
                    imgTag.Location = new Point(2, zHeight - 23);
                }
                imgTag.Font      = new Font("微软雅黑", 9F, FontStyle.Regular);
                imgTag.ForeColor = Color.White;
                imgTag.TextAlign = ContentAlignment.MiddleCenter;
                //imgTag.BackColor = Color.FromArgb(100, 0, 0, 0);
                imgTag.BackgroundImage       = Properties.Resources.mask_shadow;
                imgTag.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                imgTag.Text        = imgInfo.utag;
                imgTag.Name        = "imgTag_" + imgInfo.id.ToString();
                imgTag.MouseLeave += Dp_MouseLeave;

                imgTag.Cursor = System.Windows.Forms.Cursors.Hand;
                //下载按钮
                DuiButton btn_Download = new DuiButton();
                btn_Download.Size                  = new Size(35, 35);
                btn_Download.Radius                = 35;
                btn_Download.Name                  = "btn_Download_" + imgInfo.id.ToString();
                btn_Download.Text                  = "";
                btn_Download.Location              = new Point(0, 0);
                btn_Download.Cursor                = System.Windows.Forms.Cursors.Hand;
                btn_Download.AdaptImage            = false;
                btn_Download.IsPureColor           = true;
                btn_Download.BaseColor             = Color.Transparent;
                btn_Download.BackgroundImage       = Properties.Resources.dl;
                btn_Download.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
                btn_Download.ShowBorder            = false;
                btn_Download.MouseClick           += Btn_Download_MouseClick;
                btn_Download.Tag         = "保存|" + imgInfo.url_thumb;
                btn_Download.MouseEnter += Btn_Download_MouseEnter;
                btn_Download.MouseLeave += Btn_Download_MouseLeave;
                //收藏按钮
                DuiButton btn_sc = new DuiButton();
                btn_sc.Location              = new Point(35, 0);
                btn_sc.Size                  = new Size(35, 35);
                btn_sc.Text                  = "";
                btn_sc.Cursor                = System.Windows.Forms.Cursors.Hand;
                btn_sc.AdaptImage            = false;
                btn_sc.Name                  = "btn_Sc_" + imgInfo.id.ToString();
                btn_sc.BaseColor             = Color.Transparent;//Color.FromArgb(100, 0, 0, 0);
                btn_sc.Radius                = 35;
                btn_sc.ShowBorder            = false;
                btn_sc.BackgroundImage       = Properties.Resources.sc0;
                btn_sc.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
                btn_sc.MouseClick           += Btn_Sc_MouseClick;
                btn_sc.IsPureColor           = true;
                btn_sc.Tag         = "收藏|" + getSetUrl(imgInfo);
                btn_sc.MouseEnter += Btn_Download_MouseEnter;
                btn_sc.MouseLeave += Btn_Download_MouseLeave;
                //设置按钮
                DuiButton btn_Setting = new DuiButton();
                btn_Setting.Location              = new Point(70, 0);
                btn_Setting.Size                  = new Size(35, 35);
                btn_Setting.Text                  = "";
                btn_Setting.Cursor                = System.Windows.Forms.Cursors.Hand;
                btn_Setting.AdaptImage            = false;
                btn_Setting.Name                  = "btn_Setting_" + imgInfo.id.ToString();
                btn_Setting.BaseColor             = Color.Transparent;//Color.FromArgb(100, 0, 0, 0);
                btn_Setting.Radius                = 35;
                btn_Setting.Tag                   = "设置|" + getSetUrl(imgInfo);
                btn_Setting.ShowBorder            = false;
                btn_Setting.BackgroundImage       = Properties.Resources.set;
                btn_Setting.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
                btn_Setting.MouseClick           += Btn_Setting_MouseClick;
                btn_Setting.IsPureColor           = true;
                btn_Setting.MouseEnter           += Btn_Download_MouseEnter;
                btn_Setting.MouseLeave           += Btn_Download_MouseLeave;
                //按钮底层控件
                DuiBaseControl btnBaseControl = new DuiBaseControl();
                btnBaseControl.Size      = new Size(zWidth / 3, 35);
                btnBaseControl.Cursor    = System.Windows.Forms.Cursors.Hand;
                btnBaseControl.Location  = new Point(zWidth / 3 * 2 - 12, zHeight - 52);
                btnBaseControl.BackColor = Color.Transparent;
                //btnBaseControl.MouseEnter += Dp_MouseEnter;
                btnBaseControl.MouseLeave += Dp_MouseLeave;
                btnBaseControl.MouseMove  += BtnBaseControl_MouseMove;
                btnBaseControl.Controls.Add(btn_Download);
                btnBaseControl.Controls.Add(btn_sc);
                btnBaseControl.Controls.Add(btn_Setting);
                btnBaseControl.Name    = "btnBaseControl_" + imgInfo.id.ToString();
                btnBaseControl.Visible = false;

                Borders baseBorder = new Borders(baseControl);
                baseBorder.BottomWidth = 2;
                baseBorder.TopWidth    = 2;
                baseBorder.LeftWidth   = 2;
                baseBorder.RightWidth  = 2;

                abaseControl.Borders = baseBorder;
                abaseControl.Controls.Add(dp);
                abaseControl.Controls.Add(imgTag);
                abaseControl.Controls.Add(btnBaseControl);
                baseControl.Controls.Add(abaseControl);
                i++;
            }
            baseControl.Name = "imgListBaseControl_" + baseID;
            Items.Add(baseControl);
            //更新列表
            RefreshList();
            GC.Collect();
            return(true);
        }
コード例 #7
0
        /// <summary>
        /// 添加图片列表
        /// </summary>
        /// <param name="imgInfos"></param>
        /// <returns></returns>
        public Boolean AddImgList(List <Entity.MovieListEntity.DataItem> imgInfos)
        {
            if (imgInfos.Count == 0)
            {
                return(false);
            }
            int            thisWidth   = this.Width - 5;//减去滚动条宽度
            int            zWidth      = (int)(thisWidth / 3);
            int            zHeight     = (int)(thisWidth / 3 * 0.57);
            DuiBaseControl baseControl = new DuiBaseControl();

            baseControl.Size      = new Size(thisWidth, zHeight);
            baseControl.BackColor = Color.FromArgb(245, 245, 247);
            int    i      = 0;
            string baseID = "0";

            foreach (var imgInfo in imgInfos)
            {
                //EDate.DataItem newImgInfo = isValidImgInfo(imgInfo);
                baseID = imgInfo.videoID.ToString();
                DuiBaseControl abaseControl = new DuiBaseControl();
                abaseControl.Size     = new Size(zWidth, zHeight);
                abaseControl.Location = new Point(i * zWidth, 0);
                abaseControl.Name     = "back_" + imgInfo.videoID.ToString();
                //背景图
                DuiPictureBox dp = new DuiPictureBox();
                dp.Size = new Size(zWidth - 4, zHeight - 4);
                int thisWidthScreen   = Screen.PrimaryScreen.Bounds.Width;
                int thisHeiightScreen = Screen.PrimaryScreen.Bounds.Height;
                dp.Tag = imgInfo.photo;
                getImagePathByUIrlDelegate newg = new getImagePathByUIrlDelegate(PicDeal.DownloaImage);
                dp.BackgroundImage       = Image.FromFile(newg(imgInfo.photo));
                dp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                dp.Name     = "back_" + imgInfo.videoID.ToString();
                dp.Location = new Point(2, 2);
                //dp.Cursor = System.Windows.Forms.Cursors.Hand;
                dp.MouseEnter += Dp_MouseEnter;
                dp.MouseLeave += Dp_MouseLeave;
                //dp.MouseClick += Dp_MouseClick;
                //视频名称
                DuiLabel imgTag = new DuiLabel();
                imgTag.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                string ingTxt = (string.IsNullOrEmpty(imgInfo.videoName) ? imgInfo.videoType : imgInfo.videoName);
                if (ingTxt.Length * 12 > zWidth)
                {
                    imgTag.Size     = new Size(zWidth - 4, 12 * 4);
                    imgTag.Location = new Point(2, zHeight - 48);
                }
                else
                {
                    imgTag.Size     = new Size(zWidth - 4, 12 * 2);
                    imgTag.Location = new Point(2, zHeight - 24);
                }
                imgTag.Font      = new Font("微软雅黑", 9F, FontStyle.Regular);
                imgTag.ForeColor = Color.White;
                imgTag.TextAlign = ContentAlignment.MiddleCenter;
                //imgTag.BackColor = Color.FromArgb(100, 0, 0, 0);
                imgTag.BackgroundImage       = Properties.Resources.mask_shadow;
                imgTag.BackColor             = Color.FromArgb(125, 255, 92, 138);
                imgTag.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                imgTag.Text        = ingTxt;
                imgTag.Name        = "imgTag_" + imgInfo.videoID.ToString();
                imgTag.MouseLeave += Dp_MouseLeave;
                imgTag.Cursor      = System.Windows.Forms.Cursors.Hand;
                //视频时长
                DuiLabel tvLength = new DuiLabel();
                tvLength.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                string tvTimeStr = "上架时间:";
                if (!string.IsNullOrEmpty(imgInfo.onDate))
                {
                    tvTimeStr = "上架时间:" + imgInfo.onDate;
                }
                tvLength.Size      = new Size(tvTimeStr.Length * 12, 12 * 2);
                tvLength.Location  = new Point(zWidth - tvTimeStr.Length * 12 - 2, 2);
                tvLength.Font      = new Font("微软雅黑", 9F, FontStyle.Regular);
                tvLength.ForeColor = Color.White;
                tvLength.TextAlign = ContentAlignment.MiddleCenter;
                //imgTag.BackColor = Color.FromArgb(100, 0, 0, 0);
                tvLength.BackgroundImage       = Properties.Resources.mask_shadow;
                tvLength.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                tvLength.Text        = tvTimeStr;
                tvLength.Name        = "tvLength_" + imgInfo.videoID.ToString();
                tvLength.MouseLeave += Dp_MouseLeave;
                tvLength.Cursor      = System.Windows.Forms.Cursors.Hand;
                //播放按钮
                DuiButton btn_Download = new DuiButton();
                btn_Download.Size                  = new Size(35, 35);
                btn_Download.Radius                = 35;
                btn_Download.Name                  = "btn_Download_" + imgInfo.videoID.ToString();
                btn_Download.Text                  = "";
                btn_Download.Location              = new Point((zWidth - 20 - 35) / 2, (zHeight - 20 - 35) / 2);
                btn_Download.Cursor                = System.Windows.Forms.Cursors.Hand;
                btn_Download.AdaptImage            = false;
                btn_Download.IsPureColor           = true;
                btn_Download.BaseColor             = Color.Transparent;
                btn_Download.BackgroundImage       = Properties.Resources.play1;
                btn_Download.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
                btn_Download.ShowBorder            = false;
                btn_Download.MouseClick           += Btn_Download_MouseClick;
                btn_Download.Tag         = imgInfo;
                btn_Download.MouseEnter += Btn_Download_MouseEnter;
                btn_Download.MouseLeave += Btn_Download_MouseLeave;
                //收藏次数
                DuiButton btn_sc = new DuiButton();
                btn_sc.Location   = new Point(0, 0);
                btn_sc.Size       = new Size(30, 30);
                btn_sc.Text       = "";
                btn_sc.Cursor     = System.Windows.Forms.Cursors.Hand;
                btn_sc.AdaptImage = false;
                btn_sc.Name       = "btn_Sc_" + imgInfo.videoID.ToString();
                btn_sc.BaseColor  = Color.Transparent;//Color.FromArgb(100, 0, 0, 0);
                //btn_sc.Radius = 35;
                btn_sc.ShowBorder            = false;
                btn_sc.BackgroundImage       = Properties.Resources.sc0;
                btn_sc.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
                btn_sc.IsPureColor           = true;
                btn_sc.Tag         = imgInfo;
                btn_sc.MouseEnter += Btn_Download_MouseEnter;
                btn_sc.MouseLeave += Btn_Download_MouseLeave;
                DuiLabel dltxt = new DuiLabel();
                dltxt.Text      = imgInfo.actorName.ToString();
                dltxt.Size      = new Size(30, 16);
                dltxt.ForeColor = Color.White;
                dltxt.Location  = new Point(30, 7);
                dltxt.BackColor = Color.Transparent;
                DuiBaseControl scControl = new DuiBaseControl();
                scControl.Name     = "scControl_" + imgInfo.videoID.ToString();
                scControl.Size     = new Size(60, 30);
                scControl.Location = new Point(zWidth - 20 - 60, zHeight - 20 - 30);
                scControl.Controls.Add(btn_sc);
                scControl.Controls.Add(dltxt);
                //查看次数
                DuiButton btn_Setting = new DuiButton();
                btn_Setting.Location   = new Point(0, 0);
                btn_Setting.Size       = new Size(30, 30);
                btn_Setting.Text       = "";
                btn_Setting.Cursor     = System.Windows.Forms.Cursors.Hand;
                btn_Setting.AdaptImage = false;
                btn_Setting.Name       = "btn_Setting_" + imgInfo.videoID.ToString();
                btn_Setting.BaseColor  = Color.Transparent;//Color.FromArgb(100, 0, 0, 0);
                //btn_Setting.Radius = 35;
                btn_Setting.Tag                   = imgInfo;
                btn_Setting.ShowBorder            = false;
                btn_Setting.BackgroundImage       = Properties.Resources.eye;
                btn_Setting.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
                btn_Setting.IsPureColor           = true;
                btn_Setting.MouseEnter           += Btn_Download_MouseEnter;
                btn_Setting.MouseLeave           += Btn_Download_MouseLeave;
                DuiLabel dlatxt = new DuiLabel();
                dlatxt.Text      = imgInfo.videoTypeID.ToString();
                dlatxt.Size      = new Size(30, 16);
                dlatxt.Location  = new Point(30, 7);
                dlatxt.BackColor = Color.Transparent;
                dlatxt.ForeColor = Color.White;
                DuiBaseControl seeControl = new DuiBaseControl();
                seeControl.Name     = "seeControl_" + imgInfo.videoID.ToString();
                seeControl.Size     = new Size(60, 30);
                seeControl.Location = new Point(0, zHeight - 20 - 30);
                seeControl.Controls.Add(btn_Setting);
                seeControl.Controls.Add(dlatxt);
                //按钮底层控件
                DuiBaseControl btnBaseControl = new DuiBaseControl();
                btnBaseControl.Size        = new Size(zWidth - 20, zHeight - 20);
                btnBaseControl.Cursor      = System.Windows.Forms.Cursors.Hand;
                btnBaseControl.Location    = new Point(10, 10);
                btnBaseControl.BackColor   = Color.Transparent;
                btnBaseControl.MouseLeave += Dp_MouseLeave;
                btnBaseControl.MouseMove  += BtnBaseControl_MouseMove;
                btnBaseControl.Controls.Add(btn_Download);
                btnBaseControl.Controls.Add(scControl);
                btnBaseControl.Controls.Add(seeControl);
                btnBaseControl.Name    = "btnBaseControl_" + imgInfo.videoID.ToString();
                btnBaseControl.Visible = false;

                Borders baseBorder = new Borders(baseControl);
                baseBorder.BottomWidth = 2;
                baseBorder.TopWidth    = 2;
                baseBorder.LeftWidth   = 2;
                baseBorder.RightWidth  = 2;

                abaseControl.Borders = baseBorder;
                abaseControl.Controls.Add(dp);
                abaseControl.Controls.Add(imgTag);
                abaseControl.Controls.Add(tvLength);
                abaseControl.Controls.Add(btnBaseControl);
                baseControl.Controls.Add(abaseControl);
                i++;
            }
            baseControl.Name = "imgListBaseControl_" + baseID;
            Items.Add(baseControl);
            //更新列表
            RefreshList();
            GC.Collect();
            return(true);
        }
コード例 #8
0
ファイル: MusicList.cs プロジェクト: imengyu/MiniMusic
        public MusicItem AddItem(string name, string listname, bool b = false)
        {
            MusicItem se       = null;
            bool      Searched = false;

            foreach (MusicListItem iy in Groups)
            {
                if (iy.Name == listname)
                {
                    Searched = true;
                }
            }
            if (Searched)
            {
                if (IsInList(name, listname))
                {
                    return(null);
                }
                else
                {
                    int a = 0;
                    for (int i = 0; i < Items.Count; i++)
                    {
                        if (Items[i].Tag != null)
                        {
                            if (Items[i].Tag.ToString() == listname)
                            {
                                a = a + 1;
                            }
                        }
                    }
                    DuiBaseControl ix = null;
                    foreach (DuiBaseControl ixx in Items)
                    {
                        if (ixx.Name.Replace("list_", "") == listname)
                        {
                            ix = ixx;
                        }
                    }
                    if (File.Exists(name))
                    {
                        #region 本地音乐
                        Mp3Info info = MP3Info.GetMp3Info(name);

                        string   artists       = info.Artist;
                        string   album         = info.Album;
                        string   length        = info.MusicLength;
                        string   title         = info.Title;
                        DuiLabel infoforsinger = new DuiLabel();
                        infoforsinger.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAlias;
                        infoforsinger.Size           = new Size(140, 20);
                        if (artists != "")
                        {
                            infoforsinger.Text = "-" + artists;
                        }
                        infoforsinger.Location  = new Point(160, 4);
                        infoforsinger.ForeColor = Color.FromArgb(220, 220, 220);
                        infoforsinger.Font      = new Font("微软雅黑", 9F);
                        infoforsinger.Name      = "infoforsinger";

                        DuiPictureBox albumpic = new DuiPictureBox();
                        albumpic.Size                  = new Size(50, 50);
                        albumpic.Location              = new Point(5, 0);
                        albumpic.Name                  = "albumpic";
                        albumpic.BackgroundImage       = Properties.Resources.default_album;
                        albumpic.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
                        albumpic.Visible               = false;

                        DuiLabel infoforTimer = new DuiLabel();
                        infoforTimer.Size           = new Size(70, 20);
                        infoforTimer.Text           = length;
                        infoforTimer.Location       = new Point(350, 4);
                        infoforTimer.ForeColor      = Color.FromArgb(255, 255, 255);
                        infoforTimer.Font           = new Font("微软雅黑", 9F);
                        infoforTimer.Name           = "infoforTimer";
                        infoforTimer.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAlias;

                        DuiButton btnplay = new DuiButton();
                        btnplay.Size         = new Size(20, 20);
                        btnplay.Location     = new Point(295, 3);
                        btnplay.NormalImage  = Properties.Resources.list_btn_play_normal;
                        btnplay.HoverImage   = Properties.Resources.list_btn_play_hover;
                        btnplay.PressedImage = Properties.Resources.list_btn_play_press;
                        btnplay.MouseClick  += Btnplay_MouseDown;
                        btnplay.MouseEnter  += Btnplay_MouseEnter;
                        btnplay.MouseLeave  += Btnplay_MouseLeave;
                        btnplay.Name         = "btnplay";
                        btnplay.Tag          = name;
                        btnplay.Visible      = false;

                        DuiButton btnpause = new DuiButton();
                        btnpause.Size         = new Size(20, 20);
                        btnpause.Location     = new Point(295, 3);
                        btnpause.NormalImage  = Properties.Resources.list_btn_pause_normal;
                        btnpause.HoverImage   = Properties.Resources.list_btn_pause_hover;
                        btnpause.PressedImage = Properties.Resources.list_btn_pause_press;
                        btnpause.MouseClick  += Btnpause_MouseClick;
                        btnpause.Name         = "btnpause";
                        btnpause.Tag          = name;
                        btnpause.MouseEnter  += Btnpause_MouseEnter;
                        btnpause.MouseLeave  += Btnpause_MouseLeave;
                        btnpause.Visible      = false;

                        DuiButton btndel = new DuiButton();
                        btndel.Size         = new Size(20, 20);
                        btndel.Location     = new Point(317, 3);
                        btndel.NormalImage  = Properties.Resources.btn_del_h;
                        btndel.HoverImage   = Properties.Resources.btn_del_n;
                        btndel.PressedImage = Properties.Resources.btn_del_p;
                        btndel.MouseClick  += Btndel_MouseClick;
                        btndel.MouseEnter  += Btndel_MouseEnter;
                        btndel.MouseLeave  += Btndel_MouseLeave;
                        btndel.Name         = "btndel";
                        btndel.Tag          = listname;
                        btndel.Visible      = false;

                        DuiLabel lbl = new DuiLabel();
                        lbl.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAlias;
                        lbl.Size           = new System.Drawing.Size(160, 17);
                        if (Path.GetFileNameWithoutExtension(name).Length > 14)
                        {
                            lbl.Text        = Path.GetFileNameWithoutExtension(name).Remove(13).Insert(13, "...");
                            lbl.Tag         = Path.GetFileNameWithoutExtension(name);
                            lbl.MouseEnter += Lbl_MouseEnter;
                            lbl.MouseLeave += Lbl_MouseLeave;
                        }
                        else
                        {
                            lbl.Text = Path.GetFileNameWithoutExtension(name);
                            lbl.Tag  = Path.GetFileNameWithoutExtension(name);
                        }
                        lbl.Location  = new Point(10, 4);
                        lbl.ForeColor = Color.FromArgb(255, 255, 255);
                        lbl.Font      = new Font("微软雅黑", 9F);
                        lbl.Name      = "lbl";


                        DuiBaseControl listx = new DuiBaseControl();
                        listx.BackColor = Color.FromArgb(0, Color.Black);
                        listx.Width     = Width;
                        listx.Height    = 25;
                        listx.Controls.Add(lbl);
                        listx.Controls.Add(infoforsinger);
                        listx.Controls.Add(infoforTimer);
                        listx.Controls.Add(btndel);
                        listx.Controls.Add(btnplay);
                        listx.Controls.Add(btnpause);
                        listx.Controls.Add(albumpic);
                        listx.MouseDown        += Listx_MouseDown;
                        listx.MouseUp          += Listx_MouseUp;
                        listx.MouseMove        += Listx_MouseMove;
                        listx.MouseEnter       += Listx_MouseEnter;
                        listx.MouseLeave       += Listx_MouseLeave;
                        listx.MouseDoubleClick += Listx_MouseDoubleClick;
                        listx.MouseClick       += Listx_MouseClick;
                        listx.Name              = name;
                        listx.Height            = 25;
                        listx.Tag = listname;

                        if (!b)
                        {
                            Items.Add(listx);
                        }
                        else
                        {
                            Items.Insert(Items.IndexOf(ix) + a + 1, listx);
                        }

                        foreach (MusicListItem iy in Groups)
                        {
                            if (iy.Name == listname)
                            {
                                MusicItem m = new MusicItem();
                                m.Path       = name;
                                m.IsOnline   = false;
                                m.ParentName = listname;
                                if (title != "")
                                {
                                    m.Name = title;
                                }
                                else
                                {
                                    m.Name = lbl.Tag.ToString();
                                }
                                m.Singer = artists;
                                iy.musics.Add(m);
                            }
                        }

                        if (OpenedList == listname)
                        {
                            listx.Visible = true;
                        }
                        else
                        {
                            listx.Visible = false;
                        }
                        #endregion
                    }
                    else
                    {
                        #region 失效音乐

                        DuiLabel infoforTimer = new DuiLabel();
                        infoforTimer.Size           = new Size(70, 20);
                        infoforTimer.Text           = "文件失效";
                        infoforTimer.Location       = new Point(350, 4);
                        infoforTimer.ForeColor      = Color.Red;
                        infoforTimer.Font           = new Font("微软雅黑", 9F);
                        infoforTimer.Name           = "infoforTimer";
                        infoforTimer.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAlias;

                        DuiButton btndel = new DuiButton();
                        btndel.Size         = new Size(20, 20);
                        btndel.Location     = new Point(317, 3);
                        btndel.NormalImage  = Properties.Resources.btn_del_h;
                        btndel.HoverImage   = Properties.Resources.btn_del_n;
                        btndel.PressedImage = Properties.Resources.btn_del_p;
                        btndel.MouseClick  += Btndel_MouseClick;
                        btndel.MouseEnter  += Btndel_MouseEnter;
                        btndel.MouseLeave  += Btndel_MouseLeave;
                        btndel.Name         = "btndel";
                        btndel.Tag          = listname;
                        btndel.Visible      = false;

                        DuiLabel lbl = new DuiLabel();
                        lbl.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAlias;
                        lbl.Size           = new System.Drawing.Size(160, 20);
                        if (Path.GetFileNameWithoutExtension(name).Length > 14)
                        {
                            lbl.Text        = Path.GetFileNameWithoutExtension(name).Remove(13).Insert(13, "...");
                            lbl.MouseEnter += Lbl_MouseEnter;
                        }
                        else
                        {
                            lbl.Text = Path.GetFileNameWithoutExtension(name);
                        }
                        lbl.Location    = new Point(10, 4);
                        lbl.ForeColor   = Color.Red;
                        lbl.Font        = new Font("微软雅黑", 9F);
                        lbl.Name        = "lbl";
                        lbl.Tag         = Path.GetFileNameWithoutExtension(name);
                        lbl.MouseLeave += Lbl_MouseLeave;

                        DuiBaseControl listx = new DuiBaseControl();
                        listx.BackColor = Color.FromArgb(0, Color.Black);
                        listx.Width     = Width;
                        listx.Height    = 25;
                        listx.Controls.Add(lbl);
                        listx.Controls.Add(infoforTimer);
                        listx.Controls.Add(btndel);
                        listx.MouseMove  += Listx_MouseMove;
                        listx.MouseDown  += Listx_MouseDown;
                        listx.MouseUp    += Listx_MouseUp;
                        listx.MouseEnter += Listx_MouseEnterLose;
                        listx.MouseLeave += Listx_MouseLeaveLose;
                        listx.Name        = name;
                        listx.Height      = 25;
                        listx.Tag         = listname;

                        if (!b)
                        {
                            Items.Add(listx);
                        }
                        else
                        {
                            Items.Insert(Items.IndexOf(ix) + a + 1, listx);
                        }

                        foreach (MusicListItem iy in Groups)
                        {
                            if (iy.Name == listname)
                            {
                                MusicItem m = new MusicItem();
                                m.Path     = name;
                                m.IsOnline = false;

                                iy.musics.Add(m);
                            }
                        }

                        if (OpenedList == listname)
                        {
                            listx.Visible = true;
                        }
                        else
                        {
                            listx.Visible = false;
                        }

                        #endregion
                    }
                    a = a + 1;
                    if (a == 0)
                    {
                        ((DuiLabel)ix.FindControl("Count")[0]).Text = "[这个列表没有歌曲,可以直接把歌曲拖到这里来哦]";
                    }
                    else
                    {
                        ((DuiLabel)ix.FindControl("Count")[0]).Text = "[" + a.ToString() + "]";
                    }
                    RefreshList();
                }
            }
            GC.Collect();
            return(se);
        }
コード例 #9
0
ファイル: MusicList.cs プロジェクト: imengyu/MiniMusic
        public bool AddList(string name)
        {
            bool Searched = false;

            foreach (MusicListItem a in Groups)
            {
                if (a.Name == "list_" + name)
                {
                    Searched = true;
                }
                else
                {
                    Searched = false;
                }
            }
            if (!Searched)
            {
                DuiBaseControl b = new DuiBaseControl();
                b.Name      = "list_" + name;
                b.Size      = new Size(Width, 35);
                b.BackColor = Color.Transparent;
                b.Tag       = "List";
                Borders b1 = new Borders(b);
                b1.BottomWidth = 1;
                b1.BottomColor = Color.FromArgb(50, 0, 0, 0);
                b.Borders      = b1;
                DuiLabel l = new DuiLabel();
                l.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                l.Location       = new Point(30, 8);
                l.AutoSize       = true;
                l.Font           = new Font("微软雅黑", 11F, FontStyle.Bold);
                l.ForeColor      = Color.White;
                l.Text           = name;
                l.Name           = "name";
                DuiLabel l2 = new DuiLabel();

                l2.Name = "Count";
                if (name == "我喜欢")
                {
                    l2.Location = new Point(l.Width + 43, 11);
                }
                else
                {
                    l2.Location = new Point(l.Width + 25, 11);
                }
                l2.AutoSize       = true;
                l2.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                l2.Font           = new Font("微软雅黑", 9F);
                l2.ForeColor      = Color.White;
                l2.Text           = "[列表无歌曲,可直接把歌曲拖到这里来哦]";
                l2.Tag            = (Items.Count + 1).ToString();
                DuiButton btn = new DuiButton();
                btn.Size         = new Size(22, 22);
                btn.Location     = new Point(b.Width - 35, 8);
                btn.NormalImage  = Properties.Resources.btn_list_menu_n;
                btn.HoverImage   = Properties.Resources.btn_list_menu_h;
                btn.PressedImage = Properties.Resources.btn_list_menu_p;
                btn.MouseClick  += Btn_MouseClick;
                btn.Tag          = name;
                DuiPictureBox ilike = new DuiPictureBox();
                if (name == "我喜欢")
                {
                    ilike.Size     = new Size(22, 22);
                    ilike.Location = new Point(78, 8);
                    ilike.Image    = Properties.Resources.btn_iliked_p;
                }
                btn.Tag = name;
                DuiPictureBox more = new DuiPictureBox();
                more.Size     = new Size(23, 23);
                more.Location = new Point(10, 7);
                if (name == "默认列表")
                {
                    more.Image = Properties.Resources.btn_more_close;
                    more.Tag   = "Open";
                }
                else
                {
                    more.Image = Properties.Resources.btn_more_open;
                    more.Tag   = "Close";
                }
                more.MouseClick += More_MouseClick;

                more.Name = "more";

                DuiTextBox tb = new DuiTextBox();
                tb.Size            = new Size(100, 22);
                tb.Location        = new Point(31, 9);
                tb.Visible         = false;
                tb.Name            = "tb";
                tb.ForeColor       = Color.White;
                tb.FocusedChanged += Tb_FocusedChanged;
                tb.KeyDown        += Tb_KeyDown;
                tb.Font            = new Font("微软雅黑", 9F);

                b.Controls.Add(tb);
                b.Controls.Add(btn);
                b.Controls.Add(l);
                b.Controls.Add(l2);
                b.Controls.Add(more);
                if (name == "我喜欢")
                {
                    b.Controls.Add(ilike);
                }
                b.MouseDoubleClick += B_MouseDoubleClick;

                Items.Add(b);
                RefreshList();

                MusicListItem m = new MusicListItem(name, new List <MusicItem>());
                Groups.Add(m);
            }

            GC.Collect();

            return(!Searched);
        }