wns9778.com_威尼斯wns.9778官网

热门关键词: wns9778.com,威尼斯wns.9778官网
wns9778.com > 计算机教程 > 单列wns9778.com:,单例模式

原标题:单列wns9778.com:,单例模式

浏览次数:160 时间:2019-05-11

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;

单列,单例模式

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:\wns9778.com,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();
        }
    }
}

 

http://www.bkjia.com/C_jc/1202204.htmlwww.bkjia.comtruehttp://www.bkjia.com/C_jc/1202204.htmlTechArticle单列,单例模式 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime....

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;

本文由wns9778.com发布于计算机教程,转载请注明出处:单列wns9778.com:,单例模式

关键词: wns9778.com

上一篇:[转]Windows 下常用盗版软件的替代免费软件列表

下一篇:没有了