Ejemplo n.º 1
0
        /// <summary>
        /// Recreates the menu entries to import exported creatures.
        /// </summary>
        private void CreateImportExportedMenu()
        {
            importExportedCreaturesToolStripMenuItem.DropDownItems.Clear();
            if (Properties.Settings.Default.ExportCreatureFolders?.Any() == true)
            {
                foreach (string f in Properties.Settings.Default.ExportCreatureFolders)
                {
                    ATImportExportedFolderLocation aTImportExportedFolderLocation =
                        ATImportExportedFolderLocation.CreateFromString(f);
                    string menuItemHeader = string.IsNullOrEmpty(aTImportExportedFolderLocation.ConvenientName)
                        ? "<unnamed>"
                        : aTImportExportedFolderLocation.ConvenientName;
                    ToolStripMenuItem tsmi = new ToolStripMenuItem(menuItemHeader
                                                                   + (string.IsNullOrEmpty(
                                                                          aTImportExportedFolderLocation.OwnerSuffix)
                                                                       ? string.Empty
                                                                       : " - " + aTImportExportedFolderLocation.OwnerSuffix))
                    {
                        Tag = aTImportExportedFolderLocation
                    };
                    tsmi.Click += OpenImportExportForm;
                    importExportedCreaturesToolStripMenuItem.DropDownItems.Add(tsmi);
                }

                importExportedCreaturesToolStripMenuItem.DropDownItems.Add(new ToolStripSeparator());
            }

            // open folder for importExport
            ToolStripMenuItem tsmif = new ToolStripMenuItem("Open folder for importing exported files");

            tsmif.Click += ImportAllCreaturesInSelectedFolder;
            importExportedCreaturesToolStripMenuItem.DropDownItems.Add(tsmif);
        }
Ejemplo n.º 2
0
        private void AddExportFolderToMenu(string folderPath)
        {
            var  folders       = Properties.Settings.Default.ExportCreatureFolders?.ToList() ?? new List <string>();
            bool alreadyExists = false;

            foreach (var f in folders)
            {
                var impExpFolder = ATImportExportedFolderLocation.CreateFromString(f);
                if (impExpFolder.FolderPath == folderPath)
                {
                    alreadyExists = true;
                    break;
                }
            }

            if (alreadyExists)
            {
                return;
            }

            folders.Add(new ATImportExportedFolderLocation(Path.GetFileName(folderPath), null, folderPath).ToString());
            Properties.Settings.Default.ExportCreatureFolders = folders.ToArray();
            CreateImportExportedMenu();
        }