コード例 #1
0
 private void DelItem()
 {
     try
     {
         Exercices.Remove(SelectedItem);
         Messenger.Default.Send <string>("", "DefilementListeSupp");
     }
     catch (Exception ex)
     {
         GestionErreur.GerrerErreur(ex);
     }
 }
コード例 #2
0
ファイル: PersistedData.cs プロジェクト: superboum/mic
        public Exercice getOrAddExercice(string name)
        {
            var exercice = Exercices.Find((e) => e.Name == name);

            if (exercice == null)
            {
                Dirty    = true;
                exercice = new Exercice(name);
                Exercices.Add(exercice);
            }
            return(exercice);
        }
コード例 #3
0
        private void AdItem()
        {
            try
            {
                ExerciceJeu exJeu;
                switch (nomExerciceSelectionne)
                {
                case "Discret statique": exJeu = ExerciceGenerator.GetExerciceJeu(SelectedTheme, difficulte);
                    exJeu.StaticDyn            = false;
                    exJeu.ImageDifficulte      = imageDifficulte;
                    exJeu.NomExercice          = "DS";
                    Exercices.Add(exJeu);
                    break;

                case "Discret dynamique": exJeu = ExerciceGenerator.GetExerciceJeu(SelectedTheme, difficulte);
                    exJeu.StaticDyn             = true;
                    exJeu.ImageDifficulte       = imageDifficulte;
                    exJeu.NomExercice           = "DD";
                    Exercices.Add(exJeu);
                    break;

                case "Discret cognitif":;
                    break;

                case "Cyclique":;
                    break;

                case "Complexe":;
                    break;

                default:
                    break;
                }
                Messenger.Default.Send <string>("", "DefilementListe");
            }
            catch (Exception ex)
            {
                GestionErreur.GerrerErreur(ex);
            }
        }
コード例 #4
0
        /// <summary>
        /// Loads all exercices located in the Plugins folder.
        /// </summary>
        public void LoadExercices()
        {
            menuItemNew.DropDownItems.Clear();
            menuItemHome.Enabled = false;
            panelExercice.Controls.Clear();

            try
            {
                DisplayBackground();

                TableLayoutPanel tableLayoutPanelMenu = new TableLayoutPanel();
                tableLayoutPanelMenu.Dock        = DockStyle.Left;
                tableLayoutPanelMenu.AutoSize    = true;
                tableLayoutPanelMenu.Padding     = new Padding(20, 0, 0, 0);
                tableLayoutPanelMenu.BackColor   = Color.Transparent;
                tableLayoutPanelMenu.ColumnCount = 1;
                tableLayoutPanelMenu.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                panelExercice.Controls.Add(tableLayoutPanelMenu);

                Panel pictureBoxTitle = new Panel();
                pictureBoxTitle.Dock                  = DockStyle.Top;
                pictureBoxTitle.Width                 = 300;
                pictureBoxTitle.Padding               = new Padding(0, 20, 0, 20);
                pictureBoxTitle.BackgroundImage       = Resources.logo_title;
                pictureBoxTitle.BackgroundImageLayout = ImageLayout.Zoom;
                tableLayoutPanelMenu.Controls.Add(pictureBoxTitle, 0, 0);

                int indexLoading = 0;

                foreach (string pathPlugin in Directory.GetFiles(Directory.GetCurrentDirectory() + DirectoryPlugins, "*.dll", SearchOption.AllDirectories))
                {
                    foreach (Type type in Assembly.LoadFile(pathPlugin).GetTypes())
                    {
                        if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(Exercice)))
                        {
                            Exercice exercice = (Exercice)Activator.CreateInstance(type);
                            exercice.Form = this;
                            Exercices.Add(exercice);

                            Action <object, EventArgs> onClick = new Action <object, EventArgs>((sender, e) => { LoadExercice(exercice); });

                            ToolStripMenuItem menuItem = new ToolStripMenuItem();
                            menuItem.Name   = "menuItemNew" + type.Name;
                            menuItem.Text   = exercice.Title;
                            menuItem.Click += onClick.Invoke;
                            menuItemNew.DropDownItems.Add(menuItem);

                            Button menuButton = new Button();
                            menuButton.Name   = "menuButton" + type.Name;
                            menuButton.Text   = exercice.Title;
                            menuButton.Height = 60;
                            menuButton.Dock   = DockStyle.Top;
                            menuButton.Click += onClick.Invoke;
                            tableLayoutPanelMenu.Controls.Add(menuButton);

                            tableLayoutPanelMenu.RowCount++;
                            tableLayoutPanelMenu.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
                            tableLayoutPanelMenu.Controls.Add(menuButton, 0, indexLoading + 1);

                            indexLoading++;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                DisplayError(exception.Message);
            }
        }