static void WriteTreeIndexToConsole(BranchMenuItem bMenuItem) { Console.WriteLine(bMenuItem.Text + " => " + bMenuItem.GetTreeIndexString()); foreach (var i in bMenuItem.Items) { WriteTreeIndexToConsole(i); } }
// Itemın Itemslarını ekle static void AddItemToStripMenuItem(BranchMenuItem item, ToolStripMenuItem stripMenuItem) { foreach (var i in item.Items) { var newItem = GetMenuItem(i); stripMenuItem.DropDownItems.Add(newItem); AddItemToStripMenuItem(i, newItem); } }
//BranchMenuItem dan ToolStripMenuItem oluştur static ToolStripMenuItem GetMenuItem(BranchMenuItem item) { var stripMenuItem = new ToolStripMenuItem(); ApplyStripMenuItem(ref stripMenuItem, item); stripMenuItem.Tag = item;//SmartOperation stripMenuItem_Click kontrol et return(stripMenuItem); }
static void Main(string[] args) { ////Init Repositories //IRepository<Pet> petRepo = new PetRepository(); //IRepository<Owner> ownerRepo = new OwnerRepository(); ////Init Services IPetService petService = new PetService(petRepo); IOwnerService ownerService = new OwnerService(ownerRepo); //init UI - Leaf And Branch Menuitems SortedList <int, IMenuItem> options = new SortedList <int, IMenuItem>(); options.Add(1, new BranchMenuItem("Create", GetCreateOptions(petService, ownerService))); options.Add(2, new BranchMenuItem("Read", GetReadOptions(petService, ownerService))); options.Add(3, new BranchMenuItem("Update", GetUpdateOptions(petService, ownerService))); options.Add(4, new BranchMenuItem("Delete", GetDeleteOptions(petService, ownerService))); BranchMenuItem main = new BranchMenuItem( " \n" + " _____ _____ ____ ____ _____ \n" + " ___|\\ \\ ___|\\ \\ | | | | ___|\\ \\ \n" + " / /\\ \\ | |\\ \\ | | | | | |\\ \\ \n" + " | | | | | | | | | | | | | | | |\n" + " | | |____| | |/____/ | | | | | | | |\n" + " | | ____ | |\\ \\ | | | | | | | |\n" + " | | | | | | | | | | | | | | | |\n" + " |\\ ___\\/ /| ___ |____| |____| ___ |\\___\\_|____| ___ |____|/____/|\n" + " | | /____/ | | | | | | | | | | | | | | | | / | |\n" + " \\| ___| | / |___| |____| |____| |___| \\|____|____| |___| |____|____|/ \n" + " \\( |____|/ \\( )/ \\( )/ \\( )/ \n" + " ' )/ ' ' ' ' ' ' \n" + " ' \n" + " -The PetShop\n", options); main.display(); Console.Clear(); }