Example #1
0
        /// <summary>
        /// Здесь запускается аддон
        /// </summary>
        /// <param name="mainWindow">Главное окно Цирцеи</param>
        public override void Run(IMainWindow mainWindow)
        {
            this.mainWindow = mainWindow;
            this.data       = Data.Load();

            IBaseWindow activeWindow = mainWindow.ActiveIRCWindow;

            if (activeWindow is IServerWindow)
            {
                IServerWindow server = activeWindow as IServerWindow;
                this.data.Info.Server.Name = server.Server.Name;
                this.data.Info.Nick        = new NickName(server.Nick);
            }
            else if (activeWindow is IChannelWindow)
            {
                IChannelWindow channelWindow2 = activeWindow as IChannelWindow;
                this.data.Info.Server.Name = channelWindow2.OwnerServerWindow.Server.Name;
                this.data.Info.Nick        = new NickName(channelWindow2.OwnerServerWindow.Nick);
                this.data.Channel          = channelWindow2.WindowName;
            }
            else if (activeWindow is IPrivateWindow)
            {
                IPrivateWindow privateWindow = activeWindow as IPrivateWindow;
                this.data.Info.Server.Name = privateWindow.OwnerServerWindow.Server.Name;
                this.data.Info.Nick        = new NickName(privateWindow.OwnerServerWindow.Nick);
            }
            else
            {
                this.data.Info.Nick = new NickName(mainWindow.DefaultNick);
            }

            this.connectionForm = (ConnectionForm)this.mainWindow.CreateObject(AppDomain.CurrentDomain, typeof(ConnectionForm), this.data);

            if (this.connectionForm == null)
            {
                ManualClose();
                return;
            }

            if (this.mainWindow.ShowDialog(connectionForm) == DialogResult.OK)
            {
                this.data                   = this.connectionForm.Data;
                this.serverWindow           = mainWindow.OpenConnection(this.data.Info);
                this.serverWindow.Disposed += (sender, e) => ManualClose();
                if (this.serverWindow.IsConnected)
                {
                    this.mainWindow.RunCallback(new Special.Action(Futher));
                }
                else
                {
                    this.serverWindow.OnConnected += new EventHandler(serverWindow_OnConnected);
                    this.serverWindow.Connect();
                }
            }
            else
            {
                ManualClose();
            }
        }
Example #2
0
        private void Futher2()
        {
            channelWindow = (IChannelWindow)serverWindow[this.data.Channel];
            if (channelWindow == null)
            {
                ManualClose();
                return;
            }

            Init();

            this.channelWindow.Disposed += (sender, e) => this.ManualClose();
        }