Exemplo n.º 1
0
 private void RaiseCommandsChanged()
 {
     if (CommandsChanged != null)
     {
         CommandsChanged.Invoke(this, new EventArgs());
     }
 }
Exemplo n.º 2
0
        public async Task RedoCommands(int commandsCount)
        {
            for (var i = 0; i < commandsCount; i++)
            {
                var command = _redoStack.Pop();
                await command.Do();

                _undoStack.Push(command);
            }
            CommandsChanged?.Invoke();
        }
Exemplo n.º 3
0
        public void Log(string command, DateTime executionStartTimestamp, DateTime executionEndTimestamp)
        {
            lock (_logQueue)
            {
                if (_logQueue.Count >= LogLimit)
                {
                    _logQueue.Dequeue();
                }

                var commandLogEntry = new CommandLogEntry(command, executionStartTimestamp, executionEndTimestamp);
                _logQueue.Enqueue(commandLogEntry);
            }

            CommandsChanged?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 4
0
        public static ProcessOperation LogProcessStart(string fileName, string arguments = "")
        {
            const int MaxEntryCount = 500;

            var entry = new CommandLogEntry(fileName, arguments, DateTime.Now, ThreadHelper.JoinableTaskContext.IsOnMainThread);

            _queue.Enqueue(entry);

            // Trim extra items
            while (_queue.Count >= MaxEntryCount)
            {
                _queue.TryDequeue(out _);
            }

            CommandsChanged?.Invoke();

            return(new ProcessOperation(entry, Stopwatch.StartNew(), () => CommandsChanged?.Invoke()));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Add the command to the log fifo queue
        /// </summary>
        /// <param name="command">The (Git) command to log</param>
        /// <param name="timestamp">The time for the log</param>
        /// <returns>The log entry reference, null if not added</returns>
        public CommandLogEntry LogEntry(string command, DateTime timestamp)
        {
            CommandLogEntry commandLogEntry = null;

            lock (_logQueue)
            {
                if (_logQueue.Count >= LogLimit)
                {
                    _logQueue.Dequeue();
                }

                commandLogEntry = new CommandLogEntry(command, timestamp);
                _logQueue.Enqueue(commandLogEntry);
            }

            CommandsChanged?.Invoke(this, EventArgs.Empty);
            return(commandLogEntry);
        }
Exemplo n.º 6
0
 public static void Clear()
 {
     _queue = new ConcurrentQueue <CommandLogEntry>();
     CommandsChanged?.Invoke();
 }
Exemplo n.º 7
0
 public void LogEnd()
 {
     CommandsChanged?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 8
0
 private void OnCommandsCollectionChanged(object sender,
                                          System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     CommandsChanged?.Invoke(Commands);
 }
Exemplo n.º 9
0
 protected virtual void OnCommandsChanged()
 {
     CommandsChanged?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 10
0
        public void DisposeCommandFromStackByDependency(ICommandStackDependencySource dep)
        {
            var relatedItems = _undoStack.Where(command => command.Dependencies.Any(o => o == dep));

            CommandsChanged?.Invoke();
        }
Exemplo n.º 11
0
 public void AddStackingCommand(IStackingCommand newStackingCommand)
 {
     _undoStack.Push(newStackingCommand);
     _redoStack.Clear();
     CommandsChanged?.Invoke();
 }