Permalink
Browse files

Small refactorings

  • Loading branch information...
1 parent 2dd815c commit bc2842599d6e925dedcf6e0b84784cc52420ae80 @igstan committed Oct 24, 2010
Showing with 21 additions and 17 deletions.
  1. +21 −17 Nemira/MainWindow.xaml.cs
@@ -57,28 +57,17 @@ public void OpenAccount(string email, string pass)
{
this.readerAccount = new ReaderAccount(email, pass);
- PopulateSubscriptionsTree();
+ LoadSubscriptions();
Show();
}
- private void PopulateSubscriptionsTree()
- {
- subscriptions.ItemsSource = new Subscriptions(readerAccount);
- }
-
- private void OnAddFeed(object sender, RoutedEventArgs e)
- {
- // feedCategories.ElementAt(0).Feeds.Add(new Feed(feedUrl.Text, "http://someaddress.com/"));
- }
-
private void OnSelectedFeed(object sender, RoutedEventArgs e)
{
if (subscriptions.SelectedItem is Subscription)
{
var subscription = subscriptions.SelectedItem as Subscription;
- editSubscription.IsEnabled = true;
- deleteSubscription.IsEnabled = true;
+ EnableSubscriptionToolbarButtons();
feedTitle.Text = subscription.Title;
feedItemTooltip.Content = subscription.SourceUrl;
@@ -89,8 +78,7 @@ private void OnSelectedFeed(object sender, RoutedEventArgs e)
{
var item = subscriptions.SelectedItem as SubscriptionItem;
- editSubscription.IsEnabled = false;
- deleteSubscription.IsEnabled = false;
+ DisableSubscriptionToolbarButtons();
feedTitle.Text = item.Title;
feedItemTooltip.Content = "Open in default Web browser";
@@ -102,6 +90,17 @@ private void OnSelectedFeed(object sender, RoutedEventArgs e)
private void OnUnselectedFeed(object sender, RoutedEventArgs e)
{
+ DisableSubscriptionToolbarButtons();
+ }
+
+ private void EnableSubscriptionToolbarButtons()
+ {
+ editSubscription.IsEnabled = true;
+ deleteSubscription.IsEnabled = true;
+ }
+
+ private void DisableSubscriptionToolbarButtons()
+ {
editSubscription.IsEnabled = false;
deleteSubscription.IsEnabled = false;
}
@@ -140,7 +139,7 @@ private void OnAddSubscription(object sender, RoutedEventArgs e)
if (addSubscriptionDialog.ShowDialog() == true)
{
readerAccount.AddSubscription(addSubscriptionDialog.FeedUrl);
- subscriptions.ItemsSource = new Subscriptions(readerAccount);
+ LoadSubscriptions();
}
}
@@ -154,9 +153,14 @@ private void OnDeleteSubscription(object sender, RoutedEventArgs e)
if (MessageBox.Show(message, title, button, icon) == MessageBoxResult.OK) {
readerAccount.RemoveSubscription(subscription);
- subscriptions.ItemsSource = new Subscriptions(readerAccount);
+ LoadSubscriptions();
}
}
+
+ private void LoadSubscriptions()
+ {
+ subscriptions.ItemsSource = new Subscriptions(readerAccount);
+ }
}
public class Subscriptions : ObservableCollection<Subscription>

0 comments on commit bc28425

Please sign in to comment.