private void LoadDB() { if (File.Exists(PATH_DAT)) { try { using (FileStream stream = new FileStream(PATH_DAT, FileMode.Open)) { BinaryFormatter formatter = new BinaryFormatter(); MemoStore store = (MemoStore)formatter.Deserialize(stream); rtfDic = store.Dictionary; Bounds = store.Bounds; if (store.Opacity > 0.2) { Opacity = store.Opacity; } txtDic = store.TxtDictionary; } } catch (Exception) { } } else { Bounds = new Rectangle(Point.Empty, Size); } if (rtfDic == null) { StringComparer currentCultureIgnoreCase = StringComparer.CurrentCultureIgnoreCase; rtfDic = new Dictionary <string, string>(currentCultureIgnoreCase); txtDic = new Dictionary <string, string>(currentCultureIgnoreCase); } }
private void SaveDB() { MemoStore graph = new MemoStore(); graph.Bounds = Bounds; graph.Dictionary = rtfDic; graph.TxtDictionary = txtDic; graph.Opacity = Opacity; if (!Directory.Exists(Path.GetDirectoryName(PATH_DAT))) { Directory.CreateDirectory(Path.GetDirectoryName(PATH_DAT)); } BinaryFormatter formatter = new BinaryFormatter(); using (FileStream stream = new FileStream(PATH_DAT, FileMode.Create)) { formatter.Serialize(stream, graph); } }
private void SaveDB() { MemoStore graph = new MemoStore(); graph.Bounds = base.Bounds; graph.Dictionary = this.rtfDic; graph.TxtDictionary = this.txtDic; graph.Opacity = base.Opacity; if(!Directory.Exists(Path.GetDirectoryName(PATH_DAT))) { Directory.CreateDirectory(Path.GetDirectoryName(PATH_DAT)); } BinaryFormatter formatter = new BinaryFormatter(); using(FileStream stream = new FileStream(PATH_DAT, FileMode.Create)) { formatter.Serialize(stream, graph); } }