private void richTextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.Control & e.KeyCode == Keys.S) { KanngHelper.SingleKanng(LoadPath).WriteFile(richTextBox1.Text); } }
public void LoadUrl() { // Uri rulpaht = new Uri("http://www.kanng.net"); //webBrowser1.Url = rulpaht; richTextBox1.Text = KanngHelper.SingleKanng(LoadPath).ReadAllText(); List <UrlModel> urlModel = UrlXmlIO.ReadAllUrl(); if (urlModel != null) { foreach (UrlModel model in urlModel) { this.urlPatte1 = new UrlPatte(); urlPatte1.SetModel(model.guid, model.url, model.name); // // urlPatte1 // this.urlPatte1.Cursor = System.Windows.Forms.Cursors.Hand; this.urlPatte1.Location = new System.Drawing.Point(3, 3); this.urlPatte1.Name = "urlPatte1"; this.urlPatte1.Size = new System.Drawing.Size(87, 51); this.urlPatte1.TabIndex = 3; this.flowLayoutPanel1.Controls.Add(this.urlPatte1); } } }
private void richTextBox1_DragDrop(object sender, DragEventArgs e) { Array arrarFileName = (Array)e.Data.GetData(DataFormats.FileDrop); string strFileName = arrarFileName.GetValue(0).ToString(); syntaxTextBox1.Text += strFileName + "\r\n"; KanngHelper.SingleKanng(LoadPath).WriteFile(syntaxTextBox1.Text); }
private void button2_Click(object sender, EventArgs e) { string[] strs = KanngHelper.SingleKanng(LoadPath).ReadAllLines(); bool rlb = false; string errorFiles = ""; if (strs != null) { foreach (string str in strs) { try { if (!string.IsNullOrEmpty(str)) { //跳过注释 if (!str.StartsWith("#")) { rlb |= true; Process.Start(str); Thread.Sleep(Limetime); //if (File.Exists(str) || Directory.Exists(str)) //{ //} ////else if (Directory.Exists(str)) ////{ //// rlb |= true; //// Process.Start("Explorer.exe", str); //// Thread.Sleep(Limetime); ////} //else //{ // errorFiles += str + "\r\n"; //} } } } catch (Exception ex)//容错处理 { errorFiles += str + "\r\n"; } } } if (!rlb) { MessageBox.Show("没有需要启动的文件,您可以拖动文件到界面来添加文件!"); } if (errorFiles.Length > 0) { MessageBox.Show("没有启动成功的文件:\r\n" + errorFiles); } }
private void 保存ToolStripMenuItem_Click(object sender, EventArgs e) { if (tabControl1.SelectedIndex == 3) { KanngHelper.SingleKanng(LoadPath).WriteHostsFile(richTextBox2.Text); } else { KanngHelper.SingleKanng(LoadPath).WriteFile(richTextBox1.Text); } }
private void tabPage1_DragDrop(object sender, DragEventArgs e) { string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); int i; if (s != null) { for (i = 0; i < s.Length; i++) { richTextBox1.Text += s[i] + "\r\n"; } } KanngHelper.SingleKanng(LoadPath).WriteFile(richTextBox1.Text); }
public void Save() { new Thread(() => { Action <string> action = (s) => { toolStripProgressBar1.Visible = true; toolStripStatusLabel1.Text = s; toolStripProgressBar1.Value = 0; while (toolStripProgressBar1.Value < 100) { toolStripProgressBar1.PerformStep(); } }; this.Invoke(action, LoadPath + "项目正在保存"); Thread.Sleep(1000); this.Invoke(action, LoadPath + "项目保存完成"); }).Start(); if (tabControl1.SelectedIndex == 3) { TaskHelper.Single().WriteFile(syntaxTextBox2.Text); } else if (tabControl1.SelectedIndex == 2) { if (tabControl2.SelectedIndex == 1) { KanngHelper.SingleKanng(LoadPath).WriteHostsFile(richTextBox2.Text); } else if (tabControl2.SelectedIndex == 2) { KanngHelper.SingleKanng(LoadPath).WriteHostsFile(richTextBox1.Text); } } else { KanngHelper.SingleKanng(LoadPath).WriteFile(syntaxTextBox1.Text); } }