示例#1
0
 internal IrcUser(string nickname, IrcClient ircclient)
 {
     _IrcClient = ircclient;
     _Nick      = nickname;
 }
示例#2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Extend Aero glass into client area
            this.TryExtendAeroGlass();

            #region Hide
            // Irc setup
            this.irc = new IrcClient();
            this.irc.AutoNickHandling = true;
            this.irc.OnChannelAction += new ActionEventHandler(irc_OnChannelAction);
            this.irc.OnChannelMessage += new IrcEventHandler(irc_OnChannelMessage);
            this.irc.OnConnected += new EventHandler(irc_OnConnected);
            this.irc.OnConnecting += new EventHandler(irc_OnConnecting);
            this.irc.OnJoin += new JoinEventHandler(irc_OnJoin);
            this.irc.OnMotd += new MotdEventHandler(irc_OnMotd);
            this.irc.OnNames += new NamesEventHandler(irc_OnNames);
            this.irc.OnNickChange += new NickChangeEventHandler(irc_OnNickChange);
            this.irc.OnPart += new PartEventHandler(irc_OnPart);
            this.irc.OnQuit += new QuitEventHandler(irc_OnQuit);
            this.irc.OnReadLine += new ReadLineEventHandler(irc_OnReadLine);
            this.irc.OnTopic += new TopicEventHandler(irc_OnTopic);
            this.irc.OnWriteLine += new WriteLineEventHandler(irc_OnWriteLine);

            ThreadPool.QueueUserWorkItem(state =>
            {
                try { this.irc.Connect(Cfg.Default.IrcServer, Int32.Parse(Res.IrcPort)); }
                catch { this.AddChatMsg("# Connection failed :("); }
            });

            // Setup some controls
            MainWindow.TextChangedInt32Filter = new TextChangedEventHandler((_s, _e) =>
            {
                #region Allow only numbers
                TextBox textBox = _s as TextBox;
                Int32 selectionStart = textBox.SelectionStart;
                Int32 selectionLength = textBox.SelectionLength;
                String newText = String.Empty;
                Boolean check = false;

                foreach (Char c in textBox.Text.ToCharArray())
                {
                    if (Char.IsDigit(c) || Char.IsControl(c)) newText += c;
                    else check = true;
                }

                textBox.Text = newText;
                textBox.SelectionStart = selectionStart <= textBox.Text.Length ?
                    selectionStart : textBox.Text.Length;

                if (check) System.Media.SystemSounds.Beep.Play();
                #endregion
            });

            this.gridForumTypesHolder.Height = double.NaN;
            this.txtTopicSectionId.TextChanged += MainWindow.TextChangedInt32Filter;
            this.txtTopicIconId.TextChanged += MainWindow.TextChangedInt32Filter;
            this.txtPauseCfg.TextChanged += MainWindow.TextChangedInt32Filter;
            this.txtTimeoutCfg.TextChanged += MainWindow.TextChangedInt32Filter;
            this.txtStartPageCfg.TextChanged += MainWindow.TextChangedInt32Filter;

            // Setup special events
            this.SetupDateScenarios();

            // Close splash and show window
            if (Cfg.Default.EnableSplash)
            {
                splash.Close(new TimeSpan(0, 0, 1));
                this.Show();
            }

            Cfg.Default.IsFirstRun = false;
            Cfg.Default.Save();

            // Misc stuff
            this.lstForumType.ScrollIntoView(this.lstForumType.SelectedItem);
            #endregion

            // Leech client setup
            this.leechClient.Error += new Engine.ErrorEventHandler(leechClient_Error);
            this.leechClient.TopicRead += new TopicReadEventHandler(leechClient_TopicRead);
            this.leechClient.Started += new EventHandler(leechClient_Started);
            this.leechClient.Stopped += new EventHandler(leechClient_Stopped);

            // Clean up before we start
            GC.Collect();
        }