Esempio n. 1
0
        void tSBShow_Click(object sender, EventArgs e)
        {
            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 /*icon != null ? icon.Handle : IntPtr.Zero*/);
            this.mainFormHost.Closed += Wrap(mainFormHost_Closed);
            formSync.Reset();

            commandPanel.ShowVisible = false;
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        public ICIRCeItem AddItem(ICIRCeItem parent, IntPtr handle, string title, IntPtr hIcon)
        {
            if (this.parent.InvokeRequired)
            {
                return((ICIRCeItem)this.parent.EndInvoke(this.parent.BeginInvoke(new Func <ICIRCeItem, IntPtr, string, IntPtr, ICIRCeItem>(AddItem), parent, handle, title, hIcon)));
            }

            var parentItem = parent as CIRCeItem;

            if (parentItem == null)
            {
                return(null);
            }

            IRCProviders.Win32.RECT rect;
            IRCProviders.Win32.GetWindowRect(handle, out rect);

            var icon = hIcon != IntPtr.Zero ? Icon.FromHandle(hIcon) : null;

            var hostForm = new IRCProviders.IRCForm {
                Icon = icon, Text = title, Width = rect.right - rect.left, Height = rect.bottom - rect.top + 2
            };

            var hostPanel = new HwndHost {
                Dock = System.Windows.Forms.DockStyle.Fill
            };

            hostPanel.Child = handle;

            hostForm.Controls.Add(hostPanel);

            this.parent.RegisterAsMDIChild(parentItem.Form, hostForm, null);

            if (icon != null)
            {
                IRCProviders.Win32.DestroyIcon(icon.Handle);
            }

            return(new CIRCeItem(hostForm));
        }
Esempio n. 4
0
        /// <summary>
        /// Закрыть аддон
        /// </summary>
        public override void Dispose()
        {
            var invokeNeeded = this.commandPanel != null && this.commandPanel.InvokeRequired;

            if (invokeNeeded)
            {
                this.commandPanel.EndInvoke(this.commandPanel.BeginInvoke(new Action(Dispose)));
                return;
            }

            try
            {
                lock (this.sync)
                {
                    this.isDisposed = true;

                    if (this.startUpForm != null && this.startUpForm.PackageDoc != null)
                    {
                        this.startUpForm.PackageDoc.Dispose();
                    }

                    ClearTempFile();

                    if (mainFormHost != null)
                    {
                        this.mainFormHost.Close();
                    }

                    if (gameConfig != null)
                    {
                        gameConfig.Save();
                    }

                    if (this.application != null)
                    {
                        this.application.Status("");
                    }

                    if (this.channel != null)
                    {
                        this.channel.Closed -= Wrap(Stop);
                        var commands = this.channel.UsersList.Commands;
                        if (commands != null && this.tSMISI != null)
                        {
                            commands.Remove(this.separator);
                            commands.Remove(this.tSMISI);
                            commands.Remove(this.tSMISIAnswer);
                            commands.Remove(this.tSMISICall);
                            if (this.tSMISIChooser != null)
                            {
                                commands.Remove(this.tSMISIChooser);
                            }
                        }
                    }

                    if (this.commandPanel != null)
                    {
                        this.channel.ChatPanel.RemoveBottom(commandPanel.Handle);
                    }

                    if (mainFormHost != null)
                    {
                        formSync.WaitOne();
                        mainFormHost = null;
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }
        }