public void CreateTab(TabModel info) { this._tabs.Add(info); this.CurrentFocusTabIndex = this._tabs.Count - 1; // commit changes TabManager.Save(); }
public TabModel ToTabModel() { FilterQuery filter; try { filter = QueryCompiler.Compile(Query); } catch (FilterQueryException ex) { BackstageModel.RegisterEvent(new QueryCorruptionEvent(Name, ex)); filter = null; } var model = new TabModel { Name = Name, FilterQuery = filter, RawQueryString = Query, BindingHashtags = this.BindingHashtags.Guard(), NotifyNewArrivals = this.NotifyNewArrivals, NotifySoundSource = this.NotifySoundSource, ShowUnreadCounts = this.ShowUnreadCounts }; this.BindingAccountIds.ForEach(model.BindingAccounts.Add); return model; }
public TabDescription(TabModel model) { this.Name = model.Name; this.ShowUnreadCounts = model.ShowUnreadCounts; this.NotifyNewArrivals = model.NotifyNewArrivals; this.BindingAccountIds = model.BindingAccounts.ToArray(); this.BindingHashtags = model.BindingHashtags.ToArray(); this.Query = model.FilterQuery != null ? model.FilterQuery.ToQuery() : null; }
public TabViewModel(ColumnViewModel parent, TabModel model) : base(model) { this._parent = parent; this._model = model; this._model.OnNewStatusArrival += _ => this.UnreadCount++; this._model.BindingAccountsChanged += () => this.RaisePropertyChanged(() => this.CurrentAccounts); this._model.FocusRequired += this.SetFocus; model.IsActivated = true; }
public TabDescription(TabModel model) { this.Name = model.Name; this.ShowUnreadCounts = model.ShowUnreadCounts; this.NotifyNewArrivals = model.NotifyNewArrivals; this.BindingAccountIds = model.BindingAccounts.ToArray(); this.BindingHashtags = model.BindingHashtags.ToArray(); this.NotifySoundSource = model.NotifySoundSource; this.Query = model.GetQueryString(); }
internal static void NotifyNewArrival(TwitterStatus status, TabModel model) { lock (_acceptingArrivals) { List<TabModel> list; if (_acceptingArrivals.TryGetValue(status.Id, out list)) { list.Add(model); } } }
/// <summary> /// Find tab info where existed. /// </summary> /// <param name="info">tab info</param> /// <param name="colIndex">column index</param> public static int FindTabIndex(TabModel info, int colIndex) { for (var ti = 0; ti < Columns[colIndex].Tabs.Count; ti++) { if (Columns[colIndex].Tabs[ti] == info) { return(ti); } } return(-1); }
/// <summary> /// Create new tab model /// </summary> /// <param name="name">tab name</param> /// <param name="query">tab query(KQ)</param> /// <returns>tab model</returns> public static TabModel Create(string name, string query) { var model = new TabModel { Name = name, FilterQuery = query != null?QueryCompiler.Compile(query) : null, RawQueryString = query, ShowUnreadCounts = true, NotifyNewArrivals = false, }; var cf = TabManager.CurrentFocusTab; cf?.BindingAccounts.ForEach(model.BindingAccounts.Add); return(model); }
/// <summary> /// Create new tab model /// </summary> /// <param name="name">tab name</param> /// <param name="query">tab query(KQ)</param> /// <returns>tab model</returns> public static TabModel Create(string name, string query) { var model = new TabModel { Name = name, FilterQuery = query != null ? QueryCompiler.Compile(query) : null, IsShowUnreadCounts = true, IsNotifyNewArrivals = true }; var cf = TabManager.CurrentFocusTab; if (cf != null) { cf.BindingAccounts.ForEach(model.BindingAccounts.Add); } return model; }
private void StartTabConfigure(Tuple<TabModel, ISubject<Unit>> args) { var model = args.Item1; var callback = args.Item2; this._completeCallback = callback; this._currentConfigurationTarget = model; this.IsConfigurationActive = true; _filterQuery = model.FilterQuery; _initialQuery = _filterQuery == null ? String.Empty : _filterQuery.ToQuery(); _foundError = false; _currentQueryString = _initialQuery; RaisePropertyChanged(() => TabName); RaisePropertyChanged(() => IsShowUnreadCounts); RaisePropertyChanged(() => IsNotifyNewArrivals); RaisePropertyChanged(() => QueryString); RaisePropertyChanged(() => FoundError); }
/// <summary> /// Find tab info where existed. /// </summary> /// <param name="info">tab info</param> /// <param name="colIndex">column index</param> /// <param name="tabIndex">tab index</param> public static bool FindColumnTabIndex(TabModel info, out int colIndex, out int tabIndex) { for (var ci = 0; ci < Columns.Count; ci++) { for (var ti = 0; ti < Columns[ci].Tabs.Count; ti++) { if (Columns[ci].Tabs[ti] != info) { continue; } colIndex = ci; tabIndex = ti; return(true); } } colIndex = -1; tabIndex = -1; return(false); }
public TabViewModel(ColumnViewModel parent, TabModel model) : base(model) { this._parent = parent; this._model = model; this.CompositeDisposable.Add( new EventListener<Action<TwitterStatus>>( h => _model.OnNewStatusArrival += h, h => model.OnNewStatusArrival -= h, _ => this.UnreadCount++)); this.CompositeDisposable.Add( new EventListener<Action>( h => _model.BindingAccountsChanged += h, h => _model.BindingAccountsChanged -= h, () => this.RaisePropertyChanged(() => this.CurrentAccounts))); this.CompositeDisposable.Add( new EventListener<Action>( h => _model.FocusRequired += h, h => _model.FocusRequired -= h, this.SetFocus)); model.IsActivated = true; }
/// <summary> /// Create tab into specified column /// </summary> public static void CreateTab(TabModel info, int columnIndex) { // ReSharper disable LocalizableElement if (columnIndex > Columns.Count) // column index is only for existed or new column { throw new ArgumentOutOfRangeException( "columnIndex", "currently " + Columns.Count + " columns are existed. so, you can't set this parameter as " + columnIndex + "."); } // ReSharper restore LocalizableElement if (columnIndex == Columns.Count) { // create new CreateColumn(info); } else { Columns[columnIndex].CreateTab(info); Save(); } }
private void ResolveTabReference() { if (string.IsNullOrEmpty(_tabName)) { return; } if (_tab == null) { if (!TabManager.GetColumnInfoData().Any()) { // tabs are initializing, skip return; } _tab = TabManager.GetColumnInfoData() .SelectMany(c => c.Tabs) .FirstOrDefault(t => t.Name == _tabName); if (_tab == null) { throw new ArgumentException(FilterObjectResources.FilterLocalTabNotFound); } } if (EnumerableEx.Return(this) .Expand(f => f._tab != null && f._tab.FilterQuery != null ? f._tab.FilterQuery.Sources.OfType<FilterLocal>() : Enumerable.Empty<FilterLocal>() ) .Skip(1) .Any(f => f._tab == _tab) ) { throw new ArgumentException(FilterObjectResources.FilterLocalTabIsRecursion); } }
private void StartTabConfigure(Tuple<TabModel, ISubject<Unit>> args) { // ensure close before starting configuration this.IsConfigurationActive = false; var model = args.Item1; var callback = args.Item2; this._completeCallback = callback; this._currentConfigurationTarget = model; this.IsConfigurationActive = true; this._lastValidFilterQuery = model.FilterQuery; this._initialNormalizedQuery = _lastValidFilterQuery == null ? String.Empty : _lastValidFilterQuery.ToQuery(); _foundError = false; _currentQueryString = model.GetQueryString(); RaisePropertyChanged(() => TabName); RaisePropertyChanged(() => IsShowUnreadCounts); RaisePropertyChanged(() => IsNotifyNewArrivals); RaisePropertyChanged(() => NotifySoundSourcePath); RaisePropertyChanged(() => QueryString); RaisePropertyChanged(() => FoundError); }
public void CreateTab(TabModel info) { this._tabs.Add(info); this.CurrentFocusTabIndex = this._tabs.Count - 1; }
/// <summary> /// Create tab into specified column /// </summary> public static void CreateTab(TabModel info, int columnIndex) { // ReSharper disable LocalizableElement if (columnIndex > _columns.Count) // column index is only for existed or new column throw new ArgumentOutOfRangeException( "columnIndex", "currently " + _columns.Count + " columns are existed. so, you can't set this parameter as " + columnIndex + "."); // ReSharper restore LocalizableElement if (columnIndex == _columns.Count) { // create new CreateColumn(info); } else { _columns[columnIndex].CreateTab(info); Save(); } }
/// <summary> /// Create tab /// </summary> /// <param name="info">tab information</param> public static void CreateTab(TabModel info) { CreateTab(info, _currentFocusColumnIndex); Save(); }
/// <summary> /// Find tab info where existed. /// </summary> /// <param name="info">tab info</param> /// <param name="colIndex">column index</param> /// <param name="tabIndex">tab index</param> public static bool FindColumnTabIndex(TabModel info, out int colIndex, out int tabIndex) { for (var ci = 0; ci < _columns.Count; ci++) { for (var ti = 0; ti < _columns[ci].Tabs.Count; ti++) { if (_columns[ci].Tabs[ti] != info) continue; colIndex = ci; tabIndex = ti; return true; } } colIndex = -1; tabIndex = -1; return false; }
/// <summary> /// Find tab info where existed. /// </summary> /// <param name="info">tab info</param> /// <param name="colIndex">column index</param> public static int FindTabIndex(TabModel info, int colIndex) { for (var ti = 0; ti < _columns[colIndex].Tabs.Count; ti++) { if (_columns[colIndex].Tabs[ti] == info) { return ti; } } return -1; }
public static IObservable<Unit> ShowTabConfigure(TabModel model) { var notifier = new Subject<Unit>(); var handler = TabModelConfigureRaised; if (handler != null) handler(Tuple.Create(model, (ISubject<Unit>)notifier)); return notifier; }
public static void NotifyChangeFocusingTab(TabModel tabModel) { if (_currentFocusTabModel == tabModel) return; _currentFocusTabModel = null; if (!_bindingAccounts.Select(a => a.Id).SequenceEqual(tabModel.BindingAccounts)) { _bindingAccounts.Clear(); tabModel.BindingAccounts .Select(Setting.Accounts.Get) .Where(_ => _ != null) .ForEach(_bindingAccounts.Add); } if (!_bindingHashtags.SequenceEqual(tabModel.BindingHashtags)) { _bindingHashtags.Clear(); tabModel.BindingHashtags.ForEach(_bindingHashtags.Add); } _currentFocusTabModel = tabModel; }
public void CopyTab() { var model = new TabModel { Name = this.Name, FilterQuery = this.Model.FilterQuery != null ? QueryCompiler.Compile(this.Model.FilterQuery.ToQuery()) : null, BindingHashtags = this.Model.BindingHashtags.ToArray(), NotifyNewArrivals = this.Model.NotifyNewArrivals, ShowUnreadCounts = this.Model.ShowUnreadCounts, NotifySoundSource = this.Model.NotifySoundSource }; this.Model.BindingAccounts.ForEach(id => model.BindingAccounts.Add(id)); this.Parent.Model.CreateTab(model); }
public static IObservable<Unit> ShowTabConfigure(TabModel model) { var notifier = new Subject<Unit>(); var handler = TabConfigureRequested; if (handler != null) { handler(Tuple.Create(model, (ISubject<Unit>)notifier)); } else { notifier.OnCompleted(); } return notifier; }
internal void ChangeFocusingTab(TabModel previous, TabModel replace) { _currentFocusTabModel = null; if (previous != null) { previous.BindingHashtags = _bindingHashtags.ToArray(); } _bindingHashtags.Clear(); if (replace != null) { replace.BindingHashtags .Guard() .ToArray() .ForEach(_bindingHashtags.Add); } _currentFocusTabModel = replace; }
public void CopyTab() { try { var model = new TabModel { Name = this.Name, FilterQuery = this.Model.FilterQuery != null ? QueryCompiler.Compile(this.Model.FilterQuery.ToQuery()) : null, RawQueryString = this.Model.RawQueryString, BindingHashtags = this.Model.BindingHashtags.ToArray(), NotifyNewArrivals = this.Model.NotifyNewArrivals, ShowUnreadCounts = this.Model.ShowUnreadCounts, NotifySoundSource = this.Model.NotifySoundSource }; this.Model.BindingAccounts.ForEach(id => model.BindingAccounts.Add(id)); this.Parent.Model.CreateTab(model); } catch (FilterQueryException fqex) { BackstageModel.RegisterEvent( new OperationFailedEvent(QueryCompilerResources.QueryCompileFailed, fqex)); } }