Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 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
     }
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public void Traverse(BTNode child)
        {
            var i = child.preOrderIndex;

            traversal.Push(i);
            requestedTraversals.Enqueue(i);

#if UNITY_EDITOR
            child.StatusEditorResult = BTNode.EStatusEditor.Running;
#endif
        }
Esempio n. 8
0
        /// <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");
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
            }
        }
Esempio n. 13
0
    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();
    }
Esempio n. 14
0
        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();
                }
            }
        }
Esempio n. 15
0
 /// <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);
     }
 }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
 public void FixedSizeStack_CanPush()
 {
     FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
     stack.Push(1);
     Assert.AreEqual(1, stack.Count);
 }
Esempio n. 18
0
        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"));
        }
Esempio n. 19
0
        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);
            }
        }