/// <summary> /// ノート新規作成 /// </summary> public void newNote() { NoteForm noteForm = new NoteForm(); notes.Add(noteForm); //ノートのコレクションに追加 noteForm.Owner = this; //MainFormを親フォームとして渡す。 noteForm.Show(); }
/// <summary> /// ノートの読み込み /// </summary> public void loadNotes() { //フォルダ作成 makeDir(); //ノートを読込 IEnumerable <string> files = Directory.EnumerateFiles(@".\Notes"); XmlSerializer serializer = new XmlSerializer(typeof(Settings)); foreach (string file in files) { try { StreamReader sr = new StreamReader(file, new UTF8Encoding(false)); Settings settings = (Settings)serializer.Deserialize(sr); sr.Close(); //ノートを作ってプロパティをセット NoteForm nf = new NoteForm(); notes.Add(nf); nf.Size = settings.Size; nf.Location = settings.Point; Color color = Color.FromArgb(settings.Color); nf.BackColor = color; nf.title = settings.Title; nf.isHyperLink = settings.HyperLink; nf.isTopMost = settings.TopMost; nf.loadRtf(settings.RtfName); nf.StartPosition = FormStartPosition.Manual; nf.Owner = this; nf.Show(); settings = null; } catch { MessageBox.Show("ノートの読み込みに失敗しました。"); } } if (Application.OpenForms.Count == 1) { newNote(); } }