/// <summary> /// 保存操作信息 /// </summary> /// <param name="richTextBox"></param> /// <returns></returns> public bool SaveLogcatMessage(string messagePath, RichTextBox richTextBox) { try { if (!File.Exists(messagePath)) { File.Create(messagePath); } TextRange documentTextRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd); if (!string.IsNullOrWhiteSpace(documentTextRange.Text)) { if (!File_Encode_Operate.AppendToTextFileAndHideFile(messagePath, documentTextRange.Text)) { MessageBox.Show("保存数据失败!"); } } return(true); } catch (DirectoryNotFoundException de) { return(false); } catch (Exception ex) { return(false); } }
private void Save() { //获取要保存的参数 string content = ""; //保存静态账户数据 if (this.staticAccountCollection.Count > 0) { foreach (AccountClass a in this.staticAccountCollection) { content += a.ToString() + "#"; } } //保存动态账户数据 if (this.dynamicAccountCollection.Count > 0) { foreach (AccountClass a in this.dynamicAccountCollection) { content += a.ToString() + "#"; } } //保存参数 if (!File_Encode_Operate.SaveToTextFileAndHideFile(this.dataSavePath, content)) { //参数保存失败 MessageBox.Show("参数保存失败!"); } //保存年度计划 if (this.annualTargetList.Count > 0) { if (!Annual.Save(this.annualSavePath, this.annualTargetList)) { //参数保存失败 MessageBox.Show("参数保存失败!"); } } //保存logcat信息 SaveLogcatMessage(this.infoSavePath, this.logcatRtb); //根据设定更新版本信息 updateVersion(); }
/// <summary> /// 载入RTF信息 /// </summary> /// <param name="richTextBox"></param> private void LoadRTFInfos(RichTextBox richTextBox) { string[] ss = File_Encode_Operate.LoadFromHiddenTextFile(messagePath); if (ss != null && ss.Length > 0) { messages = ""; foreach (string s in ss) { if (!string.IsNullOrWhiteSpace(s.Replace("\r\n", " "))) { messages += s; } } richTextBox.AppendText(messages); } }
/// <summary> /// 加载存储的参数值 /// </summary> private void LoadSaveDatas() { string[] datas = File_Encode_Operate.LoadFromHiddenTextFile(dataSavePath); //读取文件成功,加载信息 if (datas != null) { string[] fields = datas[0].Split("#".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); if (fields != null && fields.Length > 0) { //依次加载所有的对象 foreach (string s in fields) { if (!string.IsNullOrWhiteSpace(s)) { AccountClass a; //初始化对象 if (AccountClass.Load(s, out a)) { //收支型和信用卡类型的账户放入datagrid中显示 if (a.AccoutType1 == AccountClass.AccoutType.收支 || a.AccoutType1 == AccountClass.AccoutType.信用卡 || a.AccoutType1 == AccountClass.AccoutType.现金) { this.dynamicAccountCollection.Add(a); } //其他账户静态显示,不能由用户直接更改 else { this.staticAccountCollection.Add(a); } } } } } } }