/// <summary>
    /// this is the method to be used by the 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void AddChannelMenuItem_OnClick(object sender, RoutedEventArgs e)
    {
      // Get user input
      NameChannelWindow createChannelWindow = new NameChannelWindow();
      createChannelWindow.ShowDialog();

      if (createChannelWindow.DialogResult == true)
      {
        // Create feed and add it
        Channel channel = new Channel(createChannelWindow.Channel);
        channel.ContextMenu.Items.Add(MakeContextMenuItem(AddFeedGestureText, AddFeedItem));
        channel.ContextMenu.Items.Add(MakeContextMenuItem(AddChannelGestureText, AddChannelItem));
        channel.ContextMenu.Items.Add(MakeContextMenuItem(RemoveGestureText, RemoveMenuOption));
        Subscriptions.AddChannel(channel);
        ContentTreeView.Items.Add(channel);
      }
    }
        /// <summary>
        /// Adds a channel to the visual tree
        /// </summary>
        /// <remarks>
        /// Mainly for the facade
        /// </remarks>
        public static Tuple<TreeViewItem,Channel> AddChannelToTree()
        {
            var createChannelWindow = new HelperWindows.NameChannelWindow();
            createChannelWindow.ShowDialog();
            Tuple<TreeViewItem, Channel> result = null;

            if (createChannelWindow.DialogResult == true)
            {
                // Create feed and add it
                var channel = new Channel(createChannelWindow.Channel);

                var channelViewItem = MakeTreeViewItem(channel.ChannelName);

                channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(AddFeedGestureText, AddFeedItem));
                channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(AddChannelGestureText, AddChannelItem));
                channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(RemoveGestureText, RemoveMenuOption));

                TreeView.Items.Add(channelViewItem);
                AddChannelToSubscriptions(channel);
                result = new Tuple<TreeViewItem, Channel>(channelViewItem, channel);
            }

            return result;
        }
    /// <summary>
    /// This is the method to be used by other tree view items
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void AddChannelItem(object sender, RoutedEventArgs e)
    {
      // Get input
      NameChannelWindow newChannel = new NameChannelWindow();
      newChannel.ShowDialog();

      TreeViewItem parent = ContentTreeView.SelectedItem as TreeViewItem;

      if (parent != null)
      {
        if (ContentTreeView.SelectedItem != null && true == newChannel.DialogResult)
        {
          // create channel and add
          Channel channel = new Channel(newChannel.Channel);
          channel.ContextMenu.Items.Add(MakeContextMenuItem(AddFeedGestureText, AddFeedItem));
          channel.ContextMenu.Items.Add(MakeContextMenuItem(AddChannelGestureText, AddChannelItem));
          channel.ContextMenu.Items.Add(MakeContextMenuItem(RemoveGestureText, RemoveMenuOption));
          parent.Items.Add(channel);
        }
      }
    }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void AddChannelItemToParent(object sender, RoutedEventArgs e)
        {
            // Get user input
            var addChannelWindow = new HelperWindows.NameChannelWindow();
            addChannelWindow.ShowDialog();

            if (addChannelWindow.DialogResult == true)
            {
                Channel newChannel = new Channel(addChannelWindow.Channel);
                _subscriptions.AddChannel(newChannel);

                TreeViewItem channelViewItem = MakeTreeViewItem(newChannel.ChannelName);

                channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(AddFeedGestureText, AddFeedItem));
                channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(RemoveGestureText, RemoveMenuOption));
                channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(RenameGesureText, RenameMenuOption));

                // Add to UI
                TreeView.Items.Add(channelViewItem);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Move a feed from a channel
        /// </summary>
        /// <param name="feed"></param>
        /// <param name="channel"></param>
        /// <remarks>
        /// If a feed exists in a channel, remove it from the channel and return the same feed, otherwise return null
        /// </remarks>
        public Feed MoveFromChannel(Feed feed, Channel channel)
        {
            Feed feedToRemove = null;

            if (channel.Feeds.Contains(feed))
            {
                channel.Feeds.Remove(feed);
                feedToRemove = feed;
            }

            return feedToRemove;
        }
        /// <summary>
        /// This is the method to be used by other tree view items
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void AddChannelItem(object sender, RoutedEventArgs e)
        {
            // Get input
            HelperWindows.NameChannelWindow newChannel = new HelperWindows.NameChannelWindow();
            newChannel.ShowDialog();

            TreeViewItem parent = TreeView.SelectedItem as TreeViewItem;

            if (parent != null)
            {
                if (TreeView.SelectedItem != null && true == newChannel.DialogResult)
                {
                    // create channel and add
                    Channel channel = new Channel(newChannel.Channel);

                    TreeViewItem channelViewItem = MakeTreeViewItem(channel.ChannelName);

                    channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(AddFeedGestureText, AddFeedItem));
                    channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(AddChannelGestureText, AddChannelItem));
                    channelViewItem.ContextMenu.Items.Add(MakeContextMenuItem(RemoveGestureText, RemoveMenuOption));
                    try {
                        parent.Items.Add(channelViewItem);
                    }
                    catch (InvalidOperationException)
                    { // Handle exception by just adding channel to root node
                        TreeView.Items.Add(channelViewItem);
                    }
                    var channelParent = _subscriptions.SearchForChannel(parent.Header.ToString());

                    channelParent?.AddChannel(channel);
                }
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Adds a given feed to a given channel
 /// </summary>
 /// <param name="feed"></param>
 /// <param name="channel"></param>
 public void AddFeedtoChannel(Feed feed, Channel channel)
 {
     channel.Feeds.Add(feed);
 }
Esempio n. 8
0
 /// <summary>
 /// Moves a feed to a channel
 /// </summary>
 /// <param name="feed"></param>
 /// <param name="channel"></param>
 public void MoveToChannel(Feed feed, Channel channel)
 {
     channel.Feeds.Add(feed);
 }
Esempio n. 9
0
        /// <summary>
        ///has option to save all the feeds in that channel and add them to feeds list
        ///or just delete the channel and all of its contents
        /// </summary>
        /// <param name="channel"></param>
        public bool RemoveChannel(Channel channel)
        {
            const string messageBoxPrompt = "This will delete all feeds and channels in this channel. Continue?";
            const string messageBoxCaption = "Remove Channel";
            bool result = false;

            if (ChannelList.Contains(channel))
            {
                if (channel.Feeds.Count > 0 || channel.Channels.Count > 0)
                {
                    MessageBoxResult messageBoxResult = MessageBox.Show(messageBoxPrompt, messageBoxCaption,
                    MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (messageBoxResult == MessageBoxResult.Yes)
                    {
                        ChannelList.Remove(channel);
                        result = true;
                    }

                }
                else
                {
                    ChannelList.Remove(channel);
                    result = true;
                }
            }

            return result;
        }
Esempio n. 10
0
 /// <summary>
 /// Removes a given feed from a given channel
 /// </summary>
 /// <param name="feed"></param>
 /// <param name="channel"></param>
 public void RemoveFeedfromChannel(Feed feed, Channel channel)
 {
     channel.Feeds.Remove(feed);
 }
Esempio n. 11
0
 /// <summary>
 /// we will allow channels with bad names, just can't be accessed until named correctly
 /// </summary>
 /// <param name="channel"></param>
 public void AddChannel(Channel channel)
 {
     if (channel != null && ! ChannelList.Contains(channel))
     {
         ChannelList.Add(channel);
     }
 }
 /// <summary>
 /// Adds a channel
 /// </summary>
 /// <param name="channel"></param>
 public static void AddChannelToSubscriptions(Channel channel)
 {
     _subscriptions.AddChannel(channel);
 }
        private static void AddChannelRecursively(ref HashSet<string> feedsEncountered, ref TreeViewItem parent, Channel channel)
        {            
            foreach (var chan in channel.Channels)
            {
                var chanViewItem = MakeTreeViewItem(chan.ChannelName);
                AddChannelRecursively(ref feedsEncountered, ref chanViewItem, chan);
            }

            foreach (var feed in channel.Feeds)
            {
                if (!feedsEncountered.Contains(feed.Name))
                {
                    feedsEncountered.Add(feed.Name);
                    var feedViewItem = MakeTreeViewItem(feed.Name);
                    feedViewItem.ContextMenu.Items.Add(MakeContextMenuItem(RemoveGestureText, RemoveMenuOption));
                    feedViewItem.ContextMenu.Items.Add(MakeContextMenuItem(RenameGesureText, RenameMenuOption));
                    // Add to UI
                    parent.Items.Add(feedViewItem);
                }
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Removes a channel to the channel list
 /// </summary>
 /// <param name="channel"></param>
 public void RemoveChannel(Channel channel)
 {
     if (channel != null && Channels.Contains(channel))
     {
         Channels.Remove(channel);
     }
 }
Esempio n. 15
0
 /// <summary>
 /// Adds a channel to the channel list
 /// </summary>
 /// <param name="channel"></param>
 public void AddChannel(Channel channel)
 {
     if (!Channels.Contains(channel) && channel != null)
     {
         Channels.Add(channel);
     }
 }