示例#1
0
 private void addWall(string f)
 {
     var keyAndName = f.Replace(this.folder, string.Empty);
     this.tabControl.TabPages.Add(keyAndName, keyAndName);
     var newWall = new Wall(f + Path.DirectorySeparatorChar);
     this.walls.Add(newWall);
     this.tabControl.TabPages[keyAndName].Controls.Add(newWall);
     this.tabControl.TabPages[keyAndName].Controls[0].Dock = DockStyle.Fill;
 }
 public StickyNote(string folder, Wall wall)
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     this.folder = folder;
     this.wall = wall;
 }
        public static void loadAll(string folder, Wall wall)
        {
            if(folder == null || folder == string.Empty)
            {
                return;
            }

            var files = Directory.EnumerateFiles(folder, "*.txt", SearchOption.TopDirectoryOnly).ToArray();
            foreach(var file in files)
            {
                var lines = File.ReadAllLines(file);
                if(lines.Length >= 5)
                {
                    var note = new StickyNote(folder, wall);
                    note.id = Guid.Parse(lines[0].Trim());
                    note.textBoxTitle.Text = lines[1].Trim();
                    if(lines[2].Trim() == "Color 1")
                    {
                        note.textBoxNote.BackColor = Color.LightGray;
                    }
                    else if(lines[2].Trim() == "Color 2")
                    {
                        note.textBoxNote.BackColor = Color.Bisque;
                    }
                    else if(lines[2].Trim() == "Color 3")
                    {
                        note.textBoxNote.BackColor = Color.Gold;
                    }
                    else if(lines[2].Trim() == "Color 4")
                    {
                        note.textBoxNote.BackColor = Color.DarkKhaki;
                    }

                    note.Location = new Point(int.Parse(lines[3].Trim()), int.Parse(lines[4].Trim()));
                    note.textBoxNote.Lines = lines.Skip(5).ToArray();
                    wall.addStikyNote(note);
                }
            }
        }