private void add() { string rssURL = urlBox.Text; // Get user provided URL string feedName = nameBox.Text; // Get user provided name if (!IsValidURL(rssURL)) // Check if URL is valid web address and contains .rss or .xml { InvalidURL(); // If not valid, reset input box and pop error return; // Exit add function } if (feedName.Equals("")) // If user doesn't provide a name provide a default. { feedName = "New Feed" + unnamedFeeds.ToString(); // Default base name is New FeedX unnamedFeeds++; // Increment 'X' } ComponentTreeViewItem newFeed = new ComponentTreeViewItem(feedName); // Create item to be displayed in left hand newFeed.MouseLeftButtonUp += treeComp_MouseLeftButtonUp; // Link the event to the proper handler newFeed.PreviewMouseRightButtonDown += treeView_PreviewMouseRightButtonDown; newFeed.addChannel.Click += AddComponentToChannel; // Routing events to proper handlers newFeed.removeChannel.Click += removeFromChannel; newFeed.renameFeed.Click += RenameChannel; // Call the Component_View's Add_Feed function to pass proper info to the logic engine to create feed compView.Add_Feed("/" + feedName, rssURL); this.treeView.Items.Add(newFeed); // Show the new feed in the TreeView menu urlBox.Text = ""; // Restore default text values in the textboxes nameBox.Text = ""; }
private void RenameChannel(object sender, RoutedEventArgs e) { ComponentTreeViewItem newNameComp = (ComponentTreeViewItem)treeView.SelectedItem; string currentName = (string)newNameComp.Header; string currentPath = newNameComp.Path; RenameComponentWindow renameWindow = new RenameComponentWindow(); }
private void AddComponentToChannel(object sender, RoutedEventArgs e) { ComponentTreeViewItem movingComp = (ComponentTreeViewItem)treeView.SelectedItem; addToChannelWindow = new AddToChannelWindow(); addToChannelWindow.Show(); addToChannelWindow.OpenWindow(movingComp); addToChannelWindow.OnComponentMoved += this.OnAddToChannelWindowClose; }
private void OnCreateChannelWindowClose(object sender, EventArgs e) // Handler for when Creating a new Channel { // Need to have channel have the same click properties as the other feeds in base CreateChannelWindow source = (CreateChannelWindow)sender; string channelName = source.TextBox.Text; ComponentTreeViewItem newChannel = new ComponentTreeViewItem(channelName); // Create item to be displayed in left hand newChannel.PreviewMouseRightButtonDown += treeView_PreviewMouseRightButtonDown; newChannel.addChannel.Click += AddComponentToChannel; // Routing events to proper handlers newChannel.removeChannel.Click += removeFromChannel; newChannel.renameFeed.Click += RenameChannel; this.treeView.Items.Add(newChannel); }
private void OnAddToChannelWindowClose(object sender, EventArgs e) // Handler for when adding Component to a Channel { ComponentTreeViewItem movedComponent = (ComponentTreeViewItem)sender; this.treeView.Items.Remove(movedComponent); // Remove the moved component from the UI foreach (ComponentTreeViewItem c in treeView.Items) { if (MoveComponentTreeViewItem(movedComponent.Path, c, movedComponent)) { break; } } }
private void PopulateOnLoad(List <String> newTree) { foreach (String i in newTree) { if (compView.Is_Channel(i)) // We know there are either more channels or feeds internal, need to recursively call { List <String> components = compView.Get_Children_Of(i); PopulateOnLoad(components); } else { ComponentTreeViewItem newFeed = new ComponentTreeViewItem(i); // Create item to be displayed in left hand menu treeView.Items.Add(newFeed); } } }
private bool MoveComponentTreeViewItem(string path, ComponentTreeViewItem currentComponent, ComponentTreeViewItem movedComponent) { ComponentTreeViewItem parentComp; // Need to find second slash int highestLevelSlash = path.IndexOf("/", 1); string highestLevel = path.Substring(1, highestLevelSlash - 1); // Should be highest level in path string secondLevel = ""; int movedSlash = path.LastIndexOf("/"); int secondLevelSlash = path.IndexOf("/", highestLevelSlash + 1); if (secondLevelSlash != -1) { secondLevel = path.Substring(highestLevelSlash + 1, (secondLevelSlash - highestLevelSlash) - 1); } int parentSlash = path.LastIndexOf("/", movedSlash - 1); string parent = path.Substring(parentSlash + 1, (movedSlash - parentSlash) - 1); if (parent == (string)currentComponent.Header) { // Need to figure out parent container if (movedComponent.Parent != null) { parentComp = (ComponentTreeViewItem)movedComponent.Parent; parentComp.Items.Remove(movedComponent); } currentComponent.Items.Add(movedComponent); return(true); } else if (currentComponent.HasItems) { // Recurse downward foreach (ComponentTreeViewItem c in currentComponent.Items) { if (secondLevel == (string)c.Header) { MoveComponentTreeViewItem(path.Substring(highestLevelSlash + 1), c, movedComponent); } } } return(false); }
private void treeComp_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { articleList.Items.Clear(); ComponentTreeViewItem senderComp = (ComponentTreeViewItem)sender; // Typecast so we can figure out the sender List <Article> articles; // Create a new list of articles for the return articles = compView.Get_Articles_Under(senderComp.Path); // Get the list of articles below the current selection foreach (Article i in articles) { ArticleListItem articleListItem = new ArticleListItem(); // Create a new ArticleListItem to be displayed articleListItem.Title = i.Title; // Get the correct title articleListItem.Date = i.Publication_Date; // Get the correct date articleListItem.URL = i.URL; articleListItem.Description = i.Summary; articleListItem.Read = ""; // Setting default to unread articleList.Items.Add(articleListItem); // Place in the UI } }
public void add(string feedName, string rssURL) { if (!IsValidURL(rssURL)) // Check if URL is valid web address and contains .rss or .xml { InvalidURL(); // If not valid, reset input box and pop error return; // Exit add function } if (feedName.Equals("")) // If user doesn't provide a name provide a default. { feedName = "New Feed" + unnamedFeeds.ToString(); // Default base name is New FeedX unnamedFeeds++; // Increment 'X' } ComponentTreeViewItem newFeed = new ComponentTreeViewItem(feedName); // Create item to be displayed in left hand menu // Call the Component_View's Add_Feed function to pass proper info to the logic engine to create feed compView.Add_Feed("/" + feedName, rssURL); this.treeView.Items.Add(newFeed); // Show the new feed in the TreeView menu urlBox.Text = ""; // Restore default text values in the textboxes nameBox.Text = ""; }
// Ensures that we do not have a null value when using Context Menus private void treeView_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { selectedItem = (ComponentTreeViewItem)sender; }
public void OpenWindow(ComponentTreeViewItem movedComp) { sourceComponent = movedComp; this.oldPath = sourceComponent.Path; }