public override void InitializeLayout() { base.InitializeLayout(); Window.DisableResizing(); Window.Padding = new Padding(0, 2, 0, 0); DockedTabControl d = new DockedTabControl(Window); CreateVisualSettingsTabPageControls(d.AddPage("Visual Settings "), "VisualSettings"); CreateOffsetsTabPageControls(d.AddPage("Offsets "), "Offsets"); }
public void MoveTabsTo(DockedTabControl target) { var children = TabStrip.Children.ToArray(); // copy because collection will be modified foreach (Base child in children) { TabButton button = child as TabButton; if (button == null) continue; target.AddPage(button); } Invalidate(); }
private void CreateVisualSettingsTabPageControls(TabButton tab, string name) { Base page = tab.Page; page.Name = $"{name}Page"; page.Padding = new Padding(-6, 0, -6, -6); DockedTabControl d = new DockedTabControl(page); TabButton defaultButton = d.AddPage("Default "); TabButton boatButton = d.AddPage("Boat "); TabButton heliButton = d.AddPage("Helicopter "); CreateSpotlightDataTabPageControls(defaultButton, $"{name}Default"); CreateSpotlightDataTabPageControls(boatButton, $"{name}Boat"); CreateSpotlightDataTabPageControls(heliButton, $"{name}Helicopter"); if (Game.LocalPlayer.Character.IsInAnyVehicle(false)) { // there isn't any TabControl.CurrentButton setter so we're doing it the reflection way FieldInfo currentButtonFieldInfo = typeof(TabControl).GetField("m_CurrentButton", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo pageFieldInfo = typeof(TabButton).GetField("m_Page", BindingFlags.NonPublic | BindingFlags.Instance); Model m = Game.LocalPlayer.Character.CurrentVehicle.Model; Base b = (Base)pageFieldInfo.GetValue(d.CurrentButton); b.IsHidden = true; if (m.IsHelicopter) { currentButtonFieldInfo.SetValue(d, heliButton); } else if (m.IsBoat) { currentButtonFieldInfo.SetValue(d, boatButton); } else { currentButtonFieldInfo.SetValue(d, defaultButton); } b = (Base)pageFieldInfo.GetValue(d.CurrentButton); b.IsHidden = false; } }