Example #1
0
		private void CreateContextMenu()
		{
			System.Windows.Forms.ToolStripMenuItem root = new System.Windows.Forms.ToolStripMenuItem("ユーザー管理(&U)");
			System.Windows.Forms.ToolStripMenuItem getProfileName = new System.Windows.Forms.ToolStripMenuItem("名前を取得");
			System.Windows.Forms.ToolStripMenuItem changeName = new System.Windows.Forms.ToolStripMenuItem("名前をつける");
			System.Windows.Forms.ToolStripMenuItem autoChangeColor = new System.Windows.Forms.ToolStripMenuItem("適当な色をつける");
			System.Windows.Forms.ToolStripMenuItem changeColor = new System.Windows.Forms.ToolStripMenuItem("色を指定する");
			System.Windows.Forms.ToolStripMenuItem reset = new System.Windows.Forms.ToolStripMenuItem("設定をリセットする");

			getProfileName.Click += new EventHandler(getProfileName_Click);
			changeName.Click += new EventHandler(changeName_Click);
			autoChangeColor.Click += new EventHandler(autoChangeColor_Click);
			changeColor.Click += new EventHandler(changeColor_Click);
			reset.Click += new EventHandler(reset_Click);

			root.DropDownItems.Add(getProfileName);
			root.DropDownItems.Add(changeName);
			root.DropDownItems.Add(autoChangeColor);
			root.DropDownItems.Add(changeColor);
			root.DropDownItems.Add(reset);

			// コンテクストメニューへの追加と、メニューが開かれた際の動作を指定
			_host.AddContextMenuItem(root, delegate(object sender, EventArgs e)
			{

				if (_host.IsConnected) {
					_selectedChat = _host.GetSelectedChat();
					if (_selectedChat != null && _users.ContainsKey(_selectedChat.UserId)) {
						_selectedUser = _users[_selectedChat.UserId];
					} else {
						_selectedUser = null;
					}
				}

				root.Enabled = (_selectedChat != null);
				getProfileName.Enabled = (_selectedChat != null && !_selectedChat.Anonymity);
				changeName.Enabled = (_selectedChat != null);
				autoChangeColor.Enabled = (_selectedChat != null);
				changeColor.Enabled = (_selectedChat != null);
				reset.Enabled = (_selectedChat != null && _selectedUser != null);

			});
		}
Example #2
0
		public void Dispose()
		{
			_host = null;
			_dataBase.Dispose();
			_dataBase = null;
			_selectedChat = null;
			_selectedUser = null;
			_users = null;
		}
Example #3
0
		public List<User> GetUsers(string comid) {

			// Select用コマンドオブジェクト作成
			using (DbCommand scmd = _connection.CreateCommand()) {

				string select = "SELECT uid, name, color, date FROM user NATURAL INNER JOIN com_user WHERE com_user.cid = @cid";
				scmd.CommandText = select;

				DbParameter p1 = scmd.CreateParameter();
				p1.ParameterName = "@cid";
				p1.Value = comid;
				scmd.Parameters.Add(p1);

				using (DbDataReader dr = scmd.ExecuteReader()) {
					List<User> users = new List<User>();
					
					while (dr.Read()) { 
						User u = new User((string)dr["uid"], (string)dr["name"], (int)(long)dr["color"], (long)dr["date"]);
						users.Add(u);
					}

					return users;
				}
			}
		}