Inheritance: INotifyPropertyChanged
Ejemplo n.º 1
0
        private static Inline FormatMsg(ChatControl control, string text, TraceEventType eventType, int id)
        {
            if (!control.Dispatcher.CheckAccess())
            {
                return(control.Dispatcher.Invoke(new Action(() => FormatMsg(control, text, eventType, id))) as Inline);
            }
            var result = new Run(text);

            return(FormatInline(control, result, eventType, id));
        }
Ejemplo n.º 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var mess = value as IGameMessage;

            if (mess == null)
            {
                return(null);
            }
            return(ChatControl.GameMessageToBlock(mess));
        }
Ejemplo n.º 3
0
 private static Inline FormatMsg(ChatControl control,string text, TraceEventType eventType, int id)
 {
     var result = new Run(text);
     return FormatInline(control,result, eventType, id);
 }
Ejemplo n.º 4
0
        private static Inline FormatInline(ChatControl control, Inline inline, TraceEventType eventType, int id, Object[] args = null)
        {
            switch (eventType)
            {
                case TraceEventType.Error:
                case TraceEventType.Warning:
                    inline.Foreground = Brushes.Red;
                    inline.FontWeight = FontWeights.Bold;
                    break;
                case TraceEventType.Information:
                    if ((id & EventIds.Chat) != 0)
                        inline.FontWeight = FontWeights.Bold;
                    if (args == null || args.GetUpperBound(0) == -1)
                    {
                        if ((id & EventIds.OtherPlayer) == 0)
                            inline.Foreground = Brushes.DarkGray;
                    }
                    else
                    {
                        int i = 0;
                        var p = args[i] as Player;
                        while (p == null && i < args.Length - 1)
                        {
                            i++;
                            p = args[i] as Player;
                        }
                        inline.Foreground = p != null ? new SolidColorBrush(p.Color) : Brushes.Red;

                        if (p != null && Player.LocalPlayer.Id != p.Id)
                        {
                            var theinline = inline;
                            theinline.Initialized += (sender, eventArgs) =>
                                {
                                    try
                                    {
                                        var curcolor = (theinline.Foreground as SolidColorBrush).Color;
                                        var dbAscending = new ColorAnimation(curcolor, Colors.Tomato, new Duration(TimeSpan.FromMilliseconds(500)))
                                            { RepeatBehavior = new RepeatBehavior(2), AutoReverse = true };
                                        var storyboard = new Storyboard();
                                        Storyboard.SetTarget(dbAscending, theinline);
                                        Storyboard.SetTargetProperty(dbAscending, new PropertyPath("Foreground.Color"));
                                        storyboard.Children.Add(dbAscending);
                                        storyboard.Begin(control);
                                    }
                                    catch (Exception)
                                    {
                                    }
                                };
                        }
                    }
                    break;
            }
            return inline;
        }
Ejemplo n.º 5
0
 public ChatTraceListener(string name, ChatControl ctrl)
     : base(name)
 {
     _ctrl = ctrl;
 }
Ejemplo n.º 6
0
 public ChatTraceListener(string name, ChatControl ctrl)
     : base(name)
 {
     Dispatcher = ctrl.Dispatcher;
     _ctrl = ctrl;
 }
Ejemplo n.º 7
0
        private static Inline FormatMsg(ChatControl control, string text, TraceEventType eventType, int id)
        {
            var result = new Run(text);

            return(FormatInline(control, result, eventType, id));
        }
Ejemplo n.º 8
0
        private static Inline FormatInline(ChatControl control, Inline inline, TraceEventType eventType, int id, Object[] args = null)
        {
            switch (eventType)
            {
            case TraceEventType.Error:
            case TraceEventType.Warning:
                inline.Foreground = Brushes.Red;
                inline.FontWeight = FontWeights.Bold;
                break;

            case TraceEventType.Information:
                if ((id & EventIds.Chat) != 0)
                {
                    inline.FontWeight = FontWeights.Bold;
                }
                if (args == null || args.GetUpperBound(0) == -1)
                {
                    if ((id & EventIds.OtherPlayer) == 0)
                    {
                        inline.Foreground = Brushes.DarkGray;
                    }
                }
                else
                {
                    int i = 0;
                    var p = args[i] as Player;
                    while (p == null && i < args.Length - 1)
                    {
                        i++;
                        p = args[i] as Player;
                    }
                    inline.Foreground = p != null ? new SolidColorBrush(p.Color) : Brushes.Red;

                    if (p != null && Player.LocalPlayer.Id != p.Id)
                    {
                        var theinline = inline;
                        theinline.Initialized += (sender, eventArgs) =>
                        {
                            try
                            {
                                var curcolor    = (theinline.Foreground as SolidColorBrush).Color;
                                var dbAscending = new ColorAnimation(curcolor, Colors.Tomato, new Duration(TimeSpan.FromMilliseconds(500)))
                                {
                                    RepeatBehavior = new RepeatBehavior(2), AutoReverse = true
                                };
                                var storyboard = new Storyboard();
                                Storyboard.SetTarget(dbAscending, theinline);
                                Storyboard.SetTargetProperty(dbAscending, new PropertyPath("Foreground.Color"));
                                storyboard.Children.Add(dbAscending);
                                storyboard.Begin(control);
                            }
                            catch (Exception)
                            {
                            }
                        };
                    }
                }
                break;
            }
            return(inline);
        }
Ejemplo n.º 9
0
 public ChatTraceListener(string name, ChatControl ctrl)
     : base(name)
 {
     _ctrl = ctrl;
 }
Ejemplo n.º 10
0
 public ChatTraceListener(string name, ChatControl ctrl)
     : base(name)
 {
     Dispatcher = ctrl.Dispatcher;
     _ctrl      = ctrl;
 }
Ejemplo n.º 11
0
 private static Inline FormatMsg(ChatControl control,string text, TraceEventType eventType, int id)
 {
     if (!control.Dispatcher.CheckAccess())
     {
         return control.Dispatcher.Invoke(new Action(() => FormatMsg(control, text, eventType, id))) as Inline;
     }
     var result = new Run(text);
     return FormatInline(control,result, eventType, id);
 }