private void ListBox_SelectedIndexChanged(object sender, EventArgs e) { if (isClearing) { return; } ListBox listBox = sender as ListBox; int key = Convert.ToInt32(listBox.Name.Split('_')[1]); CustemFileInfo finfo = listBox.SelectedItem as CustemFileInfo; if (listBox.SelectedIndex != -1) { if (File.Exists(finfo.FullPath)) { DataFormat.AddPicture(key, finfo.FullPath); } } DataFormat.NowFormat(); if (DataFormat.NewPicture.Width <= pictureBox1.Width && DataFormat.NewPicture.Height <= pictureBox1.Height) { pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; } else { pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; } pictureBox1.Image = DataFormat.NewPicture; if (!(iv == null || iv.IsDisposed)) { iv.PictureChange((Bitmap)pictureBox1.Image); } toolStripStatusLabel1.Text = "合成的文件名字:" + DataFormat.SaveFileName; }
private void ListBox_MouseClick(object sender, MouseEventArgs e) { ListBox listBox = sender as ListBox; //MessageBox.Show(((FileInf)listBox.SelectedItem).FullPath); //return; int key = Convert.ToInt32(listBox.Name.Split('_')[1]); CustemFileInfo finfo = listBox.SelectedItem as CustemFileInfo; //尝试自行寻找规则文件。 if (string.IsNullOrEmpty(RuleFilePath)) { try { TryToFindRuleFile(); } catch (Exception ex) { MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (string.IsNullOrEmpty(RuleFilePath)) { SelectTextFile_Click(sender, e); } } } if (listBox.SelectedIndex != -1) { if (File.Exists(finfo.FullPath)) { DataFormat.AddPicture(key, finfo.FullPath); } } DataFormat.NowFormat(); if (DataFormat.NewPicture.Width <= pictureBox1.Width && DataFormat.NewPicture.Height <= pictureBox1.Height) { pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; } else { pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; } pictureBox1.Image = DataFormat.NewPicture; if (!(iv == null || iv.IsDisposed)) { iv.PictureChange((Bitmap)pictureBox1.Image); } toolStripStatusLabel1.Text = "合成的文件名字:" + DataFormat.SaveFileName; }
private void ListBox_DragDrop(object sender, DragEventArgs e) { ListBox listBox = sender as ListBox; if (listBox.Items.Count != 0) { HaveItemListBoxCount--; } listBox.Items.Clear(); string[] array = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string path in array) { CustemFileInfo cfi = new CustemFileInfo(path); if (cfi.Extension == ".png" || cfi.Extension == ".tlg") { if (string.IsNullOrEmpty(examplePicFullName)) { examplePicFullName = path; } if (string.IsNullOrEmpty(saveFullPath)) { saveFullPath = Path.GetDirectoryName(path); savePathBox.Text = saveFullPath; } listBox.Items.Add(cfi); } } if (listBox.Items.Count != 0) { HaveItemListBoxCount++; } //依次打开listbox的限制 switch (HaveItemListBoxCount) { case 1: fgPart_2.BackColor = SystemColors.Window; fgPart_2.AllowDrop = true; break; case 2: fgPart_3.BackColor = SystemColors.Window; fgPart_3.AllowDrop = true; break; case 3: fgPart_4.BackColor = SystemColors.Window; fgPart_4.AllowDrop = true; break; case 4: fgPart_5.BackColor = SystemColors.Window; fgPart_5.AllowDrop = true; break; case 5: fgPart_6.BackColor = SystemColors.Window; fgPart_6.AllowDrop = true; break; case 6: fgPart_7.BackColor = SystemColors.Window; fgPart_7.AllowDrop = true; break; case 7: fgPart_8.BackColor = SystemColors.Window; fgPart_8.AllowDrop = true; break; case 8: fgPart_9.BackColor = SystemColors.Window; fgPart_9.AllowDrop = true; break; case 9: fgPart_10.BackColor = SystemColors.Window; fgPart_10.AllowDrop = true; break; case 10: fgPart_11.BackColor = SystemColors.Window; fgPart_11.AllowDrop = true; break; case 11: fgPart_12.BackColor = SystemColors.Window; fgPart_12.AllowDrop = true; break; } }