Exemplo n.º 1
0
    public TabBookmark FindMatches(IList list)
    {
        TabModel    tabModel     = TabModel.Create("", list);
        TabBookmark bookmarkNode = tabModel.FindMatches(Filter, Filter.Depth);

        return(bookmarkNode);
    }
Exemplo n.º 2
0
 public void PinToTab()
 {
     TabManager.CreateTab(TabModel.Create(
                              _parent.ScreenName,
                              "from local where (user == @" + _parent.ScreenName + " & !retweet) | retweeter == @" +
                              _parent.ScreenName));
     _parent.Close();
 }
Exemplo n.º 3
0
    public bool IsMatch(object obj)
    {
        if (Filter == null || Filter.FilterText.IsNullOrEmpty())
        {
            return(true);
        }

        TabModel    tabModel     = TabModel.Create("Search", obj);
        TabBookmark bookmarkNode = tabModel.FindMatches(Filter, Filter.Depth);

        return(bookmarkNode.SelectedObjects.Count > 0);
    }
Exemplo n.º 4
0
        public void PinToTab()
        {
            var sn = _parent.ScreenName;

            if (sn.StartsWith("@"))
            {
                sn = sn.Substring(1);
            }
            TabManager.CreateTab(TabModel.Create(sn,
                                                 "from local where (user == @" + sn + " & !retweet) | retweeter == @" + sn));
            _parent.Close();
        }
Exemplo n.º 5
0
        public void ExtractSelecteds()
        {
            var users = SelectedStatuses
                        .Select(s => s.OriginalStatus.User.ScreenName)
                        .Distinct();

            TabManager.CreateTab(TabModel.Create(
                                     "extracted",
                                     "from all where " +
                                     users.Select(u => "user == \"" + u + "\"")
                                     .JoinString("||")));
            DeselectAll();
        }
Exemplo n.º 6
0
        public void CreateNewTab()
        {
            var creating = TabModel.Create(String.Empty, null);

            MainWindowModel.ShowTabConfigure(creating)
            .Subscribe(_ =>
            {
                if (String.IsNullOrEmpty(creating.Name) && creating.FilterQuery == null)
                {
                    return;
                }
                this.Model.CreateTab(creating);
            });
        }
Exemplo n.º 7
0
 public void PinToTab()
 {
     try
     {
         var filterQuery = _model.CreateFilterQuery();
         try
         {
             TabManager.CreateTab(TabModel.Create(Query, filterQuery));
             this._parent.RewindStack();
         }
         catch (Exception ex)
         {
             throw new InvalidOperationException(
                       "Invalid query was generated: " + filterQuery, ex);
         }
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException(
                   "Failed pinning into tab: " + Query, ex);
     }
 }
Exemplo n.º 8
0
    public static Control CreateChildControl(TabInstance parentTabInstance, object obj, string label = null, ITabSelector tabControl = null)
    {
        object value = obj.GetInnerValue();

        if (value == null || value is bool)
        {
            return(null);
        }

        if (label == null)
        {
            // use object? or inner value?
            label = obj.Formatted();
            if (label.IsNullOrEmpty())
            {
                label = "(" + obj.GetType().Name + ")";
            }
        }

        TabBookmark tabBookmark = null;         // Also assigned to child TabView's, tabView.tabInstance.tabBookmark = tabBookmark;

        if (parentTabInstance.TabBookmark != null && parentTabInstance.TabBookmark.ChildBookmarks != null)
        {
            if (parentTabInstance.TabBookmark.ChildBookmarks.TryGetValue(label, out tabBookmark))
            {
                // FindMatches only
                if (tabBookmark.TabModel != null)
                {
                    value = tabBookmark.TabModel;
                }
            }
        }

        string labelOverride = null;

        if (value is Exception)
        {
        }
        else if (parentTabInstance is ITabCreator parentTabCreator)
        {
            value = parentTabCreator.CreateControl(value, out labelOverride);
        }
        else if (tabControl is ITabCreator tabCreator)
        {
            value = tabCreator.CreateControl(value, out labelOverride);
        }
        if (value == null)
        {
            return(null);
        }

        if (labelOverride != null)
        {
            label = labelOverride;
        }

        Type type = value.GetType();

        if (value is string || value is decimal || type.IsPrimitive)
        {
            value = new TabText(value.ToString());             // create an ITab
        }

        /*else if (value is Uri uri)
         * {
         *      var tabWebBrowser = new TabWebBrowser(uri);
         *      value = tabWebBrowser;
         * }*/

        if (value is ILoadAsync loadAsync)
        {
            var childTabInstance = new TabInstanceLoadAsync(loadAsync)
            {
                Project     = parentTabInstance.Project,
                TabBookmark = tabBookmark,
            };
            childTabInstance.Model.Name = label;
            value = new TabView(childTabInstance);
        }

        if (value is ITabCreatorAsync creatorAsync)
        {
            //value = new TabCreatorAsync(creatorAsync);
            // todo: move elsewhere, we shouldn't be blocking during creation
            value = Task.Run(() => creatorAsync.CreateAsync(new Call())).GetAwaiter().GetResult();
        }

        if (value is ITab iTab)
        {
            // Custom controls implement ITab
            TabInstance childTabInstance = parentTabInstance.CreateChildTab(iTab);
            if (childTabInstance == null)
            {
                return(null);
            }

            childTabInstance.TabBookmark ??= tabBookmark;
            //childTabInstance.Reintialize(); // todo: fix, called in TabView
            childTabInstance.Model.Name = label;
            var tabView = new TabView(childTabInstance);
            tabView.Load();
            return(tabView);
        }
        else if (value is TabView tabView)
        {
            tabView.Instance.ParentTabInstance = parentTabInstance;
            tabView.Instance.TabBookmark       = tabBookmark ?? tabView.Instance.TabBookmark;
            tabView.Label = label;
            tabView.Load();
            return(tabView);
        }
        else if (value is Control control)
        {
            return(control);
        }

        /*else if (value is FilePath filePath)
         * {
         *      var tabAvalonEdit = new TabAvalonEdit(name);
         *      tabAvalonEdit.Load(filePath.path);
         *      return tabAvalonEdit;
         * }*/
        else
        {
            if (value is Enum && parentTabInstance.Model.Object.GetType().IsEnum)
            {
                return(null);
            }

            TabModel childTabModel;
            if (value is TabModel tabModel)
            {
                childTabModel      = tabModel;
                childTabModel.Name = label;
            }
            else
            {
                childTabModel = TabModel.Create(label, value);
                if (childTabModel == null)
                {
                    return(null);
                }
            }
            childTabModel.Editing = parentTabInstance.Model.Editing;

            TabInstance childTabInstance = parentTabInstance.CreateChild(childTabModel);
            childTabInstance.Label = label;

            var tabModelView = new TabView(childTabInstance);
            tabModelView.Load();
            return(tabModelView);
        }
    }
Exemplo n.º 9
0
 public static TabModel GenerateHomeTab()
 {
     return(TabModel.Create("home", "from local where user <- *.following | (retweet & (retweeter <- * | retweeter <- *.followings)) | user <- * | to -> *"));
 }
Exemplo n.º 10
0
 public static TabModel GenerateGeneralTab()
 {
     return(TabModel.Create("general", "from all where ()"));
 }
Exemplo n.º 11
0
 public static TabModel GenerateActivitiesTab()
 {
     return(TabModel.Create("activities", "from all where user <- * & (favs > 0 | rts > 0)"));
 }
Exemplo n.º 12
0
 public static TabModel GenerateMeTab()
 {
     return(TabModel.Create("me", "from all where (user <- * & !retweet) | retweeter <- *"));
 }
Exemplo n.º 13
0
 public static TabModel GenerateMentionTab()
 {
     return(TabModel.Create("mentions", "from all where to -> * & !retweet"));
 }
Exemplo n.º 14
0
 public void PinToTab()
 {
     TabManager.CreateTab(TabModel.Create(Query, _model.CreateFilterQuery()));
     this._parent.RewindStack();
 }