資源簡介
【實例簡介】將包轉到中,就能實現textbox的撤銷與恢復的功能
【部分代碼截圖】
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?DMSkin.Controls;
using?Excel?=?Microsoft.Office.Interop.Excel;
using?System.Reflection;
using?System.Drawing.Imaging;
using?System.Threading;
using?System.IO;
using?System.Data.SqlClient;
using?System.xml;
using?test_Charp.CommandMode;
namespace?test_Charp
{
????public?partial?class?Form1?:?Form
????{
????????Stack?undoStack?=?new?Stack();
????????Stack?redoStack?=?new?Stack();
????????String?oldStr;
????????Boolean?flag?=?true;
?????????public?Form1()
?????????{
????????????InitializeComponent();
????????????this.StartPosition?=?FormStartPosition.CenterScreen;
?????????}????
?????????
?????????private?void?button1_Click(object?sender?EventArgs?e)?//撤銷
?????????{
?????????????if?(undoStack.Count?==?0)
?????????????????return;
?????????????flag?=?false;
?????????????Command?com?=?undoStack.Pop();
?????????????com.undo();
?????????????redoStack.Push(com);
?????????}
?????????private?void?button2_Click(object?sender?EventArgs?e)?//恢復
?????????{
?????????????if?(redoStack.Count?==?0)
?????????????????return;
?????????????flag?=?false;
?????????????Command?com?=?redoStack.Pop();
?????????????com.execute();
?????????????undoStack.Push(com);
?????????}
?????????private?void?textBox1_TextChanged(object?sender?EventArgs?e)
?????????{
?????????????if?(flag)
?????????????{
?????????????????TextChangedCommand?com?=?new?TextChangedCommand((TextBox)textBox1?((TextBox)textBox1).Text?oldStr);
?????????????????undoStack.Push(com);
?????????????????oldStr?=?((TextBox)textBox1).Text;
?????????????}?????????????
?????????????flag?=?true;
?????????}????????
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-06-07?14:56??test_Charp\
?????目錄???????????0??2016-09-30?13:40??test_Charp\test_Charp\
?????目錄???????????0??2016-08-18?14:20??test_Charp\test_Charp\bin\
?????目錄???????????0??2016-08-19?10:55??test_Charp\test_Charp\bin\Debug\
?????文件???????37016??2016-08-11?10:47??test_Charp\test_Charp\bin\Debug\1.gif
?????文件???????16384??2016-08-11?09:44??test_Charp\test_Charp\bin\Debug\AxInterop.IDRCoreLib.dll
?????目錄???????????0??2016-08-19?10:55??test_Charp\test_Charp\bin\Debug\Config\
?????文件?????????154??2016-07-20?09:55??test_Charp\test_Charp\bin\Debug\Config\server.xm
?????文件?????1517568??2015-09-01?14:49??test_Charp\test_Charp\bin\Debug\DMSkin.dll
?????文件?????????992??2016-08-18?13:56??test_Charp\test_Charp\bin\Debug\GA_2016-08-18.csv
?????文件???????10509??2016-06-21?09:22??test_Charp\test_Charp\bin\Debug\hope.xls
?????文件???????16384??2016-09-27?09:59??test_Charp\test_Charp\bin\Debug\Interop.IDRCoreLib.dll
?????文件?????1048576??2002-09-06?12:52??test_Charp\test_Charp\bin\Debug\Microsoft.Office.Interop.Excel.dll
?????文件??????607232??2013-04-26?16:25??test_Charp\test_Charp\bin\Debug\SkinForm.dll
?????文件???????53760??2016-09-30?13:45??test_Charp\test_Charp\bin\Debug\test_Charp.exe
?????文件???????42496??2016-09-30?13:45??test_Charp\test_Charp\bin\Debug\test_Charp.pdb
?????文件???????14328??2016-09-30?13:46??test_Charp\test_Charp\bin\Debug\test_Charp.vshost.exe
?????文件?????????490??2009-06-11?05:14??test_Charp\test_Charp\bin\Debug\test_Charp.vshost.exe.manifest
?????目錄???????????0??2016-09-29?16:40??test_Charp\test_Charp\CommandMode\
?????文件????????1086??2016-09-29?16:40??test_Charp\test_Charp\CommandMode\ComboboxIndexChangedCommand.cs
?????文件?????????219??2016-09-29?09:38??test_Charp\test_Charp\CommandMode\Command.cs
?????文件?????????832??2016-09-29?13:12??test_Charp\test_Charp\CommandMode\TextChangedCommand.cs
?????文件????????1896??2016-09-30?13:40??test_Charp\test_Charp\Form1.cs
?????文件????????3259??2016-09-30?13:31??test_Charp\test_Charp\Form1.Designer.cs
?????文件????????5814??2016-09-30?13:31??test_Charp\test_Charp\Form1.resx
?????目錄???????????0??2016-06-07?14:56??test_Charp\test_Charp\obj\
?????目錄???????????0??2016-09-30?13:45??test_Charp\test_Charp\obj\Debug\
?????文件???????16384??2016-08-11?09:44??test_Charp\test_Charp\obj\Debug\AxInterop.IDRCoreLib.dll
?????文件???????16384??2016-09-27?09:59??test_Charp\test_Charp\obj\Debug\Interop.IDRCoreLib.dll
?????目錄???????????0??2016-06-29?09:26??test_Charp\test_Charp\obj\Debug\Refactor\
?????文件???????15269??2016-08-18?13:47??test_Charp\test_Charp\obj\Debug\ResolveAssemblyReference.cache
............此處省略26個文件信息
評論
共有 條評論