internal void _GetFonts() { try { MyFont = new UiFontConf(); foreach (UiFontConf i in MainWindow.SqliteSource.EnumUiFont()) { MyFont.Brush = i.Brush; MyFont.FontSize = i.FontSize; MyFont.Fontname = i.Fontname; MyFont.Isbold = i.Isbold; MyFont.Isitalic = i.Isitalic; MyFont.ColorName = i.ColorName; } ChkIsBold.IsChecked = MyFont.Isbold; ChkIsItalic.IsChecked = MyFont.Isitalic; foreach (var i in CboxFont.Items) { if (i.Equals(MyFont.Fontname)) { CboxFont.SelectedItem = i; } } foreach (var i in CboxFontSize.Items) { if (i.Equals(MyFont.FontSize)) { CboxFontSize.SelectedItem = i; } } foreach (var i in CboxColors.Items) { var n = i.ToString().ToUpper(); if (n.Equals(MyFont.ColorName.ToUpper())) { CboxColors.SelectedItem = i; } } } catch (Exception ex) { MyDelegates.OnDebugMessageCallBack(ex.ToString()); } }
/// <summary> /// add ResourceDictionary /// </summary> internal void _addresource() { try { List <TemplateLang> lang = Clanguage.Langs; ResourceDictionary d = new ResourceDictionary(); foreach (TemplateLang i in lang) { if (i.Lang.ToUpper() == Clanguage.GetLangInClient()) { d.Source = new Uri(i.FileLink, UriKind.Absolute); Resources.MergedDictionaries.Add(d); } } } catch (Exception ex) { MyDelegates.OnDebugMessageCallBack(ex.StackTrace); } }
private void MnuMyChannels(string s) { CanvasAllShowHide(false); // atualiza o canal if (s != null && s != Configuration.StConfiguration.Channel) { Configuration.StConfiguration.Channel = s; } // connect clicked // call connecion IRC try { // check se esta em chat send QUIT encerrar conexao //if(CanvasContent.Visibility == Visibility.Visible) { _Quit();} MenuChannels.Visibility = Visibility.Collapsed; MenuClose.Visibility = Visibility.Visible; // kill thread if exist ThIrc?.Abort(); ThIrc = new Thread(ThreadIrc) { IsBackground = true }; ThIrc.Start(); } catch (Exception ex) { MyDelegates.OnDebugMessageCallBack(ex.StackTrace); } // save config in SQLite SqliteSource.UpdateSaved(); //Console.WriteLine(s); }
public void SendToIrc(string s, bool iscommand = false) { if (ThIrc == null) { return; } string[] r = s.Split(new string[] { "/", " " }, StringSplitOptions.None); _output = new StreamWriter(_sock.GetStream()); try { // check se for comando if (iscommand) { if (r[0] == @"QUIT") { Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate { _output.Write("QUIT" + "\r\n"); _output.Flush(); // //_Quit(); ListChat.Items.Clear(); CanvasWelcome.Visibility = Visibility.Visible; CanvasContent.Visibility = Visibility.Hidden; TxtSend.Visibility = Visibility.Collapsed; CanvasProgressring.Visibility = Visibility.Collapsed; RingP.IsActive = false; // mensagem de boas vindas Effectfade(LblChan, Efeitos.Surgir, Resources.MergedDictionaries[0]["Status"].ToString(), 5, Color.DodgerBlue); Title = Resources.MergedDictionaries[0]["Status"].ToString(); }); return; } switch (r[1]) { // AUTH case "AUTH": string[] content = s.Split(new string[] { " ", "/" }, StringSplitOptions.None); _output.Write(@"AUTH " + content[2] + @" " + content[3] + "\r\n"); _output.Flush(); MyDelegates.OnChatCallBack(@"system :", "Auth Sucess"); break; // kick => KICK <#channel> <nick> <comment banned> // exemplo : /KICK usuario comentario case "KICK": string[] k = s.Split(new string[] { "/", " " }, StringSplitOptions.None); _output.Write(@"KICK " + MainWindow.Configuration.StConfiguration.Channel + " " + k[2] + " " + k[3] + "\r\n"); _output.Flush(); break; // autokick // exemplo : /ADDKICK usuario case "ADDKICK": string[] ak = s.Split(new string[] { "/", " " }, StringSplitOptions.None); if (ak[2] != string.Empty) { Autokick.AddUser(ak[2]); } break; // removeautokick // ex: /REMOVEAUTOKICK usuario case "REMOVEKICK": string[] rk = s.Split(new string[] { "/", " " }, StringSplitOptions.None); if (rk[2] != string.Empty) { Autokick.RemoveUser(rk[2]); } break; // clearall // ex: /CLEARAUTOKICK case "CLEARKICK": Autokick.ClearAll(); break; // clear chat client // exemplo : /CLEAR case "CLEAR": Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate { ListChat.Items.Clear(); MyDelegates.OnChatCallBack(@"system :", @"clean client chat"); }); break; // envia comando TCP direto // exemplos no site quakenet => https://www.quakenet.org/help/q-commands case "CMD": Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate { _output.Write(s.Replace("/CMD", string.Empty) + "\r\n"); _output.Flush(); }); break; // Debug Show and Hide case "DEBUGON": Showconsole.ShowConsole(); break; case "DEBUGOFF": Showconsole.ShowConsole(false); break; } return; } _output.Write("PRIVMSG " + Configuration.StConfiguration.Channel + " : " + s + "\r\n"); _output.Flush(); MyDelegates.OnChatCallBack(@"system :", s); } catch (Exception ex) { MyDelegates.OnDebugMessageCallBack(ex.StackTrace); } }
/// <summary> /// thread creat for IRC service /// </summary> internal void ThreadIrc() { try { _sock = new TcpClient(); _sock.Connect(Configuration.StConfiguration.Server, Configuration.StConfiguration.Port); if (!_sock.Connected) { MyDelegates.OnDebugMessageCallBack(@"failed to connect " + Environment.NewLine + @"internal void ThreadIrc()"); } _input = new StreamReader(_sock.GetStream()); _output = new StreamWriter(_sock.GetStream()); _output.Write( "USER " + Configuration.StConfiguration.Nick + " 0 * :" + Configuration.StConfiguration.Owner + "\r\n" + "NICK " + Configuration.StConfiguration.Owner + "\r\n"); _output.Flush(); // check auth ssl if (Configuration.StConfiguration.AuthSsl.ToString() == @"true") { // auth enabled LoginSsl(Configuration.StConfiguration.Nick, Configuration.StConfiguration.Password); MyDelegates.OnCallStatus(Resources.MergedDictionaries[0]["AuthSslEnabled"].ToString()); } else { // auth disabled Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate { MyDelegates.OnCallStatus(Resources.MergedDictionaries[0]["AuthSslDisabled"].ToString()); }); } for (Buff = _input.ReadLine();; Buff = _input.ReadLine()) { if (Buff == null) { return; } MyDelegates.OnCallBackOut(Buff); // send pong reply to any ping messages if (Buff != null && Buff.StartsWith("PING")) { _output.Write(Buff.Replace("PING", "PONG") + "\r\n"); _output.Flush(); } if (Buff != null && Buff[0] != ':') { continue; } if (Buff != null && Buff.Split(' ')[1] == "001") { _output.Write("MODE " + Configuration.StConfiguration.Nick + "+o \r\n" + "JOIN " + Configuration.StConfiguration.Channel + "\r\n"); _output.Flush(); } } } catch (Exception ex) { if (ex.HResult != -2146233040) { MyDelegates.OnDebugMessageCallBack(ex.StackTrace); } } }