public static string ObjToSetting(MessageSetting obj) { var sb = new System.Text.StringBuilder(); // NickColor sb.Append(string.Format("{0:X2}{1:X2}{2:X2}", obj.NickColor.Color.R, obj.NickColor.Color.G, obj.NickColor.Color.B)); sb.Append('|'); if (obj.OneColorOnly == false) { // MessageColor sb.Append(string.Format("{0:X2}{1:X2}{2:X2}", obj.MessageColor.Color.R, obj.MessageColor.Color.G, obj.MessageColor.Color.B)); sb.Append('|'); } // Size sb.Append(obj.Size); sb.Append('|'); // Bold sb.Append(obj.Bold == FontWeights.Bold ? 1 : 0); sb.Append('|'); // Italic sb.Append(obj.Italic == FontStyles.Italic ? 1 : 0); sb.Append('|'); // Strikethrough sb.Append(obj.Strikethrough ? 1 : 0); sb.Append('|'); // Underline sb.Append(obj.Underline ? 1 : 0); sb.Append('|'); // Font family sb.Append(obj.Fontfamily.ToString()); return(sb.ToString()); }
public MessageClass(Client Sender, string Message, MessageSetting setting) { this.Sender = Sender; this.Message = Message; this.Style = setting; this.Time = DateTime.Now; }
private void AddStyleSetting(Grid grid, string name, string text, MessageSetting setting) { int row = grid.RowDefinitions.Count; grid.RowDefinitions.Add(new RowDefinition() { Height = System.Windows.GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(10) }); // <Label Grid.Column="0" Grid.Row="1" Content="Auto login at startup:"></Label> TextBlock tb = new TextBlock(); tb.Text = text; Grid.SetRow(tb, row); Grid.SetColumn(tb, 0); grid.Children.Add(tb); Run run, run2 = null; TextBlock tb2 = new TextBlock(); tb2.VerticalAlignment = System.Windows.VerticalAlignment.Center; if (setting.OneColorOnly) { run = new Run("Example"); MessageSettings.LoadSettingsFor(run, setting); run.Foreground = setting.NickColor; tb2.Inlines.Add(run); } else { run = new Run("Player: "); MessageSettings.LoadSettingsFor(run, setting); run.FontWeight = FontWeights.Bold; run.Foreground = setting.NickColor; tb2.Inlines.Add(run); run2 = new Run("message"); MessageSettings.LoadSettingsFor(run2, setting); run2.Foreground = setting.MessageColor; tb2.Inlines.Add(run2); } Grid.SetRow(tb2, row); Grid.SetColumn(tb2, 1); grid.Children.Add(tb2); // <Button Grid.Row="1" Grid.Column="1" Content="Change" Click="FontChange" Name="UserMessage"></Button> Button b = new Button(); b.Focusable = false; b.Tag = new object[] { name, text, setting, run, run2 }; b.Content = "Change"; b.Click += StyleHandler; Grid.SetRow(b, row); Grid.SetColumn(b, 2); grid.Children.Add(b); }
public MessageUITask(IRCCommunicator sender, string clientName, string channelHash, string message, MessageSetting setting) { this.Sender = sender; this.ClientName = clientName; this.ChannelHash = channelHash; this.Message = message; this.Setting = setting; }
// This method ensures that the initialization will be made from the appropriate thread public static void Initialize() { ChannelMessage = SettingToObj(Properties.Settings.Default.ChannelMessageStyle, MessageTypes.Channel, false, false); JoinMessage = SettingToObj(Properties.Settings.Default.JoinMessageStyle, MessageTypes.Join, true, false); QuitMessage = SettingToObj(Properties.Settings.Default.QuitMessageStyle, MessageTypes.Quit, false, false); PartMessage = SettingToObj(Properties.Settings.Default.PartMessageStyle, MessageTypes.Part, true, false); OfflineMessage = SettingToObj(Properties.Settings.Default.OfflineMessageStyle, MessageTypes.Offline, true, false); ActionMessage = SettingToObj(Properties.Settings.Default.ActionMessageStyle, MessageTypes.Action, false, false); UserMessage = SettingToObj(Properties.Settings.Default.UserMessageStyle, MessageTypes.User, false, false); NoticeMessage = SettingToObj(Properties.Settings.Default.NoticeMessageStyle, MessageTypes.Notice, false, false); MessageTimeStyle = SettingToObj(Properties.Settings.Default.MessageTimeStyle, MessageTypes.Time, true, true); HyperLinkStyle = SettingToObj(Properties.Settings.Default.HyperLinkStyle, MessageTypes.Hyperlink, true, true); LeagueFoundMessage = SettingToObj(Properties.Settings.Default.LeagueFoundMessageStyle, MessageTypes.League, true, true); }
// Add a message public void AddMessage(Client sender, string message, MessageSetting style) { if (Messages.Count + 1 > GlobalManager.MaxMessagesInMemory) { Log(GlobalManager.NumOfOldMessagesToBeLoaded); } MessageClass msg = new MessageClass(sender, message, style); Messages.Add(msg); if (!sender.IsBanned || !IsPrivMsgChannel && Properties.Settings.Default.ShowBannedMessages) { if (mw.EnergySaveModeOn) { this.MessageReloadNeeded = true; } else { mw.AddNewMessage(this, msg, false); } } }
void window_SaveSetting(object sender, EventArgs e) { this.Dispatcher.Invoke(new Action(delegate() { object[] tag = (object[])helper.Tag; MessageSetting setting = (MessageSetting)tag[2]; Run run = (Run)tag[3]; MessageSettings.LoadSettingsFor(run, setting); run.Foreground = setting.NickColor; if (setting.OneColorOnly == false) { Run run2 = (Run)tag[4]; MessageSettings.LoadSettingsFor(run2, setting); run2.Foreground = setting.MessageColor; } if (SettingChanged != null) { SettingChanged(this, new SettingChangedEventArgs((string)tag[0], SettingChangedType.Style)); } } )); }
private bool ProcessClientMessage(string line) { // :[email protected] PART #AnythingGoes Match m = messageRegex.Match(line); if (!m.Success) { return(false); } string command = m.Groups[3].Value.ToLower(); // :[email protected] PART #AnythingGoes if (command == "part") { string clientNameL = m.Groups[1].Value.ToLower(); string channelHash = m.Groups[4].Value.ToLower(); GlobalManager.UITasks.Enqueue(new PartedUITask(this, channelHash, clientNameL)); } // :[email protected] JOIN :#RopersHeaven else if (command == "join") { string clientName = m.Groups[1].Value; string channelHash = m.Groups[4].Value.ToLower(); string clan = m.Groups[2].Value.ToLower() == "username" ? string.Empty : m.Groups[2].Value; GlobalManager.UITasks.Enqueue(new JoinedUITask(this, channelHash, clientName, clan)); } // :[email protected] QUIT :Joined Game else if (command == "quit") { string clientNameL = m.Groups[1].Value.ToLower(); string message = m.Groups[4].Value; if (clientNameL == this.User.LowerName) { System.Windows.MessageBox.Show("Server disconnected: " + message); return(true); } GlobalManager.UITasks.Enqueue(new QuitUITask(this, clientNameL, message)); } // :[email protected] PRIVMSG #AnythingGoes :can u take my oral // :AeF`[email protected] PRIVMSG #AnythingGoes :\x01ACTION ads\x01 else if ((command == "privmsg" || command == "notice")) { string clientName = m.Groups[1].Value; string clientLower = clientName.ToLower(); if (!IsWormNet && clientLower == "global") { return(false); } int spacePos = m.Groups[4].Value.IndexOf(' '); if (spacePos != -1) { string channelHash = m.Groups[4].Value.Substring(0, spacePos).ToLower(); if (channelHash == this.User.LowerName) { channelHash = clientName; // Hashname for pm channels are case-sensitive! } string message = m.Groups[4].Value.Substring(spacePos + 2); /* * if (!IsWormNet && lower == "authserv" && ConnectionState != null) * { * if (message == "I recognize you.") * { * ConnectionState(this, ConnectionStates.AuthOK); * return false; * } * else * ConnectionState(this, ConnectionStates.AuthBad); * } */ // Is it an action message? (CTCP message) (\x01ACTION message..\x01) if (message.Length > 2 && message[0] == '\x01' && message[message.Length - 1] == '\x01') { spacePos = message.IndexOf(' '); if (spacePos != -1) // ctcp command with message { string ctcpCommand = message.Substring(1, spacePos - 1).ToLower(); // skip \x01 message = message.Substring(spacePos + 1, message.Length - spacePos - 2); // skip \x01 int vertBarPos; switch (ctcpCommand) { case "action": GlobalManager.UITasks.Enqueue(new MessageUITask(this, clientName, channelHash, message, MessageSettings.ActionMessage)); break; case "cmessage": vertBarPos = message.IndexOf('|'); if (vertBarPos != -1) { channelHash = SplitUserAndSenderName(message.Substring(0, vertBarPos), clientName); string msg = message.Substring(vertBarPos + 1); GlobalManager.UITasks.Enqueue(new MessageUITask(this, clientName, channelHash, msg, MessageSettings.ChannelMessage)); } break; case "caction": vertBarPos = message.IndexOf('|'); if (vertBarPos != -1) { channelHash = SplitUserAndSenderName(message.Substring(0, vertBarPos), clientName); string msg = message.Substring(vertBarPos + 1); GlobalManager.UITasks.Enqueue(new MessageUITask(this, clientName, channelHash, msg, MessageSettings.ActionMessage)); } break; case "clientadd": vertBarPos = message.IndexOf('|'); if (vertBarPos != -1) { channelHash = SplitUserAndSenderName(message.Substring(0, vertBarPos), clientName); string clientNameToAdd = message.Substring(vertBarPos + 1); GlobalManager.UITasks.Enqueue(new ClientAddOrRemoveTask(this, channelHash, clientName, clientNameToAdd, ClientAddOrRemoveTask.TaskType.Add)); } break; case "clientrem": vertBarPos = message.IndexOf('|'); if (vertBarPos != -1) { channelHash = SplitUserAndSenderName(message.Substring(0, vertBarPos), clientName); string clientNameToRemove = message.Substring(vertBarPos + 1); GlobalManager.UITasks.Enqueue(new ClientAddOrRemoveTask(this, channelHash, clientName, clientNameToRemove, ClientAddOrRemoveTask.TaskType.Remove)); } break; case "cleaving": channelHash = SplitUserAndSenderName(message, clientName); GlobalManager.UITasks.Enqueue(new ClientLeaveConvTask(this, channelHash, clientName)); break; } } else { string ctcpCommand = message.Substring(1, message.Length - 2).ToLower(); switch (ctcpCommand) { case "version": Send("NOTICE " + clientName + " :VERSION Great Snooper v" + App.GetVersion()); break; } } } else { MessageSetting setting = (command == "privmsg") ? MessageSettings.ChannelMessage : MessageSettings.NoticeMessage; GlobalManager.UITasks.Enqueue(new MessageUITask(this, clientName, channelHash, message, setting)); } } } // :[email protected] NICK :Tomi3 else if (!IsWormNet && command == "nick") { string oldClientName = m.Groups[1].Value; string newClientName = m.Groups[4].Value; GlobalManager.UITasks.Enqueue(new NickUITask(this, oldClientName, newClientName)); } return(false); }
public static void LoadSettingsFor(System.Windows.Documents.TextElement element, MessageSetting setting) { element.FontFamily = setting.Fontfamily; element.FontWeight = setting.Bold; element.FontStyle = setting.Italic; element.FontSize = setting.Size; element.FontWeight = setting.Bold; if (element is Inline) { Inline inline = (Inline)element; inline.TextDecorations = setting.Textdecorations; } else if (element is Paragraph) { Paragraph p = (Paragraph)element; p.TextDecorations = setting.Textdecorations; } }
} // Never used, but visual stdio throws an error if not exists public FontChooser(string styleName, string title, MessageSetting setting) { InitializeComponent(); Title = title; SortedDictionary <string, FontFamily> fontFamilies = new SortedDictionary <string, FontFamily>(); IEnumerator <FontFamily> iterator = Fonts.SystemFontFamilies.GetEnumerator(); while (iterator.MoveNext()) { fontFamilies.Add(iterator.Current.ToString(), iterator.Current); } TheFontfamily.ItemsSource = fontFamilies; this.styleName = styleName; for (double i = 1; i <= 20; i++) { TheSize.Items.Add(i); } actSetting = setting; if (actSetting.OneColorOnly) { tb1 = new TextBlock() { Text = "Example" }; ExampleSP.Children.Add(tb1); } else { tb1 = new TextBlock() { Text = "Player: ", FontWeight = FontWeights.Bold }; tb2 = new TextBlock() { Text = "message" }; ExampleSP.Children.Add(tb1); ExampleSP.Children.Add(tb2); } TheFontfamily.SelectedItem = new KeyValuePair <string, FontFamily>(setting.Fontfamily.ToString(), setting.Fontfamily); TheFontfamily.ScrollIntoView(TheFontfamily.SelectedItem); TheSize.SelectedItem = setting.Size; NickColor.SelectedColor = setting.NickColor.Color; if (setting.OneColorOnly == false) { MessageColor.SelectedColor = setting.MessageColor.Color; } else { MessageColor.Visibility = System.Windows.Visibility.Collapsed; } TheBold.IsChecked = setting.Bold == FontWeights.Bold; BoldChanged(null, null); TheItalic.IsChecked = setting.Italic == FontStyles.Italic; ItalicChanged(null, null); TheStrikethrough.IsChecked = setting.Strikethrough; StrikethroughChanged(null, null); TheUnderline.IsChecked = setting.Underline; UnderlineChanged(null, null); }