📄 eventplaysoundform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using NiceTracker.Events;
namespace NiceTracker
{
/// <summary>
/// Summary description for EventFlashBacklightForm.
/// </summary>
public class EventPlaySoundForm : System.Windows.Forms.Form
{
private EventPlaySound configEvent = null;
private System.Windows.Forms.Label labelDescription;
private System.Windows.Forms.TextBox textBoxDescription;
private System.Windows.Forms.Label labelTrigger;
private System.Windows.Forms.RadioButton radioButtonEntry;
private System.Windows.Forms.RadioButton radioButtonExit;
private Microsoft.WindowsCE.Forms.InputPanel inputPanel1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.Button buttonCells;
private System.Windows.Forms.Label labelMode;
private System.Windows.Forms.RadioButton radioButtonOnce;
private System.Windows.Forms.RadioButton radioButtonEach;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button buttonAreas;
private System.Windows.Forms.Button buttonTestEvent;
private System.Windows.Forms.TextBox textBoxFilename;
private System.Windows.Forms.Button buttonBrowse;
private System.Windows.Forms.OpenFileDialog openFileDialogSoundFiles;
private System.Windows.Forms.Label labelTitle;
public EventPlaySoundForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
buttonTestEvent.Visible = false;
}
public EventPlaySoundForm( EventPlaySound evt )
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
configEvent = evt;
buttonTestEvent.Visible = true;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(EventPlaySoundForm));
this.labelTitle = new System.Windows.Forms.Label();
this.labelDescription = new System.Windows.Forms.Label();
this.textBoxDescription = new System.Windows.Forms.TextBox();
this.labelTrigger = new System.Windows.Forms.Label();
this.radioButtonEntry = new System.Windows.Forms.RadioButton();
this.radioButtonExit = new System.Windows.Forms.RadioButton();
this.inputPanel1 = new Microsoft.WindowsCE.Forms.InputPanel();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.buttonCells = new System.Windows.Forms.Button();
this.labelMode = new System.Windows.Forms.Label();
this.radioButtonOnce = new System.Windows.Forms.RadioButton();
this.radioButtonEach = new System.Windows.Forms.RadioButton();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.buttonAreas = new System.Windows.Forms.Button();
this.buttonTestEvent = new System.Windows.Forms.Button();
this.textBoxFilename = new System.Windows.Forms.TextBox();
this.buttonBrowse = new System.Windows.Forms.Button();
this.openFileDialogSoundFiles = new System.Windows.Forms.OpenFileDialog();
//
// labelTitle
//
this.labelTitle.Location = new System.Drawing.Point(8, 88);
this.labelTitle.Size = new System.Drawing.Size(56, 20);
this.labelTitle.Text = "Filename:";
//
// labelDescription
//
this.labelDescription.Location = new System.Drawing.Point(8, 8);
this.labelDescription.Size = new System.Drawing.Size(72, 20);
this.labelDescription.Text = "Description:";
//
// textBoxDescription
//
this.textBoxDescription.Location = new System.Drawing.Point(80, 8);
this.textBoxDescription.Size = new System.Drawing.Size(152, 20);
this.textBoxDescription.Text = "";
this.textBoxDescription.LostFocus += new System.EventHandler(this.textBox_LostFocus);
this.textBoxDescription.GotFocus += new System.EventHandler(this.textBox_GotFocus);
//
// labelTrigger
//
this.labelTrigger.Location = new System.Drawing.Point(8, 40);
this.labelTrigger.Size = new System.Drawing.Size(56, 20);
this.labelTrigger.Text = "Trigger:";
//
// radioButtonEntry
//
this.radioButtonEntry.Checked = true;
this.radioButtonEntry.Size = new System.Drawing.Size(72, 20);
this.radioButtonEntry.Text = "Enter cell";
//
// radioButtonExit
//
this.radioButtonExit.Location = new System.Drawing.Point(80, 0);
this.radioButtonExit.Size = new System.Drawing.Size(64, 20);
this.radioButtonExit.Text = "Exit cell";
//
// buttonCells
//
this.buttonCells.Location = new System.Drawing.Point(168, 128);
this.buttonCells.Size = new System.Drawing.Size(64, 20);
this.buttonCells.Text = "Cells...";
this.buttonCells.Click += new System.EventHandler(this.buttonCells_Click);
//
// labelMode
//
this.labelMode.Location = new System.Drawing.Point(8, 64);
this.labelMode.Size = new System.Drawing.Size(64, 20);
this.labelMode.Text = "Fire event:";
//
// radioButtonOnce
//
this.radioButtonOnce.Size = new System.Drawing.Size(80, 20);
this.radioButtonOnce.Text = "Once only";
//
// radioButtonEach
//
this.radioButtonEach.Location = new System.Drawing.Point(80, 0);
this.radioButtonEach.Size = new System.Drawing.Size(72, 20);
this.radioButtonEach.Text = "Each cell";
//
// panel1
//
this.panel1.Controls.Add(this.radioButtonEntry);
this.panel1.Controls.Add(this.radioButtonExit);
this.panel1.Location = new System.Drawing.Point(80, 40);
this.panel1.Size = new System.Drawing.Size(160, 24);
//
// panel2
//
this.panel2.Controls.Add(this.radioButtonOnce);
this.panel2.Controls.Add(this.radioButtonEach);
this.panel2.Location = new System.Drawing.Point(80, 64);
this.panel2.Size = new System.Drawing.Size(152, 24);
//
// buttonAreas
//
this.buttonAreas.Location = new System.Drawing.Point(88, 128);
this.buttonAreas.Size = new System.Drawing.Size(64, 20);
this.buttonAreas.Text = "Areas...";
this.buttonAreas.Click += new System.EventHandler(this.buttonAreas_Click);
//
// buttonTestEvent
//
this.buttonTestEvent.Location = new System.Drawing.Point(8, 128);
this.buttonTestEvent.Size = new System.Drawing.Size(64, 20);
this.buttonTestEvent.Text = "Test";
this.buttonTestEvent.Click += new System.EventHandler(this.buttonTestEvent_Click);
//
// textBoxFilename
//
this.textBoxFilename.Location = new System.Drawing.Point(80, 88);
this.textBoxFilename.Size = new System.Drawing.Size(128, 20);
this.textBoxFilename.Text = "";
this.textBoxFilename.LostFocus += new System.EventHandler(this.textBox_LostFocus);
this.textBoxFilename.GotFocus += new System.EventHandler(this.textBox_GotFocus);
//
// buttonBrowse
//
this.buttonBrowse.Location = new System.Drawing.Point(208, 88);
this.buttonBrowse.Size = new System.Drawing.Size(24, 20);
this.buttonBrowse.Text = "...";
this.buttonBrowse.Click += new System.EventHandler(this.buttonBrowse_Click);
//
// openFileDialogSoundFiles
//
this.openFileDialogSoundFiles.Filter = "WMA (*.wma)|*.wma|WAV (*.wav)|*.wav";
//
// EventPlaySoundForm
//
this.ClientSize = new System.Drawing.Size(240, 272);
this.Controls.Add(this.buttonBrowse);
this.Controls.Add(this.textBoxFilename);
this.Controls.Add(this.buttonTestEvent);
this.Controls.Add(this.buttonAreas);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.labelMode);
this.Controls.Add(this.buttonCells);
this.Controls.Add(this.labelTrigger);
this.Controls.Add(this.textBoxDescription);
this.Controls.Add(this.labelDescription);
this.Controls.Add(this.labelTitle);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Text = "Flash Backlight";
this.Load += new System.EventHandler(this.EventFlashBacklightForm_Load);
}
#endregion
private void buttonOK_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void textBox_GotFocus(object sender, System.EventArgs e)
{
inputPanel1.Enabled = true;
}
public EventPlaySound ConfiguredEvent
{
get
{
return configEvent;
}
}
private void textBox_LostFocus(object sender, EventArgs e)
{
inputPanel1.Enabled = false;
}
private void EventFlashBacklightForm_Load(object sender, System.EventArgs e)
{
textBoxFilename.Text = configEvent.Filename;
if ( configEvent.Trigger == EventBase.TriggerType.EnterCell )
radioButtonEntry.Checked = true;
else if ( configEvent.Trigger == EventBase.TriggerType.ExitCell )
radioButtonExit.Checked = true;
if ( configEvent.TriggerMode == EventBase.TriggerModeType.OneCell )
radioButtonOnce.Checked = true;
else if ( configEvent.TriggerMode == EventBase.TriggerModeType.EachCell )
radioButtonEach.Checked = true;
textBoxDescription.Text = configEvent.Description;
Application.DoEvents();
}
private void buttonCells_Click(object sender, System.EventArgs e)
{
CellChooserForm ccf = new CellChooserForm( configEvent );
if ( ccf.ShowDialog() == DialogResult.OK )
{
configEvent.ClearCells();
foreach ( GSMCell gsmCell in ccf.SelectedCells )
{
configEvent.AddCell( gsmCell );
}
}
}
private void buttonAreas_Click(object sender, System.EventArgs e)
{
AreaChooserForm acf = new AreaChooserForm( configEvent );
if ( acf.ShowDialog() == DialogResult.OK )
{
configEvent.ClearAreas();
foreach ( GSMCell gsmCell in acf.SelectedAreas )
{
configEvent.AddArea( gsmCell );
}
}
}
public void MakeChanges( )
{
configEvent.Filename = textBoxFilename.Text;
if ( radioButtonEntry.Checked )
configEvent.Trigger = EventBase.TriggerType.EnterCell;
else if ( radioButtonExit.Checked )
configEvent.Trigger = EventBase.TriggerType.ExitCell;
configEvent.Description = textBoxDescription.Text;
}
private void buttonTestEvent_Click(object sender, System.EventArgs e)
{
if ( configEvent != null )
{
string oldFilename = configEvent.Filename;
configEvent.Filename = textBoxFilename.Text;
configEvent.Action();
configEvent.Filename = oldFilename;
}
}
private void buttonBrowse_Click(object sender, System.EventArgs e)
{
if ( openFileDialogSoundFiles.ShowDialog() == DialogResult.OK )
{
textBoxFilename.Text = openFileDialogSoundFiles.FileName;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -