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 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); }
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"); }
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)); }
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")); }
/// <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")); }
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 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 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 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); } }