简易备忘录

2024-06-17 16:44
文章标签 简易 备忘录

本文主要是介绍简易备忘录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

目录

一  设计原型效果

二 后台源码


一  设计原型效果

勾选每个选项时,代表已经完成该项,程序会自动删除。

二 后台源码

using Newtonsoft.Json;namespace 简易备忘录
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private string NoteContentPath = Directory.GetCurrentDirectory() + "\\NoteContent.json";List<string> Notes = new List<string>();private void Note_SelectedIndexChanged(object sender, EventArgs e){//移除已完成的事项for (int i = 0; i < this.Note.Items.Count; i++){if (this.Note.GetItemChecked(i)){this.Note.Items.RemoveAt(i);Notes.RemoveAt(i);File.WriteAllText(NoteContentPath, JsonConvert.SerializeObject(Notes));}}}private void Add_Click(object sender, EventArgs e){//弹出记事弹窗Info info = new Info();info.ShowDialog();if (info.IsOk){Note.Items.Add(info.MyInfo);Notes.Add(info.MyInfo);File.WriteAllText(NoteContentPath, JsonConvert.SerializeObject(Notes));}}private void Form1_Load(object sender, EventArgs e){Note.Items.Clear();Notes.Clear();try{Notes = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(NoteContentPath));foreach (var item in Notes){Note.Items.Add(item);}}catch (Exception){}}}
}
namespace 简易备忘录
{public partial class Info : Form{public Info(){InitializeComponent();}public bool IsOk = false;public string MyInfo = "";private void button1_Click(object sender, EventArgs e){MyInfo = contentTxt.Text.Trim();if (MyInfo == ""){MessageBox.Show("内容不能为空。。。");return;}else{IsOk = true;}this.Close();}private void button2_Click(object sender, EventArgs e){IsOk = false;this.Close();}}
}

设计器自动生成代码:

namespace 简易备忘录
{partial class Form1{/// <summary>///  Required designer variable./// </summary>private System.ComponentModel.IContainer components = null;/// <summary>///  Clean up any resources being used./// </summary>/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows Form Designer generated code/// <summary>///  Required method for Designer support - do not modify///  the contents of this method with the code editor./// </summary>private void InitializeComponent(){Note = new CheckedListBox();Add = new Button();SuspendLayout();// // Note// Note.BackColor = SystemColors.InactiveCaption;Note.Font = new Font("Microsoft YaHei UI", 18F, FontStyle.Regular, GraphicsUnit.Point, 134);Note.FormattingEnabled = true;Note.Location = new Point(15, 15);Note.Name = "Note";Note.Size = new Size(536, 554);Note.TabIndex = 0;Note.SelectedIndexChanged += Note_SelectedIndexChanged;// // Add// Add.BackColor = SystemColors.HotTrack;Add.Location = new Point(15, 584);Add.Name = "Add";Add.Size = new Size(536, 29);Add.TabIndex = 1;Add.Text = "添加记事";Add.UseVisualStyleBackColor = false;Add.Click += Add_Click;// // Form1// AutoScaleDimensions = new SizeF(9F, 20F);AutoScaleMode = AutoScaleMode.Font;BackColor = SystemColors.ActiveCaption;ClientSize = new Size(563, 626);Controls.Add(Add);Controls.Add(Note);MaximizeBox = false;Name = "Form1";StartPosition = FormStartPosition.CenterScreen;Text = "备忘录";Load += Form1_Load;ResumeLayout(false);}#endregionprivate CheckedListBox Note;private Button Add;}
}
namespace 简易备忘录
{partial class Info{/// <summary>/// Required designer variable./// </summary>private System.ComponentModel.IContainer components = null;/// <summary>/// Clean up any resources being used./// </summary>/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows Form Designer generated code/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InitializeComponent(){label1 = new Label();contentTxt = new RichTextBox();button1 = new Button();button2 = new Button();SuspendLayout();// // label1// label1.AutoSize = true;label1.Font = new Font("Microsoft YaHei UI", 18F, FontStyle.Regular, GraphicsUnit.Point, 134);label1.Location = new Point(-4, 55);label1.Name = "label1";label1.Size = new Size(107, 39);label1.TabIndex = 0;label1.Text = "内容:";// // contentTxt// contentTxt.Location = new Point(100, 33);contentTxt.Name = "contentTxt";contentTxt.Size = new Size(266, 99);contentTxt.TabIndex = 1;contentTxt.Text = "";// // button1// button1.Location = new Point(100, 159);button1.Name = "button1";button1.Size = new Size(94, 29);button1.TabIndex = 2;button1.Text = "确定";button1.UseVisualStyleBackColor = true;button1.Click += button1_Click;// // button2// button2.Location = new Point(272, 159);button2.Name = "button2";button2.Size = new Size(94, 29);button2.TabIndex = 3;button2.Text = "取消";button2.UseVisualStyleBackColor = true;button2.Click += button2_Click;// // Info// AutoScaleDimensions = new SizeF(9F, 20F);AutoScaleMode = AutoScaleMode.Font;BackColor = SystemColors.GradientActiveCaption;ClientSize = new Size(378, 202);Controls.Add(button2);Controls.Add(button1);Controls.Add(contentTxt);Controls.Add(label1);MaximizeBox = false;MinimizeBox = false;Name = "Info";StartPosition = FormStartPosition.CenterScreen;Text = "记事输入窗口";ResumeLayout(false);PerformLayout();}#endregionprivate Label label1;private RichTextBox contentTxt;private Button button1;private Button button2;}
}

这篇关于简易备忘录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1069985

相关文章

Python结合Flask框架构建一个简易的远程控制系统

《Python结合Flask框架构建一个简易的远程控制系统》这篇文章主要为大家详细介绍了如何使用Python与Flask框架构建一个简易的远程控制系统,能够远程执行操作命令(如关机、重启、锁屏等),还... 目录1.概述2.功能使用系统命令执行实时屏幕监控3. BUG修复过程1. Authorization

python实现简易SSL的项目实践

《python实现简易SSL的项目实践》本文主要介绍了python实现简易SSL的项目实践,包括CA.py、server.py和client.py三个模块,文中通过示例代码介绍的非常详细,对大家的学习... 目录运行环境运行前准备程序实现与流程说明运行截图代码CA.pyclient.pyserver.py参

使用PyQt实现简易文本编辑器

《使用PyQt实现简易文本编辑器》这篇文章主要为大家详细介绍了如何使用PyQt5框架构建一个简单的文本编辑器,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录分析主窗口类 (MyWindow)菜单操作语法高亮 (SyntaxHighlighter)运行程序主要组件代码图示分析实现

5分钟获取deepseek api并搭建简易问答应用

《5分钟获取deepseekapi并搭建简易问答应用》本文主要介绍了5分钟获取deepseekapi并搭建简易问答应用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需... 目录1、获取api2、获取base_url和chat_model3、配置模型参数方法一:终端中临时将加

用Java打造简易计算器的实现步骤

《用Java打造简易计算器的实现步骤》:本文主要介绍如何设计和实现一个简单的Java命令行计算器程序,该程序能够执行基本的数学运算(加、减、乘、除),文中通过代码介绍的非常详细,需要的朋友可以参考... 目录目标:一、项目概述与功能规划二、代码实现步骤三、测试与优化四、总结与收获总结目标:简单计算器,设计

如何用Python绘制简易动态圣诞树

《如何用Python绘制简易动态圣诞树》这篇文章主要给大家介绍了关于如何用Python绘制简易动态圣诞树,文中讲解了如何通过编写代码来实现特定的效果,包括代码的编写技巧和效果的展示,需要的朋友可以参考... 目录代码:效果:总结 代码:import randomimport timefrom math

通过C#和RTSPClient实现简易音视频解码功能

《通过C#和RTSPClient实现简易音视频解码功能》在多媒体应用中,实时传输协议(RTSP)用于流媒体服务,特别是音视频监控系统,通过C#和RTSPClient库,可以轻松实现简易的音视... 目录前言正文关键特性解决方案实现步骤示例代码总结最后前言在多媒体应用中,实时传输协议(RTSP)用于流媒体服

海龟绘图简易教程|Turtle for Python

turtle 是 python 内置的一个比较有趣味的模块,俗称 海龟绘图,它是基于 tkinter 模块打造,提供一些简单的绘图工具,海龟作图最初源自 20 世纪 60 年代的 Logo 编程语言,之后一些很酷的 Python 程序员构建了 turtle 库,让其他程序员只需要 import turtle,就可以在 Python 中使用海龟作图。 原文链接|海龟绘图简易教程 1. 基本

使用jetty和mongodb做个简易文件系统

使用jetty和mongodb做个简易文件系统 - ciaos 时间 2014-03-09 21:21:00   博客园-所有随笔区 原文   http://www.cnblogs.com/ciaos/p/3590662.html 主题  MongoDB  Jetty  文件系统 依赖库: 1,jetty(提供http方式接口) 2,mongodb的java驱动(访问mo

HarmonyOS】ArkTS学习之基于TextTimer的简易计时器的elapsedTime最小时间单位问题

本文旨在纪录自己对TextTimer使用过程的疑惑问题 我在查看教程时候,发现很多博客在onTimer(event: (utc: number, elapsedTime: number) => void) 这里提到elapsedTime:计时器经过的时间,单位为毫秒。我不清楚是否为版本问题。 在我查看version11和version10的api时候,说的都是设置格式的最小单位。 经过个人检验的