コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        public bool RemoveOnlineEntrySource(OnlineEntrySource source)
        {
            lock (this)
            {
                if (_onlineEntrySources.Remove(source) == false)
                {
                    return false;
                }
            }

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

            return true;
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        /// <param name="entry"></param>
        void SetItemAsOnlineEntry(ListViewItem item, OnlineEntrySource entry)
        {
            if (listViewOnlineEntries.Groups[entry.Source] == null)
            {
                listViewOnlineEntries.Groups.Add(entry.Source, entry.Source);
            }

            listViewOnlineEntries.Groups[entry.Source].Items.Add(item);

            if (item.Text != entry.SymbolName)
            {
                item.Text = entry.SymbolName;
            }

            Color foreColor = SystemColors.ControlText;
            if (entry.IsDownloading)
            {
                foreColor = Color.Red;
            }

            if (item.ForeColor != foreColor)
            {
                item.ForeColor = foreColor;
            }

            if (item.Tag != entry)
            {
                if (item.Tag != null)
                {
                    OnlineEntrySource previousEntry = item.Tag as OnlineEntrySource;
                    previousEntry.DataDownloadUpdateEvent -= new OnlineEntrySource.EntrySourceUpdateDelegate(entry_DataDownloadUpdateEvent);
                    item.Tag = null;
                }

                item.Tag = entry;
                entry.DataDownloadUpdateEvent += new OnlineEntrySource.EntrySourceUpdateDelegate(entry_DataDownloadUpdateEvent);
            }

            while (item.SubItems.Count < 5)
            {
                item.SubItems.Add("");
            }

            if (item.SubItems[1].Text != item.SubItems[1].Text)
            {
                item.SubItems[1].Text = entry.Period.ToString();
            }

            if (item.SubItems[2].Text != Path.GetFileName(entry.Uri))
            {
                item.SubItems[2].Text = Path.GetFileName(entry.Uri);
            }

            if (item.SubItems[3].Text != "-")
            {
                item.SubItems[3].Text = "-";
            }

            if (item.SubItems[4].Text != entry.DownloadProgressPercentage.ToString())
            {
                // Quote count.
                item.SubItems[4].Text = entry.DownloadProgressPercentage.ToString();
            }
        }
 void Manager_OnlineEntrySourceRemovedEvent(DataStore manager, OnlineEntrySource entrySource)
 {
     WinFormsHelper.BeginFilteredManagedInvoke(this, TimeSpan.FromMilliseconds(250), UpdateUI);
 }
コード例 #4
0
 void entry_DataDownloadUpdateEvent(OnlineEntrySource entrySource)
 {
     WinFormsHelper.BeginFilteredManagedInvoke(this, UpdateUI);
 }
コード例 #5
0
 void source_DataDownloadedEventToDirectory(OnlineEntrySource source)
 {
     source.DataDownloadedEvent -= new OnlineEntrySource.EntrySourceUpdateDelegate(source_DataDownloadedEventToDataStore);
     source.EndDownload(false);
     WinFormsHelper.BeginFilteredManagedInvoke(this, UpdateUI);
 }
コード例 #6
0
        void source_DataDownloadedEventToDataStore(OnlineEntrySource source)
        {
            source.DataDownloadedEvent -= new OnlineEntrySource.EntrySourceUpdateDelegate(source_DataDownloadedEventToDataStore);

            if (source.DownloadSucceeded)
            {
                foreach (string filePath in source.DownloadedTempFilesPaths)
                {
                    Manager.AddEntryFromLocalFile(filePath);
                }

                WinFormsHelper.BeginManagedInvoke(this, delegate()
                {
                    toolStripStatusLabel1.DisplayStyle = ToolStripItemDisplayStyle.Text;
                    toolStripStatusLabel1.Text = "Download of [" + source.Uri.ToString() + "] successful.";
                });
            }
            else
            {
                WinFormsHelper.BeginManagedInvoke(this, delegate()
                {
                    toolStripStatusLabel1.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                    toolStripStatusLabel1.Text = "Download of [" + source.Uri.ToString() + "] failed.";
                });
            }

            source.EndDownload(true);
            WinFormsHelper.BeginFilteredManagedInvoke(this, UpdateUI);
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <param name="entry"></param>
        void SetItemAsOnlineEntry(ListViewItem item, OnlineEntrySource entry)
        {
            if (listViewOnlineEntries.Groups[entry.Source] == null)
            {
                listViewOnlineEntries.Groups.Add(entry.Source, entry.Source);
            }

            listViewOnlineEntries.Groups[entry.Source].Items.Add(item);

            if (item.Text != entry.SymbolName)
            {
                item.Text = entry.SymbolName;
            }

            Color foreColor = SystemColors.ControlText;

            if (entry.IsDownloading)
            {
                foreColor = Color.Red;
            }

            if (item.ForeColor != foreColor)
            {
                item.ForeColor = foreColor;
            }

            if (item.Tag != entry)
            {
                if (item.Tag != null)
                {
                    OnlineEntrySource previousEntry = item.Tag as OnlineEntrySource;
                    previousEntry.DataDownloadUpdateEvent -= new OnlineEntrySource.EntrySourceUpdateDelegate(entry_DataDownloadUpdateEvent);
                    item.Tag = null;
                }

                item.Tag = entry;
                entry.DataDownloadUpdateEvent += new OnlineEntrySource.EntrySourceUpdateDelegate(entry_DataDownloadUpdateEvent);
            }

            while (item.SubItems.Count < 5)
            {
                item.SubItems.Add("");
            }

            if (item.SubItems[1].Text != item.SubItems[1].Text)
            {
                item.SubItems[1].Text = entry.Period.ToString();
            }

            if (item.SubItems[2].Text != Path.GetFileName(entry.Uri))
            {
                item.SubItems[2].Text = Path.GetFileName(entry.Uri);
            }

            if (item.SubItems[3].Text != "-")
            {
                item.SubItems[3].Text = "-";
            }

            if (item.SubItems[4].Text != entry.DownloadProgressPercentage.ToString())
            {
                // Quote count.
                item.SubItems[4].Text = entry.DownloadProgressPercentage.ToString();
            }
        }
コード例 #8
0
 void Manager_OnlineEntrySourceRemovedEvent(DataStore manager, OnlineEntrySource entrySource)
 {
     WinFormsHelper.BeginFilteredManagedInvoke(this, TimeSpan.FromMilliseconds(250), UpdateUI);
 }