You'll need to use a VB to C# conversion tool if you are working in C#.
Code:
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
SetupMenu()
FlattenAutoMenu()
If AppLogic.AppConfigBool("Layouts.Enabled") Then
Code:
Private Sub FlattenAutoMenu()
If aspnetMenu IsNot Nothing Then
Do While aspnetMenu.Items(0).ChildItems.Count > 0
aspnetMenu.Items.Add(aspnetMenu.Items(0).ChildItems(0))
Loop
aspnetMenu.Items.RemoveAt(0)
End If
End Sub
Your not trying to flatten the page.menu.xml.config file, actually you want to pad that file. What you want to do is pad the page.menu.xml.config file such that the static entries are one level deeper than the autogenerated categories menu. Then run the FlattenAutoMenu routine as many times as you need to get the categories to show at the top level.
If you are going for a look simular to what you have now, you probably won't need to flatten the menu at all, or maybe just once, but instead set the StaticDisplayLevels to one higher and then put a blank holder in the menu such that the menu item that appears on the page as a top level item (at the same level as categories root) is actually blank, and the only thing you see are the static menus at the same level as the categories. I personally thing that would look foolish.
What might help is if you include your page.menu.xml.config file and a typed out description of what you want it to look like. I'll then give pointed suggestions.
e.g.
Code:
item 1
-sub 1 (collapsed)
item 2
-sub 1 (collapsed)
-sub 2 (collapsed)
categories
-cat 1 (uncollapsed)
--sub cat 1 (collapsed)
--sub cat 2 (collapsed)
-cat 2 (uncollapsed)