public NotificationWindow(Message message)
 {
     InitializeComponent();
     Title = string.Format(Strings.Events_Message_TitleOne, message.Sender.Name);
     MessageView.BbCode = BbCodeParser.Parse(message.Text);
     Image.Source       = new BitmapImage(new Uri(CharacterViewModel.GetAvatar(message.Sender.Name)));
     Loaded            += OnLoaded;
 }
        public NotificationWindow(EventViewModel evm)
        {
            InitializeComponent();
            switch (evm.Event)
            {
            case LoginEvent loginEvent:
                Title        = loginEvent.Character.Name;
                Image.Source = new BitmapImage(new Uri(CharacterViewModel.GetAvatar(loginEvent.Character.Name)));
                break;

            case LogoutEvent logoutEvent:
                Title        = logoutEvent.Character.Name;
                Image.Source = new BitmapImage(new Uri(CharacterViewModel.GetAvatar(logoutEvent.Character.Name)));
                break;

            case BroadcastEvent broadcastEvent:
                Title        = Strings.Events_Broadcast_Notification;
                Image.Source = new BitmapImage(new Uri(CharacterViewModel.GetAvatar(broadcastEvent.Character.Name)));
                break;

            case StatusEvent statusEvent:
                Title        = statusEvent.Character.Name;
                Image.Source = new BitmapImage(new Uri(CharacterViewModel.GetAvatar(statusEvent.Character.Name)));
                break;

            case NoteEvent noteEvent:
                Title        = noteEvent.Character.Name;
                Image.Source = new BitmapImage(new Uri(CharacterViewModel.GetAvatar(noteEvent.Character.Name)));
                break;

            case MentionEvent highlightEvent:
                Title        = string.Format(Strings.Events_Highlight_Notification, highlightEvent.Channel.Name);
                Image.Source = new BitmapImage(new Uri(CharacterViewModel.GetAvatar(highlightEvent.Message.Sender.Name)));
                break;

            default:
                return;
            }
            MessageView.BbCode = evm.Formatted;

            Loaded += OnLoaded;
        }
Ejemplo n.º 3
0
        public static Inline ToInline(TagNode node, TextPointer start = null, TextPointer end = null)
        {
            var parameter = node.AttributeValues.Count > 0 ? node.AttributeValues.Values.First() : null;

            switch (node.Tag.Name)
            {
            case "b":
                return(new Bold());

            case "i":
                return(new Italic());

            case "u":
                return(new Underline());

            case "s":
                return(new Span {
                    TextDecorations = TextDecorations.Strikethrough
                });

            case "sub":
                return(new Span {
                    BaselineAlignment = BaselineAlignment.Subscript, FontSize = 9
                });

            case "sup":
                return(new Span {
                    BaselineAlignment = BaselineAlignment.Superscript, FontSize = 9
                });

            case "url":
                parameter = parameter ?? node.ToText();
                var copyItem = new MenuItem {
                    Header = Strings.Chat_CopyLink
                };
                copyItem.Click += (sender, args) => Clipboard.SetText(parameter);
                var incognitoItem = new MenuItem {
                    Header = Strings.Chat_OpenIncognito
                };
                incognitoItem.Click += (sender, args) => {
                    using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice")) {
                        switch (key?.GetValue("Progid")?.ToString())
                        {
                        case "FirefoxURL":
                            Process.Start("firefox.exe", "-private-window " + parameter);
                            break;

                        case "ChromeHTML":
                            Process.Start("chrome.exe", "-incognito " + parameter);
                            break;

                        default:
                            Process.Start("iexplore.exe", "-private " + parameter);
                            break;
                        }
                    }
                };
                var link = new Hyperlink {
                    NavigateUri = new Uri(parameter), ToolTip = parameter, ContextMenu = new ContextMenu {
                        Items = { copyItem, incognitoItem }
                    }
                };
                link.RequestNavigate += (sender, e) => {
                    if (UserSettings.Instance.General.AlwaysIncognito)
                    {
                        incognitoItem.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                    }
                    else
                    {
                        Process.Start(e.Uri.ToString());
                    }
                };
                return(link);

            case "big":
                return(new Span {
                    FontSize = App.Current.Theme.FontSizeBig
                });

            case "small":
                return(new Span {
                    FontSize = App.Current.Theme.FontSizeSmall
                });

            case "color":
                return(new Span {
                    Foreground = GetColor(parameter)
                });

            case "icon":
                return(new InlineUIContainer(new Image {
                    Source = new BitmapImage(new Uri(CharacterViewModel.GetAvatar(node.ToText()))),
                    Height = 50,
                    Width = 50
                })
                {
                    BaselineAlignment = BaselineAlignment.Center
                });

            case "eicon":
                var source = new BitmapImage(new Uri($"https://static.f-list.net/images/eicon/{node.ToText().ToLower()}.gif"));
                var image  = new Image {
                    Height = 50, Width = 50
                };
                ImageBehavior.SetAnimatedSource(image, source);
                return(new InlineUIContainer(image));

            case "session":                     //TODO channellistitem
                var session = new Hyperlink {
                    Inlines = { new InlineUIContainer(new Path {
                            Data = Icons.Channel, Fill = App.Current.Theme.Foreground, Margin = new Thickness(0, 0, 5, 0)
                        }) },
                    NavigateUri = new Uri("http://x.com")
                };
                var id = node.ToText();
                session.RequestNavigate += (sender, args) => Mvx.GetSingleton <IChannelManager>().JoinChannel(id);
                node.SubNodes.Clear();
                node.SubNodes.Add(new TextNode(parameter));
                return(session);

            case "user":
                return(new InlineUIContainer(new Views.UserView {
                    Character = Mvx.GetSingleton <CharacterViewModels>().GetCharacterViewModel(node.ToText())
                }));
            }
            return(new Span());
        }