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); }
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)); } } )); }
public Login() { if (firstStart) { WormNetCharTable.Initialize(); if (!Properties.Settings.Default.SettingsUpgraded) { try { Properties.Settings.Default.Upgrade(); if (Properties.Settings.Default.Group0List.Length == 0) { Properties.Settings.Default.Group0List = Properties.Settings.Default.BuddyList; } // new colors if (Properties.Settings.Default.ChannelMessageStyle == "F0FFFF|13|0|0|0|0|Tahoma") { Properties.Settings.Default.ChannelMessageStyle = (string)Properties.Settings.Default.Properties["ChannelMessageStyle"].DefaultValue; } if (Properties.Settings.Default.JoinMessageStyle == "808000|12|0|0|0|0|Tahoma") { Properties.Settings.Default.JoinMessageStyle = (string)Properties.Settings.Default.Properties["JoinMessageStyle"].DefaultValue; } if (Properties.Settings.Default.PartMessageStyle == "808000|12|0|0|0|0|Tahoma") { Properties.Settings.Default.PartMessageStyle = (string)Properties.Settings.Default.Properties["PartMessageStyle"].DefaultValue; } if (Properties.Settings.Default.QuitMessageStyle == "808000|12|0|0|0|0|Tahoma") { Properties.Settings.Default.QuitMessageStyle = (string)Properties.Settings.Default.Properties["QuitMessageStyle"].DefaultValue; } if (Properties.Settings.Default.OfflineMessageStyle == "FF0000|13|0|0|0|0|Tahoma") { Properties.Settings.Default.OfflineMessageStyle = (string)Properties.Settings.Default.Properties["OfflineMessageStyle"].DefaultValue; } if (Properties.Settings.Default.ActionMessageStyle == "FFFF00|13|0|0|0|0|Tahoma") { Properties.Settings.Default.ActionMessageStyle = (string)Properties.Settings.Default.Properties["ActionMessageStyle"].DefaultValue; } if (Properties.Settings.Default.UserMessageStyle == "E9967A|13|0|0|0|0|Tahoma") { Properties.Settings.Default.UserMessageStyle = (string)Properties.Settings.Default.Properties["UserMessageStyle"].DefaultValue; } if (Properties.Settings.Default.NoticeMessageStyle == "E9967A|13|0|0|0|0|Tahoma") { Properties.Settings.Default.NoticeMessageStyle = (string)Properties.Settings.Default.Properties["NoticeMessageStyle"].DefaultValue; } } catch (Exception) { } var validator = new GSVersionValidator(); string quitMessage = Properties.Settings.Default.QuitMessagee; if (Properties.Settings.Default.QuitMessagee == string.Empty || validator.Validate(ref quitMessage) != string.Empty) { Properties.Settings.Default.QuitMessagee = "Great Snooper v" + App.GetVersion(); } Properties.Settings.Default.SettingsUpgraded = true; Properties.Settings.Default.Save(); } MessageSettings.Initialize(); CountriesClass.Initialize(); GlobalManager.Initialize(); UserGroups.Initialize(); Sounds.Initialize(); // Reducing Timeline frame rate Timeline.DesiredFrameRateProperty.OverrideMetadata( typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 25 } ); } InitializeComponent(); DataContext = this; nickRegex = new Regex(@"^[a-z`]", RegexOptions.IgnoreCase); nickRegex2 = new Regex(@"^[a-z`][a-z0-9`\-]*$", RegexOptions.IgnoreCase); ServerList = new SortedObservableCollection <string>(); ServerList.DeSerialize(Properties.Settings.Default.ServerAddresses); Server.SelectedItem = Properties.Settings.Default.ServerAddress; switch (Properties.Settings.Default.LoginType) { case "simple": LoginTypeChooser.SelectedIndex = 0; break; default: LoginTypeChooser.SelectedIndex = 1; break; } AutoLogIn.IsChecked = Properties.Settings.Default.AutoLogIn; Nick.Text = Properties.Settings.Default.UserName; Country.ItemsSource = CountriesClass.Countries; if (Properties.Settings.Default.UserCountry != -1) { CountryClass country = CountriesClass.GetCountryByID(Properties.Settings.Default.UserCountry); Country.SelectedItem = country; } else { CultureInfo ci = CultureInfo.InstalledUICulture; CountryClass country; if (ci != null) { country = CountriesClass.GetCountryByCC(ci.TwoLetterISOLanguageName.ToUpper()); } else { country = CountriesClass.DefaultCountry; } Country.SelectedItem = country; } Rank.ItemsSource = RanksClass.Ranks; Rank.SelectedIndex = Properties.Settings.Default.UserRank; Clan.Text = Properties.Settings.Default.UserClan; TUSNick.Text = Properties.Settings.Default.TusNick; TUSPass.Password = Properties.Settings.Default.TusPass; }
public bool AddNewMessage(Channel ch, MessageClass message, bool insert = false) { if (Properties.Settings.Default.ChatMode && ( message.Style.Type == MessageTypes.Part || message.Style.Type == MessageTypes.Join || message.Style.Type == MessageTypes.Quit) ) { return(false); } try { Paragraph p = new Paragraph(); MessageSettings.LoadSettingsFor(p, message.Style); p.Foreground = message.Style.MessageColor; p.Margin = new Thickness(0, 2, 0, 2); p.Tag = message; p.MouseRightButtonDown += InstantColorMenu; // Time when the message arrived if (Properties.Settings.Default.MessageTime) { Run word = new Run(message.Time.ToString("T") + " "); MessageSettings.LoadSettingsFor(word, MessageSettings.MessageTimeStyle); word.Foreground = MessageSettings.MessageTimeStyle.NickColor; p.Inlines.Add(word); } // Sender of the message Run nick = (message.Style.Type == MessageTypes.Action) ? new Run(message.Sender.Name + " ") : new Run(message.Sender.Name + ": "); SolidColorBrush b; // Instant color if (InstantColors.TryGetValue(message.Sender.LowerName, out b)) { nick.Foreground = b; } // Group color else if (message.Sender.Group.ID != UserGroups.SystemGroupID) { nick.Foreground = message.Sender.Group.TextColor; nick.FontStyle = FontStyles.Italic; } else { nick.Foreground = message.Style.NickColor; } nick.FontWeight = FontWeights.Bold; p.Inlines.Add(nick); // Message content if (message.Style.IsFixedText) { p.Inlines.Add(new Run(message.Message)); } else { string[] words; if (message.Words != null) { words = message.Words; } else { words = message.Message.Split(' '); } Uri uri = null; HightLightTypes highlightType; sb.Clear(); // this StringBuilder is for minimizing the number on Runs in a paragraph for (int i = 0; i < words.Length; i++) { if (message.HighlightWords != null && message.HighlightWords.TryGetValue(i, out highlightType)) { // Flush the sb content if (sb.Length > 0) { p.Inlines.Add(new Run(sb.ToString())); sb.Clear(); } Run word = new Run(words[i]); if (highlightType == HightLightTypes.Highlight) { word.FontStyle = FontStyles.Italic; } else { MessageSettings.LoadSettingsFor(word, MessageSettings.LeagueFoundMessage); word.Foreground = MessageSettings.LeagueFoundMessage.NickColor; } p.Inlines.Add(word); } // Links else if ( ( words[i].StartsWith("ftp://", StringComparison.OrdinalIgnoreCase) || words[i].StartsWith("http://", StringComparison.OrdinalIgnoreCase) || words[i].StartsWith("https://", StringComparison.OrdinalIgnoreCase) ) && Uri.TryCreate(words[i], UriKind.RelativeOrAbsolute, out uri) ) { // Flush the sb content if (sb.Length > 0) { p.Inlines.Add(new Run(sb.ToString())); sb.Clear(); } Hyperlink word = new Hyperlink(new Run(words[i])); MessageSettings.LoadSettingsFor(word, MessageSettings.HyperLinkStyle); word.Foreground = MessageSettings.HyperLinkStyle.NickColor; word.NavigateUri = new Uri(words[i]); word.RequestNavigate += OpenURLInBrowser; p.Inlines.Add(word); } else { sb.Append(words[i]); } if (i + 1 < words.Length) { sb.Append(' '); } } // Flush the sb content if (sb.Length > 0) { p.Inlines.Add(new Run(sb.ToString())); } } // Insert the new paragraph if (insert) { ch.TheFlowDocument.Blocks.InsertBefore(ch.TheFlowDocument.Blocks.FirstBlock, p); } else { ch.TheFlowDocument.Blocks.Add(p); } while (ch.TheFlowDocument.Blocks.Count > GlobalManager.MaxMessagesInMemory) { ch.TheFlowDocument.Blocks.Remove(ch.TheFlowDocument.Blocks.FirstBlock); } return(true); } catch (Exception e) { ErrorLog.Log(e); } return(false); }
private void SaveClick(object sender, RoutedEventArgs e) { actSetting.Fontfamily = new FontFamily(tb1.FontFamily.ToString()); actSetting.NickColor = new SolidColorBrush(NickColor.SelectedColor); if (actSetting.OneColorOnly) { actSetting.MessageColor = new SolidColorBrush(NickColor.SelectedColor); } else { actSetting.MessageColor = new SolidColorBrush(MessageColor.SelectedColor); } actSetting.Size = tb1.FontSize; actSetting.Bold = TheBold.IsChecked.Value ? FontWeights.Bold : FontWeights.Normal; actSetting.Italic = TheItalic.IsChecked.Value ? FontStyles.Italic : FontStyles.Normal; actSetting.Strikethrough = TheStrikethrough.IsChecked.Value; actSetting.Underline = TheUnderline.IsChecked.Value; Properties.Settings.Default.GetType().GetProperty(styleName).SetValue(Properties.Settings.Default, MessageSettings.ObjToSetting(actSetting), null); Properties.Settings.Default.Save(); if (SaveSetting != null) { SaveSetting.BeginInvoke(this, null, null, null); } this.Close(); }