⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sssoundcontrol.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace Imps.Client.Pc.Options
{
    using Imps.Client;
    using Imps.Client.Core;
    using Imps.Client.Pc;
    using Imps.Client.Pc.Controls;
    using Imps.Client.Resource;
    using Imps.Client.Utils;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.IO;
    using System.Media;
    using System.Windows.Forms;

    public class SsSoundControl : OptionsControlBase
    {
        private IFrameworkWindow _iFrameworkWnd;
        private NotifyWinodwSetting _ns;
        private Image _playPic = ImpsResources.GetImage("Images.play.png");
        private Dictionary<int, SoundFile> _soundList;
        private CheckBox chkMsgNotify;
        private CheckBox ckEnableSound;
        private DataGridViewImageColumn Column1;
        private DataGridViewTextBoxColumn Column2;
        private DataGridViewButtonColumn Column3;
        private DataGridViewButtonColumn Column4;
        private IContainer components;
        private DataGridView dgvSound;
        private XLabel label1;
        private XLabel lbNotify;
        private XLabel lbPreTip;
        private XLabel lbSound;
        private OpenFileDialog openFileDialogSound;
        private PictureBox pbPreview;
        private RadioButton rbAllNo;
        private RadioButton rbAllYes;
        private RadioButton rbByContact;
        private Imps.Client.Core.SoundSetting ss;
        private XTextBox xtbFilePath;

        public SsSoundControl(IFrameworkWindow iFrameworkWnd)
        {
            this._iFrameworkWnd = iFrameworkWnd;
            this.ss = this._user.Configuration.UserSetting.SoundSetting;
            this._ns = this._user.Configuration.UserSetting.NotifyWinodwSetting;
            this.InitializeComponent();
            this.initSoundList();
            this.initSoundUIList();
            this.handleUiEvent();
            this.pbPreview.Image = ImpsResources.GetImage("Images.play.png");
        }

        public override bool CheckUserInput()
        {
            return true;
        }

        private void ckEnableSound_CheckedChanged(object sender, EventArgs e)
        {
            this.dgvSound.Enabled = this.ckEnableSound.Checked;
            this.xtbFilePath.Enabled = this.ckEnableSound.Checked;
        }

        private void deleteSound(int index)
        {
            this._soundList[index].Path = "";
            this.xtbFilePath.Text = "";
        }

        private void dgvSound_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string path = this._soundList[e.RowIndex].Path;
            if (path != null)
            {
                this.xtbFilePath.Text = path;
            }
            else
            {
                this.xtbFilePath.Text = "";
            }
        }

        private void dgvSound_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            this.dgvSound.Rows[e.RowIndex].Cells[1].Selected = true;
            if (e.ColumnIndex == 0)
            {
                this.playSound(e.RowIndex);
            }
            if (e.ColumnIndex == 2)
            {
                this.dgvSound.Rows[e.RowIndex].Cells[1].Selected = true;
                if (string.IsNullOrEmpty(this._soundList[e.RowIndex].Path))
                {
                    this._iFrameworkWnd.UnifiedMessageBox.ShowInfo(this, "提示音已为空");
                }
                else if (this._iFrameworkWnd.UnifiedMessageBox.ShowConfirmation(string.Format("您确定要删除{0}的提示音吗?", this.dgvSound.Rows[e.RowIndex].Cells[1].Value.ToString())) == DialogResult.Yes)
                {
                    this.deleteSound(e.RowIndex);
                }
            }
            else if (e.ColumnIndex == 3)
            {
                this.modifySound(e.RowIndex);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void handleUiEvent()
        {
            this.ckEnableSound.CheckedChanged += new EventHandler(this.uiData_Changed);
            this.rbAllNo.CheckedChanged += new EventHandler(this.uiData_Changed);
            this.rbAllYes.CheckedChanged += new EventHandler(this.uiData_Changed);
            this.rbByContact.CheckedChanged += new EventHandler(this.uiData_Changed);
            this.chkMsgNotify.CheckedChanged += new EventHandler(this.uiData_Changed);
            this.xtbFilePath.TextChanged += new EventHandler(this.uiData_Changed);
        }

        private void InitializeComponent()
        {
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(SsSoundControl));
            DataGridViewCellStyle style2 = new DataGridViewCellStyle();
            DataGridViewCellStyle style3 = new DataGridViewCellStyle();
            this.lbSound = new XLabel();
            this.ckEnableSound = new CheckBox();
            this.lbNotify = new XLabel();
            this.chkMsgNotify = new CheckBox();
            this.dgvSound = new DataGridView();
            this.Column1 = new DataGridViewImageColumn();
            this.Column2 = new DataGridViewTextBoxColumn();
            this.Column3 = new DataGridViewButtonColumn();
            this.Column4 = new DataGridViewButtonColumn();
            this.xtbFilePath = new XTextBox();
            this.openFileDialogSound = new OpenFileDialog();
            this.rbAllYes = new RadioButton();
            this.rbAllNo = new RadioButton();
            this.rbByContact = new RadioButton();
            this.label1 = new XLabel();
            this.pbPreview = new PictureBox();
            this.lbPreTip = new XLabel();
            XLabel label = new XLabel();
            XLabel label2 = new XLabel();
            ((ISupportInitialize) this.dgvSound).BeginInit();
            ((ISupportInitialize) this.pbPreview).BeginInit();
            base.SuspendLayout();
            label.AutoEllipsis = false;
            label.BorderColor = Color.Black;
            label.BorderStyle = BorderStyle.Fixed3D;
            label.ButtonBorderStyle = ButtonBorderStyle.Solid;
            label.Location = new Point(0x41, 15);
            label.Name = "lbLine";
            label.Size = new Size(280, 2);
            label.TabIndex = 1;
            label.TextAlign = ContentAlignment.TopLeft;
            label.UseMnemonic = false;
            label2.AutoEllipsis = false;
            label2.BorderColor = Color.Black;
            label2.BorderStyle = BorderStyle.Fixed3D;
            label2.ButtonBorderStyle = ButtonBorderStyle.Solid;
            label2.Location = new Point(0x27, 0xd7);
            label2.Name = "lbLine2";
            label2.Size = new Size(0x13d, 2);
            label2.TabIndex = 6;
            label2.TextAlign = ContentAlignment.TopLeft;
            label2.UseMnemonic = false;
            this.lbSound.AutoEllipsis = false;
            this.lbSound.AutoSize = true;
            this.lbSound.BorderColor = Color.Black;
            this.lbSound.BorderStyle = BorderStyle.None;
            this.lbSound.ButtonBorderStyle = ButtonBorderStyle.Solid;
            this.lbSound.Location = new Point(5, 9);
            this.lbSound.Name = "lbSound";
            this.lbSound.Size = new Size(0x38, 14);
            this.lbSound.TabIndex = 0;
            this.lbSound.Text = "声音设定";
            this.lbSound.TextAlign = ContentAlignment.TopLeft;
            this.lbSound.UseMnemonic = false;
            this.ckEnableSound.AutoSize = true;
            this.ckEnableSound.Location = new Point(0x13, 0x1f);
            this.ckEnableSound.Name = "ckEnableSound";
            this.ckEnableSound.Size = new Size(0x71, 0x11);
            this.ckEnableSound.TabIndex = 2;
            this.ckEnableSound.Text = "启用提示音(点击";
            this.ckEnableSound.UseVisualStyleBackColor = true;
            this.ckEnableSound.CheckedChanged += new EventHandler(this.ckEnableSound_CheckedChanged);
            this.lbNotify.AutoEllipsis = false;
            this.lbNotify.AutoSize = true;
            this.lbNotify.BorderColor = Color.Black;
            this.lbNotify.BorderStyle = BorderStyle.None;
            this.lbNotify.ButtonBorderStyle = ButtonBorderStyle.Solid;
            this.lbNotify.Location = new Point(5, 0xd0);
            this.lbNotify.Name = "lbNotify";
            this.lbNotify.Size = new Size(0x1f, 14);
            this.lbNotify.TabIndex = 5;
            this.lbNotify.Text = "通知";
            this.lbNotify.TextAlign = ContentAlignment.TopLeft;
            this.lbNotify.UseMnemonic = false;
            this.chkMsgNotify.AutoSize = true;
            this.chkMsgNotify.Location = new Point(0x10, 0x149);
            this.chkMsgNotify.Name = "chkMsgNotify";
            this.chkMsgNotify.Size = new Size(0x92, 0x11);
            this.chkMsgNotify.TabIndex = 11;
            this.chkMsgNotify.Text = "新消息到达时显示通知";
            this.chkMsgNotify.UseVisualStyleBackColor = true;
            this.dgvSound.AllowUserToAddRows = false;
            this.dgvSound.AllowUserToDeleteRows = false;
            this.dgvSound.AllowUserToResizeColumns = false;
            this.dgvSound.AllowUserToResizeRows = false;
            this.dgvSound.BackgroundColor = SystemColors.Window;
            this.dgvSound.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
            this.dgvSound.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dgvSound.ColumnHeadersVisible = false;
            this.dgvSound.Columns.AddRange(new DataGridViewColumn[] { this.Column1, this.Column2, this.Column3, this.Column4 });
            this.dgvSound.GridColor = SystemColors.Window;
            this.dgvSound.Location = new Point(0x13, 0x36);
            this.dgvSound.MultiSelect = false;
            this.dgvSound.Name = "dgvSound";
            this.dgvSound.ReadOnly = true;
            this.dgvSound.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
            this.dgvSound.RowHeadersVisible = false;
            this.dgvSound.RowTemplate.Height = 0x17;
            this.dgvSound.Size = new Size(0x147, 0x70);
            this.dgvSound.TabIndex = 3;
            this.dgvSound.CellClick += new DataGridViewCellEventHandler(this.dgvSound_CellClick);
            this.dgvSound.CellContentClick += new DataGridViewCellEventHandler(this.dgvSound_CellContentClick);
            style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style.NullValue = manager.GetObject("dataGridViewCellStyle7.NullValue");
            style.SelectionBackColor = SystemColors.Window;
            style.SelectionForeColor = SystemColors.Window;
            this.Column1.DefaultCellStyle = style;
            this.Column1.Frozen = true;
            this.Column1.HeaderText = "";
            this.Column1.MinimumWidth = 40;
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.Resizable = DataGridViewTriState.False;
            this.Column1.ToolTipText = "点击这里试听您所设定的声音!";
            this.Column1.Width = 40;
            this.Column2.Frozen = true;
            this.Column2.HeaderText = "";
            this.Column2.MaxInputLength = 100;
            this.Column2.Name = "Column2";
            this.Column2.ReadOnly = true;
            this.Column2.Resizable = DataGridViewTriState.False;
            this.Column2.SortMode = DataGridViewColumnSortMode.NotSortable;
            this.Column2.Width = 0xa5;
            style2.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style2.SelectionBackColor = Color.Transparent;
            style2.SelectionForeColor = Color.Transparent;
            this.Column3.DefaultCellStyle = style2;
            this.Column3.Frozen = true;
            this.Column3.HeaderText = "";
            this.Column3.Name = "Column3";
            this.Column3.ReadOnly = true;
            this.Column3.Resizable = DataGridViewTriState.False;
            this.Column3.Width = 60;
            style3.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style3.SelectionBackColor = Color.Transparent;
            style3.SelectionForeColor = Color.Transparent;
            this.Column4.DefaultCellStyle = style3;
            this.Column4.Frozen = true;
            this.Column4.HeaderText = "";
            this.Column4.Name = "Column4";
            this.Column4.ReadOnly = true;
            this.Column4.Resizable = DataGridViewTriState.False;
            this.Column4.Width = 60;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -