public void Execute(HistoryAction action) { action.Do(); futureActions.Clear(); historyActions.Push(action); }
public async Task <IHttpActionResult> PutHistoryAction(int id, HistoryAction historyAction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != historyAction.Id) { return(BadRequest()); } db.Entry(historyAction).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HistoryActionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void PerformAndRecord(HistoryAction action, bool onlyRecord = false) { //If there are undos, erase them if (actionStack.Count != index) { actionStack.RemoveRange(index, actionStack.Count - index); Debug.Log("Erased saved Undos because an a new action has been performed"); } Debug.Log("Performed and recorded " + action.GetType() + " to the actionStack"); actionStack.Add(action); if (!onlyRecord) { actionStack[index].PerformAction(); } index++; //cap the number of recorded actions while (actionStack.Count > maxUndos) { Debug.Log("Removed last entry of the history manager, as it's full"); actionStack.RemoveAt(0); index--; } }
void loadSelectedHistoryItems(HistoryAction action) { Logger.LogDebug("WQE.net", 1, "Loading selected history items\n"); if (null == historyEntriesView.CurrentRow) { return; } List <int> sel_indexes = new List <int>(); foreach (DataGridViewRow row in historyDetailsView.SelectedRows) { sel_indexes.Add(row.Index); } sel_indexes.Sort(); String sql = dbSqlEditorBE.restore_sql_from_history(historyEntriesView.CurrentRow.Index, sel_indexes); String action_name = ""; switch (action) { case HistoryAction.HistoryAppendToEditor: action_name = "append"; break; case HistoryAction.HistoryReplaceEditor: action_name = "replace"; break; case HistoryAction.HistoryCopyToClipboard: action_name = "copy"; break; } dbSqlEditorBE.handle_history_action(action_name, sql); Logger.LogDebug("WQE.net", 1, "Done loading selected history items\n"); }
private (HistoryAction action, int entry) GetAction(CommandContext context) { HistoryAction action = HistoryAction.Unknown; int entry = 0; if (context.Arguments.Length == 0) { // No arguments, just list the current history action = HistoryAction.List; } else if (int.TryParse(context.Arguments[0], out entry)) { // Recall and execute the specified command entry action = HistoryAction.Recall; } else { // One of the predefined history actions string actionText = context.CleanArgument(0); if (!Enum.TryParse <HistoryAction>(actionText, out action)) { action = HistoryAction.Unknown; } } return(action, entry); }
public void EditedWithAction(HistoryAction action) { if (Edited != null) { Edited(this, new ScreenEditEventArgs(action)); } }
public void Highlight(SubItem item, bool fromHistory) { if (!fromHistory) { if (currentSelected == null) { HistoryAction ha = new HistoryAction(ActionType.SelectSubItem, ActionType.DeselectSubItem, item, null); HistoryManager.instance.AddHistory(ha); } else { HistoryAction ha = new HistoryAction(ActionType.SelectSubItem, ActionType.SelectBackItem, item, currentSelected); HistoryManager.instance.AddHistory(ha); } } currentSelected = item; foreach (SubItem i in gtDisplayList) { i.Dark(); } if (item != null) { item.Highlight(); } }
void applyDeletionChanges(HistoryAction action, object obj) { TileChangesRegion changes = obj as TileChangesRegion; if (action == HistoryAction.Undo) { SelectionRectangle = new Rectangle(changes.Offset.X, changes.Offset.Y, changes.Region.Width, changes.Region.Height); } else { SelectionRectangle = Rectangle.Empty; } Rectangle offsetRect = new Rectangle(0, 0, changes.Region.Width, changes.Region.Height), changeRect = offsetRect; changeRect.X = Math.Max(0, changes.Offset.X); changeRect.Y = Math.Max(0, changes.Offset.Y); for (int x = changes.Offset.X, ox = 0; x < changes.Offset.X + changes.Region.Width; x++, ox++) { for (int y = changes.Offset.Y, oy = 0; y < changes.Offset.Y + changes.Region.Height; y++, oy++) { if (PointInWorld(x, y) && changeRect.Contains(x, y) && offsetRect.Contains(ox, oy)) { SetTile(x, y, changes.Region[ox, oy], changes.Layer); } } } SelectLayer(changes.Layer); }
public void AddThink(bool fromHistory) { GameObject act = Instantiate(lThink, content); act.AddComponent <LinkDrag>(); Button btn = act.GetComponent <Button>(); btn.onClick.RemoveAllListeners(); int count = Session.actionList.Count; content.GetComponent <RectTransform>().sizeDelta += new Vector2(200, 0); Transform actBtn = act.transform.GetChild(1); actBtn.gameObject.SetActive(true); Link newLink = new Link(LinkType.Think, true); Session.actionList.Add(newLink); AddSubItem(actBtn, newLink); if (!fromHistory) { HistoryAction ha = new HistoryAction(ActionType.AddThink, ActionType.RemoveThink); HistoryManager.instance.AddHistory(ha); } }
public static void Save(IHistory orgHistory, User user, HistoryAction action = HistoryAction.Создал) { HistoryList historyList = HistoryList.GetUniqueInstance(); History history; if (action == HistoryAction.Удалил) { history = new History(orgHistory, user); history.Action = action; } else { var list = historyList.GetList(orgHistory); if (list.Count == 2) { history = historyList.GetItem(orgHistory, HistoryAction.едактировал); history._user = user; } else { history = new History(orgHistory, user); history.Action = (list.Count == 0) ? HistoryAction.Создал : HistoryAction.едактировал; } } history._datetime = DateTime.Now; history.Save(); historyList.Add(history); }
public static void Save(IHistory orgHistory, User user, HistoryAction action = HistoryAction.Создал) { HistoryList historyList = HistoryList.GetUniqueInstance(); History history; if (action == HistoryAction.Удалил) { history = new History(orgHistory, user); history.Action = action; } else { var list = historyList.GetList(orgHistory); if (list.Count == 2) { history = historyList.GetItem(orgHistory, HistoryAction.Редактировал); history._user = user; } else { history = new History(orgHistory, user); history.Action = (list.Count == 0) ? HistoryAction.Создал : HistoryAction.Редактировал; } } history._datetime = DateTime.Now; history.Save(); historyList.Add(history); }
private void UpdateClient(Client client, HistoryAction action) { using (var tran = DataContext.Connection.BeginTransaction()) { DataContext.Transaction = tran; ClientsHistory hst = new ClientsHistory() { AccountId = client.AccountId, Action = action, CreatedByClientId = client.CreatedByClientId, DateCreated = client.DateCreated, DeallerOfClientId = client.DeallerOfClientId, Id = client.Id, IsDeleted = client.IsDeleted, OrganizationName = client.OrganizationName, Status = client.Status, ManagerId = LoginedUser == null ? (Guid?)null : (Guid)LoginedUser.ProviderUserKey, OperationalClientId = OperationalClientId, RealClientId = RealClientId, VersionDate = DateTime.Now }; DataContext.ClientsHistories.InsertOnSubmit(hst); DataContext.SubmitChanges(); tran.Commit(); } }
private void buttonAdd_Click(object sender, EventArgs e) { string maKh = textBoxMaKHoa.Text; string tenKh = textBoxTenKhoa.Text; int adminID = Admin.getAdminIdByUser(a.User1); if (adminID == 0) { MessageBox.Show("Can't not find out " + a.User1); return; } if (maKh.Length != 0 && tenKh.Length != 0) { Khoa k = new Khoa(maKh, tenKh); //add khoa if (Khoa.insertKhoa(k)) { MessageBox.Show("Add Khoa Success"); } DateTime d = DateTime.Now; if (HistoryAction.insertHistoryAction(adminID, "Insert", d, "Insert Khoa with MaKhoa = " + k.MaKhoa1 + " and " + k.TenKhoa1)) { MessageBox.Show("Add History Success"); } } else { MessageBox.Show("You must input Data!"); } }
private void button1_Click(object sender, EventArgs e) { string maMon = (string)textBoxMaMon.Text; string tenMon = (string)textBoxTenMon.Text; string slot = (string)textBoxSlot.Text; if (!checkFormat(maMon, tenMon, slot)) { return; } int adminID = Admin.getAdminIdByUser(a.User1); if (adminID == 0) { MessageBox.Show("Can't not find out " + a.User1); return; } MonHoc m = new MonHoc(maMon, tenMon, Convert.ToInt32(slot)); if (!MonHoc.insertMonHoc(m)) { return; } DateTime d = DateTime.Now; if (HistoryAction.insertHistoryAction(adminID, "Insert", d, "Insert MonHoc with MaMonHoc: " + m.MaMh1 + ", TenMh: " + m.TenMh1 + " ,slot: " + m.Slot1)) { MessageBox.Show("Add Success"); } }
public HttpResponseMessage Create(HttpRequestMessage request, HistoryActionViewModel historyActionVM) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var newHistoryAction = new HistoryAction(); newHistoryAction.UpdateHistoryAction(historyActionVM); newHistoryAction.ActionDate = DateTime.Now; _historyActionService.Add(newHistoryAction); _historyActionService.Save(); var responseData = Mapper.Map <HistoryAction, HistoryActionViewModel>(newHistoryAction); response = request.CreateResponse(HttpStatusCode.Created, responseData); } return response; })); }
private void SaveActionButton_Click(object sender, RoutedEventArgs e) { string myAction = ""; var screen = new saveActionDialog(myAction); if (screen.ShowDialog() == true) { // Truyền theo kiểu tà đạo myAction = screen.myNameAction; var checkSameName = _preset.Where(x => x.actionName == myAction); if (checkSameName.Count() != 0) { MessageBox.Show($"{myAction} is a already exists "); return; } var numberAction = _action.Count(); var act = new BindingList <StringOperation>(); for (int i = 0; i < numberAction; i++) { act.Add(_action[i]); } var saveAction = new HistoryAction { action = act, actionName = myAction }; _preset.Add(saveAction); } }
public static History Create(HistoryAction action) { History history = new History(); history.Action = action; history.Date = TimeProvider.Current.UtcNow; return history; }
public static void UpdateHistoryAction(this HistoryAction historyAction, HistoryActionViewModel historyActionVM) { historyAction.ID = historyActionVM.ID; historyAction.UserName = historyActionVM.UserName; historyAction.ActionName = historyActionVM.ActionName; historyAction.ActionDate = historyActionVM.ActionDate; historyAction.Status = historyActionVM.Status; }
public void MinusSign(bool fromHistory) { currentSelected.Decrease(); if (!fromHistory) { HistoryAction ha = new HistoryAction(ActionType.DecreaseValue, ActionType.IncreaseValue); HistoryManager.instance.AddHistory(ha); } }
public void Add(HistoryAction action) { if (CurrentAction != null) { ClearFrom(index); } actions.Add(action); index = actions.Count; }
public override void ApplyHistoryAction(HistoryAction action) { if (action is PencilHistoryAction <ColorRgba32> pencilAction) { foreach (var point in pencilAction.ModifiedPoints) { _directImage.SetPixel(point.X, point.Y, pencilAction.PencilColor); } } }
public async Task <IHttpActionResult> GetHistoryAction(int id) { HistoryAction historyAction = await db.HistoryActions.FindAsync(id); if (historyAction == null) { return(NotFound()); } return(Ok(historyAction)); }
public async Task <IHttpActionResult> PostHistoryAction(HistoryAction historyAction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.HistoryActions.Add(historyAction); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = historyAction.Id }, historyAction)); }
public void OnPointerUp(PointerEventData eventData) { if (dragging) { Session.dragging = false; dragging = false; img.color = Color.white; HistoryAction ha = new HistoryAction(ActionType.MoveOn, ActionType.MoveBack, transform.GetSiblingIndex(), indexFrom); HistoryManager.instance.AddHistory(ha); } }
public void AddHistory(HistoryAction ha) { int count = historyList.Count; for (int i = index + 1; i < count; i++) { historyList.RemoveAt(historyList.Count - 1); } historyList.Add(ha); index = historyList.Count - 1; }
/// <summary> /// Generic history callback delegate specifically for tile based tools /// </summary> /// <param name="obj"> History arguement</param> protected virtual void ApplyTileChanges(HistoryAction action, object obj) { lastRenderedPoint = PointNull; TileChangesList changes = (TileChangesList)obj; foreach (var change in changes) { World.SetTile(change.Key.X, change.Key.Y, change.Value, changes.Layer); } World.SelectLayer(changes.Layer); }
private void buttonRemove_Click(object sender, EventArgs e) { string Notes = "Remove DiemThi with MaSv: "; int adminID = Admin.getAdminIdByUser(a.User1); if (adminID == 0) { MessageBox.Show("Can't not find out " + a.User1); return; } int count = 0; List <SinhVienAndPoint> list = new List <SinhVienAndPoint>(); for (int i = 0; i < dataGridViewClass.RowCount - 1; i++) { if (Convert.ToBoolean(dataGridViewClass.Rows[i].Cells["Select"].Value) == true) { count++; string MaSv = (String)dataGridViewClass[2, i].Value; string MaMh = dataGridViewClass.Rows[i].Cells["mamh"].Value.ToString(); int LanThi = Convert.ToInt32(dataGridViewClass.Rows[i].Cells["lanthi"].Value.ToString()); SinhVienAndPoint svap = new SinhVienAndPoint(null, MaSv, null, null, MaMh, 0, LanThi); list.Add(svap); Notes += MaSv + " \nMaSv"; } } foreach (SinhVienAndPoint sv in list) { MessageBox.Show("List Sinh vien " + sv.MaSv1 + " " + sv.MaMh1); } if (count == 0) { MessageBox.Show("You must choose at least one"); } if (SinhVienAndPoint.removeListPointSinhVien(list)) { MessageBox.Show("Remove success"); } else { return; } DateTime d = DateTime.Now; if (HistoryAction.insertHistoryAction(adminID, "Delete", d, Notes)) { MessageBox.Show("Add History Success"); } }
public async Task <IHttpActionResult> DeleteHistoryAction(int id) { HistoryAction historyAction = await db.HistoryActions.FindAsync(id); if (historyAction == null) { return(NotFound()); } db.HistoryActions.Remove(historyAction); await db.SaveChangesAsync(); return(Ok(historyAction)); }
protected override void ApplyTileChanges(HistoryAction action, object obj) { TileChangesRegion changes = obj as TileChangesRegion; //iterate through the changed region and apply it to the current layer for (int x = changes.Offset.X, ox = 0; x < changes.Offset.X + changes.Region.Width; x++, ox++) { for (int y = changes.Offset.Y, oy = 0; y < changes.Offset.Y + changes.Region.Height; y++, oy++) { World.SetTile(x, y, changes.Region[ox, oy], changes.Layer); } } World.SelectLayer(changes.Layer); }
public HistoryEntry(Game game, Player player, HistoryAction action, long turnNo) { this.GameId = game.Id; this.Game = game; if (player != null) { this.ActorId = player.Id; this.Actor = player; } this.Action = action; this.TurnNo = turnNo; this.DateTime = DateTime.UtcNow; }
internal static void ExecuteAction(HistoryAction action) { lock (Service.Locker) { Service._redoStack.Clear(); Service._undoStack.Push(action); action.Execute(); ActionExecuted?.Invoke(action); if (DebugSettings.LogHistoryActions) { Service.Logger.Trace($"HistoryService: action pushed"); } } }
public void UndoClick() { if (index == -1) { return; } HistoryAction ha = (HistoryAction)historyList[index]; if (OnUndo != null) { OnUndo(ha.backType); } index--; }
public void RedoClick() { if (index == historyList.Count - 1) { return; } index++; HistoryAction ha = (HistoryAction)historyList[index]; if (OnUndo != null) { OnUndo(ha.actType); } }
void loadSelectedHistoryItems(HistoryAction action) { Logger.LogDebug("WQE.net", 1, "Loading selected history items\n"); if (null == historyEntriesView.CurrentRow) return; List<int> sel_indexes = new List<int>(); foreach (DataGridViewRow row in historyDetailsView.SelectedRows) sel_indexes.Add(row.Index); sel_indexes.Sort(); String sql = dbSqlEditorBE.restore_sql_from_history(historyEntriesView.CurrentRow.Index, sel_indexes); String action_name = ""; switch (action) { case HistoryAction.HistoryAppendToEditor: action_name = "append"; break; case HistoryAction.HistoryReplaceEditor: action_name = "replace"; break; case HistoryAction.HistoryCopyToClipboard: action_name = "copy"; break; } dbSqlEditorBE.handle_history_action(action_name, sql); Logger.LogDebug("WQE.net", 1, "Done loading selected history items\n"); }
public History GetItem(IHistory orgHistory, HistoryAction action) { var list = GetList(orgHistory).Where(item => item.Action == action).ToList(); return (list.Count == 0) ? null : list.First(); }
public ScreenEditEventArgs(HistoryAction action) { Action = action; }
public string GetItemString(IHistory orgHistory, HistoryAction action) { History history = GetItem(orgHistory, action); return (history == null) ? string.Empty : history.ToString(); }
public void EditedWithAction(HistoryAction action) { if (Edited != null) Edited(this, new ScreenEditEventArgs(action)); }
void applySelectionChange(HistoryAction action, object rectangle) { World.SelectionRectangle = (Rectangle)rectangle; World.InvalidateCanvas(); }
/// <summary> /// Generic history callback delegate specifically for tile based tools /// </summary> /// <param name="obj"> History arguement</param> protected virtual void ApplyTileChanges(HistoryAction action, object obj) { lastRenderedPoint = PointNull; TileChangesList changes = (TileChangesList)obj; foreach (var change in changes) World.SetTile(change.Key.X, change.Key.Y, change.Value, changes.Layer); World.SelectLayer(changes.Layer); }
public void sendHistoryRequest(string with) { Console.WriteLine("Sending. Connected = {0}", connected); if (connected) { Console.WriteLine("Sending history respons! FurikoConnection.cs>213"); HistoryAction ha = new HistoryAction(with); ha.send(); } }
void applyDeletionChanges(HistoryAction action, object obj) { TileChangesRegion changes = obj as TileChangesRegion; if (action == HistoryAction.Undo) { SelectionRectangle = new Rectangle(changes.Offset.X, changes.Offset.Y, changes.Region.Width, changes.Region.Height); } else { SelectionRectangle = Rectangle.Empty; } Rectangle offsetRect = new Rectangle(0, 0, changes.Region.Width, changes.Region.Height), changeRect = offsetRect; changeRect.X = Math.Max(0, changes.Offset.X); changeRect.Y = Math.Max(0, changes.Offset.Y); for (int x = changes.Offset.X, ox = 0; x < changes.Offset.X + changes.Region.Width; x++, ox++) { for (int y = changes.Offset.Y, oy = 0; y < changes.Offset.Y + changes.Region.Height; y++, oy++) { if (PointInWorld(x, y) && changeRect.Contains(x, y) && offsetRect.Contains(ox, oy)) SetTile(x, y, changes.Region[ox, oy], changes.Layer); } } SelectLayer(changes.Layer); }
/* * push - Adds a new action to the stack. If the stack already has actions after the current, * why not insert them? Even better than photoshop! * * Ex: * * Suppose the current history looks like this: * * (1,4,Wall) <- currentAction * (1,3,Wall) * (1,2,Wall) * (1,1,Wall) * * Then we execute two undos to get * * (1,4,Wall) * (1,3,Wall) * (1,2,Wall) <- currentAction * (1,1,Wall) * * So what happens if we push another onto the stack? Try inserting! * * (1,4,Wall) * (1,3,Wall) * (1,3,Enemy) <- currentAction * (1,2,Wall) * (1,1,Wall) * * The only current issue with this is that the action ahead of current doesn't have the correct * "previous" brush, so undoing it won't result in the correct state, you have to undo twice * and then redo to get back to it. This can be corrected. * * */ public void Push(HistoryAction action) { currentAction += 1; stack.Insert(currentAction, action); UpdateHistoryForm(); }