Exemple #1
0
        public void SaveFile()
        {
            string     str = System.IO.Directory.GetCurrentDirectory();
            FileStream fs  = new FileStream(str + "\\data.txt", FileMode.Open);

            fs.Seek(0, SeekOrigin.Begin);
            fs.SetLength(0);
            fs.Close();
            //Directory.Delete((str + "\\data.txt"),true);
            //FileStream fs1 = new FileStream((str + "\\data.txt"), FileMode.Create, FileAccess.Write);
            using (System.IO.StreamWriter file = new System.IO.StreamWriter((str + "\\data.txt"), true))
            {
                for (int i = 0; i < _items.Count; i++)
                {
                    object i_ditem = _items[i];
                    ditem  j_ditem = (ditem)i_ditem;
                    file.WriteLine("@" + j_ditem._l.Text + "#");// 直接追加文件末尾,换行
                }
                foreach (Form1 s in sonForm)
                {
                    foreach (Form1.item i in s._items._item)
                    {
                        string id = Convert.ToString(s.f_id);
                        file.WriteLine("文件序号:" + id + "#文件内容:" + i._l.Text + "#");
                    }
                }
                file.Close();
            }
        }
Exemple #2
0
 private void TextBox_MouseUp(object sender, MouseEventArgs e)//鼠标抬起换位置
 {
     if (e.Button == MouseButtons.Left)
     {
         Point mousePos = Control.MousePosition;
         mousePos.Offset(mouse_offset.X, mouse_offset.Y);
         bool down = false;
         foreach (ditem i in _items)
         {
             {
                 ditem t = (ditem)i;
                 if (mouse_offset.X - t._l.Location.X != 0 && mouse_offset.Y - t._l.Location.Y != 0)
                 {
                     if (((Control)sender).Parent.PointToClient(mousePos).X - t._l.Location.X <= 100 && ((Control)sender).Parent.PointToClient(mousePos).X - t._l.Location.X >= -100)
                     {
                         if (((Control)sender).Parent.PointToClient(mousePos).Y - t._l.Location.Y <= 50 && ((Control)sender).Parent.PointToClient(mousePos).Y - t._l.Location.Y >= -50)
                         {
                             int x = t._l.Location.X;
                             int y = t._l.Location.Y;
                             t.setlocation(((Control)sender).Location.X, ((Control)sender).Location.Y);
                             ((Control)sender).Location = new Point(x, y);
                             down = true;
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #3
0
        public ArrayList sonForm  = new ArrayList(); //子窗口数组
                                                     //GlobalMouseHandler
        public void Read(string path)                //初始化读文件还原上次关闭
        {
            StreamReader sr = new StreamReader(path);

            string[] result = Regex.Matches(File.ReadAllText(path), @"(?<=@).*?(?=#)").Cast <Match>().Select(S => S.Value.Trim()).ToArray();
            foreach (string line in result)
            {
                this.panel2.VerticalScroll.Value = panel2.VerticalScroll.Minimum;   //滚动条
                                                                                    //System.Threading.Thread.Sleep(500);


                Label l = new Label();                                               //文本框label
                l.Location = new System.Drawing.Point(8 + (text_cont % 2) * 200, 18 + (text_cont / 2) * 100);

                l.Name         = "新文件夹";
                l.Size         = new System.Drawing.Size(180, 85);
                l.TabIndex     = 6;
                l.BackColor    = Color.FromArgb(35, 35, 35);
                l.Text         = line;
                l.TextAlign    = System.Drawing.ContentAlignment.MiddleCenter;
                l.DoubleClick += new System.EventHandler(this.document_Click);
                l.Click       += new System.EventHandler(this.move_Click);
                l.Font         = new System.Drawing.Font("等线", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                l.Tag          = _id;
                //用于移动
                l.MouseDown += new System.Windows.Forms.MouseEventHandler(TextBox_MouseDown);
                l.MouseUp   += new System.Windows.Forms.MouseEventHandler(TextBox_MouseUp);
                l.Click     += new System.EventHandler(this.Edit_Click_l);


                /*Button edit = new Button();                                         //编辑按钮
                 * edit.Location = new System.Drawing.Point(150, 6);
                 * edit.Name = "E";
                 * edit.Size = new System.Drawing.Size(25, 25);
                 * edit.TabIndex = 1;
                 * edit.Text = "E";
                 * edit.UseVisualStyleBackColor = true;
                 * edit.Click += new System.EventHandler(this.Edit_Click);
                 * edit.Tag = _id;*/


                TextBox t = new TextBox();                                          //重命名时的修改框
                t.Location     = new System.Drawing.Point(8 + (text_cont % 2) * 200, 18 + (text_cont / 2) * 100);
                t.Name         = "textBox";
                t.Size         = new System.Drawing.Size(180, 85);
                t.Text         = l.Text;
                t.Font         = new System.Drawing.Font("等线", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                t.TabIndex     = 1;
                t.TextChanged += new System.EventHandler(this.TextChanged);
                t.DoubleClick += new System.EventHandler(this.t_Edit_Click);
                t.Multiline    = true;
                t.Tag          = _id;
                text_cont++;

                this.panel2.Controls.Add(l);                            //添加操作,不用改
                                                                        //l.Controls.Add(edit);
                this.panel2.Controls.Add(t);
                t.Visible = false;
                ditem i = new ditem();
                i._l = l;
                //i._del = edit;
                i._t = t;
                i.id = _id++;
                _items.Add(i);
            }

            sr.Close();
        }
Exemple #4
0
        private void AddButton_Click(object sender, EventArgs e)                //添加ditem, for_HYL UI主要在这里改
        {
            this.panel2.VerticalScroll.Value = panel2.VerticalScroll.Minimum;   //滚动条
            //System.Threading.Thread.Sleep(500);


            Label l = new Label();                                               //文本框label

            l.Location = new System.Drawing.Point(8 + (text_cont % 2) * 200, 18 + (text_cont / 2) * 100);

            l.Name         = "新文件夹";
            l.Size         = new System.Drawing.Size(180, 85);
            l.TabIndex     = 6;
            l.BackColor    = Color.FromArgb(35, 35, 35);
            l.Text         = "新文件夹";
            l.TextAlign    = System.Drawing.ContentAlignment.MiddleCenter;
            l.DoubleClick += new System.EventHandler(this.document_Click);
            l.Click       += new System.EventHandler(this.move_Click);
            l.Font         = new System.Drawing.Font("等线", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            l.Tag          = _id;
            //用于移动
            l.MouseDown += new System.Windows.Forms.MouseEventHandler(TextBox_MouseDown);
            l.MouseUp   += new System.Windows.Forms.MouseEventHandler(TextBox_MouseUp);
            l.Click     += new System.EventHandler(this.Edit_Click_l);


            /*Button edit = new Button();                                         //编辑按钮
             * edit.Location = new System.Drawing.Point(150, 6);
             * edit.Name = "E";
             * edit.Size = new System.Drawing.Size(25, 25);
             * edit.TabIndex = 1;
             * edit.Text = "E";
             * edit.UseVisualStyleBackColor = true;
             * edit.Click += new System.EventHandler(this.Edit_Click);
             * edit.Tag = _id;*/


            TextBox t = new TextBox();                                          //重命名时的修改框

            t.Location     = new System.Drawing.Point(8 + (text_cont % 2) * 200, 18 + (text_cont / 2) * 100);
            t.Name         = "textBox";
            t.Size         = new System.Drawing.Size(180, 85);
            t.Text         = l.Text;
            t.Font         = new System.Drawing.Font("等线", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            t.TabIndex     = 1;
            t.TextChanged += new System.EventHandler(this.TextChanged);
            t.DoubleClick += new System.EventHandler(this.t_Edit_Click);
            t.Multiline    = true;
            t.Tag          = _id;
            text_cont++;

            this.panel2.Controls.Add(l);                            //添加操作,不用改
            //l.Controls.Add(edit);
            this.panel2.Controls.Add(t);
            t.Visible = false;
            ditem i = new ditem();

            i._l = l;
            //i._del = edit;
            i._t = t;
            i.id = _id++;
            _items.Add(i);
        }