/// <inheritdoc /> protected override Task OnInitializeDesigner() { Procedure process1 = new Procedure { Label = "Process 1" }; Procedure process2 = new Procedure { Label = "Process 2" }; //var groupIndex = 0; //this.Views = new string[] { "Catégories", "Lieux" }.GroupBy(key => "group" + groupIndex++).ToArray(); // TODO //this.SelectedView = this.Views[0].ToArray()[0]; Items = new BulkObservableCollection <IActionReferential> { new Operator { Label = "Referential1", Color = "#FFFF0000", Process = process1 }, new Operator { Label = "And Referential2", Color = "#FF00FF00", Process = process2 } }; return(Task.CompletedTask); }
public void ReplaceTest() { CollectionChangedEventArgs args = null; Random random = new Random(); var collection = new BulkObservableCollection <int>(Enumerable.Range(0, 50)); collection.CollectionChanged += (sender, e) => args = e; for (int i = 0; i < 20; i++) { int index = random.Next(collection.Count); if (collection[index] == 1337) { continue; } args = null; collection[index] = 1337; Assert.IsNotNull(args); Assert.AreEqual(NotifyCollectionChangedAction.Replace, args.Action); Assert.AreEqual(1, args.NewItems.Count); Assert.AreEqual(1337, args.NewItems[0]); Assert.AreEqual(index, args.NewIndex); Assert.AreEqual(1, args.OldItems.Count); Assert.AreEqual(index, args.OldItems[0]); Assert.AreEqual(index, args.OldIndex); Assert.AreEqual(50, collection.Count); } }
public override void Dismiss() { if (!_isDismissed) { // Stop listening to the caret movement event if (_trackCaret) { base.textView.Caret.PositionChanged -= new EventHandler <CaretPositionChangedEventArgs>(OnCaretPositionChanged); } _isDismissed = true; // Fire the "Dismissed" event. This will signal consumers (namely, the session stack) to release pointers to this // session and let us die a peaceful death of garbage collection base.RaiseDismissed(); // Now that we're dismissed, there's no reason to hang-on to the rest of this stuff. _componentContext = null; _activeSignatures = null; _readOnlySignatures = null; _selectedSignature = null; base.Dismiss(); } }
public void AddRangeTest() { CollectionChangedEventArgs args = null; var collection = new BulkObservableCollection <int>(); collection.CollectionChanged += (sender, e) => args = e; collection.Add(1); Assert.IsNotNull(args); Assert.AreEqual(NotifyCollectionChangedAction.Add, args.Action); Assert.AreEqual(1, args.NewItems.Count); Assert.AreEqual(1, args.NewItems[0]); args = null; collection.AddRange(new[] { 2, 3, 4, 5 }); Assert.IsNotNull(args); Assert.AreEqual(NotifyCollectionChangedAction.Add, args.Action); Assert.AreEqual(4, args.NewItems.Count); Assert.AreEqual(2, args.NewItems[0]); Assert.AreEqual(5, args.NewItems[3]); Assert.AreEqual(5, collection.Count); args = null; collection.AddRange(new[] { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }); Assert.IsNotNull(args); Assert.AreEqual(NotifyCollectionChangedAction.Add, args.Action); Assert.AreEqual(10, args.NewItems.Count); Assert.AreEqual(6, args.NewItems[0]); Assert.AreEqual(15, args.NewItems[9]); Assert.AreEqual(15, collection.Count); }
/// <summary> /// Perform a bulk update of a collection of <see cref="Completion"/> instances to match the values /// contained in a pair of source collections. /// </summary> /// <remarks>The <see cref="Completion"/> instances in <paramref name="sourceCompletions"/> and /// <paramref name="secondSourceCompletions"/> are merged and sorted using /// <see cref="CompletionDisplayTextComparer.Default"/>. /// /// <list type="bullet"> /// <item>Any items present in <paramref name="result"/> but not present in the merged collection are /// removed from <paramref name="result"/>.</item> /// <item>Any items not already present in <paramref name="result"/> are inserted at the correct /// location.</item> /// </list> /// /// <note type="caller">The <paramref name="result"/> collection is assumed to already be sorted /// according to <see cref="CompletionDisplayTextComparer.Default"/> before this method is called.</note> /// </remarks> /// <param name="result">The collection holding the merged result.</param> /// <param name="sourceCompletions">The collection of <see cref="Completion"/> instances from the first /// source.</param> /// <param name="secondSourceCompletions">The collection of <see cref="Completion"/> instances from the /// second source.</param> private static void UpdateCompletionList(BulkObservableCollection <Completion> result, IEnumerable <Completion> sourceCompletions, IEnumerable <Completion> secondSourceCompletions) { try { result.BeginBulkOperation(); // SortedSet<Completion> provides for immediate sorting, and also allows Contains() to be used // below instead of a manual call to CompletionDisplayTextComparer.Compare(). SortedSet <Completion> filteredCompletions = new SortedSet <Completion>(CompletionDisplayTextComparer.Default); filteredCompletions.UnionWith(sourceCompletions); filteredCompletions.UnionWith(secondSourceCompletions); int j = 0; foreach (Completion completion in filteredCompletions) { while (j < result.Count && !filteredCompletions.Contains(result[j])) { result.RemoveAt(j); } if (j == result.Count || completion != result[j]) { result.Insert(j, completion); j++; } } } finally { result.EndBulkOperation(); } }
/// <summary> /// Initializes a new instance with the specified properties. /// </summary> /// <param name="moniker">The unique, non-localized identifier for the /// completion set.</param> /// <param name="displayName">The localized name of the completion set. /// </param> /// <param name="applicableTo">The tracking span to which the /// completions apply.</param> /// <param name="completions">The list of completions.</param> /// <param name="options">The options to use for filtering and /// selecting items.</param> /// <param name="comparer">The comparer to use to order the provided /// completions.</param> public FuzzyCompletionSet(string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable <DynamicallyVisibleCompletion> completions, CompletionOptions options, IComparer <Completion> comparer, Func <string, IEnumerable <DynamicallyVisibleCompletion> > deferredLoadCallback) : base(moniker, displayName, applicableTo, null, null) { _options = options; _initialComparer = comparer; _completions = new BulkObservableCollection <Completion>(); _loadedDeferredCompletionSubsets = new HashSet <string>(StringComparer.OrdinalIgnoreCase); _deferredLoadCallback = deferredLoadCallback; _completions.AddRange(completions .Where(c => c != null && !string.IsNullOrWhiteSpace(c.DisplayText)) .OrderBy(c => c, comparer) ); _comparer = new FuzzyStringMatcher(options.SearchMode); _shouldFilter = options.FilterCompletions; _shouldHideAdvanced = options.HideAdvancedMembers && !_completions.All(IsAdvanced); if (_shouldFilter | _shouldHideAdvanced) { _filteredCompletions = new WritableFilteredObservableCollection <Completion>(_completions); foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = !_shouldHideAdvanced || !IsAdvanced(c); } _filteredCompletions.Filter(IsVisible); } }
private BulkObservableCollection <BaseItem> CreateDiagnosticAndGeneratorItems(ProjectId projectId, string language, CompilationOptions options, AnalyzerConfigOptionsResult?analyzerConfigOptions) { // Within an analyzer assembly, an individual analyzer may report multiple different diagnostics // with the same ID. Or, multiple analyzers may report diagnostics with the same ID. Or a // combination of the two may occur. // We only want to show one node in Solution Explorer for a given ID. So we pick one, but we need // to be consistent in which one we pick. Diagnostics with the same ID may have different // descriptions or messages, and it would be strange if the node's name changed from one run of // VS to another. So we group the diagnostics by ID, sort them within a group, and take the first // one. Contract.ThrowIfFalse(HasItems); var collection = new BulkObservableCollection <BaseItem>(); collection.AddRange( AnalyzerReference.GetAnalyzers(language) .SelectMany(a => _diagnosticAnalyzerService.AnalyzerInfoCache.GetDiagnosticDescriptors(a)) .GroupBy(d => d.Id) .OrderBy(g => g.Key, StringComparer.CurrentCulture) .Select(g => { var selectedDiagnostic = g.OrderBy(d => d, s_comparer).First(); var effectiveSeverity = selectedDiagnostic.GetEffectiveSeverity(options, analyzerConfigOptions); return(new DiagnosticItem(projectId, AnalyzerReference, selectedDiagnostic, effectiveSeverity, language, CommandHandler)); })); collection.AddRange( AnalyzerReference.GetGenerators(language) .Select(g => new SourceGeneratorItem(projectId, g, AnalyzerReference))); return(collection); }
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); }
private ProfilerViewModel() : base("Views/ProfilerView") { this.routineList = new SortedList <int, RoutineViewModel>(); this.routines = new BulkObservableCollection <RoutineViewModel>(); this.readOnlyRoutines = routines.AsReadOnly(); }
public SnapshotViewModel(ISnapshotModel snapshotModel) { this.snapshotModel = snapshotModel; // InitialUpdate(); progressText = string.Empty; fileName = string.Empty; isNotSaving = true; RawDataSelected = false; IsStartEnabled = true; Resolutions = SnapshotDefaults.Resolutions; SelectedResolution = Resolutions[0]; NumberOfSamples = SnapshotDefaults.SampleNumberMinimum; SampleMinimumX = 0; SampleMaximumX = (double)numberOfSamples / (double)selectedResolution; StartCommand = new RelayCommand(param => Start()); StopCommand = new RelayCommand(param => Stop()); CancelCommand = new RelayCommand(param => Cancel()); SetNumberOfSamplesCommand = new RelayCommand(param => SetNumberOfSamples()); SaveCommand = new RelayCommand(param => SaveSamples()); BrowseCommand = new RelayCommand(param => Browse()); VSenseCollection = new BulkObservableCollection <DataPoint>(); IRefCollection = new BulkObservableCollection <DataPoint>(); ISenseCollection = new BulkObservableCollection <DataPoint>(); TemperatureOneCollection = new BulkObservableCollection <DataPoint>(); TemperatureTwoCollection = new BulkObservableCollection <DataPoint>(); TemperatureThreeCollection = new BulkObservableCollection <DataPoint>(); TemperatureFourCollection = new BulkObservableCollection <DataPoint>(); }
public QuickInfoSession(ITextView textView, ITrackingPoint triggerPoint, bool trackMouse, IIntellisensePresenterFactoryService intellisensePresenterFactoryService, Lazy <IQuickInfoSourceProvider, IOrderableContentTypeMetadata>[] quickInfoSourceProviders) { if (textView == null) { throw new ArgumentNullException(nameof(textView)); } if (triggerPoint == null) { throw new ArgumentNullException(nameof(triggerPoint)); } if (intellisensePresenterFactoryService == null) { throw new ArgumentNullException(nameof(intellisensePresenterFactoryService)); } if (quickInfoSourceProviders == null) { throw new ArgumentNullException(nameof(quickInfoSourceProviders)); } Properties = new PropertyCollection(); QuickInfoContent = new BulkObservableCollection <object>(); TextView = textView; this.triggerPoint = triggerPoint; TrackMouse = trackMouse; this.intellisensePresenterFactoryService = intellisensePresenterFactoryService; this.quickInfoSourceProviders = quickInfoSourceProviders; TextView.Closed += TextView_Closed; }
/// <summary> /// Initialise une nouvelle instance de la classe <see cref="GridActionsManager"/>. /// </summary> /// <param name="items">La collection des éléments.</param> /// <param name="currentItemSetter">Un délégué capable de définir l'élément sélectionné.</param> /// <param name="videoGetter">Un délégué capable d'obtenir une vidéo à partir de son identifiant.</param> public GridActionsManager(BulkObservableCollection <DataTreeGridItem> items, Action <DataTreeGridItem> currentItemSetter, Func <int, Video> videoGetter) : base(currentItemSetter, videoGetter) { _items = items; base.EnableGroupsTimingCoercion = true; base.EnableRessourceLoad = false; base.EnablePredecessorTimingFix = true; }
public MessageLogViewModel(DebuggerService debuggerService) : base("MessageLogView") { this.debuggerService = debuggerService; this.debuggerService.MachineCreated += DebuggerService_MachineCreated; this.debuggerService.MachineDestroyed += DebuggerService_MachineDestroyed; this.messages = new BulkObservableCollection <MessageViewModel>(); }
/// <summary> /// Initialise une nouvelle instance de la classe <see cref="GanttActionsManager"/>. /// </summary> /// <param name="items">La collection d'élélments.</param> /// <param name="currentItemSetter">Un délégué capable de définir l'élément sélectionné.</param> /// <param name="videoGetter">Un délégué capable d'obtenir une vidéo à partir de son identifiant.</param> public GanttActionsManager(BulkObservableCollection <GanttChartItem> items, Action <GanttChartItem> currentItemSetter, Func <int, Video> videoGetter) : base(currentItemSetter, videoGetter) { _items = items; base.EnableGroupsTimingCoercion = true; base.EnableRessourceLoad = false; base.EnablePredecessorTimingFix = true; base.EnableReducedPercentageRefresh = true; }
public ShadowedBOCollection( BulkObservableCollection <object> originalSource, TranslateFunc translation) { this.source = originalSource; this.source.CollectionChanged += OnSourceModified; this.translator = translation; UpdateFromSource(); }
/// <summary> /// Crée l'ActionManager. /// </summary> private void CreateManager() { _collection = new BulkObservableCollection <DataTreeGridItem>(); var manager = new GridActionsManager(_collection, null, null); manager.ChangeView(GanttGridView.WBS, null); manager.RegisterInitialActions(_actions); manager.FixPredecessorsSuccessorsTimings(); }
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); }
public void Initialize() { ServicesHelper.RegisterMockServices(); //Arbre initial : // G1 1 // T1 1.1 // T2 1.2 // T21 1.2.1 // T22 1.2.2 // T3 1.3 // T31 1.3.1 // T4 1.4 _g1 = new KAction() { Label = "G1", WBS = "1" }; _t1 = new KAction() { Label = "T1", WBS = "1.1" }; _t2 = new KAction() { Label = "T2", WBS = "1.2" }; _t21 = new KAction() { Label = "T21", WBS = "1.2.1" }; _t22 = new KAction() { Label = "T22", WBS = "1.2.2" }; _t3 = new KAction() { Label = "T3", WBS = "1.3" }; _t31 = new KAction() { Label = "T31", WBS = "1.3.1" }; _t4 = new KAction() { Label = "T4", WBS = "1.4" }; _actions = new KAction[] { _g1, _t1, _t2, _t21, _t22, _t3, _t31, _t4 }; _collection = new BulkObservableCollection <DataTreeGridItem>(); _manager = new GridActionsManager(_collection, v => _currentItem = v, null); _manager.ChangeView(GanttGridView.WBS, null); }
/// <summary> /// Méthode invoquée lors de l'initialisation du viewModel en mode design /// </summary> protected override Task OnInitializeDesigner() { Users = new BulkObservableCollection <User>(DesignData.GenerateUsers()); Roles = DesignData.GenerateRoles().Select(r => new PresentationRole(this, r)).ToArray(); DesignData.LinkUsersWithRoles(Users, Roles.Select(r => r.Role)); Languages = DesignData.GenerateLanguages().ToArray(); CurrentUser = Users.First(); return(Task.CompletedTask); }
private MemoryViewModel(FileService fileService) : base("MemoryView") { this.fileService = fileService; this.fileService.FileOpened += FileOpened; this.fileService.FileClosed += FileClosed; this.lines = new BulkObservableCollection <MemoryLineViewModel>(pageSize: 4096); this.readOnlyLines = lines.AsReadOnly(); }
public void TestCanAddPredecessor() { var t1 = new KAction() { Label = "T1", WBS = "1" }; var g1 = new KAction() { Label = "G1", WBS = "2" }; var t2 = new KAction() { Label = "T2", WBS = "2.1" }; var t3 = new KAction() { Label = "T3", WBS = "2.2" }; var t4 = new KAction() { Label = "T4", WBS = "3" }; var t5 = new KAction() { Label = "T5", WBS = "4" }; var actions = new List <KAction>() { t1, g1, t2, t3, t4, t5 }; t3.Predecessors.Add(t1); t3.Predecessors.Add(t2); t4.Predecessors.Add(t3); t5.Predecessors.Add(t3); var collection = new BulkObservableCollection <DataTreeGridItem>(); var manager = new GridActionsManager(collection, null, null); manager.ChangeView(GanttGridView.WBS, null); manager.RegisterInitialActions(actions); Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t1, t1)); Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t1, t3)); Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), g1, t3)); Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t4, t1)); Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t5, t1)); Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t2, t1)); }
public void TestGetCriticalPath3() { // Prédecesseurs multiples var t1 = new KAction() { Label = "T1", WBS = "1", BuildStart = 0, BuildDuration = 2 }; var t2 = new KAction() { Label = "T2", WBS = "2", BuildStart = 0, BuildDuration = 3 }; var t3 = new KAction() { Label = "T3", WBS = "3", BuildStart = 0, BuildDuration = 4 }; var t4 = new KAction() { Label = "T4", WBS = "4", BuildStart = 0, BuildDuration = 2 }; var t5 = new KAction() { Label = "T5", WBS = "5", BuildStart = 0, BuildDuration = 2 }; var actions = new List <KAction>() { t1, t2, t3, t4, t5 }; t3.Predecessors.Add(t1); t3.Predecessors.Add(t2); t4.Predecessors.Add(t3); t5.Predecessors.Add(t3); var collection = new BulkObservableCollection <DataTreeGridItem>(); var manager = new GridActionsManager(collection, null, null); manager.ChangeView(GanttGridView.WBS, null); manager.RegisterInitialActions(actions); manager.FixPredecessorsSuccessorsTimings(); var actual = manager.UpdateCriticalPath().ToList(); var expected = new List <ActionPath>() { actual.First(c => c.Action == t2), actual.First(c => c.Action == t3), actual.First(c => c.Action == t4) }; CollectionAssert.AreEqual(expected, actual); }
public void TestGetCriticalPath1() { var g1 = new KAction() { Label = "G1", WBS = "1" }; var t1 = new KAction() { Label = "T1", WBS = "1.1", BuildStart = 0, BuildDuration = 2 }; var t2 = new KAction() { Label = "T2", WBS = "1.2" }; var t21 = new KAction() { Label = "T21", WBS = "1.2.1", BuildStart = 0, BuildDuration = 2 }; var t22 = new KAction() { Label = "T22", WBS = "1.2.2", BuildStart = 0, BuildDuration = 2 }; var actions = new List <KAction>() { g1, t1, t2, t21, t22 }; t22.Predecessors.Add(t1); t21.Predecessors.Add(t22); var collection = new BulkObservableCollection <DataTreeGridItem>(); var manager = new GridActionsManager(collection, null, null); manager.ChangeView(GanttGridView.WBS, null); manager.RegisterInitialActions(actions); manager.FixPredecessorsSuccessorsTimings(); var actual = manager.UpdateCriticalPath().ToList(); //var actual = manager.GetCriticalPathv2().ToList(); var expected = new List <ActionPath>() { actual.First(c => c.Action == t1), actual.First(c => c.Action == t22), actual.First(c => c.Action == t21) }; CollectionAssert.AreEqual(expected, actual); }
private void Modify(GridActionsManager actionsManager, BulkObservableCollection <DataTreeGridItem> collection, Scenario scenario) { // On va descendre la première tache actionsManager.MoveDown((ActionGridItem)collection[0]); // On change la vidéo sur la première tache scenario.Actions[0].Video = null; // On vide les prédecesseurs de T2 scenario.Actions[1].Predecessors.Clear(); // Ajouter un prédécesseur à T3 scenario.Actions[2].Predecessors.Add(scenario.Actions[0]); }
public MemoryViewModel( StoryService storyService, DebuggerService debuggerService) : base("MemoryView") { this.storyService = storyService; this.storyService.StoryOpened += StoryService_StoryOpened; this.storyService.StoryClosing += StoryService_StoryClosing; this.debuggerService = debuggerService; this.debuggerService.StateChanged += DebuggerService_StateChanged; this.lines = new BulkObservableCollection <MemoryLineViewModel>(); }
public CallStackViewModel( DebuggerService debuggerService, RoutineService routineService) : base("CallStackView") { this.debuggerService = debuggerService; this.debuggerService.MachineCreated += DebuggerService_MachineCreated; this.debuggerService.MachineDestroyed += new System.EventHandler <MachineDestroyedEventArgs>(DebuggerService_MachineDestroyed); this.debuggerService.StateChanged += DebuggerService_StateChanged; this.debuggerService.Stepped += DebuggerService_ProcessorStepped; this.routineService = routineService; this.stackFrames = new BulkObservableCollection <StackFrameViewModel>(); }
public ObjectsViewModel( StoryService storyService) : base("ObjectsView") { this.storyService = storyService; this.storyService.StoryOpened += StoryService_StoryOpened; this.storyService.StoryClosing += StoryService_StoryClosing; this.NavigateCommand = RegisterCommand <int>( text: "Navigate", name: "Navigate", executed: NavigateExecuted, canExecute: CanNavigateExecute); objects = new BulkObservableCollection <ObjectViewModel>(); }
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); }
static void FillCompletionList(AsyncServerMessage.CompleteWord msg, BulkObservableCollection <Completion> completions) { foreach (var elem in msg.completionList) { switch (elem) { case CompletionElem.Literal literal: completions.Add(new NitraCompletion(literal.text, literal.text, "literal", null, null)); break; case CompletionElem.Symbol symbol: completions.Add(new NitraCompletion(symbol.name, symbol.name, symbol.description, null, null)); break; } } }
public QuickInfoSession(ITextView textView, ITrackingPoint triggerPoint, bool trackMouse, IIntellisensePresenterFactoryService intellisensePresenterFactoryService, Lazy<IQuickInfoSourceProvider, IOrderableContentTypeMetadata>[] quickInfoSourceProviders) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); if (intellisensePresenterFactoryService == null) throw new ArgumentNullException(nameof(intellisensePresenterFactoryService)); if (quickInfoSourceProviders == null) throw new ArgumentNullException(nameof(quickInfoSourceProviders)); Properties = new PropertyCollection(); QuickInfoContent = new BulkObservableCollection<object>(); TextView = textView; this.triggerPoint = triggerPoint; TrackMouse = trackMouse; this.intellisensePresenterFactoryService = intellisensePresenterFactoryService; this.quickInfoSourceProviders = quickInfoSourceProviders; TextView.Closed += TextView_Closed; }
public void TestFixWBS() { var g1 = new KAction() { Label = "G1", WBS = "1" }; var t1 = new KAction() { Label = "T1", WBS = "1.2" }; var t2 = new KAction() { Label = "T2", WBS = "1.3" }; var t21 = new KAction() { Label = "T21", WBS = "1.3.0" }; var t22 = new KAction() { Label = "T22", WBS = "1.3.2" }; var actions = new List <KAction>() { g1, t1, t2, t21, t22 }; var collection = new BulkObservableCollection <DataTreeGridItem>(); var manager = new GridActionsManager(collection, null, null); manager.ChangeView(GanttGridView.WBS, null); manager.RegisterInitialActions(actions); manager.FixAllWBS(); AssertWBS(g1, "1"); AssertWBS(t1, "1.1"); AssertWBS(t2, "1.2"); AssertWBS(t21, "1.2.1"); AssertWBS(t22, "1.2.2"); }
public ImportSettings(IInterpreterOptionsService service) { _service = service; if (_service != null) { AvailableInterpreters = new ObservableCollection<PythonInterpreterView>( Enumerable.Repeat(_defaultInterpreter, 1) .Concat(_service.Interpreters.Select(fact => new PythonInterpreterView(fact))) ); } else { AvailableInterpreters = new ObservableCollection<PythonInterpreterView>(); AvailableInterpreters.Add(_defaultInterpreter); } SelectedInterpreter = AvailableInterpreters[0]; TopLevelPythonFiles = new BulkObservableCollection<string>(); Customization = _projectCustomizations.First(); Filters = "*.pyw;*.txt;*.htm;*.html;*.css;*.djt;*.js;*.ini;*.png;*.jpg;*.gif;*.bmp;*.ico;*.svg"; }
public ImportSettings() { TopLevelJavaScriptFiles = new BulkObservableCollection<string>(); Filters = DefaultLanguageExtensionsFilter; }
public ImportSettings() { TopLevelJavaScriptFiles = new BulkObservableCollection<string>(); Filters = "*.txt;*.htm;*.html;*.css;*.png;*.jpg;*.gif;*.bmp;*.ico;*.svg;*.json;*.md;*.ejs;*.styl;*.jade;*.xml;*.ts"; }
/// <summary> /// Initializes a new instance with the specified properties. /// </summary> /// <param name="moniker">The unique, non-localized identifier for the completion set.</param> /// <param name="displayName">The localized name of the completion set.</param> /// <param name="applicableTo">The tracking span to which the completions apply.</param> /// <param name="completions">The list of completions.</param> /// <param name="options">The options to use for filtering and selecting items.</param> /// <param name="comparer">The comparer to use to order the provided completions.</param> /// <param name="matchInsertionText">If true, matches user input against /// the insertion text; otherwise, uses the display text.</param> public FuzzyCompletionSet( string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable<DynamicallyVisibleCompletion> completions, IComparer<Completion> comparer, bool matchInsertionText = false ) : base(moniker, displayName, applicableTo, null, null) { _matchInsertionText = matchInsertionText; _completions = new BulkObservableCollection<Completion>(); _completions.AddRange(completions .Where(c => c != null && !string.IsNullOrWhiteSpace(c.DisplayText)) .OrderBy(c => c, comparer) ); _comparer = new FuzzyStringMatcher(FuzzyMatchMode.Default); #if FALSE _shouldFilter = options.FilterCompletions; _shouldHideAdvanced = options.HideAdvancedMembers && !_completions.All(IsAdvanced); #endif _shouldFilter = true; _shouldHideAdvanced = false; if (_shouldFilter | _shouldHideAdvanced) { _filteredCompletions = new FilteredObservableCollection<Completion>(_completions); foreach (var c in _completions.Cast<DynamicallyVisibleCompletion>()) { c.Visible = !_shouldHideAdvanced || !IsAdvanced(c); } _filteredCompletions.Filter(IsVisible); } }
/// <summary> /// Initializes a new instance with the specified properties. /// </summary> /// <param name="moniker">The unique, non-localized identifier for the /// completion set.</param> /// <param name="displayName">The localized name of the completion set. /// </param> /// <param name="applicableTo">The tracking span to which the /// completions apply.</param> /// <param name="completions">The list of completions.</param> /// <param name="options">The options to use for filtering and /// selecting items.</param> /// <param name="comparer">The comparer to use to order the provided /// completions.</param> public FuzzyCompletionSet(string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable<DynamicallyVisibleCompletion> completions, CompletionOptions options, IComparer<Completion> comparer) : base(moniker, displayName, applicableTo, null, null) { _completions = new BulkObservableCollection<Completion>(); _completions.AddRange(completions.OrderBy(c => c, comparer)); _comparer = new FuzzyStringMatcher(options.SearchMode); _shouldFilter = options.FilterCompletions; _shouldHideAdvanced = options.HideAdvancedMembers; if (_shouldFilter | _shouldHideAdvanced) { _filteredCompletions = new FilteredObservableCollection<Completion>(_completions); foreach (var c in _completions.Cast<DynamicallyVisibleCompletion>()) { c.Visible = !_shouldHideAdvanced || !IsAdvanced(c); } _filteredCompletions.Filter(IsVisible); } }
/// <summary> /// Perform a bulk update of a collection of <see cref="Completion"/> instances to match the values /// contained in a pair of source collections. /// </summary> /// <remarks>The <see cref="Completion"/> instances in <paramref name="sourceCompletions"/> and /// <paramref name="secondSourceCompletions"/> are merged and sorted using /// <see cref="CompletionDisplayTextComparer.Default"/>. /// /// <list type="bullet"> /// <item>Any items present in <paramref name="result"/> but not present in the merged collection are /// removed from <paramref name="result"/>.</item> /// <item>Any items not already present in <paramref name="result"/> are inserted at the correct /// location.</item> /// </list> /// /// <note type="caller">The <paramref name="result"/> collection is assumed to already be sorted /// according to <see cref="CompletionDisplayTextComparer.Default"/> before this method is called.</note> /// </remarks> /// <param name="result">The collection holding the merged result.</param> /// <param name="sourceCompletions">The collection of <see cref="Completion"/> instances from the first /// source.</param> /// <param name="secondSourceCompletions">The collection of <see cref="Completion"/> instances from the /// second source.</param> private static void UpdateCompletionList(BulkObservableCollection<Completion> result, IEnumerable<Completion> sourceCompletions, IEnumerable<Completion> secondSourceCompletions) { try { result.BeginBulkOperation(); // SortedSet<Completion> provides for immediate sorting, and also allows Contains() to be used // below instead of a manual call to CompletionDisplayTextComparer.Compare(). SortedSet<Completion> filteredCompletions = new SortedSet<Completion>(CompletionDisplayTextComparer.Default); filteredCompletions.UnionWith(sourceCompletions); filteredCompletions.UnionWith(secondSourceCompletions); int j = 0; foreach(Completion completion in filteredCompletions) { while(j < result.Count && !filteredCompletions.Contains(result[j])) result.RemoveAt(j); if(j == result.Count || completion != result[j]) { result.Insert(j, completion); j++; } } } finally { result.EndBulkOperation(); } }