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); }
public void CanCorrectlyBuildGraph1() { var builder = new ContainerBuilder(); builder.RegisterType <A1>().SingleInstance(); builder.RegisterType <CD1>().As <IC1, ID1>().SingleInstance(); builder.RegisterType <E1>().SingleInstance(); builder.Register(ctr => new B1(ctr.Resolve <A1>())); var target = builder.Build(); E1 e = target.Resolve <E1>(); A1 a = target.Resolve <A1>(); B1 b = target.Resolve <B1>(); IC1 c = target.Resolve <IC1>(); ID1 d = target.Resolve <ID1>(); Assert.IsInstanceOf <CD1>(c); CD1 cd = (CD1)c; Assert.AreSame(a, b.A); Assert.AreSame(a, cd.A); Assert.AreNotSame(b, cd.B); Assert.AreSame(c, e.C); Assert.AreNotSame(b, e.B); Assert.AreNotSame(e.B, cd.B); }
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(); } }