///******************************************************************************* ///(-) /// MODULE NAME : 全付箋紙保存 /// MODULE ID : SaveStickyNotes /// /// PARAMETER IN : /// <param>(in)なし</param> /// PARAMETER OUT : /// <param>(out)なし</param> /// /// RETURN VALUE : /// <returns>なし</returns> /// /// FUNCTION : /// <summary> /// 付箋紙を自動的にXMLファイルに保存する /// </summary> /// ///******************************************************************************* public static void SaveStickyNotes() { TextWriter writer; CStickyNotesCollection notesDataObj = new CStickyNotesCollection(); try { writer = new StreamWriter(m_SaveXMLPath); for (int i = 0; i < NoteListMng.Count; i++) { CNoteProperties obj = new CNoteProperties(); obj.NoteID = NoteListMng[i].ThisNoteProperties.NoteID; obj.Text = NoteListMng[i].ThisNoteProperties.Text; obj.FontString = new SerializableFont(NoteListMng[i].ThisNoteProperties.FontFont); obj.ForeColor = NoteListMng[i].ThisNoteProperties.ForeColor; obj.BackColor = NoteListMng[i].ThisNoteProperties.BackColor; obj.Size = NoteListMng[i].ThisNoteProperties.Size; obj.Location = NoteListMng[i].ThisNoteProperties.Location; obj.Visible = NoteListMng[i].ThisNoteProperties.Visible; obj.Opacity = NoteListMng[i].ThisNoteProperties.Opacity; // リストに追加する notesDataObj.CNoteProperties.Add(obj); obj = null; } xmlSerializer = new XmlSerializer(typeof(CStickyNotesCollection)); xmlSerializer.Serialize(writer, notesDataObj); writer.Close(); } catch (Exception ex) { Debug.WriteLine(MethodBase.GetCurrentMethod() + ": " + ex.Message); } finally { // オブジェクトをクリア xmlSerializer = null; writer = null; } }
///******************************************************************************* ///(-) /// MODULE NAME : 付箋紙ロード /// MODULE ID : LoadStickyNotes /// /// PARAMETER IN : /// <param>(in)なし</param> /// PARAMETER OUT : /// <param>(out)なし</param> /// /// RETURN VALUE : /// <returns>なし</returns> /// /// FUNCTION : /// <summary> /// 呼び出し元の装置を立ち上げたときに、XMLに保存されている付箋紙をロードする /// </summary> /// ///******************************************************************************* public void LoadStickyNotes() { CStickyNotesCollection listObj = new CStickyNotesCollection(); XmlDocument doc; try { bool IsExist = File.Exists(m_SaveXMLPath); if (true == IsExist) { xmlSerializer = new XmlSerializer(typeof(CStickyNotesCollection)); doc = new XmlDocument(); doc.PreserveWhitespace = true; doc.Load(m_SaveXMLPath); using (XmlNodeReader reader = new XmlNodeReader(doc.DocumentElement)) { listObj = (CStickyNotesCollection)xmlSerializer.Deserialize(reader); } // trial 1 end Int32 cnt = listObj.CNoteProperties.Count(); for (int i = 0; i < cnt; i++) { StickyNote.Current_NoteProperties = new CNoteProperties(); // 付箋紙ID StickyNote.Current_NoteProperties.NoteID = i + 1; // テキストボックスの内容 StickyNote.Current_NoteProperties.Text = listObj.CNoteProperties[i].Text; // String型のフォント情報 StickyNote.Current_NoteProperties.FontString = listObj.CNoteProperties[i].FontString; // フォント:stringからFontに変換 System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Font)); Font convertedFont = (Font)tc.ConvertFromString(StickyNote.Current_NoteProperties.FontString.FontString); // Font型のフォント情報 StickyNote.Current_NoteProperties.FontFont = convertedFont; // テキスト表示色 StickyNote.Current_NoteProperties.ForeColor = listObj.CNoteProperties[i].ForeColor; // 背景色 StickyNote.Current_NoteProperties.BackColor = listObj.CNoteProperties[i].BackColor; // サイズ StickyNote.Current_NoteProperties.Size = listObj.CNoteProperties[i].Size; // x,y座標 StickyNote.Current_NoteProperties.Location = listObj.CNoteProperties[i].Location; // 表示/非表示 StickyNote.Current_NoteProperties.Visible = listObj.CNoteProperties[i].Visible; // 明瞭 StickyNote.Current_NoteProperties.Opacity = listObj.CNoteProperties[i].Opacity; // 上記の情報を使って付箋紙を生成する StickyNoteForm = new FormStickyNote(2); if (null != StickyNoteForm) { this.AddtoNoteListMng(StickyNoteForm); UpdateStickyNoteList(); SaveStickyNotes(); StickyNote.Current_NoteProperties.Clear(); } } } listObj = null; } catch (Exception ex) { Debug.WriteLine(MethodBase.GetCurrentMethod() + ": " + ex.Message); } finally { doc = null; xmlSerializer = null; } }