Esempio n. 1
0
 public void CreateTab(TabModel info)
 {
     this._tabs.Add(info);
     this.CurrentFocusTabIndex = this._tabs.Count - 1;
     // commit changes
     TabManager.Save();
 }
Esempio n. 2
0
 public void CreateTab(TabModel info)
 {
     this._tabs.Add(info);
     this.CurrentFocusTabIndex = this._tabs.Count - 1;
     // commit changes
     TabManager.Save();
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 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);
         }
     }
 }
Esempio n. 8
0
 /// <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);
 }
Esempio n. 9
0
        /// <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);
        }
Esempio n. 10
0
 /// <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);
 }
Esempio n. 12
0
 /// <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);
 }
Esempio n. 13
0
 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;
 }
Esempio n. 14
0
 /// <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();
     }
 }
Esempio n. 15
0
        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);
        }
Esempio n. 17
0
 public void CreateTab(TabModel info)
 {
     this._tabs.Add(info);
     this.CurrentFocusTabIndex = this._tabs.Count - 1;
 }
Esempio n. 18
0
 /// <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();
     }
 }
Esempio n. 19
0
 /// <summary>
 ///     Create tab
 /// </summary>
 /// <param name="info">tab information</param>
 public static void CreateTab(TabModel info)
 {
     CreateTab(info, _currentFocusColumnIndex);
     Save();
 }
Esempio n. 20
0
 /// <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;
 }
Esempio n. 21
0
 /// <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;
 }
Esempio n. 22
0
 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;
 }
Esempio n. 23
0
 /// <summary>
 ///     Create tab
 /// </summary>
 /// <param name="info">tab information</param>
 public static void CreateTab(TabModel info)
 {
     CreateTab(info, _currentFocusColumnIndex);
     Save();
 }
Esempio n. 24
0
 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;
 }
Esempio n. 25
0
 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);
 }
Esempio n. 26
0
 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;
 }
Esempio n. 27
0
 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;
 }
Esempio n. 28
0
 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));
     }
 }