Beispiel #1
0
		public static Block ToBlock(this CenterNode node, Channel _chan = null)
		{
			return new Paragraph(node.ToInline())
			{
				TextAlignment = TextAlignment.Center
			};
		}
		public ChannelUserMessageEventArgs(Channel channel, FChat.Character character, string message, Command command)
		{
			Channel = channel;
			Character = character;
			Message = message;
			Command = command;
		}
		public ChannelAdminActionEventArgs(Channel channel, FChat.Character character, FChat.Character admin, Command command)
		{
			Channel = channel;
			Character = character;
			Admin = admin;
			Command = command;
		}
		// TODO: Rework to be closer to the official FChat icons
		// TODO: Status icon
		public static string GetChanIcons(this Character ch, Channel chan = null)
		{
			string ret = "";

			if (ch.IsChatOp)
				ret += "▼".Color(ConsoleColor.Yellow);

			if (chan != null)
			{
				if (chan.Official)
				{
					if (chan.Owner == ch || ch.IsOPInChannel(chan))
						ret += "▼".Color(ConsoleColor.Red);
				}
				else
				{
					if (chan.Owner == ch)
						ret += "►".Color(ConsoleColor.Cyan);
					else if (ch.IsOPInChannel(chan))
						ret += "►".Color(ConsoleColor.Red);
				}
			}

			return ret;
		}
Beispiel #5
0
        public ChatChannel(Channel chan)
        {
            _channel = chan;
            if (_channel != null)
            {
                _channel.Connection.OnChannelUserJoin += (s, e) =>
                {
                    if (e.Channel == _channel)
                    {
                        _userList.Document.Blocks.Add(new Paragraph(new UserNode() { Text = e.Character.Name }.ToInline(_channel))
                        {
                            Tag = e.Character
                        });
                    }
                };
                _channel.Connection.OnChannelUserLeave += (s, e) =>
                {
                    if (e.Channel == _channel)
                        _userList.Document.Blocks.Remove(_userList.Document.Blocks.First(b => b.Tag == e.Character));
                };
                _channel.Connection.OnChannelChatMessage += (s, e) =>
                {
                    if (e.Channel == _channel)
                        AddMessage(e.Character, e.Message);
                };
            }

            InitializeComponent();
        }
		public static string ToSortable(this Character ch, Channel chan)
		{
			int value = 9;
			if (ch.IsFriend || ch.IsBookmark)
			    value = 1;
			if (ch.IsChatOp || ch.IsOPInChannel(chan))
				value = 0;

			return $"{value}{ch.Name}";
		}
Beispiel #7
0
		public static Block ToBlock(this HeadingNode node, Channel _chan = null)
		{
			return new Paragraph(node.ToInline())
			{
				FontSize = 14,
				KeepTogether = true,
				KeepWithNext = false,
				Margin = new Thickness(0, 10, 0, 10)
			};
		}
Beispiel #8
0
 TabItem GetTabByChannel(Channel channel)
 {
     foreach (var tab in _chatList.Items)
     {
         if ((tab as TabItem).Tag == channel)
         {
             return tab as TabItem;
         }
     }
     return null;
 }
Beispiel #9
0
		public static Block ToBlock(this IParagraphNode node, Channel _chan = null)
		{
			var type = node.GetType();

			var member = type.GetMethod("ToBlock");
			if (member == null)
				member = type.GetExtensionMethod("ToBlock");

			if (member == null)
				return null;

			return member.Invoke(null, new object[] { node, _chan }) as Block;
		}
Beispiel #10
0
		public static Inline ToInline(this INode node, Channel _chan = null)
		{
			var type = node.GetType();

			var member = type.GetMethod("ToInline");
			if (member == null)
				member = type.GetExtensionMethod("ToInline");

			if (member == null)
				return null;

			return member.Invoke(null, new object[] { node, _chan }) as Inline;
		}
Beispiel #11
0
		public static Inline ToInline(this IContentNode node, Channel _chan = null, Span _span = null)
		{
			Span inline = _span;
			if (inline == null)
			{
				if (node.Content.Count == 1)
					return node.Content.First().ToInline(_chan);

				inline = new Span();
			}

			foreach (var child in node.Content)
				inline.Inlines.Add(child.ToInline(_chan));
			return inline;
		}
Beispiel #12
0
		ChatChannel GetOrCreateChannel(Channel channel)
        {
            foreach (var tab in _chatList.Items)
            {
                if ((tab as TabItem).Tag == channel)
                {
                    return (tab as TabItem).Content as ChatChannel;
                }
            }

            var item = new TabItem()
            {
                Header = new ChatTab(channel),
                Content = new ChatChannel(channel),
                Tag = channel
            };
            _chatList.Items.Add(item);

            return item.Content as ChatChannel;
        }
Beispiel #13
0
		public static Inline ToInline(this SessionNode node, Channel chan = null)
		{
			return new Hyperlink
			{
				Inlines =
				{
					new InlineUIContainer(new Image
					{
						Source = new CroppedBitmap(App.Current.CombinedImageResource, node.IsOfficial ? new Int32Rect(96, 0, 24, 24) : new Int32Rect(0, 24, 24, 24)),
						Width = 16,
						Height = 16,

						Margin = new Thickness(4)
					}),
					new Run(node.SessionName)
					{
						FontWeight = FontWeights.Bold
					}
				},

				Foreground = Brushes.White,
				TextDecorations = null,

				NavigateUri = new Uri($"flist://session/{node.SessionADH}"),
				ToolTip = node.SessionName
			};
		}
Beispiel #14
0
		public static Inline ToInline(this SmallNode node, Channel _chan = null)
		{
			var span = (node as IContentNode).ToInline();
			span.FontSize = 6;

			return span;
		}
Beispiel #15
0
		public static Inline ToInline(this StrikethroughNode node, Channel chan = null)
		{
			var span = (node as IContentNode).ToInline(chan);
			span.TextDecorations = TextDecorations.Strikethrough;

			return span;
		}
Beispiel #16
0
		public static Block ToBlock(this IndentNode node, Channel _chan = null)
		{
			return new Paragraph(node.ToInline())
			{
				Margin = new Thickness(36, 0, 0, 0)
			};
		}
Beispiel #17
0
		public static Inline ToInline(this URLNode node, Channel chan = null)
		{
			return new Hyperlink
			{
				Inlines =
				{
					new InlineUIContainer(new Image
					{
						Source = new CroppedBitmap(App.Current.CombinedImageResource, new Int32Rect(72, 96, 24, 24)),
						Width = 16,
						Height = 16,

						Margin = new Thickness(4)
					}),
					(node as IContentNode).ToInline(chan, new Span { TextDecorations = TextDecorations.Underline })
				},

				TextDecorations = null,
				Foreground = Brushes.White,

				NavigateUri = node.Uri,
				ToolTip = node.Uri.ToString()
			};
		}
		public ChannelEntryEventArgs(Channel channel, Command command)
		{
			Channel = channel;
			Command = command;
		}
Beispiel #19
0
		public static Inline ToInline(this ItalicNode node, Channel chan = null)
		{
			var span = (node as IContentNode).ToInline(chan);
			span.FontStyle = FontStyles.Italic;

			return span;
		}
Beispiel #20
0
		public ChannelChatBuffer(Channel channel)
		{
			Channel = channel;
		}
Beispiel #21
0
		public static Inline ToInline(this ITextNode node, Channel _chan = null)
		{
			return new Run(node.Text);
		}
Beispiel #22
0
		public static Inline ToInline(this UserNode node, Channel chan = null)
		{
			var character = node.GetCharacter(App.Current.FChatClient);

			return new Hyperlink
			{
				Inlines =
				{
					(chan == null || character.CharacterSymbolRect(chan) == null ? null : new Image {
						Source = new CroppedBitmap(App.Current.CombinedImageResource, character.CharacterSymbolRect(chan).Value),
						Width = 16,
						Height = 16,

						Margin = new Thickness(2)
					}),
					new InlineUIContainer(new Image
					{
						Source = new CroppedBitmap(App.Current.CombinedImageResource, character.CharacterStatusRect()),
						Width = 16,
						Height = 16,

						Margin = new Thickness(4)
					}),
				},

				TextDecorations = null,
				Foreground = character.CharacterGenderBrush()
			};
		}
        public static string ToANSIString(this Character ch, Channel chan = null, bool full = false)
        {
			return ch.GetChanIcons(chan) + (full ? ch.Status.ToANSIString() : "") + ch.Name.Color(ch.Gender.ToColor());
        }
Beispiel #24
0
		public static Inline ToInline(this SuperscriptNode node, Channel chan = null)
		{
			var span = (node as IContentNode).ToInline(chan);
			span.BaselineAlignment = BaselineAlignment.Superscript;
			span.FontSize = 9;
			return span;
		}
Beispiel #25
0
		public static Inline ToInline(this NoparseNode node, Channel chan = null)
		{
			return new Run(node.ToString(NodeStringType.BBCode));
		}
Beispiel #26
0
		public static Block ToBlock(this HorizontalRuleNode node, Channel _chan = null)
		{
			return new Paragraph
			{
				BorderBrush = Brushes.Black
			};
		}
Beispiel #27
0
		public static Block ToBlock(this CollapseNode node, Channel _chan = null)
		{
			return new Paragraph(node.ToInline());
		}
Beispiel #28
0
		public static Inline ToInline(this UnderlineNode node, Channel chan = null)
		{
			var span = (node as IContentNode).ToInline(chan);
			span.TextDecorations = TextDecorations.Underline;
			return span;
		}
		public ChannelUserEntryEventArgs(Channel channel, FChat.Character character, Command command)
		{
			Channel = channel;
			Character = character;
			Command = command;
		}
Beispiel #30
0
		public static Inline ToInline(this IconNode node, Channel chan = null)
		{
			return new Hyperlink
			{
				Inlines =
				{
					new InlineUIContainer(new Image
					{
						Source = new BitmapImage(node.AvatarUri),

						Width = 32,
						Height = 32,
					})
				},

				NavigateUri = new Uri($"flist://character/{node.Text}"),
				ToolTip = node.Text
			};
		}