Beispiel #1
0
        public void AddChannelPanel(string channelTitle, int id)
        {
            RssChannelStackPanel rssStackPanel = new RssChannelStackPanel(id);
            rssStackPanel.Orientation = Orientation.Horizontal;
            rssStackPanel.Margin = new Thickness(10, 2, 0, 2);
            rssStackPanel.MouseEnter += new MouseEventHandler(RssChannelItem_MouseEnter);
            rssStackPanel.MouseLeave += new MouseEventHandler(RssChannelItem_MouseLeave);
            rssStackPanel.MouseLeftButtonDown += new MouseButtonEventHandler(RssChannelItem_MouseLeftButtonDown);
            rssStackPanel.MouseRightButtonDown += new MouseButtonEventHandler(RssChannelItem_MouseRightButtonDown);

            Image image = new Image();
            BitmapImage bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.UriSource = new Uri("/Pictures/rssIcon.png", UriKind.Relative);
            bitmapImage.EndInit();
            image.Source = bitmapImage;
            image.Width = 20;
            image.Height = 20;
            rssStackPanel.Children.Add(image);

            TextBlock textBlock = new TextBlock();
            textBlock.Name = "channelItem";
            textBlock.Foreground = Brushes.White;
            textBlock.FontSize = 14.0;
            textBlock.Text = channelTitle;
            textBlock.Margin = new Thickness(5, 0, 0, 0);
            textBlock.VerticalAlignment = VerticalAlignment.Center;
            rssStackPanel.Children.Add(textBlock);

            ContextMenu contextMenu = new ContextMenu();
            rssStackPanel.ContextMenu = contextMenu;

            MenuItem removeChannelMenuItem = new MenuItem();
            removeChannelMenuItem.Click += new RoutedEventHandler(removeChannelMenuItem_Click);
            removeChannelMenuItem.Header = "Remove channel";
            contextMenu.Items.Add(removeChannelMenuItem);

            channelItemPanel.Children.Add(rssStackPanel);
        }
Beispiel #2
0
 private void RssChannelItem_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
 {
     this.rightClickedRssPanel = (RssChannelStackPanel) sender;
 }