Ejemplo n.º 1
0
        private static void OnItemTextChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            List <TextSubTypes.ISubType> text = args.NewValue as List <TextSubTypes.ISubType>;

            if (text == null)
            {
                text = new List <TextSubTypes.ISubType>();
            }


            if (text.Count > 0)
            {
                DateTime      start     = DateTime.Now;
                TextblockItem textblock = (TextblockItem)obj;
                textblock.Inlines.Clear();
                textblock.generateElementsTextblock(text);
                return;
            }
        }
Ejemplo n.º 2
0
        private static void OnItemSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            TwitterItem.Client client = args.NewValue as TwitterItem.Client;
            if (client == null)
            {
                return;
            }


            if (!string.IsNullOrEmpty(client.Name))
            {
                TextblockItem textblock = (TextblockItem)obj;
                textblock.Inlines.Clear();

                TextBlock additonalInfo = new TextBlock();
                additonalInfo.Name         = "SourceClient";
                additonalInfo.TextWrapping = TextWrapping.Wrap;
                additonalInfo.FontSize     = 9;
                additonalInfo.FontStyle    = FontStyles.Italic;

                if (client.Name != "")
                {
                    additonalInfo.Inlines.Add(" via ");
                    ContextMenu contextClient = new ContextMenu();

                    MenuItem menuItemMuteClient = new MenuItem();
                    menuItemMuteClient.Header           = "Mute all tweets written with " + client.Name + " (will create a filter for current View)";;
                    menuItemMuteClient.CommandParameter = client.Name;
                    menuItemMuteClient.Click           += new RoutedEventHandler(menuItemMuteClient_Click);
                    contextClient.Items.Add(menuItemMuteClient);

                    TextBlock sourceNameTextblock = new TextBlock();
                    sourceNameTextblock.TextWrapping = TextWrapping.Wrap;
                    sourceNameTextblock.Text         = client.Name;
                    sourceNameTextblock.Foreground   = Brushes.DarkKhaki;
                    if (!string.IsNullOrEmpty(client.Url))
                    {
                        Hyperlink sourceClient = new Hyperlink();
                        sourceClient.TextDecorations = null;
                        sourceClient.TargetName      = client.Name;
                        try
                        {
                            sourceClient.NavigateUri = new Uri(client.Url);
                        }
                        catch
                        {
                            sourceClient.NavigateUri = new Uri("http://twitter.com/");
                        }
                        sourceClient.Click += new RoutedEventHandler(sourceClient_Click);

                        MenuItem menuItemOpenClientHomepage = new MenuItem();
                        menuItemOpenClientHomepage.Header           = "Open homepage of " + client.Name;
                        menuItemOpenClientHomepage.CommandParameter = client.Url;
                        menuItemOpenClientHomepage.Click           += new RoutedEventHandler(menuItemOpenClientHomepage_Click);
                        contextClient.Items.Add(menuItemOpenClientHomepage);

                        sourceClient.Inlines.Add(sourceNameTextblock);
                        additonalInfo.Inlines.Add(sourceClient);
                    }
                    else
                    {
                        additonalInfo.Inlines.Add(sourceNameTextblock);
                    }
                    sourceNameTextblock.ContextMenu = contextClient;
                }

                textblock.Inlines.Add(additonalInfo);
            }
        }