private void toolStripDropDownButtonSource_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            _selectedSource = (NewsSource)e.ClickedItem.Tag;


            UpdateUI();
        }
Exemplo n.º 2
0
        public virtual bool AddSource(NewsSource source)
        {
            lock (this)
            {
                if (_newsSources.Contains(source) || string.IsNullOrEmpty(source.Address))
                {// Already contained or invalid address.
                    return(false);
                }

                foreach (NewsSource iteratedSource in _newsSources)
                {
                    if (iteratedSource.Address == source.Address)
                    {// A source with this address already exists.
                        return(false);
                    }
                }

                _newsSources.Add(source);
                source.EnabledChangedEvent += new NewsSource.EnabledChangedDelegate(source_EnabledChangedEvent);
            }

            if (SourceAddedEvent != null)
            {
                SourceAddedEvent(this, source);
            }

            return(true);
        }
Exemplo n.º 3
0
        public virtual bool RemoveSource(NewsSource source)
        {
            lock (this)
            {
                if (_newsSources.Remove(source) == false)
                {// Not found.
                    return(false);
                }
                source.EnabledChangedEvent -= new NewsSource.EnabledChangedDelegate(source_EnabledChangedEvent);
            }

            if (SourceRemovedEvent != null)
            {
                SourceRemovedEvent(this, source);
            }

            return(true);
        }
        private void buttonSettings_Click(object sender, EventArgs e)
        {
            if (listViewFeeds.SelectedIndices.Count == 0)
            {
                return;
            }

            if (listViewFeeds.SelectedIndices.Count > 1)
            {
                MessageBox.Show("Select only one feed to show settings for.");
                return;
            }

            NewsSource source = _control.Manager.NewsSourcesUnsafe[listViewFeeds.SelectedIndices[0]];
            NewsSourceSettingsControl control = new NewsSourceSettingsControl(source);
            HostingForm form = new HostingForm("Source Settings", control);

            form.StartPosition = FormStartPosition.CenterScreen;
            form.ShowDialog();

            _control.UpdateUI();
        }
        private void buttonAddPreconfigured_Click(object sender, EventArgs e)
        {
            if (comboBoxPreconfigured.SelectedIndex < 0)
            {
                return;
            }

            Type       type      = _preconfiguredTypes[comboBoxPreconfigured.SelectedIndex];
            NewsSource newSource = (NewsSource)Activator.CreateInstance(type);

            foreach (NewsSource source in _control.Manager.NewsSourcesUnsafe)
            {
                if (source.GetType() == newSource.GetType())
                {
                    MessageBox.Show("A source of this type already created (only one instance of preconfigured types allowed).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            _control.Manager.AddSource(newSource);
            UpdateUI();
        }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 public RssNewsItem(NewsSource source)
     : base(source)
 {
 }
Exemplo n.º 7
0
 protected virtual void source_EnabledChangedEvent(NewsSource source)
 {
 }
Exemplo n.º 8
0
        public NewsSourceSettingsControl(NewsSource source)
        {
            InitializeComponent();

            _source = source;
        }
 void _manager_SourceAddedEvent(NewsManager manager, NewsSource source)
 {
     WinFormsHelper.BeginManagedInvoke(this, UpdateUI);
 }
 bool IsSourceSelected(NewsSource source)
 {
     return(_selectedSource == null || source == _selectedSource);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Extended constructor.
 /// </summary>
 public NewsItem(NewsSource source)
 {
     _source = source;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public NewsItem()
 {
     _source = null;
 }