Beispiel #1
0
        /// <summary>
        /// Handler pour l'appui d'une touche sur la listview.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ListView_KeyDown(object sender, KeyEventArgs e)
        {
            if (PathToSave != null)
            {
                ListViewController Controller = new ListViewController(this.listView1, PathToSave);

                switch (e.KeyCode)
                {
                case Keys.F5:
                    Controller.LoadListView(treeView1.SelectedNode);
                    break;

                case Keys.Delete:
                    if (this.listView1.SelectedItems.Count > 0)
                    {
                        Controller.DeleteSelectedItem(this.treeView1.SelectedNode, this);
                        InitializeTreeView TreeConstruct = new InitializeTreeView(this.treeView1);
                        TreeConstruct.ConstructTree(PathToSave);
                    }
                    break;

                case Keys.Return:
                    Console.WriteLine("Entree");
                    if (this.listView1.SelectedItems.Count > 0)
                    {
                        switch (this.listView1.SelectedItems[0].Tag)
                        {
                        case Articles a:
                            ModifierArticle ModifierA = new ModifierArticle(this, PathToSave);
                            ModifierA.StartPosition = FormStartPosition.CenterParent;
                            ModifierA.ShowDialog(this);
                            break;

                        case Familles f:
                            ModifierFamille ModifierF = new ModifierFamille(this, PathToSave);
                            ModifierF.StartPosition = FormStartPosition.CenterParent;
                            ModifierF.ShowDialog(this);
                            break;

                        case SousFamilles sf:
                            ModifierSousFamille ModifierSf = new ModifierSousFamille(this, PathToSave);
                            ModifierSf.StartPosition = FormStartPosition.CenterParent;
                            ModifierSf.ShowDialog(this);
                            break;

                        case Marques m:
                            ModifierMarque ModifierM = new ModifierMarque(this, PathToSave);
                            ModifierM.StartPosition = FormStartPosition.CenterParent;
                            ModifierM.ShowDialog(this);
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handler pour un click dans le menu contextuel.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            ListViewController Controller = new ListViewController(this.listView1, PathToSave);

            switch (e.ClickedItem.Text)
            {
            case "Ajouter":
                if (this.listView1.SelectedItems.Count > 0)
                {
                    switch (this.listView1.SelectedItems[0].Tag)
                    {
                    case Articles a:
                        AjouterArticle AjouterA = new AjouterArticle(this, PathToSave);
                        AjouterA.StartPosition = FormStartPosition.CenterParent;
                        AjouterA.ShowDialog(this);
                        break;

                    case Familles f:
                        AjouterFamille AjouterF = new AjouterFamille(this, PathToSave);
                        AjouterF.StartPosition = FormStartPosition.CenterParent;
                        AjouterF.ShowDialog(this);
                        break;

                    case SousFamilles sf:
                        AjouterSousFamille AjouterSf = new AjouterSousFamille(this, PathToSave);
                        AjouterSf.StartPosition = FormStartPosition.CenterParent;
                        AjouterSf.ShowDialog(this);
                        break;

                    case Marques m:
                        AjouterMarque AjouterM = new AjouterMarque(this, PathToSave);
                        AjouterM.StartPosition = FormStartPosition.CenterParent;
                        AjouterM.ShowDialog(this);
                        break;

                    default:
                        break;
                    }
                }
                break;

            case "Modifier":
                if (this.listView1.SelectedItems.Count > 0)
                {
                    switch (this.listView1.SelectedItems[0].Tag)
                    {
                    case Articles a:
                        ModifierArticle ModifierA = new ModifierArticle(this, PathToSave);
                        ModifierA.StartPosition = FormStartPosition.CenterParent;
                        ModifierA.ShowDialog(this);
                        break;

                    case Familles f:
                        ModifierFamille ModifierF = new ModifierFamille(this, PathToSave);
                        ModifierF.StartPosition = FormStartPosition.CenterParent;
                        ModifierF.ShowDialog(this);
                        break;

                    case SousFamilles sf:
                        ModifierSousFamille ModifierSf = new ModifierSousFamille(this, PathToSave);
                        ModifierSf.StartPosition = FormStartPosition.CenterParent;
                        ModifierSf.ShowDialog(this);
                        break;

                    case Marques m:
                        ModifierMarque ModifierM = new ModifierMarque(this, PathToSave);
                        ModifierM.StartPosition = FormStartPosition.CenterParent;
                        ModifierM.ShowDialog(this);
                        break;

                    default:
                        break;
                    }
                }
                break;

            case "Supprimer":
                Controller.DeleteSelectedItem(this.treeView1.SelectedNode, this);
                InitializeTreeView TreeConstruct = new InitializeTreeView(this.treeView1);
                TreeConstruct.ConstructTree(PathToSave);
                break;

            default:
                break;
            }
        }