From 277fc69c11caca9236af227ef92377756307ece2 Mon Sep 17 00:00:00 2001 From: Sean Kessler Date: Fri, 23 Feb 2024 06:55:00 -0500 Subject: [PATCH] Init --- .gitignore | 330 +++++++++++++++++++++++++++++ Animation/FeedManager.cs | 162 ++++++++++++++ Animation/ItemEventArgs.cs | 14 ++ Animation/TaggedDoubleAnimation.cs | 14 ++ Animation/Ticker.cs | 95 +++++++++ Helper/FeedSerializer.cs | 116 ++++++++++ Models/FeedItem.cs | 153 +++++++++++++ Properties/AssemblyInfo.cs | 36 ++++ TickerLib.csproj | 79 +++++++ TickerLib.sln | 20 ++ Views/TickerItemView.xaml | 19 ++ Views/TickerItemView.xaml.cs | 35 +++ 12 files changed, 1073 insertions(+) create mode 100644 .gitignore create mode 100644 Animation/FeedManager.cs create mode 100644 Animation/ItemEventArgs.cs create mode 100644 Animation/TaggedDoubleAnimation.cs create mode 100644 Animation/Ticker.cs create mode 100644 Helper/FeedSerializer.cs create mode 100644 Models/FeedItem.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 TickerLib.csproj create mode 100644 TickerLib.sln create mode 100644 Views/TickerItemView.xaml create mode 100644 Views/TickerItemView.xaml.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e759b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,330 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ diff --git a/Animation/FeedManager.cs b/Animation/FeedManager.cs new file mode 100644 index 0000000..321f32f --- /dev/null +++ b/Animation/FeedManager.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows.Threading; +using Ticker.Models; +using Ticker.Helper; + +namespace Ticker.Animation +{ + public class FeedManager + { + private static int FEED_DEFAULT_INTERVAL_MINUTES=1; + private static String FEED_CACHE_FILE_NAME="feedcache.txt"; + private readonly Dictionary feedItems = new Dictionary(); + private DispatcherTimer dispatcherTimer = new DispatcherTimer(); + public event EventHandler> NewFeedItem; + public delegate List GetFeedItemsEventHandler(); + public event GetFeedItemsEventHandler FeedSourceEventHandler; + private bool stop = false; + private bool isInit=true; + public FeedManager() + { + ReadCache(); + dispatcherTimer.Tick += DispatcherTimer_Tick; + dispatcherTimer.Interval = new TimeSpan(0, FEED_DEFAULT_INTERVAL_MINUTES, 0); + } + public virtual void Dispose() + { + Stop(); + } + public void MarkFeedAsRead(FeedItem item) + { + if(!feedItems.ContainsKey(item.Guid))return; + feedItems[item.Guid].Read = true; + WriteCache(item); + } + public int GetFeedItemCount() + { + int count=0; + lock(feedItems) + { + if(null==feedItems||0==feedItems.Count)return count; + List feedItemsList=new List(feedItems.Values); + count=(from FeedItem feedItem in feedItemsList where feedItem.Read==false select feedItem).Count(); + } + return count; + } + private void DispatcherTimer_Tick(object sender, EventArgs e) + { + Go(); + } + public int FeedIntervalMinutes + { + get{return dispatcherTimer.Interval.Minutes;} + set{dispatcherTimer.Interval=new TimeSpan(0,value,0);} + } + public void Start() + { + stop = false; + Go(); + dispatcherTimer.Start(); + } + public void Stop() + { + if(stop)return; + if(null!=dispatcherTimer)dispatcherTimer.Stop(); + stop = true; + } + private void Go() + { + if(stop)return; + if(isInit) + { + isInit=false; + AddOpeningBanner(); + } + ThreadPool.QueueUserWorkItem(LoadFeed,null); + } +// *************************************************************************************************************************************************** +// *************************************************************************** F E E D C A C H E **************************************************** +// *************************************************************************************************************************************************** + private void ReadCache() + { + lock(feedItems) + { + feedItems.Clear(); + List cacheItems=FeedSerializer.Deserialize(FEED_CACHE_FILE_NAME); + foreach(FeedItem feedItem in cacheItems) + { + if(!feedItems.ContainsKey(feedItem.Guid))feedItems.Add(feedItem.Guid,feedItem); + } + } + } + private void WriteCache(FeedItem feedItem) + { + lock(feedItems) + { + List cacheItems=new List(feedItems.Values); + FeedSerializer.Serialize(FEED_CACHE_FILE_NAME,DateTime.Today,feedItem); + } + } +// *************************************************************************************************************************************************** + private void AddOpeningBanner() + { + FeedItem feedItem=new FeedItem(); + DateTime today=DateTime.Now; + feedItem.Description="TradeBlotter"; + feedItem.Title=today.ToLongDateString()+" "+today.ToLongTimeString(); + feedItem.Guid=today.ToLongTimeString(); + feedItem.Link="https://www.time.gov/"; + feedItem.Source=""; + feedItem.PubDate=today.ToLongDateString(); + feedItems.Add(feedItem.Guid,feedItem); + if (NewFeedItem != null) NewFeedItem(this, new ItemEventArgs(feedItem)); + } + private void LoadFeed(object state) + { + try + { + List newFeedItems=null; + if(null==FeedSourceEventHandler)return; + newFeedItems=FeedSourceEventHandler(); + if(null==newFeedItems||0==newFeedItems.Count)return; + foreach (FeedItem item in newFeedItems) + { + if (stop) return; + if (feedItems.ContainsKey(item.Guid)) continue; + item.Title = Clean(item.Title).Replace("\r","").Replace("\n",""); + item.Description = Clean(item.Description); + lock (feedItems) + { + feedItems.Add(item.Guid, item); + } + if (NewFeedItem != null) NewFeedItem(this, new ItemEventArgs(item)); + } + } + catch(Exception) + { + } + } + private static string Clean(string input) + { + string output = input.Trim(); + output = output.Replace("'", "'"); + output = output.Replace("&", "&"); + output = output.Replace(""", "\""); + output = output.Replace(" ", " "); + output = RemoveHTMLTags(output); + return output; + } + private static string RemoveHTMLTags(string text) + { + string regularExpressionString = "<.+?>"; + Regex r = new Regex(regularExpressionString, RegexOptions.Singleline); + return r.Replace(text, ""); + } + } +} \ No newline at end of file diff --git a/Animation/ItemEventArgs.cs b/Animation/ItemEventArgs.cs new file mode 100644 index 0000000..e21b733 --- /dev/null +++ b/Animation/ItemEventArgs.cs @@ -0,0 +1,14 @@ +using System; + +namespace Ticker.Animation +{ + public class ItemEventArgs : EventArgs + { + public ItemEventArgs(T item) + { + Item = item; + } + + public T Item { get; private set; } + } +} \ No newline at end of file diff --git a/Animation/TaggedDoubleAnimation.cs b/Animation/TaggedDoubleAnimation.cs new file mode 100644 index 0000000..cbd6b37 --- /dev/null +++ b/Animation/TaggedDoubleAnimation.cs @@ -0,0 +1,14 @@ +using System.Windows; +using System.Windows.Media.Animation; + +namespace Ticker.Animation +{ + public class TaggedDoubleAnimation : DoubleAnimation + { + public FrameworkElement TargetElement { get; set; } + protected override Freezable CreateInstanceCore() + { + return new TaggedDoubleAnimation{TargetElement = TargetElement}; + } + } +} \ No newline at end of file diff --git a/Animation/Ticker.cs b/Animation/Ticker.cs new file mode 100644 index 0000000..0aa9f63 --- /dev/null +++ b/Animation/Ticker.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Threading; + +namespace Ticker.Animation +{ + public class Ticker where T : FrameworkElement + { + private static int DISPLAY_TIMER_SPEED_SECONDS=40; // This is the speed used to traverse the display from right to left + private static int DISPLAY_TIMER_INTERVAL_MILLISECONDS=1000; // This is the interval of time between displaying successive items + private readonly DispatcherTimer displayTimer=new DispatcherTimer(DispatcherPriority.Normal); // new DispatcherTimer(); + public EventHandler> ItemDisplayed; + public Ticker(Panel container) + { + SeperatorSize = 25; + Container = container; + Container.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); + Container.Arrange(new Rect(Container.DesiredSize)); + Speed = new TimeSpan(0, 0, 0, DISPLAY_TIMER_SPEED_SECONDS); + Items = new Queue(); + displayTimer.Tick += displayTimer_Tick; + displayTimer.Start(); + IsRunning = true; + } + public virtual void Dispose() + { + Stop(); + } + public bool IsRunning { get; set; } + public void Stop() + { + if(!IsRunning)return; + if(null!=displayTimer)displayTimer.Stop(); + IsRunning = false; + } + public void Start() + { + if(IsRunning)return; + if(null==displayTimer)return; + displayTimer.Start(); + displayTimer.Interval = new TimeSpan(0,0,0,0,DISPLAY_TIMER_INTERVAL_MILLISECONDS); + IsRunning = true; + } + public double SeperatorSize { get; set; } + public TimeSpan Speed { get; set; } + public Queue Items { get; set; } + public Panel Container { get; private set; } + private void displayTimer_Tick(object sender, EventArgs e) + { + DisplayNextItem(); + } + private void DisplayNextItem() + { + if (Items.Count == 0)return; + T item = Items.Dequeue(); + Container.Children.Add(item); + AnimateMove(item); + if (ItemDisplayed != null) ItemDisplayed(this, new ItemEventArgs(item)); + } + private void AnimateMove(FrameworkElement e) + { + e.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); + e.Arrange(new Rect(e.DesiredSize)); + double from = Container.ActualWidth; + double to = -500; + int unitsPerSec = Convert.ToInt32(Math.Abs(from - to)/Speed.TotalSeconds); + int nextFire = Convert.ToInt32((e.ActualWidth + SeperatorSize)/unitsPerSec); + displayTimer.Stop(); + displayTimer.Interval = new TimeSpan(0, 0, nextFire); +// displayTimer.Dispatcher.Thread.Priority=ThreadPriority.AboveNormal; + displayTimer.Start(); + TaggedDoubleAnimation animation = new TaggedDoubleAnimation(); + animation.From = from; + animation.To = to; + animation.Duration = new Duration(Speed); + animation.TargetElement = e; + animation.Completed += ani_Completed; + TranslateTransform translateTransform = new TranslateTransform(); + e.RenderTransform = translateTransform; + translateTransform.BeginAnimation(TranslateTransform.XProperty, animation, HandoffBehavior.Compose); + } + private void ani_Completed(object sender, EventArgs e) + { + Clock clock = (Clock) sender; + TaggedDoubleAnimation animation = (TaggedDoubleAnimation) clock.Timeline; + FrameworkElement element = animation.TargetElement; + Container.Children.Remove(element); + } + } +} \ No newline at end of file diff --git a/Helper/FeedSerializer.cs b/Helper/FeedSerializer.cs new file mode 100644 index 0000000..e91f526 --- /dev/null +++ b/Helper/FeedSerializer.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Windows.Media; +using MarketData.Utils; +using Ticker.Models; +// Author:Sean Kessler +namespace Ticker.Helper +{ + public class FeedSerializer + { + private FeedSerializer() + { + } + public static List Deserialize(String strPathFileName) + { + List feedItems=new List(); + if(!File.Exists(strPathFileName))return feedItems; + String strLine=null; + + if(!IsCacheCurrent(strPathFileName,DateTime.Now)) + { + RemoveCache(strPathFileName); + return feedItems; + } + StreamReader streamReader=new StreamReader(new FileStream(strPathFileName,FileMode.Open)); + DateTime cacheDate=new NVP(streamReader.ReadLine()).Get(); + while(null!=(strLine=streamReader.ReadLine())) + { + if("".Equals(strLine))continue; + FeedItem feedItem=FeedItem.FromString(strLine); + if(null==feedItem)continue; + feedItems.Add(feedItem); + } + streamReader.Close(); + streamReader.Dispose(); + return feedItems; + } + public static bool Serialize(String strPathFileName,DateTime feedDate,List feedsList) + { + try + { + if(File.Exists(strPathFileName))File.Delete(strPathFileName); + StreamWriter streamWriter=new StreamWriter(new FileStream(strPathFileName,FileMode.CreateNew)); + streamWriter.WriteLine(new NVP("CacheDate",feedDate.ToShortDateString()).ToString()); + foreach(FeedItem feedItem in feedsList) + { + String strLine=feedItem.ToNVPCollection().ToString(); + if(null==strLine||"".Equals(strLine))continue; + streamWriter.WriteLine(strLine); + } + streamWriter.Flush(); + streamWriter.Close(); + streamWriter.Dispose(); + return true; + } + catch(Exception) + { + return false; + } + } + public static bool Serialize(String strPathFileName,DateTime feedDate,FeedItem feedItem) + { + try + { + StreamWriter streamWriter=null; + String strLine=feedItem.ToNVPCollection().ToString(); + if(null==strLine||"".Equals(strLine))return false; + if(!File.Exists(strPathFileName)) + { + streamWriter=new StreamWriter(new FileStream(strPathFileName,FileMode.CreateNew)); + streamWriter.WriteLine(new NVP("CacheDate",feedDate.ToShortDateString()).ToString()); + } + else + { + streamWriter=new StreamWriter(new FileStream(strPathFileName,FileMode.Append)); + } + streamWriter.WriteLine(strLine); + streamWriter.Flush(); + streamWriter.Close(); + streamWriter.Dispose(); + return true; + } + catch(Exception) + { + return false; + } + } + private static bool IsCacheCurrent(String strPathFileName,DateTime feedDate) + { + try + { + if(!File.Exists(strPathFileName))return false; + StreamReader streamReader=new StreamReader(new FileStream(strPathFileName,FileMode.Open)); + DateTime cacheDate=new NVP(streamReader.ReadLine()).Get(); + streamReader.Close(); + return feedDate.Date.Equals(cacheDate.Date); + } + catch(Exception) + { + return false; + } + } + private static void RemoveCache(String strPathFileName) + { + try + { + if(File.Exists(strPathFileName))File.Delete(strPathFileName); + } + catch(Exception) + { + } + } + } +} \ No newline at end of file diff --git a/Models/FeedItem.cs b/Models/FeedItem.cs new file mode 100644 index 0000000..195c35b --- /dev/null +++ b/Models/FeedItem.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Windows.Media; +using MarketData.Utils; +using Ticker.Helper; + +namespace Ticker.Models +{ + public class FeedBrushes + { + public enum BrushColor{Normal=0,Red=1,Green=2}; + public static Brush[] ContextBrushes={ + new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00ABA9")), + new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF0000")), + new SolidColorBrush((Color)ColorConverter.ConvertFromString("#008000")) + }; + private FeedBrushes() + { + } + public static Brush GetContextBrush(BrushColor brushColor) + { + return ContextBrushes[(int)brushColor]; + } + } +// + public class FeedItem : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + private string title; + private string pubDate; + private string link; + private string description; + private string guid; + private string source; + private bool read; + private FeedBrushes.BrushColor brushAssignment; + + public FeedItem() + { + brushAssignment=FeedBrushes.BrushColor.Normal; + } +// Don't save the link. Firstly, we don't need it, secondly, it contains '=' which are a keyword for NVP + public NVPCollection ToNVPCollection() + { + NVPCollection nvpCollection=new NVPCollection(); + nvpCollection.Add(new NVP("Title",title)); + nvpCollection.Add(new NVP("PubDate",pubDate)); + String fixupLink=link.Replace("=","^"); + nvpCollection.Add(new NVP("Link",fixupLink)); + nvpCollection.Add(new NVP("Description",description)); + nvpCollection.Add(new NVP("Guid",guid)); + nvpCollection.Add(new NVP("Source",source)); + nvpCollection.Add(new NVP("Read",read.ToString())); + return nvpCollection; + } + public static FeedItem FromString(String strFeedItem) + { + try + { + FeedItem feedItem=new FeedItem(); + NVPCollection nvpCollection=new NVPCollection(strFeedItem); + NVPDictionary nvpDictionary=nvpCollection.ToDictionary(); + feedItem.Title=nvpDictionary["Title"].Get(); + feedItem.PubDate=nvpDictionary["PubDate"].Get(); + String fixupLink=nvpDictionary["Link"].Get(); + feedItem.Link=fixupLink.Replace("^","="); + feedItem.Description=nvpDictionary["Description"].Get(); + feedItem.Guid=nvpDictionary["Guid"].Get(); + feedItem.Source=nvpDictionary["Source"].Get(); + feedItem.Read=nvpDictionary["Read"].Get(); + return feedItem; + } + catch(Exception) + { + return null; + } + } + public Brush ForegroundBrush + { + get{return FeedBrushes.GetContextBrush(brushAssignment);} + } + public FeedBrushes.BrushColor BrushAssigment + { + get{return brushAssignment;} + set{brushAssignment=value;if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("BrushAssigment"));} + } + public bool Read + { + get { return read; } + set + { + read = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Read")); + } + } + public string Source + { + get { return source; } + set + { + source = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Source")); + } + } + public string Guid + { + get { return guid; } + set + { + guid = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Guid")); + } + } + public string Description + { + get { return description; } + set + { + description = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Description")); + } + } + public string Link + { + get { return link; } + set + { + link = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Link")); + } + } + public string PubDate + { + get { return pubDate; } + set + { + pubDate = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("PubDate")); + } + } + public string Title + { + get { return title; } + set + { + title = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Title")); + } + } + } +} \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f0c1970 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TickerLib")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TickerLib")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a5608a21-5b1c-427f-8a8a-497cb7a2cae5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TickerLib.csproj b/TickerLib.csproj new file mode 100644 index 0000000..eae0d72 --- /dev/null +++ b/TickerLib.csproj @@ -0,0 +1,79 @@ + + + + + Debug + AnyCPU + {C2682400-EEB6-41AD-AE25-1D60A307D99C} + Library + Properties + TickerLib + TickerLib + v4.6.2 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AnyCPU + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + TickerItemView.xaml + + + + + {e807f1ca-9d9c-484a-8e83-269d57707b4b} + MarketDataLib + + + + + Designer + MSBuild:Compile + + + + + \ No newline at end of file diff --git a/TickerLib.sln b/TickerLib.sln new file mode 100644 index 0000000..f327e53 --- /dev/null +++ b/TickerLib.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TickerLib", "TickerLib.csproj", "{C2682400-EEB6-41AD-AE25-1D60A307D99C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C2682400-EEB6-41AD-AE25-1D60A307D99C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2682400-EEB6-41AD-AE25-1D60A307D99C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2682400-EEB6-41AD-AE25-1D60A307D99C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2682400-EEB6-41AD-AE25-1D60A307D99C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Views/TickerItemView.xaml b/Views/TickerItemView.xaml new file mode 100644 index 0000000..4350862 --- /dev/null +++ b/Views/TickerItemView.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Views/TickerItemView.xaml.cs b/Views/TickerItemView.xaml.cs new file mode 100644 index 0000000..501d3a6 --- /dev/null +++ b/Views/TickerItemView.xaml.cs @@ -0,0 +1,35 @@ +using System.ComponentModel; +using System.Diagnostics; +using System.Windows.Navigation; +using Ticker.Models; + +namespace Ticker.Views +{ + /// + /// Interaction logic for TickerItemView.xaml + /// + public partial class TickerItemView : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + private FeedItem feedItem; + public TickerItemView(FeedItem item) + { + InitializeComponent(); + DataContext = this; + FeedItem = item; + } + public FeedItem FeedItem + { + get { return feedItem; } + set + { + feedItem = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("FeedItem")); + } + } + public void Navigate(object sender, RequestNavigateEventArgs e) + { + Process.Start(new ProcessStartInfo(e.Uri.ToString())); + } + } +}