示例#1
0
        /// <summary>
        /// Constructeur paramétré.
        /// </summary>
        /// <param name="game">Instance de la classe de jeu gérant la partie.</param>
        public ClavierService(Game game)
            : base(game)
        {
            // Initialise les tableaux des heures de dernière pression et d'état des touches
            this.heureDernierePression = new DateTime[this.NombreMaxTouches];
            this.etatPrecedent         = new bool[this.NombreMaxTouches];
            for (int key = 0; key < this.NombreMaxTouches; key++)
            {
                this.heureDernierePression[key] = new DateTime(0);
                this.etatPrecedent[key]         = false;
            }

            ServiceHelper.Add <IInputService>(this);
        }
示例#2
0
        /// <summary>
        /// Initialise l'instance de la classe ManetteService.
        /// </summary>
        /// <param name="game">Instance de Game responsable du gestionnaire de services.</param>
        private void Initialize(Game game)
        {
            // Créer les attributs vecteurs.
            for (int device = 1; device <= this.NombreMaxManettes; device++)
            {
                this.etatManette[device - 1] = GamePad.GetState(this.GetPlayerIndex(device));

                // Initialiser les tableaux d'état des boutons.
                for (int bouton = 0; bouton < this.NombreMaxBoutons; bouton++)
                {
                    this.heureDernierePression[device - 1, bouton] = new DateTime(0);
                    this.etatPrecedent[device - 1, bouton]         = false;
                }
            }

            ServiceHelper.Add <IInputService>(this);     // activer le service
        }
        private void button1_Click(object sender, EventArgs e)
        {
            panelWait.Visible = true;
            button1.Enabled   = false;
            button2.Enabled   = false;

            var insertWorker = new BackgroundWorker();

            short index = 0;

            //fix index
            foreach (MailTemplate tmpl in m_bindingList)
            {
                index++;
                tmpl.TemplateIndex = index;
            }

            insertWorker.RunWorkerCompleted += (senders, es) =>
            {
                CrossThreadUtility.InvokeControlAction <Panel>(panelWait, panel => panel.Visible = false);
            };

            insertWorker.DoWork += (senders, es) =>
            {
                try
                {
                    if (!es.Cancel)
                    {
                        ServiceHelper.Add(listBox1.DataSource as IEnumerable <MailTemplate>);

                        CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());

                        //add new template
                        m_mainRegion.MailTemplates = new List <MailTemplate>(listBox1.DataSource as IEnumerable <MailTemplate>);
                    }
                }
                finally
                {
                }
            };

            insertWorker.RunWorkerAsync();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool blValidTitle = ValidateTitle();

            if (!blValidTitle)
            {
                return;
            }

            panelWait.Visible = true;
            button1.Enabled   = false;

            this.m_position.PositionAreas = GetNodesPath(tvAreas.Nodes, null);

            //exists
            if (!m_position.IsNew)
            {
                var saveWorker = new BackgroundWorker();

                saveWorker.RunWorkerCompleted += (senders, es) =>
                {
                    CrossThreadUtility.InvokeControlAction <MainRegion>(m_region, m => m.Positions.Add(m_position));

                    CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
                };

                saveWorker.DoWork += (senders, es) =>
                {
                    try
                    {
                        if (!es.Cancel)
                        {
                            ServiceHelper.Update(m_position);
                        }
                    }
                    finally
                    {
                    }
                };

                saveWorker.RunWorkerAsync();
            }
            else
            {
                //new

                var saveWorker = new BackgroundWorker();

                saveWorker.RunWorkerCompleted += (senders, es) =>
                {
                    if (es.Error != null)
                    {
                        if (es.Error is LicenseException)
                        {
                            CrossThreadUtility.InvokeControlAction <Form>(this, f =>
                            {
                                MessageBox.Show(this, "Sorry, but this license type does not allow more entities of those types", "HunterCV", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                f.Close();
                            });
                        }
                    }
                    else
                    {
                        m_position.IsNew = false;

                        CrossThreadUtility.InvokeControlAction <MainRegion>(m_region, m => m.Positions.Add(m_position));

                        Form form = MainRegion.GetForm(typeof(PositionsForm));

                        if (form is PositionsForm)
                        {
                            CrossThreadUtility.InvokeControlAction <PositionsForm>(((PositionsForm)form), f => f.DoSearch(-1));
                        }


                        CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
                    }
                };



                saveWorker.DoWork += (senders, es) =>
                {
                    try
                    {
                        if (!es.Cancel)
                        {
                            ServiceHelper.Add(m_position);
                        }
                    }
                    finally
                    {
                    }
                };

                saveWorker.RunWorkerAsync();
            }
        }