Esempio n. 1
0
        private void OnFinishClick()
        {
            Trace.WriteLine("SubscribeToSearchFeeds -- OnFinishClick.");
            _nextButton.Enabled = false;
            if (_feedsToSubscribe == null)
            {
                throw new InvalidOperationException("Trying to finish wizard with unknown feeds to subscribe");
            }
            if (_feedsToSubscribe.Length == 0)
            {
                DoCancel();
                Close();
                return;
            }
            if (_feedsToSubscribe.Length == 1 &&
                RSSPlugin.GetExistingFeed(_feedsToSubscribe [0].Resource.GetStringProp(Props.URL)) != null)
            {
                MessageBox.Show(this, "You have already subscribed to this feed.",
                                "Subscribe to Feed");
                DoCancel();
                return;
            }

            IResource parentGroup = _titleGroupPane.SelectedGroup;

            if (parentGroup == null)
            {
                parentGroup = RSSPlugin.RootFeedGroup;
            }

            Trace.WriteLine("SubscribeToSearchFeeds -- Starting to link feeds to parent.");
            foreach (ResourceProxy proxy in _feedsToSubscribe)
            {
                if (proxy == _newFeedProxy)
                {
                    _newFeedProxy = null;
                }
                proxy.BeginUpdate();
                try
                {
                    if (_feedsToSubscribe.Length == 1)
                    {
                        proxy.SetProp(Core.Props.Name, _titleGroupPane.FeedTitle);
                    }
                    proxy.DeleteProp(Props.Transient);
                    proxy.SetProp(Core.Props.Parent, parentGroup);
                    Trace.WriteLine("SubscribeToSearchFeeds -- Link feed to parent [" + parentGroup.DisplayName + "]");
                }
                finally
                {
                    proxy.EndUpdate();
                    Trace.WriteLine("SubscribeToSearchFeeds -- EndUpdate called for a feed");
                }
                Core.WorkspaceManager.AddToActiveWorkspace(proxy.Resource);
                Trace.WriteLine("SubscribeToSearchFeeds -- AddToActiveWorkspace called for a feed.");
                RSSPlugin.GetInstance().QueueFeedUpdate(proxy.Resource);
                Trace.WriteLine("SubscribeToSearchFeeds -- QueueFeedUpdate called for a feed.");
            }

            Core.UIManager.BeginUpdateSidebar();
            if (Core.TabManager.ActivateTab("Feeds"))
            {
                Core.LeftSidebar.ActivateViewPane("Feeds");
            }
            Core.UIManager.EndUpdateSidebar();
            RSSPlugin.RSSTreePane.SelectResource(_feedsToSubscribe [0].Resource);
            RSSPlugin.SaveSubscription();

            _newFeedProxy     = null;
            _feedsToSubscribe = null;
            Close();
        }