예제 #1
0
        private void Update()
        {
            if (debuggerService.State != DebuggerState.Running)
            {
                var frames = debuggerService.Machine.GetStackFrames();

                stackFrames.BeginBulkOperation();
                try
                {
                    stackFrames.Clear();

                    for (int i = 0; i < frames.Length; i++)
                    {
                        var  frame         = frames[i];
                        uint jumpToAddress = 0;
                        if (i == 0)
                        {
                            jumpToAddress = (uint)debuggerService.Machine.PC;
                        }
                        else
                        {
                            jumpToAddress = frames[i - 1].ReturnAddress;
                        }

                        stackFrames.Add(new StackFrameViewModel(frame, routineService.RoutineTable, jumpToAddress));
                    }
                }
                finally
                {
                    stackFrames.EndBulkOperation();
                }
            }
        }
예제 #2
0
        public void OperationCollapseTest()
        {
            var argsList   = new List <CollectionChangedEventArgs>();
            var collection = new BulkObservableCollection <int>();

            collection.CollectionChanged += (sender, e) => argsList.Add(e);

            collection.BeginBatch();
            collection.Add(1);                      //  \
            collection.Add(2);                      //   > collapse into 1 add
            collection.Add(3);                      //  /
            collection.Remove(1);                   //  \
            collection.Remove(2);                   //   > collapse into 1 remove
            collection.Remove(3);                   //  /
            collection.AddRange(new[] { 1, 2, 3 }); //  \
            collection.Add(4);                      //   > collapse into 1 add
            collection.AddRange(new[] { 5, 6, 7 }); //  /
            collection.Remove(7);                   //  \
            collection.Remove(6);                   //   > collapse into 1 clear
            collection.Clear();                     //  /
            collection.Add(1);                      //  \
            collection.Add(2);                      //   > collapse into 1 add
            collection.Add(3);                      //  /
            collection[0] = 1337;                   // no collapse
            collection.Remove(1337);                // no collapse
            collection.Move(0, 1);                  // no collapse
            collection.Clear();                     // no collapse
            Assert.AreEqual(0, argsList.Count);
            collection.EndBatch();

            Assert.AreEqual(9, argsList.Count);

            Assert.AreEqual(NotifyCollectionChangedAction.Add, argsList[0].Action);
            CollectionAssert.AreEqual(new[] { 1, 2, 3 }, argsList[0].NewItems);

            Assert.AreEqual(NotifyCollectionChangedAction.Remove, argsList[1].Action);
            CollectionAssert.AreEqual(new[] { 1, 2, 3 }, argsList[1].OldItems);

            Assert.AreEqual(NotifyCollectionChangedAction.Add, argsList[2].Action);
            CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5, 6, 7 }, argsList[2].NewItems);

            Assert.AreEqual(NotifyCollectionChangedAction.Reset, argsList[3].Action);

            Assert.AreEqual(NotifyCollectionChangedAction.Add, argsList[4].Action);
            CollectionAssert.AreEqual(new[] { 1, 2, 3 }, argsList[4].NewItems);

            Assert.AreEqual(NotifyCollectionChangedAction.Replace, argsList[5].Action);

            Assert.AreEqual(NotifyCollectionChangedAction.Remove, argsList[6].Action);

            Assert.AreEqual(NotifyCollectionChangedAction.Move, argsList[7].Action);

            Assert.AreEqual(NotifyCollectionChangedAction.Reset, argsList[8].Action);
        }
예제 #3
0
        public void BeginEndBulkOperationTest()
        {
            CollectionChangedEventArgs args = null;

            var collection = new BulkObservableCollection <int>();

            collection.CollectionChanged += (sender, e) => args = e;

            collection.BeginBatch();
            collection.Add(1);
            Assert.IsNull(args);
            collection.Add(2);
            Assert.IsNull(args);
            collection.EndBatch();
            Assert.IsNotNull(args);

            args = null;
            collection.BeginBatch();
            collection.AddRange(new[] { 1, 2, 3 });
            Assert.IsNull(args);
            collection.Add(4);
            Assert.IsNull(args);
            collection.Remove(4);
            Assert.IsNull(args);
            collection.Insert(0, 5);
            Assert.IsNull(args);
            collection.Move(0, 1);
            Assert.IsNull(args);
            collection.RemoveAt(0);
            Assert.IsNull(args);
            collection.Clear();
            Assert.IsNull(args);
            collection.EndBatch();
            Assert.IsNotNull(args);
        }
예제 #4
0
        public void ReloadLogs()
        {
            logLoadTaskTokenSource?.Cancel();
            logLoadTaskTokenSource = new CancellationTokenSource();

            logs.Clear();
            LogSearchStarted?.Invoke(this, EventArgs.Empty);
            Task.Run(() => FindLogs(logLoadTaskTokenSource.Token))
            .ContinueWith(t => Application.Instance.Invoke(() => LogSearchFinished?.Invoke(null, EventArgs.Empty)));

            SetupFileSystemWatchers();
        }
예제 #5
0
        private void Update()
        {
            if (debuggerService.State != DebuggerState.Running)
            {
                var frames = debuggerService.Machine.GetStackFrames();

                stackFrames.BeginBulkOperation();
                try
                {
                    stackFrames.Clear();

                    foreach (var frame in frames)
                    {
                        stackFrames.Add(new StackFrameViewModel(frame, routineService.RoutineTable));
                    }
                }
                finally
                {
                    stackFrames.EndBulkOperation();
                }
            }
        }
예제 #6
0
 private static void replaceEntityItems(BulkObservableCollection <TNDEntityItem> entityItems, BulkObservableCollection <TNDEntityItem> checkedItems, TNDEntityItem[] arrSearchResults)
 {
     if (arrSearchResults == null || !arrSearchResults.Any())
     {
         entityItems.Clear();
     }
     else
     {
         entityItems.Clear();
         var dictCheckedItems = checkedItems.ToDictionary(_ => _);
         //
         var newCheckedItems = new List <TNDEntityItem>();
         // add the found ones - uses the found.
         foreach (var searchResult in arrSearchResults)
         {
             if (dictCheckedItems.Remove(searchResult))
             {
                 searchResult.IsChecked = true;
                 newCheckedItems.Add(searchResult);
             }
         }
         // add the not found ones - reuse the old.
         newCheckedItems.AddRange(dictCheckedItems.Keys);
         //
         var sortedNewCheckedItems
             = newCheckedItems
               .OrderBy(_ => _.MetaEntity.MetaEntityLevel)
               .ThenBy(_ => _.MetaEntityName)
               .ThenBy(_ => _.Name)
               .ToArray();
         lock (entityItems) {
             checkedItems.Replace(newCheckedItems);
             entityItems.Replace(arrSearchResults);
         }
     }
 }
예제 #7
0
        public void ResetTest()
        {
            CollectionChangedEventArgs args = null;
            var collection = new BulkObservableCollection <int>(Enumerable.Range(0, 50));

            collection.CollectionChanged += (sender, e) => args = e;

            collection.Clear();
            Assert.IsNotNull(args);
            Assert.AreEqual(NotifyCollectionChangedAction.Reset, args.Action);
            Assert.AreEqual(0, args.NewItems.Count);
            Assert.IsNull(args.NewIndex);
            Assert.AreEqual(0, args.OldItems.Count);
            Assert.IsNull(args.OldIndex);
            Assert.AreEqual(0, collection.Count);
        }
예제 #8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _activeMessages.Clear();

            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                //_activeMessages.AddRange( ApplicationViewModel.GetActiveInstances() );
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
예제 #9
0
 private void DebuggerService_MachineDestroyed(object sender, MachineDestroyedEventArgs e)
 {
     messages.Clear();
     debuggerService.StateChanged -= DebuggerService_StateChanged;
 }
예제 #10
0
        public override void Recalculate()
        {
            if (_isDismissed)
            {
                throw (new InvalidOperationException("Cannot recalculate.  The session is dismissed."));
            }

            // Clear out the active set of signatures.
            _activeSignatures.Clear();

            // In order to find the signatures to be displayed in this session, we'll need to go through each of the signature help
            // providers and ask them for signatures at the trigger point.

            List <ISignature> signatures = new List <ISignature>();

            foreach (ISignatureHelpSource provider in _componentContext.GetSignatureHelpSources(this))
            {
                provider.AugmentSignatureHelpSession(this, signatures);

                // The source could have done anything to the session.  Let's verify that we're still alive and well.
                if (this.IsDismissed)
                {
                    return;
                }
            }

            if (signatures != null)
            {
                _activeSignatures.AddRange(signatures);
            }

            // If we ended-up with zero signatures, that's it.  We need to dismiss and get out of here.
            if (_activeSignatures.Count == 0)
            {
                this.Dismiss();
                return;
            }

            // Let's determine which signature should be "selected" before we find a presenter.
            if (!_activeSignatures.Contains(_selectedSignature))
            {
                // The old selection is no longer valid (or we never had one).  Let's select the first signature.
                this.SelectedSignature = _activeSignatures[0];
            }

            // If we don't already have a presenter for this session, find one.
            if (base.presenter == null)
            {
                base.presenter = FindPresenter(this, _componentContext.OrderedIntellisensePresenterProviderExports, _componentContext.GuardedOperations);
                if (base.presenter != null)
                {
                    this.RaisePresenterChanged();
                }
                else
                {
                    this.Dismiss();
                    return;
                }
            }

            base.RaiseRecalculated();
        }
예제 #11
0
 private void DebuggerService_MachineDestroyed(object sender, MachineDestroyedEventArgs e)
 {
     lines.Clear();
     addressToLineMap.Clear();
     routineAddressAndIndexList.Clear();
 }
예제 #12
0
        private void StoryService_StoryClosing(object sender, StoryClosingEventArgs e)
        {
            lines.Clear();

            PropertyChanged("HasStory");
        }