?? mainform.cs
字號:
using System;
using System.Drawing;
using System.IO;
using System.Collections;
using System.Windows.Forms;
using System.Reflection;
using System.Threading;
using System.Data;
using NiceTracker.Config;
using NiceTracker.Events;
using NiceTracker.EventConfig;
using NiceTracker.Libraries;
namespace NiceTracker
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
#region Private member variables
private ChartControl signalChart = new ChartControl();
private ArrayList gsmCellLog = new ArrayList();
private EventManager eventManager = null;
private DataView dvCells = null;
private DataView dvAreas = null;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItemMain;
private System.Windows.Forms.MenuItem menuItemExit;
private System.Windows.Forms.Label labelLAC;
private System.Windows.Forms.Label labelCI;
private System.Windows.Forms.TextBox textBoxLAC;
private System.Windows.Forms.TextBox textBoxCI;
private CellTrack cellTracker = new CellTrack();
private System.Windows.Forms.MenuItem menuItemSave;
private System.Windows.Forms.MenuItem menuItemExport;
private System.Windows.Forms.DataGrid dataGridCellDB;
private System.Windows.Forms.Label labelLocation;
private System.Windows.Forms.TabPage tabPageLocation;
private System.Windows.Forms.TabPage tabPageLog;
private System.Windows.Forms.ListBox listBoxLog;
private System.Windows.Forms.Label labelSignal;
private System.Windows.Forms.ProgressBar progressBarSignal;
private System.Windows.Forms.Button buttonClearLog;
private System.Windows.Forms.PictureBox pictureBoxLogo;
private System.Windows.Forms.TabPage tabPageEvents;
private System.Windows.Forms.Label labelYourEvents;
private System.Windows.Forms.ListBox listBoxYourEvents;
private System.Windows.Forms.Label labelNewEvent;
private System.Windows.Forms.ListBox listBoxRegisteredEvents;
private System.Windows.Forms.Button buttonAddEvent;
private System.Windows.Forms.Button buttonRemoveEvent;
private System.Windows.Forms.Button buttonEditEvent;
private System.Windows.Forms.TabControl tabControlMain;
private System.Windows.Forms.TabPage tabPageCells;
private System.Windows.Forms.TabPage tabPageAreas;
private System.Windows.Forms.DataGrid dataGridAreaDB;
private System.Windows.Forms.Button buttonCellSave;
private System.Windows.Forms.Button buttonAreaSave;
private System.Windows.Forms.TextBox textBoxCellDescription;
private System.Windows.Forms.TextBox textBoxAreaDescription;
private System.Windows.Forms.TextBox textBoxArea;
private System.Windows.Forms.Label labelArea;
private System.Windows.Forms.MenuItem menuItemSettings;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label100Pc;
private System.Windows.Forms.Label label0Pc;
private System.Windows.Forms.Label label50Pc;
private System.Windows.Forms.MenuItem menuItemHelp;
private System.Windows.Forms.MenuItem menuItemAbout;
private System.Windows.Forms.Label labelLogTitle;
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.TextBox textBoxLocation;
private System.Windows.Forms.PictureBox pictureBoxLogo_Off;
private System.Windows.Forms.Label label75Pc;
private System.Windows.Forms.Label label25Pc;
private bool m_showDbmValue = false;
private System.Windows.Forms.Label labeldBM;
private System.Windows.Forms.Timer timerUpdate;
private System.Windows.Forms.MenuItem menuItemCellDB;
private string m_currentPictureFilename = "";
#endregion
#region Construction/Initialisation
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new MainForm());
}
public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
private void Form1_Load(object sender, System.EventArgs e)
{
// Create event manager
eventManager = new EventManager( this );
// Configure app based on settings
configureSettings();
// Load cell data
CellDB.Load();
// Set up grids on this form
setupGrids();
// Set up chart
setupChart();
// Set up events from db
refreshEventPage();
cellTracker.SignalChanged += new EventHandler(cellTracker_SignalChanged);
cellTracker.CellChanged += new EventHandler(cellTracker_CellChanged);
cellTracker.AreaChanged += new EventHandler(cellTracker_AreaChanged);
textBoxCellDescription.GotFocus += new EventHandler(textBoxCellDescription_GotFocus);
textBoxCellDescription.LostFocus += new EventHandler(textBoxCellDescription_LostFocus);
textBoxAreaDescription.GotFocus += new EventHandler(textBoxAreaDescription_GotFocus);
textBoxAreaDescription.LostFocus += new EventHandler(textBoxAreaDescription_LostFocus);
Application.DoEvents();
// Update cell tracker
refreshCellData();
// Add first cell twice so you can actually see the signal reading
signalChart.AddReading( cellTracker.Signal );
signalChart.AddReading( cellTracker.Signal );
// Check platform
if ( Environment.OSVersion.Platform == PlatformID.WinCE )
{
// Switch lights on
PPCLib.SetBacklight( PPCLib.PowerState.LowOn );
// Start update thread
timerUpdate.Enabled = true;
}
else
{
MessageBox.Show( "This application is designed to run on a Pocket PC" );
}
}
#endregion
#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(MainForm));
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItemMain = new System.Windows.Forms.MenuItem();
this.menuItemSettings = new System.Windows.Forms.MenuItem();
this.menuItemCellDB = new System.Windows.Forms.MenuItem();
this.menuItemExport = new System.Windows.Forms.MenuItem();
this.menuItemSave = new System.Windows.Forms.MenuItem();
this.menuItemExit = new System.Windows.Forms.MenuItem();
this.menuItemHelp = new System.Windows.Forms.MenuItem();
this.menuItemAbout = new System.Windows.Forms.MenuItem();
this.labelLAC = new System.Windows.Forms.Label();
this.labelCI = new System.Windows.Forms.Label();
this.textBoxLAC = new System.Windows.Forms.TextBox();
this.textBoxCI = new System.Windows.Forms.TextBox();
this.tabControlMain = new System.Windows.Forms.TabControl();
this.tabPageLocation = new System.Windows.Forms.TabPage();
this.labeldBM = new System.Windows.Forms.Label();
this.label25Pc = new System.Windows.Forms.Label();
this.label75Pc = new System.Windows.Forms.Label();
this.pictureBoxLogo = new System.Windows.Forms.PictureBox();
this.label50Pc = new System.Windows.Forms.Label();
this.label0Pc = new System.Windows.Forms.Label();
this.label100Pc = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.labelArea = new System.Windows.Forms.Label();
this.textBoxArea = new System.Windows.Forms.TextBox();
this.progressBarSignal = new System.Windows.Forms.ProgressBar();
this.labelSignal = new System.Windows.Forms.Label();
this.textBoxLocation = new System.Windows.Forms.TextBox();
this.labelLocation = new System.Windows.Forms.Label();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.pictureBoxLogo_Off = new System.Windows.Forms.PictureBox();
this.tabPageAreas = new System.Windows.Forms.TabPage();
this.textBoxAreaDescription = new System.Windows.Forms.TextBox();
this.buttonAreaSave = new System.Windows.Forms.Button();
this.dataGridAreaDB = new System.Windows.Forms.DataGrid();
this.tabPageCells = new System.Windows.Forms.TabPage();
this.buttonCellSave = new System.Windows.Forms.Button();
this.textBoxCellDescription = new System.Windows.Forms.TextBox();
this.dataGridCellDB = new System.Windows.Forms.DataGrid();
this.tabPageEvents = new System.Windows.Forms.TabPage();
this.buttonEditEvent = new System.Windows.Forms.Button();
this.buttonRemoveEvent = new System.Windows.Forms.Button();
this.buttonAddEvent = new System.Windows.Forms.Button();
this.listBoxRegisteredEvents = new System.Windows.Forms.ListBox();
this.labelNewEvent = new System.Windows.Forms.Label();
this.listBoxYourEvents = new System.Windows.Forms.ListBox();
this.labelYourEvents = new System.Windows.Forms.Label();
this.tabPageLog = new System.Windows.Forms.TabPage();
this.labelLogTitle = new System.Windows.Forms.Label();
this.buttonClearLog = new System.Windows.Forms.Button();
this.listBoxLog = new System.Windows.Forms.ListBox();
this.timerUpdate = new System.Windows.Forms.Timer();
//
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menuItemMain);
this.mainMenu1.MenuItems.Add(this.menuItemHelp);
//
// menuItemMain
//
this.menuItemMain.MenuItems.Add(this.menuItemSettings);
this.menuItemMain.MenuItems.Add(this.menuItemCellDB);
this.menuItemMain.MenuItems.Add(this.menuItemExport);
this.menuItemMain.MenuItems.Add(this.menuItemSave);
this.menuItemMain.MenuItems.Add(this.menuItemExit);
this.menuItemMain.Text = "Menu";
//
// menuItemSettings
//
this.menuItemSettings.Text = "Settings";
this.menuItemSettings.Click += new System.EventHandler(this.menuItemSettings_Click);
//
// menuItemCellDB
//
this.menuItemCellDB.Enabled = false;
this.menuItemCellDB.Text = "Cell DB";
this.menuItemCellDB.Click += new System.EventHandler(this.menuItemCellDB_Click);
//
// menuItemExport
//
this.menuItemExport.Enabled = false;
this.menuItemExport.Text = "Export";
this.menuItemExport.Click += new System.EventHandler(this.menuItemExport_Click);
//
// menuItemSave
//
this.menuItemSave.Text = "Save";
this.menuItemSave.Click += new System.EventHandler(this.menuItemSave_Click);
//
// menuItemExit
//
this.menuItemExit.Text = "Exit";
this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
//
// menuItemHelp
//
this.menuItemHelp.MenuItems.Add(this.menuItemAbout);
this.menuItemHelp.Text = "Help";
//
// menuItemAbout
//
this.menuItemAbout.Text = "About";
this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
//
// labelLAC
//
this.labelLAC.Location = new System.Drawing.Point(128, 8);
this.labelLAC.Size = new System.Drawing.Size(32, 20);
this.labelLAC.Text = "LAC:";
//
// labelCI
//
this.labelCI.Location = new System.Drawing.Point(128, 32);
this.labelCI.Size = new System.Drawing.Size(24, 20);
this.labelCI.Text = "CI: ";
//
// textBoxLAC
//
this.textBoxLAC.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
this.textBoxLAC.Location = new System.Drawing.Point(168, 5);
this.textBoxLAC.ReadOnly = true;
this.textBoxLAC.Size = new System.Drawing.Size(40, 20);
this.textBoxLAC.Text = "";
//
// textBoxCI
//
this.textBoxCI.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
this.textBoxCI.Location = new System.Drawing.Point(168, 29);
this.textBoxCI.ReadOnly = true;
this.textBoxCI.Size = new System.Drawing.Size(40, 20);
this.textBoxCI.Text = "";
//
// tabControlMain
//
this.tabControlMain.Controls.Add(this.tabPageLocation);
this.tabControlMain.Controls.Add(this.tabPageAreas);
this.tabControlMain.Controls.Add(this.tabPageCells);
this.tabControlMain.Controls.Add(this.tabPageEvents);
this.tabControlMain.Controls.Add(this.tabPageLog);
this.tabControlMain.SelectedIndex = 0;
this.tabControlMain.Size = new System.Drawing.Size(240, 272);
//
// tabPageLocation
//
this.tabPageLocation.Controls.Add(this.labeldBM);
this.tabPageLocation.Controls.Add(this.label25Pc);
this.tabPageLocation.Controls.Add(this.label75Pc);
this.tabPageLocation.Controls.Add(this.pictureBoxLogo);
this.tabPageLocation.Controls.Add(this.label50Pc);
this.tabPageLocation.Controls.Add(this.label0Pc);
this.tabPageLocation.Controls.Add(this.label100Pc);
this.tabPageLocation.Controls.Add(this.panel1);
this.tabPageLocation.Controls.Add(this.labelArea);
this.tabPageLocation.Controls.Add(this.textBoxArea);
this.tabPageLocation.Controls.Add(this.progressBarSignal);
this.tabPageLocation.Controls.Add(this.labelSignal);
this.tabPageLocation.Controls.Add(this.textBoxLocation);
this.tabPageLocation.Controls.Add(this.labelLocation);
this.tabPageLocation.Controls.Add(this.labelLAC);
this.tabPageLocation.Controls.Add(this.labelCI);
this.tabPageLocation.Controls.Add(this.textBoxLAC);
this.tabPageLocation.Controls.Add(this.textBoxCI);
this.tabPageLocation.Controls.Add(this.pictureBox);
this.tabPageLocation.Controls.Add(this.pictureBoxLogo_Off);
this.tabPageLocation.Location = new System.Drawing.Point(4, 4);
this.tabPageLocation.Size = new System.Drawing.Size(232, 246);
this.tabPageLocation.Text = "Main";
//
// labeldBM
//
this.labeldBM.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular);
this.labeldBM.Location = new System.Drawing.Point(176, 133);
this.labeldBM.Size = new System.Drawing.Size(48, 14);
this.labeldBM.Text = "-113dBM";
this.labeldBM.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// label25Pc
//
this.label25Pc.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular);
this.label25Pc.Location = new System.Drawing.Point(2, 214);
this.label25Pc.Size = new System.Drawing.Size(24, 8);
this.label25Pc.Text = "25%";
this.label25Pc.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// label75Pc
//
this.label75Pc.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular);
this.label75Pc.Location = new System.Drawing.Point(2, 178);
this.label75Pc.Size = new System.Drawing.Size(24, 8);
this.label75Pc.Text = "75%";
this.label75Pc.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// pictureBoxLogo
//
this.pictureBoxLogo.Image = ((System.Drawing.Image)(resources.GetObject("pictureBoxLogo.Image")));
this.pictureBoxLogo.Location = new System.Drawing.Point(8, 8);
this.pictureBoxLogo.Size = new System.Drawing.Size(120, 56);
this.pictureBoxLogo.Visible = false;
//
// label50Pc
//
this.label50Pc.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular);
this.label50Pc.Location = new System.Drawing.Point(2, 195);
this.label50Pc.Size = new System.Drawing.Size(24, 8);
this.label50Pc.Text = "50%";
this.label50Pc.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// label0Pc
//
this.label0Pc.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular);
this.label0Pc.Location = new System.Drawing.Point(2, 232);
this.label0Pc.Size = new System.Drawing.Size(24, 8);
this.label0Pc.Text = "0%";
this.label0Pc.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// label100Pc
//
this.label100Pc.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular);
this.label100Pc.Location = new System.Drawing.Point(2, 160);
this.label100Pc.Size = new System.Drawing.Size(24, 8);
this.label100Pc.Text = "100%";
this.label100Pc.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(26, 160);
this.panel1.Size = new System.Drawing.Size(198, 80);
//
// labelArea
//
this.labelArea.Location = new System.Drawing.Point(8, 68);
this.labelArea.Size = new System.Drawing.Size(48, 20);
this.labelArea.Text = "Area:";
//
// textBoxArea
//
this.textBoxArea.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular);
this.textBoxArea.Location = new System.Drawing.Point(64, 64);
this.textBoxArea.ReadOnly = true;
this.textBoxArea.Size = new System.Drawing.Size(160, 24);
this.textBoxArea.Text = "";
//
// progressBarSignal
//
this.progressBarSignal.Location = new System.Drawing.Point(64, 128);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -