private void button7_Click(object sender, EventArgs e) { string NBXDir = null; mAppInterface.GetAppDirEx(mAppInterface.AppName_NBX, ref NBXDir); string DIYPath = NBXDir + "\\data\\diycards.dll"; this.Text = "数据读入中,请稍候"; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "DIY卡数据文件 (diycards.dll)|diycards.dll|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 0; openFileDialog1.RestoreDirectory = true; string dirpath = DB2Config.GetInstance().GetSetting("DeckPath") + "..\\"; if (!Directory.Exists(dirpath)) { dirpath = appPath + "\\Image\\"; } if (!Directory.Exists(dirpath)) { dirpath = appPath; } openFileDialog1.InitialDirectory = dirpath; if (openFileDialog1.ShowDialog() == DialogResult.OK) { CardsReader mReader = new DIYReader(); CardLibrary cardLibrary = new CardLibrary(mReader.Read(openFileDialog1.FileName, ProcessChanged)); this.Text = "索引建立中,请稍候"; CardsSaver lSaver = new LuceneSaver(); lSaver.Save("DIYCardIndex", cardLibrary.GetCards(), ProcessChanged); this.Text = "辅助转换工具"; MessageBox.Show("索引建立完成!"); } this.Text = "辅助转换工具"; }
private void button8_Click(object sender, EventArgs e) { string DIYImageDir = null; mAppInterface.GetDIYCardImgDirEx(ref DIYImageDir); if (!Directory.Exists(DIYImageDir)) { DIYImageDir = DB2Config.GetInstance().GetSetting("DIYImagePath"); } if (!Directory.Exists(DIYImageDir)) { string NBXDir = null; mAppInterface.GetAppDirEx(mAppInterface.AppName_NBX, ref NBXDir); if (!Directory.Exists(NBXDir)) { string NBXPath = DB2Config.GetInstance().GetSetting("NBXPath"); FileInfo fi = new FileInfo(NBXPath); NBXDir = fi.Directory.FullName + "\\"; } DIYImageDir = NBXDir + "\\data\\diyimg\\"; } FolderBrowserDialog openFolderDialog1 = new FolderBrowserDialog(); openFolderDialog1.SelectedPath = DIYImageDir; openFolderDialog1.Description = "请选择DIY卡图所在目录"; openFolderDialog1.ShowNewFolderButton = false; if (openFolderDialog1.ShowDialog() == DialogResult.OK) { DIYImageDir = openFolderDialog1.SelectedPath; } else { return; } this.Text = "转换中,请稍候"; DisableAllButton(); //建立文件夹 string outdirname = appPath + "\\LargeIco\\"; if (!Directory.Exists(outdirname)) { Directory.CreateDirectory(outdirname); } //转换大图标 ImageList imagelist = new ImageList(); imagelist.ImageSize = new Size(47, 67); imagelist.ColorDepth = ColorDepth.Depth32Bit; imagelist.TransparentColor = Color.White; //计算数量 int total = 0; foreach (string sf in Directory.GetFiles(DIYImageDir)) { FileInfo f = new FileInfo(sf); if (string.Equals(f.Extension, ".jpg", StringComparison.OrdinalIgnoreCase)) { total++; } } string stotal = total.ToString(); progressBarX1.Maximum = total; int i = 0; foreach (string sf in Directory.GetFiles(DIYImageDir)) { FileInfo f = new FileInfo(sf); if (string.Equals(f.Extension, ".jpg", StringComparison.OrdinalIgnoreCase)) { string id = f.Name.Substring(0, f.Name.LastIndexOf('.')); string filename = outdirname + "\\" + id + ".jpg"; if (!File.Exists(filename)) { try { imagelist.Images.Add(Image.FromFile(f.FullName)); imagelist.Images[0].Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg); imagelist.Images.RemoveAt(0); } catch { } } i++; progressBarX1.Value = i; progressBarX1.Text = i.ToString() + "/" + stotal; Application.DoEvents(); } } this.Text = "辅助转换工具"; EnableAllButton(); MessageBox.Show("完成!"); }
private void button4_Click(object sender, EventArgs e) { string dirname = DB2Config.GetInstance().GetSetting("ImagePath"); { MessageBox.Show("请选择卡图所在目录"); FolderBrowserDialog openFolderDialog1 = new FolderBrowserDialog(); openFolderDialog1.RootFolder = Environment.SpecialFolder.MyComputer; string dirpath = DB2Config.GetInstance().GetSetting("ImagePath"); if (!Directory.Exists(dirpath)) { dirpath = appPath + "\\Image\\"; } if (!Directory.Exists(dirpath)) { dirpath = appPath; } openFolderDialog1.SelectedPath = dirpath; if (openFolderDialog1.ShowDialog() == DialogResult.OK) { dirname = openFolderDialog1.SelectedPath; } else { return; } } this.Text = "转换中,请稍候"; //建立文件夹 string outdirname = appPath + "\\LargeIco\\"; if (!Directory.Exists(outdirname)) { Directory.CreateDirectory(outdirname); } setInProcess(true); //转换大图标 ImageList imagelist = new ImageList(); imagelist.ImageSize = new Size(47, 67); imagelist.ColorDepth = ColorDepth.Depth32Bit; imagelist.TransparentColor = Color.White; int pc = 0; foreach (string sf in Directory.GetFiles(dirname)) { FileInfo f = new FileInfo(sf); if (string.Equals(f.Extension, ".jpg", StringComparison.OrdinalIgnoreCase)) { string id = f.Name.Substring(0, f.Name.LastIndexOf('.')); string filename = outdirname + "\\" + id + ".jpg"; if (!File.Exists(filename)) { try { imagelist.Images.Add(Image.FromFile(f.FullName)); imagelist.Images[0].Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg); imagelist.Images.RemoveAt(0); } catch { } } } pc++; spStat.Text = "正在转换:" + pc.ToString(); Application.DoEvents(); } this.Text = "辅助转换工具"; MessageBox.Show("完成!"); setInProcess(false); spStat.Text = "准备就绪"; }