• 单列


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Runtime.Remoting.Services;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace Day10_0200单例
    {
        public partial class FrmPlay : Form
        {
            public static FrmPlay OnlyOneForm;
            //1.构造私有
            private FrmPlay()
            {
                InitializeComponent();
            }

            public string path;
            private void FrmPlay_Load(object sender, EventArgs e)
            {
              
            }

            public void PlaySong()
            {
                Player1.URL = path;
            }


            //静态方法
            public static FrmPlay GetInstance()
            {
                if (OnlyOneForm==null)
                {
                    OnlyOneForm=new FrmPlay();
                    return OnlyOneForm;
                }
                else
                {
                    return OnlyOneForm;
                }
              
            }
        }
    }

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace Day10_0200单例
    {
        public partial class FrmList : Form
        {
            public FrmList()
            {
                InitializeComponent();
            }

            private void FrmList_Load(object sender, EventArgs e)
            {
                //整行选中
                dgvList.SelectionMode= DataGridViewSelectionMode.FullRowSelect;

                //将dgv和ContextMenuStrip  bind
                dgvList.ContextMenuStrip = cms_list;
                List<Song> list=new List<Song>();
                Song s1 = new Song("001", "北京北京", "D:\song\所谓朋友.mp3");
                Song s2 = new Song("002", "北京北京", "D:\song\吴雨霏 - 生命树.mp3");
                Song s3 = new Song("003", "北京北京", "D:\song\战长沙 - 箫配乐 - 纯音乐版.mp3");

                list.Add(s1);
                list.Add(s2);
                list.Add(s3);

                dgvList.DataSource = list;
            }

            private void 播放ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                FrmPlay frm = FrmPlay.GetInstance();
                frm.path = dgvList.SelectedRows[0].Cells[2].Value.ToString();
                frm.Show();
                frm.PlaySong();
            }
        }
    }

  • 相关阅读:
    Structured Streaming watermark总结
    技术实践第三期|HashTag在Redis集群环境下的使用
    元宇宙带来沉浸式智能登录?你学会了吗?
    技术实践第一期|友盟+开发者平台Node.js重构之路
    2021年度友盟+ APP消息推送白皮书:工作日68点通勤时间消息送达率每日最高
    技术实践第二期|Flutter异常捕获
    注意啦!还没有支持64位系统的App开发者,务必在12月底前完成这件事!
    一位大牛对于写技术博客的一些建议
    国内常用源开发环境换源(flutter换源,python换源,Linux换源,npm换源)
    初识Socket通讯编程(一)
  • 原文地址:https://www.cnblogs.com/wangbenqing/p/6617528.html
Copyright © 2020-2023  润新知