Beispiel #1
0
        public Chat()
        {
            Options = new ChatOptions();

            Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(UnhandledException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomainUnhandledException);

            MainOutputWindow = new ChannelWindow(this);
            MainOutputWindow.UserInput += ParseUserInput;
            MainOutputWindow.Closed += new EventHandler(channelWindow_Closed);
            MainOutputWindow.IsMainWindow = true;
            MainOutputWindow.Show();

            LoadConfigurationFile();

            bool proceed = true;
            if (Options.FirstChannel == null || Options.InitialNickname == null || Options.Server == null)
            {
                if (Options.FirstChannel == null) Options.FirstChannel = FIRST_CHANNEL;
                if (Options.FirstChannelKey == null) Options.FirstChannelKey = FIRST_CHANNEL_KEY;
                if (Options.InitialNickname == null) Options.InitialNickname = Environment.UserName;
                if (Options.Server == null) Options.Server = SERVER_ADDRESS;
                if (Options.ServerPort == 0) Options.ServerPort = SERVER_PORT;

                proceed = ShowConnectionWindow(MainOutputWindow);
            }

            if (proceed)
            {
                SaveConfigurationFile();

                IRC.ActiveChannelSyncing = true;
                IRC.AutoNickHandling = true;
                IRC.SupportNonRfc = true;
                IRC.Encoding = System.Text.Encoding.UTF8;
                IRC.OnConnected += new EventHandler(IRC_OnConnected);
                IRC.OnQueryAction += new ActionEventHandler(IRC_OnQueryAction);
                IRC.OnQueryMessage += new IrcEventHandler(IRC_OnQueryMessage);
                IRC.OnQueryNotice += new IrcEventHandler(IRC_OnQueryNotice);
                IRC.OnNickChange += new NickChangeEventHandler(IRC_OnNickChange);
                IRC.OnJoin += new JoinEventHandler(IRC_OnJoin);
            #if DEBUG
                IRC.OnRawMessage += new IrcEventHandler(IRC_OnRawMessage);
                IRC.OnWriteLine += new WriteLineEventHandler(IRC_OnWriteLine);
            #endif
                MainOutputWindow.Channel = Options.FirstChannel;
                MainOutputWindow.ChannelKey = Options.FirstChannelKey;

                channelWindows.Add(MainOutputWindow);

                LoadScripts();

                IRC.Connect(Options.Server, Options.ServerPort);
            }
        }
Beispiel #2
0
        private bool ShowConnectionWindow(ChannelWindow FirstWindow)
        {
            ConnectionWindow connWin = new ConnectionWindow(this);
            connWin.Owner = FirstWindow;
            if (connWin.ShowDialog().Value)
            {
                Options.FirstChannel = connWin.Channel;
                Options.InitialNickname = connWin.Nickname;
                Options.Server = connWin.Server;
                Options.FirstChannelKey = connWin.ChannelKey;
            }
            else
            {
                Application.Current.Shutdown();
            }

            return connWin.DialogResult.Value;
        }
Beispiel #3
0
        void IRC_OnJoin(object sender, JoinEventArgs e)
        {
            // this is how we know the server has successfully joined us to a channel
            if (e.Who == IRC.Nickname
                && !channelWindows.Any<ChannelWindow>(delegate(ChannelWindow chan)
                { if (chan.Channel == e.Channel) return true; else return false; }))
            {
                Application.Current.Dispatcher.Invoke(new VoidDelegate(delegate
                {
                    ChannelWindow newWindow = new ChannelWindow(this);
                    newWindow.Channel = e.Channel;
                    newWindow.UserInput += ParseUserInput;

                    newWindow.Closed += channelWindow_Closed;
                    channelWindows.Add(newWindow);
                    newWindow.Show();
                }));
            }
        }