void Page_Load(object sender, System.EventArgs e) { // declare the menu and set its properties TextMenu tm = new TextMenu(); tm.ID = "TextMenu1"; // add the menu to page Page.Controls.Add(tm); string sConnectionString; OleDbDataReader oReader; // set the connection string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../App_Data/DBDEMO.mdb"); OleDbConnection Cn = new OleDbConnection(sConnectionString); // The database has one table called items containing both parent items and menu items // LEVEL shows what level the item is at (0 - parent item, 1 - belongs to menu attached to parent item, etc) // ORDER sets what is the item's order in the current menu (1 - first item, 2 - second item, etc.) // it is very important to add parent elements first, then level 1 items, then level 2 items, etc. string SQL = "SELECT * FROM Items ORDER BY [LEVEL], [ORDER]"; OleDbCommand Com = new OleDbCommand(SQL,Cn); Cn.Open(); oReader = Com.ExecuteReader(); // Populate TM. while (oReader.Read()) { // if PARENTID is null, we're adding a parent element, otherwise it's a menu item tm.Add(oReader.IsDBNull(oReader.GetOrdinal("PARENTID")) ? null : oReader.GetString(oReader.GetOrdinal("PARENTID")), oReader.GetString(oReader.GetOrdinal("ID")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML")), oReader.IsDBNull(oReader.GetOrdinal("URL")) ? null : oReader.GetString(oReader.GetOrdinal("URL")), oReader.IsDBNull(oReader.GetOrdinal("URLTARGET")) ? null : oReader.GetString(oReader.GetOrdinal("URLTARGET"))); } oReader.Close(); Cn.Close(); }
private void Page_Load(object sender, System.EventArgs e) { TextMenu tm1 = new TextMenu(); tm1.ID = "tm1"; tm1.StyleFolder = "styles/submenuicon"; tm1.SubMenuText = ""; tm1.Add(null, "brands", "Brands", null, null); tm1.Add("brands", "ibm", "IBM"); tm1.Add("brands", "microsoft", "MICROSOFT"); tm1.Add("brands", "obout", "OBOUT", "http://www.obout.com/", "_top"); tm1.Add("obout", "treeview", "TreeView", "http://www.obout.com/t2/edraganddrop.aspx", "_top"); tm1.Add("obout", "slidemenu", "Slide Menu", "http://www.obout.com/sm3/whatisnew.aspx", "_top"); tm1.Add("obout", "calendar", "Calendar", "http://www.obout.com/calendar/", "_top"); tm1.Add("obout", "postback", "AJAXPage", "http://www.obout.com/AJAXPage/", "_top"); tm1.Add("obout", "splitter", "Splitter", "http://www.obout.com/splitter/", "_top"); tm1.Add("obout", "easymenu", "EasyMenu", "http://www.obout.com/em/", "_top"); tm1.Add("obout", "combobox", "Combobox", "http://www.obout.com/combobox/", "_top"); tm1.Add("obout", "editor", "HTML Editor", "http://www.obout.com/editor_new/", "_top"); tm1.Add("obout", "treedb", "Tree_DB", "http://www.obout.com/t_db/index.aspx", "_top"); tm1.Add("obout", "textmenu", "TextMenu", "http://www.obout.com/tm/tm.aspx", "_top"); tm1.Add(null, "systems", "Systems"); tm1.Add("systems", "desktops", "Desktops"); tm1.Add("systems", "handhelds", "Handhelds"); tm1.Add("systems", "notebooks", "Notebooks"); tm1.Add("systems", "servers", "Servers"); tm1.Add(null, "hardware", "Hardware"); tm1.Add("hardware", "accessories", "Accessories"); tm1.Add("hardware", "keyboards", "Keyboards"); tm1.Add("hardware", "memory", "Memory"); tm1.Add("hardware", "printers", "Printers"); tm1.Add("hardware", "videocards", "Video Cards"); tm1.Add(null, "software", "Software"); tm1.Add("software", "applications", "Applications"); tm1.Add("software", "licensing", "Licensing"); this.Controls.Add(tm1); }
private void Page_Load(object sender, System.EventArgs e) { System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(Server.MapPath("TextMenuXML.xml")); System.Xml.XmlNodeList menuNodes = xmlDoc.SelectNodes("/TextMenu"); foreach (System.Xml.XmlNode menuNode in menuNodes) { string menuID = menuNode.Attributes["ID"].Value; // create new TextMenu object ... TextMenu tmpMenu = new TextMenu(); tmpMenu.ID = menuID; // take the childs and create the menu items ... System.Xml.XmlNodeList menuItemsNodes = menuNode.SelectNodes("//Item"); foreach (System.Xml.XmlNode menuItemNode in menuItemsNodes) { string menuItemID = menuItemNode.Attributes["ID"].Value; string InnerHTML = menuItemNode.Attributes["InnerHTML"].Value; string parentMenuItemID = null; if (menuItemNode.Attributes["ParentID"] != null) parentMenuItemID = menuItemNode.Attributes["ParentID"].Value; string menuUrl = null; if (menuItemNode.Attributes["Url"] != null) menuUrl = menuItemNode.Attributes["Url"].Value; // create new Menu item object and add it to the created menu ... tmpMenu.Add(parentMenuItemID, menuItemID, InnerHTML, menuUrl, null); } placeHolder1.Controls.Add(tmpMenu); } }
// Reference Menu private void SetReferencePoint(int index, TextMenu.Item ti) { // This is going to get complicated... if (referencePoints[index].part != vessel.GetReferenceTransformPart()) { referencePoints[index].part.MakeReferencePart(); } activeMenu.SetSelected(index, true); }
// Decouple port menu... private void DecouplePort(int index, TextMenu.Item ti) { var thatPort = undockablesList[index] as ModuleDockingNode; var thatClaw = undockablesList[index] as ModuleGrappleNode; if (thatPort != null) { switch (thatPort.state) { case "Docked (docker)": thatPort.Undock(); break; case "PreAttached": thatPort.Decouple(); break; } } // Mihara: Claws require multiple different calls depending on state -- // Release releases the claw that grabbed something else, while Decouple releases the claw that grabbed your own vessel. // FIXME: This needs further research. if (thatClaw != null) { thatClaw.Release(); } UpdateUndockablesList(); activeMenu = topMenu; currentMenu = MenuList.Root; UpdateLists(); }
// Vessel Menu private void TargetVessel(int index, TextMenu.Item ti) { if (selectedVessel == vesselsList[index].vessel) { // Already selected. Are there ports? UpdatePortsList(); if (portsList.Count > 0) { currentMenu = MenuList.Ports; activeMenu = new TextMenu(); activeMenu.rightColumnWidth = 8; activeMenu.labelColor = nameColorTag; activeMenu.selectedColor = selectedColorTag; activeMenu.disabledColor = unavailableColorTag; activeMenu.rightTextColor = distanceColorTag; UpdateLists(); if (selectedPort != null) { int idx = portsList.FindIndex(x => x == selectedPort); activeMenu.currentSelection = idx; } } } else { vesselsList[index].SetTarget(); selectedCelestial = null; selectedPort = null; activeMenu.SetSelected(index, true); } }
private void SAS_Mode(int arg1, TextMenu.Item arg2) { vessel.Autopilot.SetMode(modes[arg1]); // find the UI object on screen RUIToggleButton[] SASbtns = UnityEngine.Object.FindObjectOfType<VesselAutopilotUI>().modeButtons; // set our mode, note it takes the mode as an int, generally top to bottom, left to right, as seen on the screen. Maneuver node being the exception, it is 9 SASbtns.ElementAt<RUIToggleButton>((int)modes[arg1]).SetTrue(true, true); }
private void ShowReferenceMenu(int index, TextMenu.Item ti) { currentMenu = MenuList.Reference; activeMenu = new TextMenu(); activeMenu.labelColor = nameColorTag; activeMenu.selectedColor = selectedColorTag; activeMenu.disabledColor = unavailableColorTag; activeMenu.rightTextColor = distanceColorTag; UpdateLists(); activeMenu.currentSelection = referencePoints.FindIndex(x => x.part == vessel.GetReferenceTransformPart()); }
private void SmartASS_KillRot(int index, TextMenu.Item tmi) { SetSmartassMode(JSIMechJeb.Target.KILLROT); }
// EVA Menu private void CrewEVA(int index, TextMenu.Item ti) { var vesselCrew = vessel.GetVesselCrew(); float acLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex); bool evaUnlocked = GameVariables.Instance.UnlockedEVA(acLevel); bool evaPossible = GameVariables.Instance.EVAIsPossible(evaUnlocked, vessel); if (evaPossible && ti.id < vesselCrew.Count && vesselCrew[ti.id] != null && HighLogic.CurrentGame.Parameters.Flight.CanEVA) { FlightEVA.SpawnEVA(vesselCrew[ti.id].KerbalRef); CameraManager.Instance.SetCameraFlight(); } }
private void ShowCrewEVA(int index, TextMenu.Item ti) { currentMenu = MenuList.CrewEVA; activeMenu = new TextMenu(); activeMenu.labelColor = nameColorTag; activeMenu.selectedColor = selectedColorTag; activeMenu.disabledColor = unavailableColorTag; activeMenu.rightTextColor = distanceColorTag; var vesselCrew = vessel.GetVesselCrew(); for (int crewIdx = 0; crewIdx < vesselCrew.Count; ++crewIdx) { if (vesselCrew[crewIdx] != null) { var tmi = new TextMenu.Item(); tmi.action = CrewEVA; tmi.labelText = vesselCrew[crewIdx].name; tmi.rightText = vesselCrew[crewIdx].experienceTrait.Title; tmi.isSelected = false; tmi.id = crewIdx; activeMenu.Add(tmi); } } }
private void ToggleForceRoll(int index, TextMenu.Item tmi) { bool newForceRollState = !ForceRollState(); forceRollMenuItem.isSelected = newForceRollState; ForceRoll(newForceRollState); }
public void Start() { if (!HighLogic.LoadedSceneIsFlight) return; rpmComp = RasterPropMonitorComputer.Instantiate(internalProp, true); // Grrrrrr. if (!string.IsNullOrEmpty(nameColor)) nameColorValue = ConfigNode.ParseColor32(nameColor); if (!string.IsNullOrEmpty(distanceColor)) distanceColorValue = ConfigNode.ParseColor32(distanceColor); if (!string.IsNullOrEmpty(selectedColor)) selectedColorValue = ConfigNode.ParseColor32(selectedColor); if (!string.IsNullOrEmpty(unavailableColor)) unavailableColorValue = ConfigNode.ParseColor32(unavailableColor); persistentVarName = "targetfilter" + internalProp.propID; // 7 is the bitmask for ship-station-probe; VesselFilterFromBitmask(rpmComp.GetPersistentVariable(persistentVarName, defaultFilter, false).MassageToInt()); nameColorTag = JUtil.ColorToColorTag(nameColorValue); distanceColorTag = JUtil.ColorToColorTag(distanceColorValue); selectedColorTag = JUtil.ColorToColorTag(selectedColorValue); unavailableColorTag = JUtil.ColorToColorTag(unavailableColorValue); distanceFormatString = distanceFormatString.UnMangleConfigText(); menuTitleFormatString = menuTitleFormatString.UnMangleConfigText(); topMenu.labelColor = nameColorTag; topMenu.selectedColor = selectedColorTag; topMenu.disabledColor = unavailableColorTag; if (!string.IsNullOrEmpty(pageTitle)) pageTitle = pageTitle.UnMangleConfigText(); foreach (CelestialBody body in FlightGlobals.Bodies) { celestialsList.Add(new Celestial(body, vessel.transform.position)); } FindReferencePoints(); UpdateUndockablesList(); var menuActions = new List<Action<int, TextMenu.Item>>(); menuActions.Add(ShowCelestialMenu); menuActions.Add(ShowVesselMenu); menuActions.Add(ShowSpaceObjectMenu); menuActions.Add(ShowReferenceMenu); menuActions.Add(ShowUndockMenu); menuActions.Add(ArmGrapple); menuActions.Add(ShowFiltersMenu); menuActions.Add(ClearTarget); menuActions.Add(ShowCrewEVA); for (int i = 0; i < rootMenu.Count; ++i) { var menuitem = new TextMenu.Item(); menuitem.labelText = rootMenu[i]; menuitem.action = menuActions[i]; topMenu.Add(menuitem); switch (menuitem.labelText) { case clearTargetItemText: clearTarget = topMenu[i]; break; case undockItemText: undockMenuItem = topMenu[i]; break; case armGrappleText: grappleMenuItem = topMenu[i]; break; case crewEvaText: float acLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex); bool evaUnlocked = GameVariables.Instance.UnlockedEVA(acLevel); menuitem.isDisabled = !GameVariables.Instance.EVAIsPossible(evaUnlocked, vessel); break; } } activeMenu = topMenu; }
private void TargetMenu(int index, TextMenu.Item tmi) { currentMenu = MJMenu.TargetMenu; activeMenu = new TextMenu(); activeMenu.labelColor = JUtil.ColorToColorTag(itemColorValue); activeMenu.selectedColor = JUtil.ColorToColorTag(selectedColorValue); activeMenu.disabledColor = JUtil.ColorToColorTag(unavailableColorValue); foreach (JSIMechJeb.Target target in targetTargets) { activeMenu.Add(new TextMenu.Item(JSIMechJeb.TargetTexts[(int)target].Replace('\n', ' '), SelectTarget)); } }
private void SmartASS_Off(int index, TextMenu.Item tmi) { SetSmartassMode(JSIMechJeb.Target.OFF); }
private void SmartASS_Node(int index, TextMenu.Item tmi) { SetSmartassMode(JSIMechJeb.Target.NODE); }
//--- Menu item callbacks // Root menu: private void ShowCelestialMenu(int index, TextMenu.Item ti) { currentMenu = MenuList.Celestials; // MOARdV: Bug warning: rightColumnWidth for ShowCelestialMenu and // ShowVesselMenu is hard-coded to 8, which fits the default format // string. It really needs to be sized appropriately, which isn't // easy if the format string is configured with non-fixed size. // Maybe the format string should be non-configurable? // // Mihara: Well, why not make it another module parameter then and // let the modder who uses it worry about that? Most won't change it. activeMenu = new TextMenu(); activeMenu.rightColumnWidth = distanceColumnWidth; activeMenu.labelColor = nameColorTag; activeMenu.selectedColor = selectedColorTag; activeMenu.disabledColor = unavailableColorTag; activeMenu.rightTextColor = distanceColorTag; UpdateLists(); if (selectedCelestial != null) { int idx = celestialsList.FindIndex(x => x.body == selectedCelestial); activeMenu.currentSelection = idx; } }
private void ShowVesselMenu(int index, TextMenu.Item ti) { currentMenu = MenuList.Vessels; activeMenu = new TextMenu(); activeMenu.rightColumnWidth = distanceColumnWidth; activeMenu.labelColor = nameColorTag; activeMenu.selectedColor = selectedColorTag; activeMenu.disabledColor = unavailableColorTag; activeMenu.rightTextColor = distanceColorTag; UpdateLists(); if (selectedVessel != null) { int idx = vesselsList.FindIndex(x => x.vessel == selectedVessel); activeMenu.currentSelection = idx; } }
private void ShowFiltersMenu(int index, TextMenu.Item ti) { currentMenu = MenuList.Filters; activeMenu = new TextMenu(); activeMenu.labelColor = nameColorTag; activeMenu.selectedColor = selectedColorTag; activeMenu.disabledColor = unavailableColorTag; activeMenu.rightTextColor = distanceColorTag; for (int i = 0; i < vesselFilter.Count; i++) { var filter = vesselFilter.ElementAt(i); var tmi = new TextMenu.Item(); tmi.labelText = filter.Key.ToString().PadRight(9) + (filter.Value ? "- On" : "- Off"); tmi.isSelected = filter.Value; tmi.action = ToggleFilter; activeMenu.Add(tmi); } }
// Port Menu private void TargetPort(int index, TextMenu.Item ti) { if (selectedVessel != null && selectedVessel.loaded && portsList[index] != null) { FlightGlobals.fetch.SetVesselTarget(portsList[index]); } selectedCelestial = null; activeMenu.SetSelected(index, true); }
private void ShowUndockMenu(int index, TextMenu.Item ti) { currentMenu = MenuList.Undock; activeMenu = new TextMenu(); activeMenu.labelColor = nameColorTag; activeMenu.selectedColor = selectedColorTag; activeMenu.disabledColor = unavailableColorTag; activeMenu.rightTextColor = distanceColorTag; UpdateLists(); }
private void SelectTarget(int index, TextMenu.Item tmi) { JSIMechJeb.Target[] activeTargets = null; switch (currentMenu) { case MJMenu.OrbitMenu: activeTargets = orbitalTargets; break; case MJMenu.SurfaceMenu: activeTargets = surfaceTargets; break; case MJMenu.TargetMenu: activeTargets = targetTargets; break; } if (activeTargets != null) { SetSmartassMode(activeTargets[index]); } }
// Celestial Menu private void TargetCelestial(int index, TextMenu.Item ti) { celestialsList[index].SetTarget(); selectedVessel = null; selectedPort = null; activeMenu.SetSelected(index, true); }
public void ButtonProcessor(int buttonID) { if (buttonID == buttonUp) { activeMenu.PreviousItem(); } if (buttonID == buttonDown) { activeMenu.NextItem(); } if (buttonID == buttonEnter) { activeMenu.SelectItem(); } if (buttonID == buttonEsc) { if (currentMenu == MenuList.Ports) { // Take advantage of the fact that ShowVesselMenu does not // care about the parameters. ShowVesselMenu(0, null); } else { activeMenu = topMenu; currentMenu = MenuList.Root; } } if (buttonID == buttonHome) { sortMode = sortMode == SortMode.Alphabetic ? SortMode.Distance : SortMode.Alphabetic; UpdateLists(); } }
// Space Object Menu private void TargetSpaceObject(int index, TextMenu.Item ti) { spaceObjectsList[index].SetTarget(); selectedCelestial = null; selectedPort = null; activeMenu.SetSelected(index, true); }
public void Start() { if (!HighLogic.LoadedSceneIsFlight) return; // Grrrrrr. if (!string.IsNullOrEmpty(nameColor)) nameColorValue = ConfigNode.ParseColor32(nameColor); if (!string.IsNullOrEmpty(distanceColor)) distanceColorValue = ConfigNode.ParseColor32(distanceColor); if (!string.IsNullOrEmpty(selectedColor)) selectedColorValue = ConfigNode.ParseColor32(selectedColor); if (!string.IsNullOrEmpty(unavailableColor)) unavailableColorValue = ConfigNode.ParseColor32(unavailableColor); persistentVarName = "targetfilter" + internalProp.propID; persistence = new PersistenceAccessor(internalProp); // 7 is the bitmask for ship-station-probe; VesselFilterFromBitmask(persistence.GetVar(persistentVarName, defaultFilter)); nameColorTag = JUtil.ColorToColorTag(nameColorValue); distanceColorTag = JUtil.ColorToColorTag(distanceColorValue); selectedColorTag = JUtil.ColorToColorTag(selectedColorValue); unavailableColorTag = JUtil.ColorToColorTag(unavailableColorValue); distanceFormatString = distanceFormatString.UnMangleConfigText(); menuTitleFormatString = menuTitleFormatString.UnMangleConfigText(); topMenu.labelColor = nameColorTag; topMenu.selectedColor = selectedColorTag; topMenu.disabledColor = unavailableColorTag; if (!string.IsNullOrEmpty(pageTitle)) pageTitle = pageTitle.UnMangleConfigText(); foreach (CelestialBody body in FlightGlobals.Bodies) { celestialsList.Add(new Celestial(body, vessel.transform.position)); } FindReferencePoints(); UpdateUndockablesList(); var menuActions = new List<Action<int, TextMenu.Item>>(); menuActions.Add(ShowCelestialMenu); menuActions.Add(ShowVesselMenu); menuActions.Add(ShowSpaceObjectMenu); menuActions.Add(ShowReferenceMenu); menuActions.Add(ShowUndockMenu); menuActions.Add(ArmGrapple); menuActions.Add(ShowFiltersMenu); menuActions.Add(ClearTarget); for (int i = 0; i < rootMenu.Count; ++i) { var menuitem = new TextMenu.Item(); menuitem.labelText = rootMenu[i]; menuitem.action = menuActions[i]; topMenu.Add(menuitem); switch (menuitem.labelText) { case clearTargetItemText: clearTarget = topMenu[i]; break; case undockItemText: undockMenuItem = topMenu[i]; break; case armGrappleText: grappleMenuItem = topMenu[i]; break; } } activeMenu = topMenu; }
// Filters Menu private void ToggleFilter(int index, TextMenu.Item ti) { vesselFilter[vesselFilter.ElementAt(index).Key] = !vesselFilter[vesselFilter.ElementAt(index).Key]; persistence.SetVar(persistentVarName, VesselFilterToBitmask(vesselFilter)); ti.isSelected = !ti.isSelected; ti.labelText = vesselFilter.ElementAt(index).Key.ToString().PadRight(9) + (ti.isSelected ? "- On" : "- Off"); }
private static void ClearTarget(int index, TextMenu.Item ti) { FlightGlobals.fetch.SetVesselTarget((ITargetable)null); }
private void SAS_Toggle(int arg1, TextMenu.Item arg2) { vessel.ActionGroups.ToggleGroup(KSPActionGroup.SAS); }
private void ArmGrapple(int index, TextMenu.Item ti) { ModuleGrappleNode thatClaw = null; foreach (PartModule thatModule in vessel.GetReferenceTransformPart().Modules) { thatClaw = thatModule as ModuleGrappleNode; if (thatClaw != null) { break; } } if (thatClaw != null) { try { ModuleAnimateGeneric clawAnimation = (vessel.GetReferenceTransformPart().Modules[thatClaw.deployAnimationController] as ModuleAnimateGeneric); if (clawAnimation != null) { clawAnimation.Toggle(); } } catch (Exception e) { JUtil.LogErrorMessage(this, "Exception trying to arm/disarm Grapple Node: {0}", e.Message); } } }