private void AddTopicContainerToParent(object sender, RoutedEventArgs e) { // Get user input var addChannelWindow = new HelperWindows.NameChannelWindow(); addChannelWindow.ShowDialog(); if (addChannelWindow.DialogResult == true) { TreeViewItem channelViewItem = InterfaceDataSource.MakeTreeViewItem(addChannelWindow.Channel); channelViewItem.ContextMenu.Items.Add(InterfaceDataSource.MakeContextMenuItem(AddTopicText, AddTopicToContainer)); channelViewItem.ContextMenu.Items.Add(InterfaceDataSource.MakeContextMenuItem(RemoveGestureText, RemoveTopicOption)); channelViewItem.ContextMenu.Items.Add(InterfaceDataSource.MakeContextMenuItem(RenameGesureText, RenameTopicMenuOption)); // Add to UI topicTreeView.Items.Add(channelViewItem); } }
/// <summary> /// adds a topic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddTopicToContainer(object sender, RoutedEventArgs e) { var parent = topicTreeView.SelectedItem as TreeViewItem; if (parent != null) { // Get user input var addChannelWindow = new HelperWindows.NameChannelWindow(); addChannelWindow.ShowDialog(); if (addChannelWindow.DialogResult == true) { TreeViewItem topicItem = InterfaceDataSource.MakeTreeViewItem(addChannelWindow.Channel); topicItem.ContextMenu.Items.Add(InterfaceDataSource.MakeContextMenuItem(RemoveGestureText, RemoveTopicOption)); topicItem.ContextMenu.Items.Add(InterfaceDataSource.MakeContextMenuItem(RenameGesureText, RenameTopicMenuOption)); // Add to UI parent.Items.Add(topicItem); } } }
/// <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> /// /// </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); } }
/// <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); } } }