private void Publish(IPopupEvent @event) { System.Diagnostics.Debug.WriteLine("publishing:" + @event.Type); events.Push(@event); foreach (var observer in Model.Observers) { observer.Handle(events, this); } }
internal void AddUndoItem(IUndoAction action) { undoStack.Push(action); notifyBuildListeners.Add(action); notifyDismantleListeners.Add(action); foreach (IUndoAction undoAction in redoStack) { notifyBuildListeners.Remove(undoAction); notifyDismantleListeners.Remove(undoAction); } redoStack.Clear(); }
public void FixedSizeStack_EnforcesSizeLimit() { FixedSizeStack<int> stack = new FixedSizeStack<int>(1); stack.Push(1); try { stack.Push(2); Assert.Fail("We were able to insert two items into a stack that is of fixed size 1."); } catch (InvalidOperationException) { // expected } }
public void FixedSizeStack_CanPeek() { FixedSizeStack<int> stack = new FixedSizeStack<int>(1); stack.Push(1); Assert.AreEqual(1, stack.Count); int peeked = stack.Peek(); Assert.AreEqual(1, peeked); Assert.AreEqual(1, stack.Count); }
public static TraceContext LogSqlInfoStart(string sql, string dataStoreKey, dynamic parameters, int stackBack = 4) { var message = dataStoreKey + "." + sql + " \r\n" + DataAccessBase.ToSQLInfo(parameters); SqlStatementStack.Push(new SqlStatementStackMessage(message)); var tcDetail = LogInfo(message, dataStoreKey, stackBack); return(new TraceContext(tcDetail)); }
public void FixedSizeStack_CanPop() { FixedSizeStack<int> stack = new FixedSizeStack<int>(1); stack.Push(1); Assert.AreEqual(1, stack.Count); int popped = stack.Pop(); Assert.AreEqual(1, popped); Assert.AreEqual(0, stack.Count); }
public void Traverse(BTNode child) { var i = child.preOrderIndex; traversal.Push(i); requestedTraversals.Enqueue(i); #if UNITY_EDITOR child.StatusEditorResult = BTNode.EStatusEditor.Running; #endif }
/// <summary> /// Pushes a navigation history entry matching the /// current state. /// </summary> private void PushNavigationHistoryEntry() { _navigationHistory.Push(new KanjiNavigationEntry() { KanjiDetailsVm = KanjiDetailsVm, KanjiFilter = _kanjiFilter }); // Raise property changed for the boolean. RaisePropertyChanged("CanNavigateBack"); }
public void FixedSizeStack_CanClear() { FixedSizeStack<int> stack = new FixedSizeStack<int>(10); for (int i = 0; i < 10; i++) { stack.Push(i); } Assert.AreEqual(10, stack.Count); stack.Clear(); Assert.AreEqual(0, stack.Count); }
public static void BeginUndoGroup(string title) { if (m_undoStack.Count > 0) { BTUndoGroup oldGroup = m_undoStack.Peek() as BTUndoGroup; if (oldGroup != null && oldGroup.IsOpen) { Debug.LogWarningFormat("You have to call BTUndoSystem.EndUndoGroup before begining a new group. Old group is '{0}', new group is '{1}'", oldGroup.Title, title); if (oldGroup.IsEmpty) { m_undoStack.Pop(); } else { oldGroup.Close(); } } } BTUndoGroup group = new BTUndoGroup(title); m_undoStack.Push(group); }
internal bool TryUndo(out string message, out bool sound) { sound = false; message = ""; if (undoStack.Count <= 0) { sound = true; message = "UndoHistoryEmptyMessage"; return(true); } if (GameMain.localPlanet?.factory == null) { return(false); } if (GameMain.mainPlayer?.controller == null) { return(false); } PlanetFactory factory = GameMain.localPlanet.factory; PlayerAction_Build actionBuild = GameMain.mainPlayer.controller.actionBuild; IUndoAction action = undoStack.Pop(); bool success = false; try { success = action.Undo(factory, actionBuild); } catch (Exception e) { BlueprintTweaksPlugin.logger.LogWarning($"Failed to undo, message: {e.Message}, stacktrace:\n{e.StackTrace}"); } if (success) { message = "UndoSuccessText"; redoStack.Push(action); } else { message = "UndoFailureText"; sound = true; notifyBuildListeners.Remove(action); notifyDismantleListeners.Remove(action); } return(true); }
protected override void brightenToolStripMenuItem_Click(object sender, EventArgs e) { if (imageList == null) { MessageBox.Show(this, Properties.Resources.LoadImage, strProgName); return; } TrackbarDialog dialog = new TrackbarDialog(); dialog.LabelText = Properties.Resources.Brightness; dialog.ValueUpdated += new TrackbarDialog.HandleValueChange(UpdatedBrightness); originalImage = imageList[imageIndex]; stack.Push(originalImage); if (dialog.ShowDialog() == DialogResult.Cancel) { // restore original image imageList[imageIndex] = originalImage; this.pictureBox1.Image = new Bitmap(originalImage); } }
private void CharacterStateOnOnModifierApplied(ModificationParameter parameter, ISubSpellHandler spell, float actualChange) { var spellName = String.Empty; if (spell != null) { spellName = spell.Spell.name; } _modLog.Push($"{spellName} <color=yellow>{parameter}</color>: {actualChange:0.##}"); foreach (var line in _modLog.Reverse()) { _stringBuilder2.AppendLine(line); } Text2.text = _stringBuilder2.ToString(); _stringBuilder2.Clear(); }
public static void Undo() { if (m_undoStack.Count > 0) { BTUndoState undoState = m_undoStack.Pop(); if (undoState.CanUndo) { undoState.Undo(); if (undoState.CanRedo) { m_redoStack.Push(undoState); } } while (m_undoStack.Count > 0 && !m_undoStack.Peek().CanUndo) { m_undoStack.Pop(); } } }
/// <summary> /// Initializes a new instance of the <see cref="SolitaireBoard"/> class. /// </summary> public SolitaireBoard() { _mainDeck = new Deck(); _mainDeck.Shuffle(); _gamePiles = new FixedSizeStack<Card>[7]; for (int i = 0; i < _gamePiles.Length; i++) { var pile = new FixedSizeStack<Card>(i + 1); for (int j = 0; j < i + 1; j++) { pile.Push(_mainDeck.Draw()); } _gamePiles[i] = pile; } _suitPiles = new FixedSizeStack<Card>[4]; for (int i = 0; i < _suitPiles.Length; i++) { _suitPiles[i] = new FixedSizeStack<Card>(13); } }
public short[] CreateModeDepthArray(short[] depthArray) { // This is a method of Weighted Moving Average per pixel coordinate across several frames of depth data. // This means that newer frames are linearly weighted heavier than older frames to reduce motion tails, // while still having the effect of reducing noise flickering. short[] modeDepthArray = new short[depthArray.Length]; modeQueue.Push(depthArray); if (modeQueue.Count < modeFrameCount) { depthArray.CopyTo(modeDepthArray, 0); } else { //recorremos for (int q = 0; q < modeFrameCount; q++) { for (int i = 0; i < depthArray.Length; i++) { //por cada pixel //coger del 0, 1 y 2... short depth = Convert.ToInt16(modeQueue.ElementAt <short[]>(q)[i] / 10); frecuencies[i].frecs[q] = depth; } } ; } //resolvemos frecuencias for (int i = 0; i < depthArray.Length; i++) { modeDepthArray[i] = Convert.ToInt16(frecuencies[i].GetMode() * 10 + 5); } return(modeDepthArray); }
public void FixedSizeStack_CanPush() { FixedSizeStack<int> stack = new FixedSizeStack<int>(1); stack.Push(1); Assert.AreEqual(1, stack.Count); }
public void TestPushOneItem() { _stack.Push("One"); Assert.That(_stack.Count, Is.EqualTo(1)); var array = _stack.ToArray(); Assert.That(array.Length, Is.EqualTo(1)); Assert.That(array[0], Is.EqualTo("One")); }
protected override void brightenToolStripMenuItem_Click(object sender, RoutedEventArgs e) { if (imageList == null) { MessageBox.Show(this, Properties.Resources.LoadImage, strProgName); return; } SliderDialog dialog = new SliderDialog(); dialog.LabelText = Properties.Resources.Brightness; dialog.ValueUpdated += new SliderDialog.HandleValueChange(UpdatedBrightness); originalImage = imageList[imageIndex]; stack.Push(originalImage); Nullable <bool> dialogResult = dialog.ShowDialog(); if (dialogResult.HasValue && !dialogResult.Value) { // restore original image imageList[imageIndex] = originalImage; this.imageMain.Source = ImageConverter.BitmapToImageSource(originalImage); } }