Ejemplo n.º 1
0
 public NewFeed(FeedConfigItem givenfci)
 {
     FeedConfig = givenfci;
     Log.Debug("Loading NewFeed Window with given feed {0}", FeedConfig.Url);
     InitializeComponent();
     Title = string.Format("Edit {0}", givenfci.Url);
 }
Ejemplo n.º 2
0
 public void DefaultColorTest()
 {
     var target = new FeedConfigItem { DefaultColorB = 111, DefaultColorG = 192, DefaultColorR = 128 };
     var expected = Color.FromArgb(255, 128, 192, 111);
     target.DefaultColor = expected;
     var actual = target.DefaultColor;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 3
0
 public void AuthTypeTest()
 {
     var target = new FeedConfigItem { AuthType = FeedAuthTypes.Other };
     const FeedAuthTypes expected = FeedAuthTypes.Other;
     target.AuthType = expected;
     var actual = target.AuthType;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor! Hurrah!
        /// </summary>
        /// <param name="feeditem"></param>
        public FeedWin(FeedConfigItem feeditem)
        {
            Log.Debug("Constructing feedwin. GUID:{0} URL: {1}", feeditem.Guid, feeditem.Url);
            InitializeComponent();

            fci = feeditem;
            Width = fci.Width;
            Left = fci.Position.X;
            Top = fci.Position.Y;
            //Kick of thread to figure out what sort of plugin to load for this sort of feed.
            ThreadPool.QueueUserWorkItem(state => GetFeedType(fci));

            //Set up the animations for the mouseovers
            fadein = new ColorAnimation { AutoReverse = false, From = fci.DefaultColor, To = fci.HoverColor, Duration = new Duration(TimeSpan.FromMilliseconds(200)), RepeatBehavior = new RepeatBehavior(1) };
            fadeout = new ColorAnimation { AutoReverse = false, To = fci.DefaultColor, From = fci.HoverColor, Duration = new Duration(TimeSpan.FromMilliseconds(200)), RepeatBehavior = new RepeatBehavior(1) };

            textbrush = new SolidColorBrush(feeditem.DefaultColor);

            //Add the right number of textblocks to the form, depending on what the user asked for.
            for (var ii = 0; ii < fci.DisplayedItems; ii++)
            {
                maingrid.RowDefinitions.Add(new RowDefinition());
                var textblock = new TextBlock
                                    {
                                        Style = (Style)FindResource("linkTextStyle"),
                                        Name = string.Format("TextBlock{0}", ii + 1),
                                        TextTrimming = TextTrimming.CharacterEllipsis,
                                        Foreground = textbrush.Clone(),
                                        Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0)),
                                        FontFamily = fci.FontFamily,
                                        FontSize = fci.FontSize,
                                        FontStyle = fci.FontStyle,
                                        FontWeight = fci.FontWeight,
                                        Visibility = Visibility.Collapsed
                                    };

                textblock.SetValue(Grid.ColumnSpanProperty, 2);
                RegisterName(textblock.Name, textblock);
                maingrid.Children.Add(textblock);
                Grid.SetRow(textblock, ii + 1);
            }

            maingrid.RowDefinitions.Add(new RowDefinition());
            movehandle = new Image();
            movehandle.Width = movehandle.Height = 16;
            movehandle.Name = "movehandle";

            movehandle.HorizontalAlignment = HorizontalAlignment.Left;

            movehandle.Cursor = Cursors.SizeAll;
            movehandle.Source = new BitmapImage(new Uri("/Feedling;component/Resources/move-icon.png", UriKind.Relative));
            movehandle.SetValue(Grid.ColumnSpanProperty, 2);
            RegisterName(movehandle.Name, movehandle);
            maingrid.Children.Add(movehandle);
            movehandle.MouseDown += movehandle_MouseDown;
            movehandle.Visibility = Visibility.Collapsed;
            Grid.SetRow(movehandle, maingrid.RowDefinitions.Count);
        }
Ejemplo n.º 5
0
 public void CopyTest()
 {
     var expected = new FeedConfigItem();
     var actual = expected.Copy();
     var properties = typeof(FeedConfigItem).GetProperties();
     foreach (var property in properties)
     {
         if (property.PropertyType != typeof(Guid))
         {
             Assert.AreEqual(property.GetValue(actual, null), property.GetValue(expected, null));
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Copy maintains equality between all variables but generates a new GUID.
        /// </summary>
        /// <returns>A new FeedConfigItem object with the same values but a different GUID.</returns>
        public FeedConfigItem Copy()
        {
            var fci = new FeedConfigItem
            {
                Url                   = Url,
                DefaultColor          = DefaultColor,
                FontFamily            = FontFamily,
                FontSize              = FontSize,
                FontStyleString       = FontStyleString,
                FontWeightString      = FontWeightString,
                HoverColor            = HoverColor,
                Position              = Position,
                TitleFontFamily       = TitleFontFamily,
                TitleFontSize         = TitleFontSize,
                TitleFontStyleString  = TitleFontStyleString,
                TitleFontWeightString = TitleFontWeightString,
                AuthType              = AuthType,
                UserName              = UserName,
                Password              = Password,
                ProxyAuth             = ProxyAuth,
                ProxyHost             = ProxyHost,
                ProxyType             = ProxyType,
                ProxyUser             = ProxyUser,
                ProxyPass             = ProxyPass,
                ProxyPort             = ProxyPort,
                UpdateInterval        = UpdateInterval,
                DisplayedItems        = DisplayedItems,
                Width                 = Width,
                XPos                  = XPos,
                YPos                  = YPos,
                NotifyOnNewItem       = NotifyOnNewItem,
                FeedLabel             = FeedLabel,
                Guid                  = Guid.NewGuid()
            };

            return(fci);
        }
Ejemplo n.º 7
0
 public void FontSizeTest()
 {
     var target = new FeedConfigItem { FontSize = 12 };
     const double expected = 12F;
     target.FontSize = expected;
     var actual = target.FontSize;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 8
0
 public void HoverColorTest()
 {
     var target = new FeedConfigItem { HoverColorR = 18, HoverColorG = 211, HoverColorB = 255 };
     var expected = Color.FromArgb(255, 18, 211, 255);
     target.HoverColor = expected;
     var actual = target.HoverColor;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 9
0
 public void FontStyleTest()
 {
     var target = new FeedConfigItem { FontStyleString = "Italic" };
     var expected = FontStyles.Italic;
     target.FontStyle = expected;
     var actual = target.FontStyle;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Takes a given FeedConfiItem and iterates through all the available plugins to see if any of them can handle it.
 /// </summary>
 private void GetFeedType(FeedConfigItem feedConfigItem)
 {
     try
     {
         Log.Debug("Getting the Feed Type");
         var document = (XmlDocument)FeedwinManager.Fetch(feedConfigItem);
         foreach (var feedplugin in FeedwinManager.thisinst.Plugins)
         {
             Log.Debug("Testing {0} to see if it can handle feed", feedplugin.PluginName);
             if (!feedplugin.CanHandle(document)) continue;
             Log.Debug("It can! Yay!");
             var reqproxy = feedConfigItem.ProxyType != HttpProxyHelper.ProxyType.Global ? feedConfigItem.Proxy : HttpProxyHelper.GetGlobalProxy();
             if (reqproxy != null)
             {
                 Log.Debug("Set Proxy for feed to {0}", reqproxy.GetProxy(new Uri(feedConfigItem.Url)));
             }
             else
             {
                 Log.Debug("Set Proxy for feed to nothing, nothing at all");
             }
             rssfeed = feedplugin.AddFeed(new Uri(feedConfigItem.Url), feedConfigItem.AuthType, feedConfigItem.UserName, feedConfigItem.Password, reqproxy);
             rssfeed.UpdateInterval = feedConfigItem.UpdateInterval;
             break;
         }
     }
     catch (XmlException ex) { errormsg = "Invalid XML Document"; Log.Error("XMLException thrown in parsing the feed", ex); }
     catch (UriFormatException ex) { errormsg = "Invalid URI"; Log.Error("URIException thrown in fetching the feed", ex); }
     catch (WebException ex) { errormsg = ex.Message; Log.Error("WebException thrown in fetching the feed", ex); }
     if (rssfeed == null)
     {
         Log.Debug("Didn't find a plugin to handle this feed");
         if (errormsg == string.Empty)
         {
             errormsg = "No Plugin to handle feed";
         }
     }
     else
     {
         rssfeed.Updated += rssfeed_Updated;
         Log.Debug("Kicking off the watcher thread");
         var t = new Thread(rssfeed.Watch) { IsBackground = true };
         t.SetApartmentState(ApartmentState.STA);
         t.Start();
     }
     RedrawWin();
 }
Ejemplo n.º 11
0
 public NewFeed()
 {
     Log.Debug("Loading NewFeed Window");
     FeedConfig = new FeedConfigItem();
     InitializeComponent();
 }
Ejemplo n.º 12
0
 public static IXPathNavigable Fetch(FeedConfigItem fci)
 {
     Log.Debug("Fetching feed from intarweb");
     HttpWebResponse resp = null;
     try
     {
         var requri = new Uri(fci.Url);
         var req = (HttpWebRequest)WebRequest.Create(requri);
         req.UserAgent = FetchUserAgentString();
         req.Proxy = fci.ProxyType != HttpProxyHelper.ProxyType.Global ? fci.Proxy : HttpProxyHelper.GetGlobalProxy();
         switch (fci.AuthType)
         {
             case FeedAuthTypes.Basic:
                 req.Credentials = new NetworkCredential(fci.UserName, fci.Password);
                 resp = (HttpWebResponse)req.GetResponse();
                 break;
             case FeedAuthTypes.Other:
             case FeedAuthTypes.None:
                 resp = (HttpWebResponse)req.GetResponse();
                 break;
         }
         var tempdoc = new XmlDocument();
         if (resp != null)
         {
             var respstream = resp.GetResponseStream();
             if (respstream != null)
             {
                 var streamtext = new StreamReader(respstream).ReadToEnd();
                 tempdoc.LoadXml(streamtext);
             }
         }
         return tempdoc;
     }
     catch (Exception ex)
     {
         Log.Error("Exception thrown when fetching feed", ex);
         throw;
     }
     finally
     {
         if (resp != null)
         {
             resp.Close();
         }
     }
 }
Ejemplo n.º 13
0
 public void Remove(FeedConfigItem feedConfigItem)
 {
     feedConfigList.Remove(feedConfigItem);
 }
Ejemplo n.º 14
0
 public void TitleFontWeightTest()
 {
     var target = new FeedConfigItem { FontWeightString = "UltraBlack" };
     var expected = FontWeights.UltraBlack;
     target.TitleFontWeight = expected;
     var actual = target.TitleFontWeight;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 15
0
 public void ToStringTest()
 {
     var target = new FeedConfigItem { Url = "http://feedling.net" };
     const string expected = "http://feedling.net";
     var actual = target.ToString();
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 16
0
 public void TitleFontSizeTest()
 {
     var target = new FeedConfigItem { TitleFontSize = 24 };
     const double expected = 24F;
     target.TitleFontSize = expected;
     var actual = target.TitleFontSize;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 17
0
 public void TitleFontStyleTest()
 {
     var target = new FeedConfigItem { FontStyleString = "Oblique" };
     var expected = FontStyles.Oblique;
     target.TitleFontStyle = expected;
     var actual = target.TitleFontStyle;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 18
0
 public void ProxyTest()
 {
     var target = new FeedConfigItem { ProxyHost = "1.2.3.4", ProxyPass = "******", ProxyType = HttpProxyHelper.ProxyType.Custom, ProxyUser = "******", ProxyAuth = true, ProxyPort = 3848 };
     IWebProxy expected = new WebProxy { Address = new Uri("http://1.2.3.4:3848"), Credentials = new NetworkCredential("proxyusername", "ProxyPassword", "proxydomain") };
     var actual = target.Proxy;
     Assert.AreEqual(expected.GetProxy(new Uri("http://www.google.com")), actual.GetProxy(new Uri("http://www.google.com")));
     Assert.AreEqual(expected.Credentials.GetCredential(new Uri("http://www.google.com"), "").Domain,
                     actual.Credentials.GetCredential(new Uri("http://www.google.com"), "").Domain);
     Assert.AreEqual(expected.Credentials.GetCredential(new Uri("http://www.google.com"), "").UserName,
                     actual.Credentials.GetCredential(new Uri("http://www.google.com"), "").UserName);
     Assert.AreEqual(expected.Credentials.GetCredential(new Uri("http://www.google.com"), "").Password,
                     actual.Credentials.GetCredential(new Uri("http://www.google.com"), "").Password);
 }
Ejemplo n.º 19
0
 public void PositionTest()
 {
     var target = new FeedConfigItem { XPos = 30, YPos = 299 };
     var expected = new Point(30, 299);
     target.Position = expected;
     var actual = target.Position;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 20
0
 public void PasswordTest()
 {
     var target = new FeedConfigItem { Password = "******" }; // TODO: Initialize to an appropriate value
     const string expected = "Passw0rd";
     target.Password = expected;
     string actual = target.Password;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 21
0
 public void DisplayedItemsTest()
 {
     var target = new FeedConfigItem { DisplayedItems = 25 };
     const int expected = 25;
     target.DisplayedItems = expected;
     var actual = target.DisplayedItems;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 22
0
 public void UpdateIntervalTest()
 {
     var target = new FeedConfigItem { UpdateInterval = 483 };
     const int expected = 483;
     target.UpdateInterval = expected;
     var actual = target.UpdateInterval;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 23
0
 public void FontFamilyTest()
 {
     var target = new FeedConfigItem { FontFamilyString = "Arial" };
     var expected = new FontFamily("Arial");
     target.FontFamily = expected;
     var actual = target.FontFamily;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 24
0
 public void Add(FeedConfigItem feedConfigItem)
 {
     feedConfigList.Add(feedConfigItem);
 }
Ejemplo n.º 25
0
 public void Add(FeedConfigItem feedConfigItem)
 {
     feedConfigList.Add(feedConfigItem);
 }
Ejemplo n.º 26
0
 public void UserNameTest()
 {
     var target = new FeedConfigItem { UserName = "******" };
     const string expected = "testusername";
     target.UserName = expected;
     var actual = target.UserName;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Copy maintains equality between all variables but generates a new GUID.
 /// </summary>
 /// <returns>A new FeedConfigItem object with the same values but a different GUID.</returns>
 public FeedConfigItem Copy()
 {
     var fci = new FeedConfigItem
                   {
                       Url = Url,
                       DefaultColor = DefaultColor,
                       FontFamily = FontFamily,
                       FontSize = FontSize,
                       FontStyleString = FontStyleString,
                       FontWeightString = FontWeightString,
                       HoverColor = HoverColor,
                       Position = Position,
                       TitleFontFamily = TitleFontFamily,
                       TitleFontSize = TitleFontSize,
                       TitleFontStyleString = TitleFontStyleString,
                       TitleFontWeightString = TitleFontWeightString,
                       AuthType = AuthType,
                       UserName = UserName,
                       Password = Password,
                       ProxyAuth = ProxyAuth,
                       ProxyHost = ProxyHost,
                       ProxyType = ProxyType,
                       ProxyUser = ProxyUser,
                       ProxyPass = ProxyPass,
                       ProxyPort = ProxyPort,
                       UpdateInterval = UpdateInterval,
                       DisplayedItems = DisplayedItems,
                       Width = Width,
                       XPos = XPos,
                       YPos = YPos,
                       NotifyOnNewItem = NotifyOnNewItem,
                       FeedLabel = FeedLabel,
                       Guid = Guid.NewGuid()
                   };
     return fci;
 }
Ejemplo n.º 28
0
 public void WidthTest()
 {
     var target = new FeedConfigItem { Width = 3948 };
     const double expected = 3948F;
     target.Width = expected;
     var actual = target.Width;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 29
0
 public void Remove(FeedConfigItem feedConfigItem)
 {
     feedConfigList.Remove(feedConfigItem);
 }
Ejemplo n.º 30
0
 public void FontWeightTest()
 {
     var target = new FeedConfigItem { FontWeightString = "SemiBold" };
     var expected = FontWeights.SemiBold;
     target.FontWeight = expected;
     var actual = target.FontWeight;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 31
0
 public void UrlTest()
 {
     var target = new FeedConfigItem { Url = "http://www.feedling.net" };
     const string expected = "http://www.feedling.net";
     target.Url = expected;
     var actual = target.Url;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 32
0
 public void GuidTest()
 {
     var testguid = Guid.NewGuid();
     var target = new FeedConfigItem { Guid = testguid };
     var expected = testguid;
     target.Guid = expected;
     var actual = target.Guid;
     Assert.AreEqual(expected, actual);
 }