private void Futher(bool first = true) { this.channel = this.server.JoinChannel(gameConfig.DefChannelName); if (this.channel == null) { Stop(); return; } this.channel.Closed += Wrap(Stop); lock (this.sync) { if (this.isDisposed) { return; } this.commandPanel = new CommandPanel(); commandPanel.Dock = DockStyle.Bottom; commandPanel.End += tSBEnd_Click; commandPanel.ShowMain += tSBShow_Click; commandPanel.NewGame += tSMINewGame_Click; this.channel.Activate(); this.channel.ChatPanel.AddBottom(commandPanel.Handle); gameConfig.CurrentStage = GameConfiguration.SIStage.Begin; gameConfig.RoundNum = gameConfig.ThemeNum = gameConfig.QuestNum = 0; this.mainForm = new MainForm(gameConfig, startUpForm.PackageDoc, this.application, this.server, this.channel, commandPanel, this); this.mainFormHost = this.application.AddItem(this.channel, mainForm.Handle, "SIGame", Resources.logo.Handle); this.mainFormHost.Closed += Wrap(mainFormHost_Closed); formSync.Reset(); var commands = this.channel.UsersList.Commands; this.separator = commands.AddSeparator(); this.tSMISI = commands.AddCommand("Добавить в список игроков", Wrap <IEnumerable <ChannelUserInfo> >(AddPerson)); this.tSMISIAnswer = commands.AddCommand("Назначить отвечающим", Wrap <IEnumerable <ChannelUserInfo> >(SetAnswerer)); if (gameConfig.GameType == GameConfiguration.GameTypes.TeleSI) { this.tSMISIChooser = commands.AddCommand("Назначить выбирающим", Wrap <IEnumerable <ChannelUserInfo> >(SetChooser)); } this.tSMISICall = commands.AddCommand("Обратиться", Wrap <IEnumerable <ChannelUserInfo> >(Call)); } if (first) { Application.Run(); } }
/// <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(); } }