ActorForm.cs
Description du code
ActorForm.cs est un fichier du projet BiblioBrol.Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/src/.
Projet BiblioBrol :
Gestion de media en CSharp.
Pour plus d'infos, vous pouvez consulter la brève analyse.
Code source ou contenu du fichier
Code c# (ActorForm.cs) (267 lignes)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using be.gaudry.bibliobrol.model; using be.gaudry.view; using be.gaudry.bibliobrol.view.utils; using be.gaudry.bibliobrol.view.dialogs; using be.gaudry.events; using be.gaudry.bibliobrol.model.identity; using be.gaudry.bibliobrol.config; using be.gaudry.model.enums; using be.gaudry.bibliobrol.model.enums; namespace be.gaudry.bibliobrol.view { public partial class ActorForm : MDIChildForm, IMDIChild { #region declarations and constructor private const String ALL_ROLES = " -Toutes les personnes- "; private const String NO_ROLE = " -Personnes sans rôle- "; private ActorRole[] roles; //private bool pictureModified; //private DataGridViewCellStyle deletedStyle, addedStyle; public ActorForm() { roles = ModelAdapter.getRoles().ToArray(); //pictureModified = false; InitializeComponent(); this.SuspendLayout(); addToolStrip(personsTS); initCB(); /* deletedStyle = new DataGridViewCellStyle(); deletedStyle.ForeColor = Color.White; deletedStyle.BackColor = Color.Crimson; addedStyle = new DataGridViewCellStyle(); addedStyle.ForeColor = Color.White; addedStyle.BackColor = Color.DarkGreen; * */ this.ResumeLayout(false); } #endregion private void initCB() { personsByRoleTSCB.Items.AddRange(roles); personsByRoleTSCB.SelectedIndex = 0; selectPersonsTSCB.Items.AddRange(roles); selectPersonsTSCB.SelectedIndex = 0; personDisplayTSCB.ComboBox.DisplayMember = "Value"; personDisplayTSCB.ComboBox.ValueMember = "Key"; personDisplayTSCB.ComboBox.SelectedItem = Config.PersonDisplay; } /// <summary> /// Load persons display list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onPersonsRoleIndexChanged(object sender, EventArgs e) { ToolStripComboBox tscb = (ToolStripComboBox)sender; if (tscb.SelectedIndex > 0)//0 = filter (ie : selection by name) { ActorRole role; try { role = (ActorRole)tscb.SelectedItem; } fillPersonsListBox(role); } } private void fillPersonsListBox(ActorRole role) { selectPersonsTSCB.SelectedItem = role; personsByRoleTSCB.SelectedItem = role; persListBox.Items.Clear(); switch (role.Name) { case ALL_ROLES: persListBox.Items.AddRange(ModelAdapter.getPersonsVos().ToArray()); break; case NO_ROLE: MessageBox.Show("Option non implémentée"); break; default: persListBox.Items.AddRange(ModelAdapter.getPersonsVos(role).ToArray()); break; } //personEditCtl.clearForm(); } private void fillPersonsListBox(string name) { selectPersonsTSCB.SelectedIndex = 0; personsByRoleTSCB.SelectedIndex = 0; persListBox.Items.Clear(); string searchTxt = name.Replace('*', '%'); persListBox.Items.AddRange(ModelAdapter.getPersonsVos(searchTxt).ToArray()); if (persListBox.Items.Count < 1) { MessageBox.Show( this, String.Format("Aucune personne trouvée correspondant à {0}.", name), "Recherche de personnes", MessageBoxButtons.OK, MessageBoxIcon.Information ); } } /// <summary> /// Load person infos for selected person /// </summary> /// <param name="sender">Button component</param> /// <param name="e">EventArgs</param> private void onPersonsSelectedIndexChanged(object sender, EventArgs e) { fillPersonFormFromListBox(); } private void fillPersonFormFromListBox() { PersonLO pers = persListBox.SelectedItem as PersonLO; if (pers != null) { enableEditForm(ModelAdapter.getPerson(pers.Id, true)); } else { enableEditForm(null); } } private void enableEditForm(Person person) { if (person != null) { personEditCtl.setPerson(person); personEditCtl.Visible = true; eidTsB.Enabled = true; persImgTSB.Enabled = true; persDelTsMic.Enabled = true; persDelBtn.Enabled = true; } else { personEditCtl.Visible = false; eidTsB.Enabled = false; persImgTSB.Enabled = false; persDelTsMic.Enabled = false; persDelBtn.Enabled = false; } } private void onAddPerson_Click(object sender, EventArgs e) { } private void onDeletePerson_Click(object sender, EventArgs e) { Person person = personEditCtl.getPerson(); if (person != null) { DialogResult r = MessageBox.Show( this, String.Format("Confirmez-vous la suppression de la personne {0} {1} ?", person.LastName, person.FirstName ), "Suppression de la personne", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 ); if (r == DialogResult.Yes) { ModelAdapter.deletePerson(person); System.IO.File.Delete(Img.getPersImgPath(person)); fillPersonsListBox((ActorRole)selectPersonsTSCB.SelectedItem); personEditCtl.clearForm(); } } } private void ActorForm_FormClosing(object sender, FormClosingEventArgs e) { try { personEditCtl.unlockPersonIfAllowed(); } catch { }//we may have null pointer exception if no person was selected } private void personDisplayTSCB_Click(object sender, EventArgs e) { Config.PersonDisplay = (PERSON_DISPLAY)EnumHelper.getEnum(personDisplayTSCB.ComboBox.SelectedItem); ; //no need to save person display onPersonsRoleIndexChanged(selectPersonsTSCB, e); } private void searchPersonTsTB_KeyUp(object sender, KeyEventArgs e) { bool enabled = searchPersonTsTB.Text != string.Empty; searchPersonTsBtn.Enabled = enabled; if (enabled && e.KeyCode == Keys.Enter) { fillPersonsListBox(searchPersonTsTB.Text); } } private void searchPersonTsBtn_Click(object sender, EventArgs e) { fillPersonsListBox(searchPersonTsTB.Text); } #region save person private void onPersSave_Click(object sender, EventArgs e) { personEditCtl.onPersonSave_Click(sender, e); } private void onPersonEditCtlEnableSave(bool enabled) { persSaveTSB.Enabled = enabled; savePersTsMi.Enabled = enabled; } #endregion private void eidTsB_Click(object sender, EventArgs e) { personEditCtl.onOpenUserForm_Click(sender, e); } private void persImgTSB_Click(object sender, EventArgs e) { personEditCtl.onModifyImage_Click(sender, e); } #region IMDIChild Members public MenuStrip getMainMenuStrip() { return mainMenuStrip; } #endregion } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1732486758 24/11/2024 23:19:18 |
| _ | wizards | 0 octets | 1541007184 31/10/2018 18:33:04 |
| _ | utils | 0 octets | 1541007184 31/10/2018 18:33:04 |
| _ | controls | 0 octets | 1541007178 31/10/2018 18:32:58 |
| _ | dialogs | 0 octets | 1541007183 31/10/2018 18:33:03 |
Utilisation de l'explorateur de code
- Navigation :
- Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
- Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
- La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
- Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
- Affichage :
- Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
- Actions :
- Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-bibliobrol-source-rf-view//ActorForm.cs.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.