/// <summary> /// 鼠标双击图片 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件</param> private void canvas_MouseDoubleClick(object sender, MouseEventArgs e) { if (image != null) { int x = (int)((double)e.X * image.Width / canvas.Width); int y = (int)((double)e.Y * image.Height / canvas.Height); Bitmap bmp = new Bitmap(image); if ((x < bmp.Width) && (y < bmp.Height)) { Color pixelColor = bmp.GetPixel(x, y); string id = GetID(pixelColor); if (id != null) { string[] data = dataTable[id] as string[]; SettingForm sForm; if (data != null) { sForm = new SettingForm(data[0], data[1], data[3], itemList); } else { sForm = new SettingForm(id, itemList); } sForm.RootPath = rootPath; DialogResult result = sForm.ShowDialog(); if (result == DialogResult.OK) { if (data != null) // 数据已经初始化过,进行值重设 { data[1] = sForm.AreaName; data[2] = "0"; data[3] = sForm.BackgroundMusic; } else // 初始化数据 { data = new string[4]; data[0] = id; data[1] = sForm.AreaName; data[2] = "0"; data[3] = sForm.BackgroundMusic; dataTable[id] = data; } } } } } }