public void test_wait_for_specific_action() { var timer = new Timer(); var instance = new Actions(timer); var complete = false; var count = 0; // Run an action which doesn't resolved immediately var task = new DeferredAction(); instance.Execute(task, (ep) => { count += 1; complete = true; }); Assert(complete == false); // Run some other action // Notice how all ActionCompleteEvents are skipped until the matching action. instance.Execute <SimpleAction>(); instance.Execute <SimpleAction>(); instance.Execute <SimpleAction>(); Assert(count == 0); Assert(complete == false); // Now we fake the deferred completion, and correctly catch it task.Complete(); Assert(count == 1); Assert(complete == true); }
public SearchTabViewModel(IChatState chatState, IBrowseThings browser) : base(chatState) { this.browser = browser; Container.RegisterType <object, SearchTabView>(SearchTabView); chatSearchCooldownTimer.Elapsed += (sender, args) => { isInSearchCoolDown = false; OnPropertyChanged("CanStartSearch"); chatSearchCooldownTimer.Stop(); }; saveTerms = DeferredAction.Create( () => SettingsService.SaveSearchTerms(ChatModel.CurrentCharacter.Name, new SearchTermsModel { AvailableTerms = availableSearchTerms.ToList(), SelectedTerms = selectedSearchTerms.ToList() })); if (ChatModel.CurrentCharacter == null) { return; } GetSearchTerms(ChatModel.CurrentCharacter.Name); }
public QuickMethodToolWindowControl(QuickMethodToolWindow oParent, bool searchInSolution, SymbolData.ESymbolType supportedSymbolTypes) { this.InitializeComponent(); mQuickMethodToolWindow = oParent; mSearchInSolution = searchInSolution; mSupportedSymbolTypes = supportedSymbolTypes; mDeferredRefresh = DeferredAction.Create(RefreshResults); mDeferredRefresh.Defer(0); DataContext = this; textBox.Focus(); // An aggregate catalog that combines multiple catalogs /* var catalog = new AggregateCatalog(); // Adds all the parts found in the necessary assemblies catalog.Catalogs.Add(new AssemblyCatalog(typeof(IGlyphService).Assembly)); catalog.Catalogs.Add(new AssemblyCatalog(typeof(SmartTagSurface).Assembly)); // Create the CompositionContainer with the parts in the catalog CompositionContainer mefContainer = new CompositionContainer(catalog); // Fill the imports of this object mefContainer.ComposeParts(this); [Import] public IGlyphService GlyphService { get; set; } */ }
private void FocusTextBox(TextBox textBox) { DeferredAction deferredAction = null; deferredAction = DeferredAction.Create(() => { if (textBox == null || App.Current == null || App.Current.MainWindow == null) { return; } textBox.Focus(); textBox.SelectAll(); FocusManager.SetFocusedElement(App.Current.MainWindow, textBox); Keyboard.Focus(textBox); if (textBox.IsVisible == false || textBox.IsKeyboardFocused) { deferredAction.Dispose(); } else { deferredAction.Defer(TimeSpan.FromSeconds(0.25)); } }); deferredAction.Defer(TimeSpan.FromSeconds(0.25)); }
private void GetSearchTerms(string character) { var cache = SettingsService.RetrieveTerms(character); if (cache == null) { var worker = new BackgroundWorker(); worker.DoWork += (sender, args) => PopulateSearchTerms(browser.GetResponse(Constants.UrlConstants.SearchFields, true)); worker.RunWorkerAsync(); } else { availableSearchTerms = new ObservableCollection <SearchTermModel>(cache.AvailableTerms); selectedSearchTerms = new ObservableCollection <SearchTermModel>(cache.SelectedTerms); } AvailableSearchTerms = new ListCollectionView(availableSearchTerms); AvailableSearchTerms.GroupDescriptions.Add(new PropertyGroupDescription("Category", new CategoryConverter())); AvailableSearchTerms.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending)); AvailableSearchTerms.Filter = o => ((SearchTermModel)o).DisplayName.ContainsOrdinal(searchString); SelectedSearchTerms = new ListCollectionView(selectedSearchTerms); SelectedSearchTerms.SortDescriptions.Add(new SortDescription("Category", ListSortDirection.Ascending)); SelectedSearchTerms.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending)); updateActiveViews = DeferredAction.Create(AvailableSearchTerms.Refresh); OnPropertyChanged("AvailableSearchTerms"); OnPropertyChanged("SelectedSearchTerms"); }
public QuickMethodToolWindowControl(QuickMethodToolWindow oParent, bool searchInSolution, SymbolData.ESymbolType supportedSymbolTypes) { this.InitializeComponent(); mQuickMethodToolWindow = oParent; mSearchInSolution = searchInSolution; mSupportedSymbolTypes = supportedSymbolTypes; mDeferredRefresh = DeferredAction.Create(RefreshResults); DataContext = this; textBox.Focus(); // An aggregate catalog that combines multiple catalogs /* * var catalog = new AggregateCatalog(); * * // Adds all the parts found in the necessary assemblies * catalog.Catalogs.Add(new AssemblyCatalog(typeof(IGlyphService).Assembly)); * catalog.Catalogs.Add(new AssemblyCatalog(typeof(SmartTagSurface).Assembly)); * * // Create the CompositionContainer with the parts in the catalog * CompositionContainer mefContainer = new CompositionContainer(catalog); * * // Fill the imports of this object * mefContainer.ComposeParts(this); * * [Import] * public IGlyphService GlyphService { get; set; } */ }
public void UpdateSkin(bool force = false) { if (force) { this.forceSkinRefresh = true; } if (!this.NeedsSkinChange()) { return; } if (this.cachedStability <= 0f || base.isServer) { this.ChangeSkin(); return; } if (!this.skinChange) { this.skinChange = new DeferredAction(this, new Action(this.ChangeSkin), ActionPriority.Medium); } if (!this.skinChange.Idle) { return; } this.skinChange.Invoke(); }
public GlobalTabViewModel(IChatState chatState) : base(chatState) { Container.RegisterType <object, GlobalTabView>(GlobalTabView); GenderSettings = new GenderSettingsModel(); SearchSettings.Updated += OnSearchSettingsUpdated; GenderSettings.Updated += OnSearchSettingsUpdated; Events.GetEvent <NewUpdateEvent>().Subscribe( args => { var thisNotification = args as CharacterUpdateModel; if (thisNotification == null) { return; } if (thisNotification.Arguments is CharacterListChangedEventArgs || thisNotification.Arguments is LoginStateChangedEventArgs) { OnPropertyChanged("SortedUsers"); } }); updateUserList = DeferredAction.Create(() => OnPropertyChanged("SortedUsers")); }
public void test_wait_for_specific_action() { var timer = new Timer(); var instance = new Actions(timer); var complete = false; var count = 0; // Run an action which doesn't resolved immediately var task = new DeferredAction(); instance.Execute(task, (ep) => { count += 1; complete = true; }); Assert(complete == false); // Run some other action // Notice how all ActionCompleteEvents are skipped until the matching action. instance.Execute<SimpleAction>(); instance.Execute<SimpleAction>(); instance.Execute<SimpleAction>(); Assert(count == 0); Assert(complete == false); // Now we fake the deferred completion, and correctly catch it task.Complete(); Assert(count == 1); Assert(complete == true); }
public void TestDeferredActionDone() { bool doneFlag = false; INetworkAction chat = new NetworkAction(); DeferredAction<INetworkAction> deferredAction = new DeferredAction<INetworkAction>() { Action = chat, Done = (action, requests, responses) => { doneFlag = true; } }; Assert.IsTrue(deferredAction.TryInsertDone(chat, new List<IPacket>() { new Packet() { Origin = PacketOrigin.Client, Type = PacketType.Request, RequestId = 1 } }, new List<IPacket>() { new Packet() { Origin = PacketOrigin.Client, Type = PacketType.Response, RequestId = 1 } })); Assert.IsTrue(doneFlag); }
public static void Enqueue(DeferredAction action) { if (!Object.op_Implicit((Object)SingletonComponent <LoadBalancer> .Instance)) { LoadBalancer.CreateInstance(); } ((LoadBalancer)SingletonComponent <LoadBalancer> .Instance).queues[action.Index].Enqueue(action); }
public static void Enqueue(DeferredAction action) { if (!SingletonComponent <LoadBalancer> .Instance) { LoadBalancer.CreateInstance(); } SingletonComponent <LoadBalancer> .Instance.queues[action.Index].Enqueue(action); }
/// <summary> /// Change the search filter when the user stops typing /// </summary> /// <param name="property"></param> internal void ChangeFilterPending(string property) { if (_deferredAction == null) { _deferredAction = DeferredAction.Create(ExecuteFilter); } _deferredAction.Defer(TimeSpan.FromMilliseconds(250)); }
public DirectoryView() { InitializeComponent(); Loaded += OnLoaded; m_delay = TimeSpan.FromMilliseconds(100); m_deferredAction = DeferredAction.Create(ApplySearchCriteria); }
public ChannelsTabViewModel(IChatState chatState, IUpdateChannelLists updater) : base(chatState) { this.updater = updater; Container.RegisterType <object, ChannelTabView>(ChannelsTabView); SearchSettings.Updated += Update; ChatModel.AllChannels.CollectionChanged += Update; updateChannelList = DeferredAction.Create(() => OnPropertyChanged("SortedChannels")); }
private void OnButtonClick2() { DeferredAction action = new DeferredAction ( () => { _buttonCallback2.InvokeIfNotNull(); OnClick.InvokeIfNotNull(2); }, 0.15f, DeferredType.TimeBased ); DrawMarker(); }
public void TestDeferredActionAlways() { bool alwaysFlag = false; INetworkAction chat = new NetworkAction(); DeferredAction<INetworkAction> deferredAction = new DeferredAction<INetworkAction>() { Action = chat, Always = action => { alwaysFlag = true; } }; Assert.IsTrue(deferredAction.TryInsertAlways(chat)); Assert.IsTrue(alwaysFlag); }
public void ScanForwardToNextTag() { while (Position < Content.Count && !Content[Position].IsTag) { if (!Content[Position].CanOutput) { DeferredAction action = Content[Position] as DeferredAction; Debug.Assert(action != null, "Internal content items should be deferred actions."); Content.RemoveAt(Position); action.Do(this); } else { ++Position; } } }
void CheckAndUnrevealDeferred() { IsBoardBlocked = true; DeferredAction doDeferred = new DeferredAction(() => { bool doMatch = Game.CheckIfCardsMatchAndDiscard(); if (!doMatch) { Game.PlayerHandler.CurrentPlayer.IncreaseMissedCount(); Game.PlayerHandler.NextTurn(); } Game.CheckIfGameIsOver(); Game.Board.UnrevealCards(); IsBoardBlocked = false; }, App.Current.Dispatcher); doDeferred.Defer(GlobalParameter.UnrevealTimeSpan); }
public QuickFileToolWindowControl(QuickFileToolWindow oQuickFileToolWindow, bool bHistoryOnly) { this.InitializeComponent(); mQuickFileToolWindow = oQuickFileToolWindow; mQuickFileToolWindow.Closing += OnClosing; mHistoryOnly = bHistoryOnly; Common.Instance.SolutionWatcher.OnFilesChanged += OnFilesChanged; mDeferredRefresh = DeferredAction.Create(RefreshResults); DataContext = this; textBox.Focus(); listView.SelectedIndex = 0; }
public UsersTabViewModel(IChatState chatState) : base(chatState) { Container.RegisterType <object, UsersTabView>(UsersTabView); GenderSettings = new GenderSettingsModel(); SearchSettings.Updated += OnSearchSettingsUpdated; GenderSettings.Updated += OnSearchSettingsUpdated; ChatModel.SelectedChannelChanged += (s, e) => { currentChan = null; OnPropertyChanged("SortContentString"); OnPropertyChanged("SortedUsers"); }; Events.GetEvent <NewUpdateEvent>().Subscribe( args => { var thisNotification = args as CharacterUpdateModel; if (thisNotification == null) { return; } if (thisNotification.Arguments is PromoteDemoteEventArgs) { OnPropertyChanged("HasPermissions"); } else if (thisNotification.Arguments is JoinLeaveEventArgs || thisNotification.Arguments is CharacterListChangedEventArgs) { OnPropertyChanged("SortedUsers"); } }); updateUserList = DeferredAction.Create(() => OnPropertyChanged("SortedUsers")); }
private void CreateDAM() { MailboxSession mailboxSession = base.Context.StoreSession as MailboxSession; base.Context.TraceDebug("Deferred action: Creating deferred action message."); using (DeferredAction deferredAction = RuleMessageUtils.CreateDAM(mailboxSession, this.folder.Id.ObjectId, this.provider)) { foreach (DeferredActionWorkItem.ActionInfo actionInfo in this.actions) { base.Context.TraceDebug <RuleAction>("Deferred action: Adding deferred action {0}.", actionInfo.Action); deferredAction.AddAction(actionInfo.RuleId, actionInfo.Action); } StoreId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); bool flag = RuleUtil.EqualsStoreId(defaultFolderId, base.Context.FinalDeliveryFolderId); deferredAction.Message[ItemSchema.DeferredActionMessageBackPatched] = !flag; base.Context.DeliveredMessage.Load(DeferredError.EntryId); byte[] value = (byte[])base.Context.DeliveredMessage[StoreObjectSchema.EntryId]; deferredAction.Message[ItemSchema.OriginalMessageEntryId] = value; base.Context.TraceDebug("Deferred action: Saving deferred action message."); deferredAction.SerializeActionsAndSave(); base.Context.TraceDebug("Deferred action: Deferred action message saved."); } }
public NovelView(INovel novel, ILibrary library) { _novel = novel; _library = library; var deactivateEditMode = new HotKey(Key.Escape, DeactivateEditMode); var activateEditMode = new HotKey(Key.Enter, ActivateEditMode); var leftTheLine = new HotKey(new Key("7"), LeftCurrentLine).WithCommand(); var centerTheLine = new HotKey(new Key("8"), CenterCurrentLine).WithCommand(); var rightTheLine = new HotKey(new Key("9"), RightCurrentLine).WithCommand(); var enableJoButton = new HotKey(new Key("]"), EnableJoButton); var enableJoButtonUpperCase = new HotKey(new Key("]"), EnableJoButtonUpperCase).WithShift(); var showAutocorrection = new HotKey(new KeyCombination(Key.Space, UIKeyModifierFlags.Shift), ShowAutocorrection); //var moveCursorToRight = new HotKey(new Key(";"), MoveCursorToRight); //var moveCursorToLeft = new HotKey(new Key("l"), MoveCursorToLeft); _viewModeScheme = new HotKeyScheme(activateEditMode); _editModeScheme = new HotKeyScheme(deactivateEditMode, leftTheLine, centerTheLine, rightTheLine, enableJoButton, enableJoButtonUpperCase, showAutocorrection); _save = new DeferredAction(TimeSpan.FromSeconds(10), () => _library.Update(this)); Initialize(); }
private static void FocusTextBox(TextBoxBase textBox) { DeferredAction.Create(context => { if (textBox == null || Application.Current == null || Application.Current.MainWindow == null) { return; } textBox.Focus(); textBox.SelectAll(); FocusManager.SetFocusedElement(Application.Current.MainWindow, textBox); Keyboard.Focus(textBox); if (textBox.IsVisible == false || textBox.IsKeyboardFocused) { context?.Dispose(); } else { context?.Defer(TimeSpan.FromSeconds(0.25)); } }).Defer(TimeSpan.FromSeconds(0.25)); }
public void UpdateSkin(bool force = false) { if (force) { forceSkinRefresh = true; } if (!NeedsSkinChange()) { return; } if (cachedStability <= 0f || base.isServer) { ChangeSkin(); return; } if (!skinChange) { skinChange = new DeferredAction(this, ChangeSkin); } if (skinChange.Idle) { skinChange.Invoke(); } }
public GlobalTabViewModel(IChatState chatState) : base(chatState) { Container.RegisterType<object, GlobalTabView>(GlobalTabView); GenderSettings = new GenderSettingsModel(); SearchSettings.Updated += OnSearchSettingsUpdated; GenderSettings.Updated += OnSearchSettingsUpdated; Events.GetEvent<NewUpdateEvent>().Subscribe( args => { var thisNotification = args as CharacterUpdateModel; if (thisNotification == null) return; if (thisNotification.Arguments is CharacterListChangedEventArgs || thisNotification.Arguments is LoginStateChangedEventArgs) OnPropertyChanged("SortedUsers"); }); updateUserList = DeferredAction.Create(() => OnPropertyChanged("SortedUsers")); }
public void TestDeferredActionGetAction() { INetworkAction chat = new NetworkAction() { ActionType = NetworkActionType.NetworkTextSay }; DeferredAction<INetworkAction> deferredAction = new DeferredAction<INetworkAction>() { Action = chat }; Assert.AreEqual(chat.Uid, deferredAction.GetAction().Uid); }
public MainForm() { InitializeComponent(); if (DesignMode || AppRunMode.DesignMode) { return; } _updateStatusDeferredAction = new DeferredAction(updateStatus) { MinNextActionTime = TimeSpan.FromSeconds(1), ReExecuteOnAbortSuspended = false, ReExecuteOnError = false }; _asyncProcessorr = new AsyncProcessor(5); _asyncProcessorr.ActionBegin += _asyncProcessorr_ActionsChanged; _asyncProcessorr.ActionEnd += _asyncProcessorr_ActionsChanged; _asyncProcessorr.ActionError += _asyncProcessorr_ActionsChanged; jobSearcher = new JobSearcher(_asyncProcessorr); formStateSaver = new FormStateSaver(this, true, "Reserve"); jobSearcher.Modified += jobSearcher_Modified; _deferredAsyncProcessor = new DeferredAsyncProcessor(new AsyncProcessor(10)); objectEditor1.DeferredAsyncProcessor = _deferredAsyncProcessor; resultList1.DeferredAsyncProcessor = _deferredAsyncProcessor; resultList2.DeferredAsyncProcessor = _deferredAsyncProcessor; resultList3.DeferredAsyncProcessor = _deferredAsyncProcessor; resultList4.DeferredAsyncProcessor = _deferredAsyncProcessor; resultList1.JobSearcher = jobSearcher; resultList2.JobSearcher = jobSearcher; resultList3.JobSearcher = jobSearcher; resultList4.JobSearcher = jobSearcher; resultList1.Results = jobSearcher.Results; resultList2.Results = jobSearcher.Favorites; resultList3.Results = jobSearcher.Favorites2; resultList4.Results = jobSearcher.BlockedResults; resultList1.BlockCompanies += resultList1_BlockCompanies; resultList2.BlockCompanies += resultList1_BlockCompanies; resultList3.BlockCompanies += resultList1_BlockCompanies; resultList4.BlockCompanies += resultList1_BlockCompanies; IDictionaryChangedDict <ICollectionChangedList <Result>, string> resultsDict = new SortDict <ICollectionChangedList <Result>, string>(CompareUtils.CompareHashCode); resultList1.ResultsDict = resultsDict; resultsDict.Add(jobSearcher.Results, "Results"); resultList2.ResultsDict = resultsDict; resultsDict.Add(jobSearcher.Favorites, "Favorites"); resultList3.ResultsDict = resultsDict; resultsDict.Add(jobSearcher.Favorites2, "Not sure"); resultsDict.Add(jobSearcher.BlockedResults, "Blocked"); resultList4.ResultsDict = resultsDict; objectEditor1.SetBindObject(jobSearcher.Sites); checkTextBox1.CheckTextChanged += checkTextBox1_CheckTextChanged; checkTextBox2.CheckTextChanged += checkTextBox1_CheckTextChanged; }
private void GetSearchTerms(string character) { var cache = SettingsService.RetrieveTerms(character); if (cache == null) { var worker = new BackgroundWorker(); worker.DoWork += (sender, args) => PopulateSearchTerms(browser.GetResponse(Constants.UrlConstants.SearchFields, true)); worker.RunWorkerAsync(); } else { availableSearchTerms = new ObservableCollection<SearchTermModel>(cache.AvailableTerms); selectedSearchTerms = new ObservableCollection<SearchTermModel>(cache.SelectedTerms); } AvailableSearchTerms = new ListCollectionView(availableSearchTerms); AvailableSearchTerms.GroupDescriptions.Add(new PropertyGroupDescription("Category", new CategoryConverter())); AvailableSearchTerms.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending)); AvailableSearchTerms.Filter = o => ((SearchTermModel) o).DisplayName.ContainsOrdinal(searchString); SelectedSearchTerms = new ListCollectionView(selectedSearchTerms); SelectedSearchTerms.SortDescriptions.Add(new SortDescription("Category", ListSortDirection.Ascending)); SelectedSearchTerms.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending)); updateActiveViews = DeferredAction.Create(AvailableSearchTerms.Refresh); OnPropertyChanged("AvailableSearchTerms"); OnPropertyChanged("SelectedSearchTerms"); }
public GeneralChannelViewModel(string name, IChatState chatState) : base(chatState) { try { Model = ChatModel.CurrentChannels.FirstOrDefault(chan => chan.Id == name) ?? ChatModel.AllChannels.First(chan => chan.Id == name); Model.ThrowIfNull("this.Model"); var safeName = StringExtensions.EscapeSpaces(name); Container.RegisterType <object, GeneralChannelView>(safeName, new InjectionConstructor(this)); isDisplayingChat = ShouldDisplayChat; ChannelManagementViewModel = new ChannelManagementViewModel(Events, (GeneralChannelModel)Model); // instance our management vm Model.Messages.CollectionChanged += OnMessagesChanged; Model.Ads.CollectionChanged += OnAdsChanged; Model.PropertyChanged += OnModelPropertyChanged; SearchSettings = new GenericSearchSettingsModel(); GenderSettings = new GenderSettingsModel(); messageManager = new FilteredMessageCollection( isDisplayingChat ? Model.Messages : Model.Ads, MeetsFilter, ConstantFilter, IsDisplayingAds); GenderSettings.Updated += (s, e) => OnPropertyChanged("GenderSettings"); SearchSettings.Updated += (s, e) => OnPropertyChanged("SearchSettings"); messageFloodTimer.Elapsed += (s, e) => { isInCoolDownMessage = false; messageFloodTimer.Enabled = false; OnPropertyChanged("CanPost"); }; adFloodTimer.Elapsed += (s, e) => { isInCoolDownAd = false; adFloodTimer.Enabled = false; OnPropertyChanged("CanPost"); OnPropertyChanged("CannotPost"); OnPropertyChanged("ShouldShowAutoPost"); if (autoPostAds) { SendAutoAd(); } else { autoPostCount = 0; } }; updateTimer.Elapsed += (s, e) => { if (!Model.IsSelected) { return; } if (CannotPost) { OnPropertyChanged("TimeLeft"); OnPropertyChanged("AutoTimeLeft"); } OnPropertyChanged("StatusString"); }; ChannelManagementViewModel.PropertyChanged += (s, e) => OnPropertyChanged("ChannelManagementViewModel"); updateTimer.Enabled = true; var newSettings = SettingsService.GetChannelSettings( ChatModel.CurrentCharacter.Name, Model.Title, Model.Id, Model.Type); Model.Settings = newSettings; ChannelSettings.Updated += (s, e) => { OnPropertyChanged("ChannelSettings"); OnPropertyChanged("HasNotifyTerms"); if (!ChannelSettings.IsChangingSettings) { SettingsService.UpdateSettingsFile( ChannelSettings, ChatModel.CurrentCharacter.Name, Model.Title, Model.Id); } }; PropertyChanged += OnPropertyChanged; updateSearch = DeferredAction.Create(() => messageManager.IsFiltering = isSearching); Events.GetEvent <NewUpdateEvent>().Subscribe(UpdateChat); LoggingSection = "general chan vm"; if (!string.IsNullOrWhiteSpace(ChannelSettings.LastMessage)) { Message = ChannelSettings.LastMessage; ChannelSettings.LastMessage = null; } SearchSettings.ShowOffline = true; Application.Current.Dispatcher.Invoke( () => Application.Current.MainWindow.Deactivated += SetLastMessageMark); } catch (Exception ex) { ex.Source = "General Channel ViewModel, init"; Exceptions.HandleException(ex); } }
public ManageListsViewModel(IChatState chatState) : base(chatState) { Container.RegisterType <object, ManageListsTabView>(ManageListsTabView); GenderSettings = new GenderSettingsModel(); SearchSettings.ShowNotInterested = true; SearchSettings.ShowIgnored = true; SearchSettings.Updated += OnSearchSettingsUpdated; GenderSettings.Updated += OnSearchSettingsUpdated; ChatModel.PropertyChanged += (s, e) => { if (e.PropertyName.Equals("OnlineFriends", StringComparison.OrdinalIgnoreCase)) { OnPropertyChanged("Friends"); } }; Events.GetEvent <NewUpdateEvent>().Subscribe( args => { var thisChannelUpdate = args as ChannelUpdateModel; if (thisChannelUpdate != null && (thisChannelUpdate.Arguments is ChannelTypeBannedListEventArgs || thisChannelUpdate.Arguments is ChannelDisciplineEventArgs)) { OnPropertyChanged("HasBanned"); OnPropertyChanged("Banned"); } var thisUpdate = args as CharacterUpdateModel; if (thisUpdate == null) { return; } var name = thisUpdate.TargetCharacter.Name; var joinLeaveArguments = thisUpdate.Arguments as JoinLeaveEventArgs; if (joinLeaveArguments != null) { if (CharacterManager.IsOnList(name, ListKind.Moderator, false)) { OnPropertyChanged("Moderators"); } if (CharacterManager.IsOnList(name, ListKind.Banned, false)) { OnPropertyChanged("Banned"); } return; } var signInOutArguments = thisUpdate.Arguments as LoginStateChangedEventArgs; if (signInOutArguments != null) { listKinds.Each(x => { if (CharacterManager.IsOnList(name, x.Key, false)) { OnPropertyChanged(x.Value); } }); return; } var thisArguments = thisUpdate.Arguments as CharacterListChangedEventArgs; if (thisArguments == null) { return; } switch (thisArguments.ListArgument) { case ListKind.Interested: OnPropertyChanged("Interested"); OnPropertyChanged("NotInterested"); OnPropertyChanged("SearchResults"); break; case ListKind.Ignored: OnPropertyChanged("Ignored"); OnPropertyChanged("SearchResults"); break; case ListKind.NotInterested: OnPropertyChanged("NotInterested"); OnPropertyChanged("Interested"); OnPropertyChanged("SearchResults"); break; case ListKind.Bookmark: OnPropertyChanged("Bookmarks"); OnPropertyChanged("SearchResults"); break; case ListKind.Friend: OnPropertyChanged("Friends"); OnPropertyChanged("SearchResults"); break; case ListKind.SearchResult: OnPropertyChanged("SearchResults"); OnPropertyChanged("HasSearchResults"); break; } }, true); ChatModel.SelectedChannelChanged += (s, e) => { OnPropertyChanged("HasUsers"); OnPropertyChanged("Moderators"); OnPropertyChanged("HasBanned"); OnPropertyChanged("Banned"); }; Events.GetEvent <ChatSearchResultEvent>().Subscribe(_ => { OnPropertyChanged("SearchResults"); OnPropertyChanged("HasSearchResults"); HasNewSearchResults = true; }); updateLists = DeferredAction.Create(UpdateBindings); }
public MainWindow() { InitializeComponent(); SearchResults = new ThreadSafeObservableCollection<SearchResult>(null, 750000); DisplaySearchResults = new ThreadSafeObservableCollection<SearchResult>(); _uiSynchronizationContext = new DispatcherSynchronizationContext(Application.Current.Dispatcher); _taskConsumer = Task.Factory.StartNew(() => ConsumeTasks(_tasks)); _updateFilter = new DeferredAction(FilterResults); _journals = new List<UsnJournal>(); // TODO: Convert to a user setting string[] drives = { "C" }; DataContext = this; if (DesignerProperties.GetIsInDesignMode(this)) { return; } _predicates = new Dictionary<PredicateOption, Func<SearchResult, bool>> { { PredicateOption.None, result => SearchCaseInsensitive(result.Name) }, { PredicateOption.MultipleTerms, result => SearchCaseInsensitiveMultiple(result.Name) }, { PredicateOption.CaseSensitive, result => Search(result.Name) }, { PredicateOption.CaseSensitive | PredicateOption.MultipleTerms, result => SearchMultiple(result.Name) } }; _searchTermNotifier = new PropertyChangeNotifier(this, "SearchTerm"); _searchTermNotifier.ValueChanged += OnSearchTermChanged; AddTask(() => EnumerateJournals(drives), "Enumerating journals"); }
public void TestDeferredActionRelease() { INetworkAction chat = new NetworkAction(); DeferredAction<INetworkAction> deferredAction = new DeferredAction<INetworkAction>() { Action = chat, Sent = (action, requests) => { }, Each = (action, request, response) => { }, Done = (action, requests, responses) => { }, Expired = (action, requests, responses) => { }, Always = action => { } }; deferredAction.Release(); Assert.IsNull(deferredAction.Sent); Assert.IsNull(deferredAction.Each); Assert.IsNull(deferredAction.Done); Assert.IsNull(deferredAction.Expired); Assert.IsNull(deferredAction.Always); }
public void TestDeferredActionSent() { bool sentFlag = false; INetworkAction chat = new NetworkAction(); DeferredAction<INetworkAction> deferredAction = new DeferredAction<INetworkAction>() { Action = chat, Sent = (action, requests) => { sentFlag = true; } }; Assert.IsTrue(deferredAction.TryInsertSent(chat, new List<IPacket>() { new Packet() { Origin = PacketOrigin.Client, Type = PacketType.Request, RequestId = 1 } })); Assert.IsTrue(sentFlag); }