public void SelectColorAndSave(string ValueToReplace) { DialogResult result = CD1.ShowDialog(); // See if user pressed ok. if (result != DialogResult.OK) { return; } // Set form background to the selected color. //this.BackColor = colorDialog1.Color; string HexColorCode = (CD1.Color.ToArgb() & 0x00FFFFFF).ToString("X6"); int DecimalColorCode = Convert.ToInt32(HexColorCode, 16); string CurrentCommonFile = ""; using (StreamReader reader = new StreamReader(new FileStream(CommonFilePath, FileMode.Open))) { string CurrentLine; while ((CurrentLine = reader.ReadLine()) != null) { if (CurrentLine.Contains(ValueToReplace)) { CurrentCommonFile += ValueToReplace + "\t" + DecimalColorCode + Environment.NewLine; } else { CurrentCommonFile += CurrentLine + Environment.NewLine; } } } File.WriteAllText(CommonFilePath, CurrentCommonFile); }
private void button1_Click(object sender, EventArgs e) { CD1.FileName = textBox4.Text; CD1.ShowDialog(); if (CD1.FileName != "") { textBox4.Text = CD1.FileName; } }
private void btnMiddleOpen_Click(object sender, EventArgs e) { CD1.FileName = ""; CD1.Filter = "*.psd|*.psd"; CD1.ShowDialog(); if (CD1.FileName != "") { txtMiddlePath.Text = CD1.FileName; } }
private void btnSmallOpen_Click(object sender, EventArgs e) { CD1.FileName = ""; CD1.Filter = "*.bmp|*.bmp"; CD1.ShowDialog(); if (CD1.FileName != "") { txtSmallPath.Text = CD1.FileName; } }
private void btnBrower_Click(object sender, EventArgs e) { CD1.FileName = ""; CD1.Filter = "tab文件(*.tab)|*.tab|所有文件(*.*)|*.*"; CD1.ShowDialog(); if (CD1.FileName != "") { tbxArtFile.Text = CD1.FileName; } }
private void btnMiddleOpen2_Click(object sender, EventArgs e) { CD1.FileName = ""; CD1.Filter = "*.ini|*.ini"; CD1.ShowDialog(); if (CD1.FileName != "") { textBoxOld.Text = CD1.FileName; } }
private void buttonX1_Click(object sender, EventArgs e) // 导入 { CD1.Multiselect = true; CD1.Filter = "TGA (*.tga)|*.tga"; DialogResult dr = CD1.ShowDialog(); if (dr == DialogResult.OK) { bool bYesToAll = false; bool bNoToAll = false; bool bCancel = false; foreach (string strSelectedFileName in CD1.FileNames) { if (bCancel) { break; } bool bNeedDoThisTime = false; if (!File.Exists(strSelectedFileName)) { continue; } FileInfo tgafile = new FileInfo(strSelectedFileName); DirectoryInfo dirIcon = new DirectoryInfo(tgaIO.StrIconFolder); if (dirIcon.GetFiles(tgafile.Name).Length > 0) { //包含重复文件 if (bNoToAll) { continue; } else if (bYesToAll) { bNeedDoThisTime = true; } else { respond form = new respond("已经包含同名文件[" + tgafile.Name + "],是否覆盖?"); if (form == null) { MessageBox.Show("G。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } form.ShowDialog(); switch (form.m_respond) { case "yestoall": bYesToAll = true; bNeedDoThisTime = true; break; case "yes": bNeedDoThisTime = true; break; case "no": continue; case "notoall": bNoToAll = true; continue; case "cancel": bCancel = true; break; default: break; } } } else { bNeedDoThisTime = true; } if (bNeedDoThisTime) { //生成文件 //File.Copy(strSelectedFileName, Path.Combine(tgaIO.StrIconFolder, tgafile.Name)); TgaToUitex(strSelectedFileName, tgaIO.StrIconFolder); //导入数据 tgaIO.InsertNewRecord(tgafile.Name.Split(new char[] { '.' })[0] + ".UITex", "", ""); } } this.Visible = false; this.Refresh(); this.Close(); Implement parent = this.Tag as Implement; parent.Init(tgaIO.sqlConn, tgaIO.StrIconFolder); parent.Show(); } }