コード例 #1
0
 private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Control & e.KeyCode == Keys.S)
     {
         KanngHelper.SingleKanng(LoadPath).WriteFile(richTextBox1.Text);
     }
 }
コード例 #2
0
        public static KanngHelper SingleKanng(string path)
        {
            KanngHelper single = new KanngHelper(FilePath);

            FilePath = System.AppDomain.CurrentDomain.BaseDirectory + "data\\" + path + "\\" + "\\data\\kanng.data";
            return(single);
        }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            DialogResult dr  = MessageBox.Show("确定要启动吗?", "确认", MessageBoxButtons.YesNo);
            bool         rlb = false;

            if (dr == DialogResult.Yes)
            {
                string[] strs       = KanngHelper.ReadAllLines();
                string   errorFiles = "";
                if (strs != null)
                {
                    foreach (string str in strs)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            //跳过注释
                            if (!str.StartsWith("#"))
                            {
                                if (File.Exists(str))
                                {
                                    rlb |= true;
                                    Process.Start(str);
                                }
                                else if (Directory.Exists(str))
                                {
                                    rlb |= true;
                                    Process.Start("Explorer.exe", str);
                                }
                                else
                                {
                                    errorFiles += str + "\r\n";
                                }
                            }
                        }
                        Thread.Sleep(200);
                    }
                }

                if (!rlb)
                {
                    MessageBox.Show("没有需要启动的文件,您可以拖动文件到界面来添加文件!");
                }
                if (errorFiles.Length > 0)
                {
                    MessageBox.Show("没有启动成功的文件:\r\n" + errorFiles);
                }
            }


            beginMove        = true;
            currentXPosition = MousePosition.X;
            currentYPosition = MousePosition.Y;
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
 private void 保存SToolStripMenuItem_Click(object sender, EventArgs e)
 {
     KanngHelper.WriteFile(richTextBox1.Text);
 }