📄 eventshowpictureform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using NiceTracker.Events;
using NiceTracker.EventConfig;
namespace NiceTracker
{
/// <summary>
/// Summary description for EventFlashBacklightForm.
/// </summary>
public class EventShowPictureForm : System.Windows.Forms.Form, IEventConfigForm
{
private EventShowPicture configEvent = null;
private System.Windows.Forms.Label labelDescription;
private System.Windows.Forms.TextBox textBoxDescription;
private System.Windows.Forms.Label labelTrigger;
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.Button buttonAreas;
private System.Windows.Forms.Button buttonTestEvent;
private System.Windows.Forms.ComboBox comboBoxTrigger;
private System.Windows.Forms.ComboBox comboBoxTriggerMode;
private System.Windows.Forms.TextBox textBoxFilename;
private System.Windows.Forms.Button buttonBrowse;
private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.Label labelPictureMode;
private System.Windows.Forms.ComboBox comboBoxPictureMode;
private System.Windows.Forms.PictureBox pictureBoxPreview;
private System.Windows.Forms.Label labelPreview;
private System.Windows.Forms.Label labelNote;
private System.Windows.Forms.Label labelTitle;
public EventShowPictureForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
buttonTestEvent.Visible = false;
}
public EventShowPictureForm( EventShowPicture 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(EventShowPictureForm));
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.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.buttonAreas = new System.Windows.Forms.Button();
this.buttonTestEvent = new System.Windows.Forms.Button();
this.comboBoxTrigger = new System.Windows.Forms.ComboBox();
this.comboBoxTriggerMode = new System.Windows.Forms.ComboBox();
this.textBoxFilename = new System.Windows.Forms.TextBox();
this.buttonBrowse = new System.Windows.Forms.Button();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.labelPictureMode = new System.Windows.Forms.Label();
this.comboBoxPictureMode = new System.Windows.Forms.ComboBox();
this.pictureBoxPreview = new System.Windows.Forms.PictureBox();
this.labelPreview = new System.Windows.Forms.Label();
this.labelNote = new System.Windows.Forms.Label();
//
// labelTitle
//
this.labelTitle.Location = new System.Drawing.Point(8, 83);
this.labelTitle.Size = new System.Drawing.Size(56, 16);
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.textBoxDescription_LostFocus);
this.textBoxDescription.GotFocus += new System.EventHandler(this.textBoxDescription_GotFocus);
//
// labelTrigger
//
this.labelTrigger.Location = new System.Drawing.Point(8, 32);
this.labelTrigger.Size = new System.Drawing.Size(56, 20);
this.labelTrigger.Text = "Trigger:";
//
// buttonCells
//
this.buttonCells.Location = new System.Drawing.Point(168, 240);
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, 56);
this.labelMode.Size = new System.Drawing.Size(64, 20);
this.labelMode.Text = "Fire event:";
//
// buttonAreas
//
this.buttonAreas.Location = new System.Drawing.Point(88, 240);
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, 240);
this.buttonTestEvent.Size = new System.Drawing.Size(64, 20);
this.buttonTestEvent.Text = "Test";
this.buttonTestEvent.Click += new System.EventHandler(this.buttonTestEvent_Click);
//
// comboBoxTrigger
//
this.comboBoxTrigger.Location = new System.Drawing.Point(80, 32);
this.comboBoxTrigger.Size = new System.Drawing.Size(152, 21);
//
// comboBoxTriggerMode
//
this.comboBoxTriggerMode.Location = new System.Drawing.Point(80, 56);
this.comboBoxTriggerMode.Size = new System.Drawing.Size(152, 21);
//
// textBoxFilename
//
this.textBoxFilename.Location = new System.Drawing.Point(80, 80);
this.textBoxFilename.Size = new System.Drawing.Size(128, 20);
this.textBoxFilename.Text = "";
//
// buttonBrowse
//
this.buttonBrowse.Location = new System.Drawing.Point(208, 80);
this.buttonBrowse.Size = new System.Drawing.Size(24, 20);
this.buttonBrowse.Text = "...";
this.buttonBrowse.Click += new System.EventHandler(this.buttonBrowse_Click);
//
// openFileDialog
//
this.openFileDialog.Filter = "Image Files|*.jpg;*.bmp|All Files|*.*";
//
// labelPictureMode
//
this.labelPictureMode.Location = new System.Drawing.Point(8, 107);
this.labelPictureMode.Size = new System.Drawing.Size(56, 16);
this.labelPictureMode.Text = "Mode:";
//
// comboBoxPictureMode
//
this.comboBoxPictureMode.Location = new System.Drawing.Point(80, 104);
this.comboBoxPictureMode.Size = new System.Drawing.Size(152, 21);
//
// pictureBoxPreview
//
this.pictureBoxPreview.Image = ((System.Drawing.Image)(resources.GetObject("pictureBoxPreview.Image")));
this.pictureBoxPreview.Location = new System.Drawing.Point(88, 128);
this.pictureBoxPreview.Size = new System.Drawing.Size(88, 80);
this.pictureBoxPreview.Click += new System.EventHandler(this.pictureBoxPreview_Click);
//
// labelPreview
//
this.labelPreview.Location = new System.Drawing.Point(8, 128);
this.labelPreview.Size = new System.Drawing.Size(56, 16);
this.labelPreview.Text = "Preview:";
//
// labelNote
//
this.labelNote.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular);
this.labelNote.Location = new System.Drawing.Point(88, 208);
this.labelNote.Size = new System.Drawing.Size(144, 24);
this.labelNote.Text = "Note: Image on main screen will not be updated";
this.labelNote.Visible = false;
//
// EventShowPictureForm
//
this.ClientSize = new System.Drawing.Size(240, 272);
this.Controls.Add(this.labelNote);
this.Controls.Add(this.labelPreview);
this.Controls.Add(this.pictureBoxPreview);
this.Controls.Add(this.comboBoxPictureMode);
this.Controls.Add(this.labelPictureMode);
this.Controls.Add(this.buttonBrowse);
this.Controls.Add(this.textBoxFilename);
this.Controls.Add(this.comboBoxTriggerMode);
this.Controls.Add(this.comboBoxTrigger);
this.Controls.Add(this.buttonTestEvent);
this.Controls.Add(this.buttonAreas);
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 = "Show Picture";
this.Load += new System.EventHandler(this.EventInternetPostForm_Load);
}
#endregion
private void buttonOK_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void textBoxDescription_GotFocus(object sender, System.EventArgs e)
{
inputPanel1.Enabled = true;
}
public EventShowPicture ConfiguredEvent
{
get
{
return configEvent;
}
}
private void textBoxDescription_LostFocus(object sender, EventArgs e)
{
inputPanel1.Enabled = false;
}
private void EventInternetPostForm_Load(object sender, System.EventArgs e)
{
comboBoxPictureMode.Items.Add( "Normal" );
comboBoxPictureMode.Items.Add( "Centered" );
comboBoxPictureMode.Items.Add( "Stretched" );
comboBoxPictureMode.SelectedItem = configEvent.PictureModeString;
textBoxFilename.Text = configEvent.Filename;
EventConfigBase.PopulateTriggerType( comboBoxTrigger );
EventConfigBase.PopulateTriggerModeType( comboBoxTriggerMode );
EventConfigBase.Adapt( configEvent, this );
loadImage( textBoxFilename.Text );
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;
configEvent.PictureModeString = comboBoxPictureMode.SelectedItem.ToString();
EventConfigBase.Adapt( this, configEvent );
}
private void buttonTestEvent_Click(object sender, System.EventArgs e)
{
if ( configEvent != null )
{
MakeChanges();
loadImage( textBoxFilename.Text );
labelNote.Visible = true;
}
}
private void buttonBrowse_Click(object sender, System.EventArgs e)
{
openFileDialog.FileName = textBoxFilename.Text;
if ( openFileDialog.ShowDialog() == DialogResult.OK )
{
textBoxFilename.Text = openFileDialog.FileName;
loadImage( openFileDialog.FileName );
}
}
private void loadImage( string filename )
{
if ( File.Exists( filename ) )
{
Bitmap image = new Bitmap( filename );
string picMode = comboBoxPictureMode.SelectedItem.ToString();
if ( picMode == "Centered" )
pictureBoxPreview.SizeMode = PictureBoxSizeMode.CenterImage;
else if ( picMode == "Stretched" )
pictureBoxPreview.SizeMode = PictureBoxSizeMode.StretchImage;
else if ( picMode == "Normal" )
pictureBoxPreview.SizeMode = PictureBoxSizeMode.Normal;
else
pictureBoxPreview.SizeMode = PictureBoxSizeMode.Normal;
pictureBoxPreview.Image = (Image)image;
}
else
{
MessageBox.Show( "Image file not found" );
}
}
public string Description
{
get
{
return textBoxDescription.Text;
}
set
{
textBoxDescription.Text = value;
}
}
public int Trigger
{
get
{
return comboBoxTrigger.SelectedIndex;
}
set
{
comboBoxTrigger.SelectedIndex = value;
}
}
public int TriggerMode
{
get
{
return comboBoxTriggerMode.SelectedIndex;
}
set
{
comboBoxTriggerMode.SelectedIndex = value;
}
}
private void pictureBoxPreview_Click(object sender, EventArgs e)
{
if ( textBoxFilename.Text != "" )
{
PicturePreviewForm form = new PicturePreviewForm(textBoxFilename.Text);
form.ShowDialog();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -