/// Suppression d'une BrainStorm, mise à jour de la liste. /// <param name="sender">BrainStormControler.</param> /// <param name="e">Suppression d'une BrainStorm.</param> void controler_BrainStormRemoved(object sender, BrainStormControler.BrainStormRemovedArgs e) { BrainStorm brainStorm = (BrainStorm)listView.Items[e.BrainStormId.ToString()].Tag; brainStorm.StatusChanged -= statusChangedEventHandler; listView.Items.RemoveByKey(e.BrainStormId.ToString()); }
/// Construction d'une vue pour une BrainStorm. /// <param name="model">BrainStorm à représenter.</param> public BrainStormView(BrainStorm model, int type) { typeView = type; isTitleEdited = false; isDetailsEdited = false; modelId = model.Id; InitializeComponent(); // Mise à jour de la vue à partir de la BrainStorm. UpdateView(model); // Abonnement aux évènements de la BrainStorm. statusChangedEventHandler = new BrainStorm.StatusChangedEventHandler(model_StatusChanged); showedEventHandler = new BrainStorm.ShowedEventHandler(model_Showed); hidedEventHandler = new BrainStorm.HidedEventHandler(model_Hided); model.StatusChanged += statusChangedEventHandler; model.Showed += showedEventHandler; model.Hided += hidedEventHandler; // Obtention d'une référence vers le controler de BrainStorms. controler = BrainStormControler.Instance; // Création du fond transparent SetTransparentBackgroundImage(); detailsTextBox.LostFocus += new EventHandler(detailsTextBox_LostFocus); detailsLabel.MouseEnter += new EventHandler(label_MouseEnter); detailsLabel.MouseLeave += new EventHandler(label_MouseLeave); titleTextBox.LostFocus += new EventHandler(titleTextBox_LostFocus); titleLabel.MouseEnter += new EventHandler(label_MouseEnter); titleLabel.MouseLeave += new EventHandler(label_MouseLeave); }
/// On détache la vue de la BrainStorm. /// <param name="model">BrainStorm représentée.</param> public void Detach(BrainStorm model) { // On retire les "event handlers" model.Hided -= hidedEventHandler; model.Showed -= showedEventHandler; model.StatusChanged -= statusChangedEventHandler; }
/// Modification d'une BrainStorm, on met à jour son item dans la liste. /// <param name="source">BrainStorm.</param> void BrainStorm_StatusChanged(object source) { BrainStorm brainStorm = (BrainStorm)source; ListViewItem item = listView.Items[brainStorm.Id.ToString()]; item.Text = brainStorm.Title; item.Tag = brainStorm; }
/// Désabonnement des évènements des BrainStorms. private void UnregisterFromBrainStormEvents() { foreach (ListViewItem item in listView.Items) { BrainStorm brainStorm = (BrainStorm)item.Tag; brainStorm.StatusChanged -= statusChangedEventHandler; } }
/// Mise à jour de la vue en fonction des propriétés de la BrainStorm. /// <param name="model">BrainStorm à représenter.</param> private void UpdateView(BrainStorm model) { Location = model.Location; Name = string.Format("{0}_{1}", model.Title, model.Id); titleLabel.Text = model.Title; titleLabel.Left = (Width - titleLabel.Width) / 2; toolTip.SetToolTip(titleLabel, titleLabel.Text); detailsLabel.Text = model.Details; toolTip.SetToolTip(detailsLabel, detailsLabel.Text); TopMost = model.Pinned; pinToolStripMenuItem.Checked = model.Pinned; }
/// Ajoute la BrainStorm à la liste. /// <param name="brainStorm">BrainStorm à ajouter.</param> private void AddBrainStorm(BrainStorm brainStorm) { ListViewItem item = new ListViewItem(); item.Text = brainStorm.Title; item.Tag = brainStorm; item.Name = brainStorm.Id.ToString(); item.ImageIndex = 0; listView.Items.Add(item); // On s'abonne aux évènements de la BrainStorm. brainStorm.StatusChanged += statusChangedEventHandler; brainStorm.Show(); }
/// Sélection d'une ou plusieurs BrainStorms. /// <param name="sender">ListView.</param> /// <param name="e">Changement de sélection.</param> private void listView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { foreach (ListViewItem item in listView.SelectedItems) { // On affiche au premier plan les BrainStorms sélectionnées. BrainStorm brainStorm = (BrainStorm)item.Tag; brainStorm.Show(); Focus(); } if (listView.SelectedItems.Count == 0) { deletedToolStripMenuItem.Enabled = false; } else { deletedToolStripMenuItem.Enabled = true; } }
public void RunWorkOut(WorkoutNames name) { currentWorkout = name; questsPassedCount = 0; questMaxCount = 10; if (name == WorkoutNames.brainStorm) { questMaxCount = 5; core = PrepareWorkout(WorkoutNames.brainStorm); brainStorm = new BrainStorm(core, levelManeger); return; } string sceneName = GetSceneName(name); if (sceneName != string.Empty) { levelManeger.LoadLevel(sceneName); } }