Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
Queueing thing doesnt quite work on the notifier yet
Browse files Browse the repository at this point in the history
  • Loading branch information
growse committed Jan 23, 2012
1 parent c6e0c7d commit afb0797
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions Feedling/Notifier.xaml.cs
Expand Up @@ -19,50 +19,60 @@ namespace Feedling
/// <summary>
/// Interaction logic for Notifier.xaml
/// </summary>
public partial class Notifier:Window
public partial class Notifier
{
private static Notifier thisinst;
public static Notifier GetNotifier()
{
return thisinst ?? (thisinst = new Notifier());
}

private readonly Storyboard board;
private PresentationSource presentationSource;
public Notifier()
{
InitializeComponent();
Opacity = 0;
board = (Storyboard)FindResource("fader");
}

public void ShowNotifier(string feedtitle, IEnumerable<Tuple<string, string>> newitemlist)
{
if (Opacity > 0)
{
//TODO: Some cunning sort of queuing system
board.Stop(this);
}
else
{
titlebox.Inlines.Clear();
titlebox.Inlines.Add(string.Format("New items in {0}", feedtitle));

foreach (var link in newitemlist)
{
titlebox.Inlines.Add(new LineBreak());
Uri linkuri;
Uri.TryCreate(link.Item2, UriKind.Absolute, out linkuri);
var hyperlink = new Hyperlink { NavigateUri = linkuri };
hyperlink.RequestNavigate += Hyperlink_RequestNavigate;
hyperlink.Inlines.Add(link.Item1);
titlebox.Inlines.Add(hyperlink);
}
Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(FadeInWindowThingieLikeAnEpicAwesomeToaster));
}
titlebox.Inlines.Add(string.Format("New items in {0}", feedtitle));

foreach (var link in newitemlist)
{
titlebox.Inlines.Add(new LineBreak());
Uri linkuri;
Uri.TryCreate(link.Item2, UriKind.Absolute, out linkuri);
var hyperlink = new Hyperlink { NavigateUri = linkuri };
hyperlink.RequestNavigate += Hyperlink_RequestNavigate;
hyperlink.Inlines.Add(link.Item1);
titlebox.Inlines.Add(hyperlink);
}
PositionWindow();
}

private void FadeInWindowThingieLikeAnEpicAwesomeToaster()
{
Opacity = 0;
Show();
Visibility = Visibility.Visible;
PositionWindow();
board.Begin(this);
}

private void PositionWindow()
{
var workingArea = Screen.PrimaryScreen.WorkingArea;
if (presentationSource != null && presentationSource.CompositionTarget != null)
{
Expand All @@ -71,15 +81,13 @@ private void FadeInWindowThingieLikeAnEpicAwesomeToaster()
Left = corner.X - ActualWidth - 20;
Top = corner.Y - ActualHeight;
}

var board = (Storyboard)FindResource("fader");
board.Begin(this);
}

private void DismissButtonClick(object sender, RoutedEventArgs e)
{
Visibility = Visibility.Collapsed;
Opacity = 0;
//Visibility = Visibility.Collapsed;
//Opacity = 0;
ShowNotifier("sdflijlij", new List<Tuple<string, string>> { new Tuple<string, string>("dsfl", "sddf") });
}

private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
Expand Down

0 comments on commit afb0797

Please sign in to comment.