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

📄 cellchooserform.cs

📁 用C#实现的取得CellID和LAC的程序源代码!
💻 CS
字号:
using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using NiceTracker.Events;

namespace NiceTracker
{
	/// <summary>
	/// Summary description for CellChooserForm.
	/// </summary>
	public class CellChooserForm : System.Windows.Forms.Form
	{
		private ArrayList alCells = new ArrayList();
		private ArrayList alSelectedCells = new ArrayList();	

		private EventBase eventBase = null;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.Label labelAvailable;
		private System.Windows.Forms.Label labelEventCells;
		private System.Windows.Forms.ListBox listBoxEventCells;
		private System.Windows.Forms.Button buttonAdd;
		private System.Windows.Forms.Button buttonRemove;
		private System.Windows.Forms.ListBox listBoxCells;
	
		public CellChooserForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
		}

		public CellChooserForm( EventBase evtBase )
		{			
			eventBase = evtBase;

			InitializeComponent();
		}

		/// <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()
		{
			this.listBoxCells = new System.Windows.Forms.ListBox();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.listBoxEventCells = new System.Windows.Forms.ListBox();
			this.labelAvailable = new System.Windows.Forms.Label();
			this.labelEventCells = new System.Windows.Forms.Label();
			this.buttonAdd = new System.Windows.Forms.Button();
			this.buttonRemove = new System.Windows.Forms.Button();
			// 
			// listBoxCells
			// 
			this.listBoxCells.Location = new System.Drawing.Point(8, 16);
			this.listBoxCells.Size = new System.Drawing.Size(224, 93);
			// 
			// listBoxEventCells
			// 
			this.listBoxEventCells.Location = new System.Drawing.Point(8, 160);
			this.listBoxEventCells.Size = new System.Drawing.Size(224, 67);
			// 
			// labelAvailable
			// 
			this.labelAvailable.Size = new System.Drawing.Size(100, 16);
			this.labelAvailable.Text = "Available cells";
			// 
			// labelEventCells
			// 
			this.labelEventCells.Location = new System.Drawing.Point(0, 144);
			this.labelEventCells.Size = new System.Drawing.Size(168, 20);
			this.labelEventCells.Text = "Cells that trigger this event";
			// 
			// buttonAdd
			// 
			this.buttonAdd.Location = new System.Drawing.Point(184, 120);
			this.buttonAdd.Size = new System.Drawing.Size(48, 24);
			this.buttonAdd.Text = "Add";
			this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
			// 
			// buttonRemove
			// 
			this.buttonRemove.Location = new System.Drawing.Point(176, 240);
			this.buttonRemove.Size = new System.Drawing.Size(56, 20);
			this.buttonRemove.Text = "Remove";
			this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
			// 
			// CellChooserForm
			// 
			this.Controls.Add(this.buttonRemove);
			this.Controls.Add(this.listBoxCells);
			this.Controls.Add(this.listBoxEventCells);
			this.Controls.Add(this.buttonAdd);
			this.Controls.Add(this.labelEventCells);
			this.Controls.Add(this.labelAvailable);
			this.Menu = this.mainMenu1;
			this.Text = "Choose cells";
			this.Load += new System.EventHandler(this.CellChooserForm_Load);

		}
		#endregion

		private void CellChooserForm_Load(object sender, System.EventArgs e)
		{			
			bool nullCells = refreshSelectedCells();

			if ( nullCells )
				MessageBox.Show( "Some cells have no names and will be omitted from this list." );
		}

		private bool refreshSelectedCells()
		{
			alCells.Clear();
			alSelectedCells.Clear();

			listBoxCells.Items.Clear();
			listBoxEventCells.Items.Clear();

			bool nullCells = false;
			foreach ( DataRow dr in CellDB.DTCells.Rows )
			{
				GSMCell gsmCell = new GSMCell( dr );
				if ( gsmCell.Description != "" )
				{
					alCells.Add( gsmCell );					
				}
				else
					nullCells = true;
			}

			// Sort list and add to list box
			alCells.Sort( new GSMCellComparer() );
			foreach ( GSMCell gsmCell in alCells )
				listBoxCells.Items.Add( gsmCell.Description );

			foreach ( GSMCell gsmCell in eventBase.ListCells() )
			{
				gsmCell.Description = CellDB.GetCellDescription( gsmCell );				
				alSelectedCells.Add( gsmCell );
				listBoxEventCells.Items.Add( gsmCell.Description );
			}			

			return nullCells;

		}

		private void buttonAdd_Click(object sender, System.EventArgs e)
		{
			if ( listBoxCells.SelectedIndex != -1 )
			{
				GSMCell newCell = alCells[ listBoxCells.SelectedIndex ] as GSMCell;
				alSelectedCells.Add( newCell );
				listBoxEventCells.Items.Add( newCell.Description );
			}
			else
			{
				MessageBox.Show( "Please select a cell" );	
			}
		}

		private void buttonRemove_Click(object sender, System.EventArgs e)
		{
			if ( listBoxEventCells.SelectedIndex != -1 )
			{
				if ( MessageBox.Show( "Are you sure you want to delete this cell?", "Delete cell", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 ) == DialogResult.Yes )
				{
					alSelectedCells.RemoveAt( listBoxEventCells.SelectedIndex );
					listBoxEventCells.Items.RemoveAt( listBoxEventCells.SelectedIndex );
				}				
			}
			else
			{
				MessageBox.Show( "Please select a cell" );	
			}
		}

		private void buttonOk_Click(object sender, System.EventArgs e)
		{
			this.DialogResult = DialogResult.OK;
			this.Close();
		}

		public ICollection SelectedCells
		{
			get
			{
				return alSelectedCells;
			}
		}
	}
}

⌨️ 快捷键说明

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