Пример #1
0
 private static MParser CreateParser(ITextWindow window)
 {
     return(new MParser(window));
 }
Пример #2
0
        public static FrameworkElement AppendTextBlock(this ITextWindow win, TextType type, string text, object tag, RoutedEventHandler linkCallback)
        {
            var brush      = Brushes.MsgSayBrush;
            var fontSize   = 12.0;
            var fontWeight = FontWeights.Normal;
            var fontStyle  = FontStyles.Normal;

            bool createLink = false;

            switch (type)
            {
            case TextType.Shout:
                brush = Brushes.MsgShoutBrush;
                break;

            case TextType.Tell:
                createLink = true;
                brush      = Brushes.MsgTellBrush;
                break;

            case TextType.System:
                brush      = Brushes.MsgSystemBrush;
                fontWeight = FontWeights.Bold;
                break;

            case TextType.Error:
                brush      = Brushes.MsgErrorBrush;
                fontWeight = FontWeights.Bold;
                break;

            case TextType.News:
                brush = Brushes.MsgNewsBrush;
                break;

            case TextType.PlaceDesc:
                brush = Brushes.MsgSystemPlaceDescBrush;
                break;

            case TextType.Positive:
                brush = Brushes.PositiveBrush;
                break;

            case TextType.Negative:
                brush = Brushes.NegativeBrush;
                break;

            case TextType.Emote:
                brush = Brushes.MsgEmoteBrush;
                break;

            case TextType.PlaceName:
                brush      = Brushes.MsgSystemPlaceNameBrush;
                fontWeight = FontWeights.Bold;
                break;

            case TextType.PlaceExits:
                brush     = Brushes.MsgSystemPlaceExitsBrush;
                fontStyle = FontStyles.Italic;
                break;

            case TextType.PlaceActors:
                brush = Brushes.MsgSystemPlaceActorsBrush;
                break;

            case TextType.PlaceAvatars:
                brush = Brushes.MsgSystemPlaceAvatarsBrush;
                break;

            case TextType.Help:
                brush      = Brushes.MsgHelpBrush;
                fontWeight = FontWeights.Bold;
                break;

            case TextType.Level:
                brush      = Brushes.MsgLevelBrush;
                fontWeight = FontWeights.Bold;
                break;

            case TextType.Cast:
                brush = Brushes.MsgCastBrush;
                break;

            case TextType.Melee:
                brush = Brushes.MsgMeleeBrush;
                break;

            case TextType.Award:
                brush = Brushes.MsgAwardBrush;
                break;
            }

            if (win.TextContainer.Children.Count == MaxDisplayItems)
            {
                win.TextContainer.Children.RemoveAt(0);
            }

            FrameworkElement element = null;

            if (createLink && linkCallback != null)
            {
                element = CreateHyperLink(text, brush, fontWeight, fontStyle, fontSize, tag, linkCallback);
            }
            else
            {
                element = CreateTextBlock(text, brush, fontWeight, fontStyle, fontSize);
            }

            win.TextContainer.Children.Add(element);
            return(element);
        }
Пример #3
0
 public MParser(ITextWindow window)
 {
     _window = window;
 }