コード例 #1
0
        protected virtual void CharacterPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            Inlines.Clear();
            if (e.OldValue is CharacterViewModel oldValue)
            {
                oldValue.CharacterLists.CollectionChanged -= CharacterListsChanged;
            }
            if (e.NewValue == null)
            {
                return;
            }
            var character = (CharacterViewModel)e.NewValue;

            Inlines.Add(new InlineUIContainer(new Image {
                Source = GetStatusImage(character.Character.Status), Height = 15, Width = 15, UseLayoutRounding = true, SnapsToDevicePixels = true
            })
            {
                BaselineAlignment = BaselineAlignment.TextBottom
            });
            Inlines.Add(new Run(" "));
            nameRun = new Run(character.Character.Name)
            {
                Foreground = new SolidColorBrush(MvxWpfColor.ToNativeColor(Character.GenderColor))
            };
            ApplyListColors();
            character.CharacterLists.CollectionChanged += CharacterListsChanged;
            Inlines.Add(nameRun);
        }
コード例 #2
0
 public static System.Windows.Media.Color ToNativeColor(this System.Drawing.Color color)
 {
     return(MvxWpfColor.ToNativeColor(color));
 }
コード例 #3
0
        private void ApplyListColors()
        {
            IEnumerable <CharacterList> lists = Character.CharacterLists.ToList();

            if (ChannelMember != null && ChannelMember.Member.Rank > Channel.RankEnum.User)
            {
                lists = lists.Concat(Mvx.GetSingleton <CharacterListProvider>().ChannelOps.SingletonEnumerable());
            }
            var list = lists.OrderBy(x => x.SortingOrder).FirstOrDefault();

            if (list != null)
            {
                var bytes = BitConverter.GetBytes(list.UnderlineColor);
                if (bytes[3] != 0)
                {
                    nameRun.TextDecorations.Add(new TextDecoration(TextDecorationLocation.Underline,
                                                                   new Pen(new SolidColorBrush(Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0])), 1.5), 0, 0, TextDecorationUnit.FontRecommended));
                }
                else
                {
                    nameRun.TextDecorations.Clear();
                }
                bytes = BitConverter.GetBytes(list.TextColor);
                nameRun.Foreground = new SolidColorBrush(bytes[3] != 0 ? Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]) : MvxWpfColor.ToNativeColor(Character.GenderColor));
            }
        }