- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在编写一个名为 Flipper 的程序,它有 3x3 个单元格用于拼图。每个单元格(按钮)最初都是绿色的。当单击某个单元格时,该单元格及其相邻单元格翻转(改变颜色)。另一个需求是撤销功能,即回到上一阶段。我不知道如何实现这个。这些是游戏中发生的主要事情。
public Puzzle(Form1 form1)
{
buttons = new Button[3, 3] { { form1.button1, form1.button2, form1.button3 },
{ form1.button4, form1.button5, form1.button6 },
{ form1.button7, form1.button8, form1.button9 } };
//button reference from form1
}
public void reset()
{
//reset all the colors of buttons in the puzzle to lime
}
public void FlipCells(int row, int col)
{
//when certain button is clicked(this event is done in the form1.cs), say for (0,0) change color of cell (0,0),///(0,1) and (1,0) by calling changeColor method
}
public void changeColor(int row, int col)
{
//test current color of the cell, and change it
}
我要求在名为 Undo 的类中实现撤消功能。任何想法表示赞赏!!!
最佳答案
通过了解上次操作更改的内容,可以实现单个撤消。
事实证明,撤消翻转可以通过...再次翻转来完成。所以只要记住你的最后一步,然后重复它!
如果您记得每步,您可以在游戏的初始状态下多次执行此操作。为此,您可以创建一堆 Action ,移动时插入,撤消时弹出。
更一般地说,要撤消,您需要做三件事:
有时,创建一个反向 Action 非常困难。在这些情况下,在执行操作之前只存储程序状态,然后在用户想要撤消时重新加载它会变得更容易。
关于c# - 如何实现撤销功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7911915/
我目前正在使用 Oracle Database Express Edition 11g 处理一些 GRANT 选项。考虑以下小代码示例,其中一些用户向其他用户授予一些权限: -- User A GRA
我不明白这两个查询之间的区别, 1.修改用户用户名账户锁定;2.REVOKE CREATE SESSION FROM 用户名; 这些查询将如何影响用户? 如果我使用撤销 session ,那么可以进行
我正在尝试撤销以下 Google token API ("Content-type:application/x-www-form-urlencoded",请求类型 POST,https://accou
我不明白这两个查询之间的区别, 1.改变用户用户名账户锁;2.REVOKE CREATE SESSION FROM用户名; 这些查询将如何影响用户? 如果我使用 revoke session 那么可以
在服务器上使用 python 访问 firestore 管理员: import firebase_admin from firebase_admin import credentials, fires
MariaDB 中是否可以撤销用户的权限并同时撤销他授予的用户的权限?到目前为止我已经尝试过类似的事情 REVOKE SELECT ON mysql.sometable FROM 'user'@'%'
如果我使用普通用户帐户创建表: create table test (a text, b text, c text); 同一用户可以对表执行所有操作... john=# \z test
在 PostgreSQL 中,当 super 用户授予任何权限时(例如 GRANT SELECT ON TABLE table_name),只有 super 用户可以撤销它们。 有没有其他 super
我试过使用文档 here但似乎没有帮助。如果可以请给我一个例子。 revoke select (column1, column2) on table from specific_user 没用。 Ac
有没有一种方法可以撤销用户对目录对象(即 information_schema)和 PostgreSQL 表(即 pg_catalog)的权限?我已经尝试了几件事并搜索了网络。我没有任何运气。我读到的
在我的应用程序中,我使用的是 APNS。我已经制作了证书,但我对使用感到困惑。我收到以下错误。 Warning: stream_socket_client(): SSL operation faile
[我检查过类似的帖子,我的问题与其他人的问题略有不同,因为我们有多个应用程序在一个证书下签名] 我们受委托(delegate)为客户开发现有的 iOS 应用程序,现在需要使用他们的证书将其分发到应用程
我的 APNs 证书即将到期,所以我撤销了 APNs 证书(只是为了确保一切正常)。但是 30 分钟后我仍然收到测试推送通知。是因为苹果的缓存吗?会持续多久? 最佳答案 根据您的问题,您的旧证书尚未过
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关于您编写的代码问题的问题必须在问题本身中描述具体问题 — 并且包括有效代码 以重现它。参见 SSC
是否可以在 C# 中执行类似的操作? logger != null ? logger.Log(消息) : ;//如果为 null 则什么都不做 或 记录器!?? logger.Log(消息);//只有
我不小心执行了以下命令: git rm -r . 毫不奇怪,它删除了所有内容。有什么办法可以恢复吗? 最佳答案 尝试: git reset HEAD 如果您没有任何您关心的未提交的更改,那么 git
我们有一个已授予某些权限的应用程序。然后用户从设置 -> 应用程序 -> 权限撤销权限。我提到该应用此时处于后台。 有时,应用会在上述流程发生时崩溃。有什么办法可以解决这个问题吗?我们可以知道何时从应
如何使用 AnkhSvn/VS 2010 撤消/恢复我已提交的更改。 (我很清楚您不能“删除”subversion 存储库中的内容)。 问题很简单, 您正在处理 HEAD(例如 rev 100)。你发
我想知道是否可以撤销 ThinkTecture Identity Server 颁发的 OAuth 2.0 token ,因为我想让我的应用程序注销。 最佳答案 这仅适用于实现 RFC 7009 的
我有一个 grails 应用程序,我希望用户授予我访问他/她的 LinkedIn 帐户的权限,以获取信息并以不同的方式显示它。 我能够做到以下几点: 获取授权码 使用该授权码获取访问 token 我将
我是一名优秀的程序员,十分优秀!