public async Task <IActionResult> Edit(int id, [Bind("Id,CheckPointId,BusId,UserId,RecorDate")] ControlRecord controlRecord) { if (id != controlRecord.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(controlRecord); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ControlRecordExists(controlRecord.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BusId"] = new SelectList(_context.Bus, "Id", "LicencePlate", controlRecord.BusId); ViewData["CheckPointId"] = new SelectList(_context.CheckPoint, "Id", "Name", controlRecord.CheckPointId); ViewData["UserId"] = new SelectList(_context.User, "Id", "FirstName", controlRecord.UserId); return(View(controlRecord)); }
public void RemoveControl(GVCore ctr) { for (int i = 0; i < gvControls.Count; i++) { ControlRecord cr = gvControls[i]; if (cr.Controller == ctr) { if (cr.Controller.View.Visible) { cr.Controller.ExecuteMessage(MsgViewWillHide); } cr.Controller.Parent = null; cr.Controller.View.Parent = null; panel1.Controls.Remove(cr.Controller.View); gvControls.RemoveAt(i); break; } } if (gvControls.Count > 0) { ControlRecord cr = LastControl; cr.Controller.View.Visible = true; LayoutControl(cr.Controller, cr.Align, cr.OriginalSize); } }
public void UncontrolUnit(ControlRecord controlRecord) { RaidSceneManager.BattleGround.Controls.Remove(controlRecord); var prisoner = controlRecord.PrisonerUnit; prisoner.Character.GetStatusEffect(StatusType.Guarded).ResetStatus(); prisoner.Character.GetStatusEffect(StatusType.Guard).ResetStatus(); prisoner.Formation.DeleteUnit(prisoner, false); Round.OrderedUnits.RemoveAll(unit => unit == prisoner); var targetFormation = prisoner.Team == Team.Monsters? HeroFormation : MonsterFormation; prisoner.Team = prisoner.Team == Team.Monsters? Team.Heroes : Team.Monsters; prisoner.transform.SetParent(targetFormation.party.transform, true); prisoner.SetMoveSmoothTime(0.1f); prisoner.Party = targetFormation.party; prisoner.Formation = targetFormation; prisoner.CombatInfo.PrepareForBattle(prisoner.CombatInfo.CombatId); prisoner.InstantFlip(); prisoner.Formation.SpawnUnit(prisoner, 4); if (controlRecord.ControllComponent.UncontrollEffects.Count > 0) { foreach (var controlEffectString in controlRecord.ControllComponent.UncontrollEffects) { var captorEffect = DarkestDungeonManager.Data.Effects[controlEffectString]; foreach (var subEffect in captorEffect.SubEffects) { subEffect.ApplyInstant(controlRecord.ControllUnit, controlRecord.PrisonerUnit, captorEffect); } } } prisoner.OverlaySlot.UpdateOverlay(); }
private void GVCenteredChildControl_SizeChanged(object sender, EventArgs e) { if (panel1.Controls.Count > 0) { ControlRecord child = LastControl; LayoutControl(child.Controller, child.Align, child.OriginalSize); } }
internal LinkAdorner(UIElement adornedElement, ControlRecord from, ControlRecord to, bool added) : base(adornedElement) { IsClipEnabled = true; _from = from; _to = to; _added = added; }
public StateAdorner(UIElement adornedElement, ControlRecord from, ControlRecord to) : base(adornedElement) { IsClipEnabled = true; IsHitTestVisible = false; _from = from; _to = to; }
public void UnregisterControl(Control control) { if (control != null) { ControlRecord record = _controls.Find(r => { return(r.Control == control); }); if (record != null) { _validateFuncs.Remove(record.ValidationFunc); _controls.Remove(record); record.Unlink(); } } }
public async Task <IActionResult> Create([Bind("Id,CheckPointId,BusId,UserId,RecorDate")] ControlRecord controlRecord) { if (ModelState.IsValid) { _context.Add(controlRecord); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BusId"] = new SelectList(_context.Bus, "Id", "LicencePlate", controlRecord.BusId); ViewData["CheckPointId"] = new SelectList(_context.CheckPoint, "Id", "Name", controlRecord.CheckPointId); ViewData["UserId"] = new SelectList(_context.User, "Id", "FirstName", controlRecord.UserId); return(View(controlRecord)); }
public void AddControl(GVCore core, GVControlAlign align) { ControlRecord cr = new ControlRecord(); cr.Controller = core; cr.Align = align; cr.OriginalSize = core.View.Size; core.ExecuteMessage(MsgViewWillAppear); HideControlsAll(true); gvControls.Add(cr); core.View.Parent = panel1; core.View.Visible = true; panel1.Controls.Add(core.View); InitialLayoutControl(core, align, cr.OriginalSize); }
private void ControlItemLoaded(object sender, RoutedEventArgs e) { // Prepare revision paths var adornerLayer = AdornerLayer.GetAdornerLayer(this); var recordControls = Helpers.FindChildrens <ControlRecord>(this); ControlRecord last = null; foreach (var child in recordControls) { if (last != null) { adornerLayer.Add(new RecordTransitionAdorner(last, last, child)); } last = child; } }
internal void ToggleSelectedRecord(ControlRecord recordControl) { if (recordControl == null) { return; } var controller = Controller; var record = (Record)recordControl.DataContext; if (controller.Selection.Contains(record)) { controller.Selection.Remove(record); } else { controller.Selection.Add(record); } }
public void RegisterControl(Control control, Func <string> validationFunc) { if (control != null && validationFunc != null) { ErrorProvider errorProvider = new ErrorProvider(); EventHandler validatedHandler = (sender, e) => { string msg = validationFunc(); if (msg != null) { errorProvider.SetIconPadding(control, DetermineErrorIconPadding(control)); errorProvider.SetError(control, msg); } else { errorProvider.SetError(control, String.Empty); } Validate(); }; EventHandler textChangedHandler = (sender, e) => { if (validationFunc() == null) { errorProvider.SetError(control, String.Empty); } Validate(); }; ControlRecord record = new ControlRecord() { Control = control, ValidationFunc = validationFunc, ErrorProvider = errorProvider, ValidatedHandler = validatedHandler, TextChangedHandler = textChangedHandler, }; record.Link(); _controls.Add(record); _validateFuncs.Add(validationFunc); } }
/// <summary> /// Connect to the specified NJE server. /// </summary> public void Connect() { ControlRecord sendRecord; ControlRecord receiveRecord; byte[] buffer; log.InfoFormat("Connecting to {0}:{1}", this.ServerHost, this.ServerPort); tcpClient.Connect(this.ServerHost, this.ServerPort); tcpStream = tcpClient.GetStream(); sendRecord = new ControlRecord("OPEN", this.ClientNodeID, "127.0.0.1", this.ServerNodeID, this.ServerHost, 0); buffer = sendRecord.GetBytes(); tcpStream.Write(buffer, 0, 33); tcpStream.Read(buffer, 0, 33); receiveRecord = new ControlRecord(buffer); log.DebugFormat("Reason code: {0}, response type: {1}.", receiveRecord.ReasonCode, receiveRecord.RequestType); if (receiveRecord.RequestType != "ACK") { log.ErrorFormat("Could not log into server {0}:{1} with Node ID {2}, server responded: {3}.", this.ServerHost, this.ServerPort, this.ServerNodeID, receiveRecord.RequestType); } else { this._isSuccessfullyConnected = true; log.InfoFormat("Connected to {0}", this.ServerNodeID); } // send SOH ENQ log.InfoFormat("Sending SOH ENQ to {0}", this.ServerNodeID); byte[] sohenq = MakeTTB(MakeTTR(new byte[] { 0x01, 0x2d })); tcpStream.Write(sohenq, 0, sohenq.Length); while (!tcpStream.DataAvailable) { log.InfoFormat("Waiting for response to SOH ENQ from {0}...", this.ServerNodeID); Thread.Sleep(500); } MemoryStream responseMS = new MemoryStream(); while (tcpStream.DataAvailable) { byte[] rbuffer = new byte[256]; int nR = tcpStream.Read(rbuffer, 0, 256); responseMS.Write(rbuffer, 0, nR); } List <IRecord> result = ProcessData(responseMS.ToArray()); if (result[0].Data[0] == 0x10 && result[0].Data[1] == 0x70) { log.InfoFormat("Received DLE ACK0 from {0}.", this.ServerNodeID); } else { log.InfoFormat("Did not DLE ACK0 from {0}!", this.ServerNodeID); } // log in now this.SignIn(); }
public void RegisterControl(Control control, Func<string> validationFunc) { if (control != null && validationFunc != null) { ErrorProvider errorProvider = new ErrorProvider(); EventHandler validatedHandler = (sender, e) => { string msg = validationFunc(); if (msg != null) { errorProvider.SetIconPadding(control, DetermineErrorIconPadding(control)); errorProvider.SetError(control, msg); } else errorProvider.SetError(control, String.Empty); Validate(); }; EventHandler textChangedHandler = (sender, e) => { if (validationFunc() == null) errorProvider.SetError(control, String.Empty); Validate(); }; ControlRecord record = new ControlRecord() { Control = control, ErrorProvider = errorProvider, ValidatedHandler = validatedHandler, TextChangedHandler = textChangedHandler, }; record.Link(); _controls.Add(record); _validateFuncs.Add(validationFunc); } }
public void LoadEffects(BattleGroundSaveData battleSaveData) { #region Load Statuses and Immobilize for (int i = 0; i < HeroParty.Units.Count; i++) { if (HeroParty.Units[i].Character[StatusType.Stun].IsApplied) { HeroParty.Units[i].SetHalo("stunned"); } else if (HeroParty.Units[i].CombatInfo.IsSurprised) { HeroParty.Units[i].SetHalo("surprised"); } if (HeroParty.Units[i].CombatInfo.IsImmobilized) { HeroParty.Units[i].SetDefendAnimation(true); } if (HeroParty.Units[i].Character.IsMonster == false) { var hero = HeroParty.Units[i].Character as Hero; if (hero[StatusType.DeathsDoor].IsApplied) { hero.ApplyDeathDoor(); } else if (hero[StatusType.DeathRecovery].IsApplied) { hero.ApplyMortality(); } } } for (int i = 0; i < MonsterParty.Units.Count; i++) { if (MonsterParty.Units[i].Character[StatusType.Stun].IsApplied) { MonsterParty.Units[i].SetHalo("stunned"); } else if (MonsterParty.Units[i].CombatInfo.IsSurprised) { MonsterParty.Units[i].SetHalo("surprised"); } if (MonsterParty.Units[i].CombatInfo.IsImmobilized) { MonsterParty.Units[i].SetDefendAnimation(true); } if (MonsterParty.Units[i].Character.IsMonster == false) { MonsterParty.Units[i].SetCombatAnimation(true); var hero = MonsterParty.Units[i].Character as Hero; if (hero[StatusType.DeathsDoor].IsApplied) { hero.ApplyDeathDoor(); } else if (hero[StatusType.DeathRecovery].IsApplied) { hero.ApplyMortality(); } } } #endregion #region Load Captures for (int i = 0; i < battleSaveData.Captures.Count; i++) { CaptureRecord newCaptureRecord = new CaptureRecord(); int prisonerId = newCaptureRecord.GetHashPrisonerId(battleSaveData.Captures[i]); int captorId = newCaptureRecord.GetHashCaptorId(battleSaveData.Captures[i]); newCaptureRecord.RemoveFromParty = newCaptureRecord.GetHashRemoveFromParty(battleSaveData.Captures[i]); if (newCaptureRecord.RemoveFromParty == false) { FormationUnit prisoner = FindById(prisonerId); FormationUnit captor = FindById(captorId); newCaptureRecord.PrisonerUnit = prisoner; newCaptureRecord.CaptorUnit = captor; prisoner.SetCaptureEffect(captor); Captures.Add(newCaptureRecord); } else { FormationUnit prisoner = loadedRemovedPrisoners.Find(removedUnit => removedUnit.CombatInfo.CombatId == prisonerId); FormationUnit captor = FindById(captorId); prisoner.RectTransform.position = captor.RectTransform.position; newCaptureRecord.PrisonerUnit = prisoner; newCaptureRecord.CaptorUnit = captor; Captures.Add(newCaptureRecord); } } #endregion #region Load Companions for (int i = 0; i < battleSaveData.Companions.Count; i++) { CompanionRecord newCompanionRecord = new CompanionRecord(); int companionId = newCompanionRecord.GetHashCompanionId(battleSaveData.Companions[i]); int targetId = newCompanionRecord.GetHashTargetId(battleSaveData.Companions[i]); FormationUnit companion = FindById(companionId); FormationUnit target = FindById(targetId); newCompanionRecord.CompanionUnit = companion; newCompanionRecord.TargetUnit = target; Companions.Add(newCompanionRecord); } #endregion #region Load Controls for (int i = 0; i < battleSaveData.Controls.Count; i++) { ControlRecord newControlRecord = new ControlRecord(); int prisonerId = newControlRecord.GetHashPrisonerId(battleSaveData.Controls[i]); int controllerId = newControlRecord.GetHashControlId(battleSaveData.Controls[i]); newControlRecord.DurationLeft = newControlRecord.GetHashDurationLeft(battleSaveData.Controls[i]); FormationUnit prisoner = FindById(prisonerId); FormationUnit controller = FindById(controllerId); newControlRecord.PrisonerUnit = prisoner; newControlRecord.ControllUnit = controller; Controls.Add(newControlRecord); } #endregion loadedRemovedPrisoners.Clear(); RaidSceneManager.Formations.HeroOverlay.UpdateOverlay(); RaidSceneManager.Formations.monsters.overlay.UpdateOverlay(); }