static IEnumerable <Menu> CreateItems(AbsoluteDirectoryPath currentDir, ILookup <IAbsolutePath, IAbsolutePath> folderToFiles, IShell shell) { var dirs = folderToFiles[currentDir].OfType <AbsoluteDirectoryPath>().OrderBy(f => f.Name); var files = folderToFiles[currentDir].OfType <AbsoluteFilePath>().OrderBy(f => f.Name); foreach (var dir in dirs) { yield return(Menu.Submenu( name: dir.Name.ToString() + Path.DirectorySeparatorChar, icon: Icons.Folder, submenu: CreateItems(dir, folderToFiles, shell).Concat())); } foreach (var file in files) { var f = file; yield return(Menu.Item( name: file.Name.ToString(), icon: Icons.GetFileIcon(f), action: () => shell.OpenWithDefaultApplication(f))); } }
static IControl CreateButtons(IObserver <bool> showWindow, Action save) { var cancelButton = CreateButton( icon: Icons.Cancel(Theme.Cancel), text: "Cancel", clicked: Command.Enabled(() => showWindow.OnNext(false))); var doneButton = CreateButton( icon: Icons.Confirm(Theme.Active), text: "Done", clicked: Command.Enabled(() => { save(); showWindow.OnNext(false); })); var leftButton = Platform.OperatingSystem == OS.Mac ? cancelButton : doneButton; var rightButton = Platform.OperatingSystem == OS.Mac ? doneButton : cancelButton; return(Layout.SubdivideHorizontally( Layout.Dock().Right(Separator.Medium).Fill(leftButton), rightButton) .WithHeight(45)); }