Exemple #1
0
        /// <summary>
        /// Запустить аддон
        /// </summary>
        /// <param name="application">Запускающее приложение</param>
        public override void Run(ICIRCeApplication application)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            this.application = application;
            this.gameConfig  = GameConfiguration.Load();

            var activeItem   = this.application.ActiveItem;
            var activeServer = activeItem as IServer;

            if (activeServer != null)
            {
                gameConfig.DefServerName = activeServer.Info.Server.Name;
                gameConfig.DefUserName   = activeServer.Info.Nick;
            }
            else
            {
                var activeChannel = activeItem as IChannel;

                if (activeChannel != null)
                {
                    gameConfig.DefServerName  = activeChannel.OwnerServer.Info.Server.Name;
                    gameConfig.DefChannelName = activeChannel.Name;
                    gameConfig.DefUserName    = activeChannel.OwnerServer.Info.Nick;
                }
                else
                {
                    var activePrivate = activeItem as IPrivateSession;

                    if (activePrivate != null)
                    {
                        gameConfig.DefServerName = activePrivate.OwnerServer.Info.Server.Name;
                        gameConfig.DefUserName   = activePrivate.OwnerServer.Info.Nick;
                    }
                    else
                    {
                        var nick = this.application.DefaultNickName;
                        if (nick != null)
                        {
                            gameConfig.DefUserName = nick;
                        }
                    }
                }
            }

            this.startUpForm = new StartUpForm(this.gameConfig);
            this.application.AddOwnedWindow(this.startUpForm.Handle);

            NewGame();
        }
Exemple #2
0
 /// <summary>
 /// Запустить аддон
 /// </summary>
 /// <param name="application">Вызывающее приложение</param>
 public abstract void Run(ICIRCeApplication application);
Exemple #3
0
        /// <summary>
        /// Здесь запускается дополнение
        /// </summary>
        /// <param name="application">Ссылка на Цирцею</param>
        public override void Run(ICIRCeApplication application)
        {
            this.application = application;
            this.data        = Data.Load();

            var activeItem = application.ActiveItem;

            if (activeItem is ICIRCeServer)
            {
                var server = activeItem as ICIRCeServer;
                this.data.Info.Server.Name = server.Info.Server.Name;
                this.data.Info.Nick        = server.Info.Nick;
            }
            else if (activeItem is ICIRCeChannel)
            {
                var channel = activeItem as ICIRCeChannel;
                this.data.Info.Server.Name = channel.OwnerServer.Info.Server.Name;
                this.data.Info.Nick        = channel.OwnerServer.Info.Nick;
                this.data.Channel          = channel.Name;
            }
            else if (activeItem is ICIRCePrivateSession)
            {
                var privateSession = activeItem as ICIRCePrivateSession;
                this.data.Info.Server.Name = privateSession.OwnerServer.Info.Server.Name;
                this.data.Info.Nick        = privateSession.OwnerServer.Info.Nick;
            }
            else
            {
                this.data.Info.Nick = application.DefaultNickName;
            }

            this.connectionForm = new ConnectionForm(this.data);
            this.application.AddOwnedWindow(this.connectionForm.Handle);

            if (this.connectionForm.ShowDialog() == DialogResult.OK)
            {
                this.data   = this.connectionForm.Data;
                this.server = application.CreateConnection(this.data.Info);

                if (!this.server.IsConnected && !this.server.Connect())
                {
                    Stop();
                    return;
                }

                this.channel = this.server.JoinChannel(this.data.Channel);

                if (channel == null)
                {
                    Stop();
                    return;
                }

                this.channel.Closed += Wrap(Stop);

                Init();
            }
            else
            {
                Stop();
            }
        }