/// <summary> /// Get CommandStrings related to key-bound Action Commands /// </summary> /// <param name="consolidatedBoundCommands"></param> /// <returns></returns> public DataTable GetRelatedCommandStrings(DataTable consolidatedBoundCommands) { // Initialise .. DataTable associatedCommands = TableShape.AssociatedCommands(); // Loop through each key-bound Command String .. foreach (DataRow consolidatedBoundCommand in consolidatedBoundCommands.Select().Distinct().OrderBy(orderingColumn => orderingColumn[Edvard.Column.VoiceAttackAction.ToString()])) { // Get required field information .. string voiceAttackCommandString = consolidatedBoundCommand[Edvard.Column.VoiceAttackAction.ToString()].ToString(); string voiceAttackActionId = consolidatedBoundCommand[Edvard.Column.VoiceAttackKeyId.ToString()].ToString(); string eliteDangerousAction = consolidatedBoundCommand[Edvard.Column.EliteDangerousAction.ToString()].ToString(); string bindingSyncStatus = consolidatedBoundCommand[Edvard.Column.KeyUpdateRequired.ToString()].ToString() == Edvard.KeyUpdateRequired.NO.ToString() ? "synchronised" : "*attention required*"; string voiceAttackFile = Path.GetFileName(consolidatedBoundCommand[Edvard.Column.VoiceAttackProfile.ToString()].ToString()); string eliteDangerousFile = Path.GetFileName(consolidatedBoundCommand[Edvard.Column.EliteDangerousBinds.ToString()].ToString()); // Find associated Command String(s) using key-bound CommandString ActionId ... var associatedCommandStrings = this.GetCommandStringsFromCommandActionContext(ref this.xCfg, this.ParseVoiceAttackProfileForKeyBoundCommandIdsFromCommandActionId(ref this.xCfg, voiceAttackActionId).Distinct().FirstOrDefault().ToString()); // Find associated Command String(s) using key-bound CommandString Value ... var associatedCommandStringsFromContext2 = this.GetCommandStringsFromCommandActionContext2(ref this.xCfg, voiceAttackCommandString); if (associatedCommandStrings.Count() > 0) { associatedCommandStrings.Concat(associatedCommandStringsFromContext2); } else { associatedCommandStrings = associatedCommandStringsFromContext2; } // Add to DataTable .. foreach (var associatedCommandString in associatedCommandStrings.Distinct()) { associatedCommands.LoadDataRow(new object[] { voiceAttackCommandString, eliteDangerousAction, associatedCommandString, bindingSyncStatus, voiceAttackFile, eliteDangerousFile }, false); } } return(associatedCommands); }
/// <summary> /// Prepare KeyCodes and their conversions. /// </summary> /// <param name="keyBoundCommands"></param> /// <returns></returns> private DataTable Finalise(IEnumerable <dynamic> keyBoundCommands) { // Initialise .. DataTable boundKeyActionDefinitions = TableShape.KeyActionDefinition(); // Extract condensed aggregation of KeyCodes .. foreach (var keyBoundCommand in keyBoundCommands) { string modifierKeyEnumerationValue = StatusCode.EmptyString; var bindingAction = keyBoundCommand.commandString; var commandActionId = keyBoundCommand.actionId; var keyActionType = keyBoundCommand.actionType; var regularKeyCode = keyBoundCommand.regular; var modifierKeyCode = keyBoundCommand.regular == keyBoundCommand.modifier ? StatusCode.EmptyStringInt : keyBoundCommand.modifier; // If we do have a modifier key code .. if (modifierKeyCode >= 0) { // Get its enumerated key value .. modifierKeyEnumerationValue = Keys.GetKeyValue(modifierKeyCode); } // Load final values into DataTable .. boundKeyActionDefinitions.LoadDataRow(new object[] { Application.Name.VoiceAttack.ToString(), //Context Keys.KeyType.ToString(), //KeyEnumerationType bindingAction, //BindingAction StatusCode.NotApplicable, //Priority StatusCode.NotApplicable, //KeyGameValue Keys.GetKeyValue(regularKeyCode), //KeyEnumerationValue regularKeyCode.ToString(), //KeyEnumerationCode keyActionType, //KeyActionType commandActionId, //KeyId StatusCode.NotApplicable, //ModifierKeyGameValue modifierKeyEnumerationValue, //ModifierKeyEnumerationValue modifierKeyCode, //ModifierKeyEnumerationCode commandActionId //ModifierKeyId }, false); } // return Datatable .. return(boundKeyActionDefinitions); }
/// <summary> /// /// </summary> /// <param name="inShape"></param> private void pAddTableAndShow(TableShape inShape) { if (TableCount <= _MAX_TABLE_NUMBER) { TableInfo table = pAddNewTable(inShape); pPopulateTableTreeView(tvTables, TableList); pShowTableInfo(table); pEnableSelectedTableAttrPanel(_canvasManager.Location.TableCount > 0); pCheckAndClearSelectedTableAttrPanel(); pCheckForInvalidTableNumber(table); } else { pShowErrorMsg(string.Format(@"Failed to add a new table. You have reached the maximum amount of table for a location [{0}]", _MAX_TABLE_NUMBER)); } }
/// <summary> /// Write Key Enumeration Dictionary as CSV /// </summary> /// <param name="directoryPath"></param> /// <param name="fileName"></param> public void WriteKeyMap(string directoryPath, string fileName) { // Create DataTable with correct structure .. DataTable keyMap = TableShape.DefineKeyMap(); // Loop through dictionary adding information to DataTable .. foreach (KeyValuePair <string, int> kvp in this.currentKeyEnumType) { keyMap.LoadDataRow(new object[] { this.KeyType.ToString(), kvp.Key, kvp.Value }, false); } // Write DataTable contents as csv .. keyMap.CreateCSV(directoryPath, fileName); }
/// <summary> /// Get commandStrings for all Categories and load into DataTable .. /// </summary> /// <returns></returns> public DataTable GetCommandStringsForAllCategories() { // Initialise .. DataTable allVoiceCommands = TableShape.AllVoiceCommands(); // Get anonymous type row data (as object types) .. var commandStrings = this.GetCommandStringsForCommandCategory(ref this.xCfg, this.GetAllCommandCategories(ref this.xCfg)); // insert object's row data into DataTable being able to access its two fields as the anonymous type commandString is declared as a 'dynamic' type .. foreach (dynamic commandString in commandStrings) { allVoiceCommands.LoadDataRow(new object[] { commandString.CommandCategory, commandString.CommandString, commandString.ActionType }, false); } return(allVoiceCommands); }
void dbEntity_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { ITable entity = sender as ITable; if (entity == null) { return; } TableShape shape = EntityLookup[entity.InternalIdentifier] as TableShape; if (shape == null) { return; } switch (e.PropertyName) { case "Name": shape.EntityName = entity.Name; break; } }
/// <summary> /// Creates the shapes in Groups. /// </summary> private void CreateShapes() { //Clear current shapes list shapes.Clear(); //The ID of the shape int ID = 0; GameObject shapesGroup = null; //Create Shapes inside groups for (int i = 0; i < ShapesManager.instance.shapes.Count; i++) { if (i % shapesPerGroup == 0) { int groupIndex = (i / shapesPerGroup); shapesGroup = Group.CreateGroup(shapesGroupPrefab, groupsParent, groupIndex, columnsPerGroup); if (!EnableGroupGridLayout) { shapesGroup.GetComponent <GridLayoutGroup>().enabled = false; } if (createGroupsPointers) { Pointer.CreatePointer(groupIndex, shapesGroup, pointerPrefab, pointersParent); } } //Create Shape ID = (i + 1); //the id of the shape GameObject tableShapeGameObject = Instantiate(shapePrefab, Vector3.zero, Quaternion.identity) as GameObject; tableShapeGameObject.transform.SetParent(shapesGroup.transform); //setting up the shape's parent TableShape tableShapeComponent = tableShapeGameObject.GetComponent <TableShape> (); //get TableShape Component tableShapeComponent.ID = ID; //setting up shape ID tableShapeGameObject.name = "Shape-" + ID; //shape name tableShapeGameObject.transform.localScale = Vector3.one; tableShapeGameObject.GetComponent <RectTransform> ().offsetMax = Vector2.zero; tableShapeGameObject.GetComponent <RectTransform> ().offsetMin = Vector2.zero; GameObject content = Instantiate(ShapesManager.instance.shapes[i].gamePrefab, Vector3.zero, Quaternion.identity) as GameObject; content.transform.SetParent(tableShapeGameObject.transform.Find("Content")); RectTransform rectTransform = tableShapeGameObject.transform.Find("Content").GetComponent <RectTransform>(); float ratio = Mathf.Max(Screen.width, Screen.height) / 1000.0f; //set up the scale content.transform.localScale = new Vector3(ratio * 0.7f, ratio * 0.7f); //release unwanted resources content.GetComponent <Shape>().enabled = false; content.GetComponent <Animator>().enabled = false; content.transform.Find("TracingHand").gameObject.SetActive(false); content.transform.Find("Collider").gameObject.SetActive(false); Animator [] animators = content.transform.GetComponentsInChildren <Animator>(); foreach (Animator a in animators) { a.enabled = false; } int from, to; string [] slices; List <Transform> paths = CommonUtil.FindChildrenByTag(content.transform.Find("Paths"), "Path"); foreach (Transform p in paths) { slices = p.name.Split('-'); from = int.Parse(slices [1]); to = int.Parse(slices [2]); p.Find("Start").gameObject.SetActive(false); Image img = CommonUtil.FindChildByTag(p, "Fill").GetComponent <Image>(); if (PlayerPrefs.HasKey("Shape-" + ID + "-Path-" + from + "-" + to)) { List <Transform> numbers = CommonUtil.FindChildrenByTag(p.transform.Find("Numbers"), "Number"); foreach (Transform n in numbers) { n.gameObject.SetActive(false); } img.fillAmount = 1; img.color = DataManager.GetShapePathColor(ID, from, to); } } tableShapeGameObject.GetComponent <Button> ().onClick.AddListener(() => GameObject.FindObjectOfType <UIEvents> ().AlbumShapeEvent(tableShapeGameObject.GetComponent <TableShape> ())); SettingUpShape(tableShapeComponent, ID); //setting up the shape contents (stars number ,islocked,...) shapes.Add(tableShapeComponent); //add table shape component to the list } collectedStarsText.text = collectedStars + "/" + (3 * ShapesManager.instance.shapes.Count); if (ShapesManager.instance.shapes.Count == 0) { Debug.Log("There are no Shapes found"); } else { Debug.Log("New shapes have been created"); } }
private void CreateShapes() { if (ShapesManager.instance == null) { return; } //Clear current shapes list shapes.Clear(); //The ID of the shape int ID = 0; GameObject shapesGroup = null; float contentScale = (Screen.width * 1.0f / Screen.height) * contentScaleRatio;//content scale //Create Shapes inside groups for (int i = 0; i < ShapesManager.instance.shapes.Count; i++) { if (i % shapesPerGroup == 0) { int groupIndex = (i / shapesPerGroup); shapesGroup = Group.CreateGroup(shapesGroupPrefab, groupsParent, groupIndex, columnsPerGroup); } ID = (i + 1); //the ID of the shape //Create a Shape GameObject tableShapeGameObject = Instantiate(shapePrefab, Vector3.zero, Quaternion.identity) as GameObject; tableShapeGameObject.transform.SetParent(shapesGroup.transform); //setting up the shape's parent TableShape tableShapeComponent = tableShapeGameObject.GetComponent <TableShape>(); //get TableShape Component tableShapeComponent.ID = ID; //setting up shape ID tableShapeGameObject.name = "Shape-" + ID; //shape name tableShapeGameObject.transform.localScale = Vector3.one; tableShapeGameObject.GetComponent <RectTransform>().offsetMax = Vector2.zero; tableShapeGameObject.GetComponent <RectTransform>().offsetMin = Vector2.zero; GameObject content = Instantiate(ShapesManager.instance.shapes[i].gamePrefab, Vector3.zero, Quaternion.identity) as GameObject; //release unwanted resources Destroy(content.GetComponent <EventTrigger>()); Destroy(content.GetComponent <UIEvents>()); if (content.transform.Find("Parts") != null) { Destroy(content.transform.Find("Parts").gameObject); } content.transform.SetParent(tableShapeGameObject.transform.Find("Content")); RectTransform rectTransform = tableShapeGameObject.transform.Find("Content").GetComponent <RectTransform>(); //set up the scale content.transform.localScale = new Vector3(contentScale, contentScale); //set up the anchor content.GetComponent <RectTransform>().anchorMin = Vector2.zero; content.GetComponent <RectTransform>().anchorMax = Vector2.one; //set up the offset content.GetComponent <RectTransform>().offsetMax = Vector2.zero; content.GetComponent <RectTransform>().offsetMin = Vector2.zero; //enable image component content.GetComponent <Image>().enabled = true; //add click listener tableShapeGameObject.GetComponent <Button>().onClick.AddListener(() => GameObject.FindObjectOfType <UIEvents>().AlbumShapeEvent(tableShapeGameObject.GetComponent <TableShape>())); content.gameObject.SetActive(true); shapes.Add(tableShapeComponent);//add table shape component to the list } if (ShapesManager.instance.shapes.Count == 0) { Debug.Log("There are no Shapes found"); } else { Debug.Log("New shapes have been created"); } }
/// <summary> /// Settings up the shape contents in the table. /// </summary> /// <param name="tableShape">Table shape.</param> /// <param name="ID">ID of the shape.</param> /// <param name="groupIndex">Index of the group.</param> private void SettingUpShape(TableShape tableShape, int ID, int groupIndex) { if (tableShape == null) { return; } tableShape.isLocked = DataManager.IsShapeLocked(ID, shapesManager); tableShape.starsNumber = DataManager.GetShapeStars(ID, shapesManager); if (tableShape.ID == 1) { tableShape.isLocked = false; } if (!tableShape.isLocked) { tableShape.transform.Find("Cover").gameObject.SetActive(false); tableShape.transform.Find("Lock").gameObject.SetActive(false); } else { tableShape.GetComponent <Button> ().interactable = false; tableShape.transform.Find("Stars").gameObject.SetActive(false); } //Set Last reached shape if (!tableShape.isLocked) { if (PlayerPrefs.HasKey(DataManager.GetLockedStrKey(ID + 1, shapesManager))) { if (DataManager.IsShapeLocked(ID + 1, shapesManager)) { SetSelectedGroup(groupIndex); } } else if (!PlayerPrefs.HasKey(DataManager.GetStarsStrKey(ID, shapesManager))) { SetSelectedGroup(groupIndex); } } tempTransform = tableShape.transform.Find("Stars"); //Apply the current Stars Rating if (tableShape.starsNumber == TableShape.StarsNumber.ONE) //One Star { tempTransform.Find("FirstStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOff; tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite = starOff; collectedStars += 1; } else if (tableShape.starsNumber == TableShape.StarsNumber.TWO) //Two Stars { tempTransform.Find("FirstStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite = starOff; collectedStars += 2; } else if (tableShape.starsNumber == TableShape.StarsNumber.THREE) //Three Stars { tempTransform.Find("FirstStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite = starOn; collectedStars += 3; } else //Zero Stars { tempTransform.Find("FirstStar").GetComponent <Image> ().sprite = starOff; tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOff; tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite = starOff; } }
/// <summary> /// Creates the shapes in Groups. /// </summary> private IEnumerator CreateShapes() { yield return(0); //Clear current shapes list shapes.Clear(); //The ID of the shape int ID = 0; //The scale ratio for the shape float ratio = Mathf.Max(Screen.width, Screen.height) / 1000.0f; //The group of the shape GameObject shapesGroup = null; //The index of the group int groupIndex = 0; pointersParent.gameObject.SetActive(false); groupsParent.gameObject.SetActive(false); //Create Shapes inside groups for (int i = 0; i < shapesManager.shapes.Count; i++) { if (i % shapesPerGroup == 0) { groupIndex = (i / shapesPerGroup); shapesGroup = Group.CreateGroup(shapesGroupPrefab, groupsParent, groupIndex, columnsPerGroup); if (!EnableGroupGridLayout) { shapesGroup.GetComponent <GridLayoutGroup> ().enabled = false; } if (createGroupsPointers) { Pointer.CreatePointer(groupIndex, shapesGroup, pointerPrefab, pointersParent); } } //Create Shape ID = (i + 1); //the id of the shape GameObject tableShapeGameObject = Instantiate(shapePrefab, Vector3.zero, Quaternion.identity) as GameObject; tableShapeGameObject.transform.SetParent(shapesGroup.transform); //setting up the shape's parent TableShape tableShapeComponent = tableShapeGameObject.GetComponent <TableShape> (); //get TableShape Component tableShapeComponent.ID = ID; //setting up shape ID tableShapeGameObject.name = "Shape-" + ID; //shape name tableShapeGameObject.transform.localScale = Vector3.one; tableShapeGameObject.GetComponent <RectTransform> ().offsetMax = Vector2.zero; tableShapeGameObject.GetComponent <RectTransform> ().offsetMin = Vector2.zero; GameObject uiShape = Instantiate(shapesManager.shapes [i].gamePrefab, Vector3.zero, Quaternion.identity) as GameObject; uiShape.transform.SetParent(tableShapeGameObject.transform.Find("Content")); RectTransform rectTransform = tableShapeGameObject.transform.Find("Content").GetComponent <RectTransform> (); uiShape.transform.localScale = new Vector3(ratio * shapeScaleFactor, ratio * shapeScaleFactor); uiShape.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero; List <Shape> shapeComponents = new List <Shape> (); if (uiShape.GetComponent <CompoundShape> () != null) { Shape[] tempS = uiShape.GetComponentsInChildren <Shape> (); foreach (Shape s in tempS) { shapeComponents.Add(s); } } else { shapeComponents.Add(uiShape.GetComponent <Shape> ()); } int compoundID; for (int s = 0; s < shapeComponents.Count; s++) { CompoundShape compundShape = shapeComponents [s].transform.parent.GetComponent <CompoundShape> (); compoundID = 0; if (compundShape != null) { compoundID = compundShape.GetShapeIndexByInstanceID(shapeComponents[s].GetInstanceID()); } shapeComponents[s].enabled = false; //release unwanted resources shapeComponents[s].GetComponent <Animator> ().enabled = false; shapeComponents[s].transform.Find("TracingHand").gameObject.SetActive(false); shapeComponents[s].transform.Find("Collider").gameObject.SetActive(false); Animator[] animators = shapeComponents[s].transform.GetComponentsInChildren <Animator> (); foreach (Animator a in animators) { a.enabled = false; } int from, to; string[] slices; List <Transform> paths = CommonUtil.FindChildrenByTag(shapeComponents[s].transform.Find("Paths"), "Path"); foreach (Transform p in paths) { slices = p.name.Split('-'); from = int.Parse(slices [1]); to = int.Parse(slices [2]); p.Find("Start").gameObject.SetActive(false); Image img = CommonUtil.FindChildByTag(p, "Fill").GetComponent <Image> (); if (PlayerPrefs.HasKey(DataManager.GetPathStrKey(ID, compoundID, from, to, shapesManager))) { List <Transform> numbers = CommonUtil.FindChildrenByTag(p.transform.Find("Numbers"), "Number"); foreach (Transform n in numbers) { n.gameObject.SetActive(false); } img.fillAmount = 1; img.color = DataManager.GetShapePathColor(ID, compoundID, from, to, shapesManager); } } } tableShapeGameObject.GetComponent <Button> ().onClick.AddListener(() => GameObject.FindObjectOfType <UIEvents> ().AlbumShapeEvent(tableShapeGameObject.GetComponent <TableShape> ())); SettingUpShape(tableShapeComponent, ID, groupIndex); //setting up the shape contents (stars number ,islocked,...) shapes.Add(tableShapeComponent); //add table shape component to the list } collectedStarsText.text = collectedStars + "/" + (3 * shapesManager.shapes.Count); if (shapesManager.shapes.Count == 0) { Debug.Log("There are no Shapes found"); } else { Debug.Log("New shapes have been created"); } GameObject.Find("Loading").SetActive(false); pointersParent.gameObject.SetActive(true); groupsParent.gameObject.SetActive(true); GameObject.FindObjectOfType <ScrollSlider> ().Init(); }
/// <summary> /// Process Elite Dangerous Config File looking for keyboard-specific bindings /// </summary> /// <remarks> /// Keys can be in assigned with Primary or Secondary Priorities /// Format: XML /// o <Root/> /// |_ <KeyboardLayout/> /// |_ <things></things>.[Value] attribute /// |_ <things/> /// |_<Binding/> /// |_<Inverted/> /// |_<Deadzone/> /// |_ <things/> /// |_<Primary/> /// |_<Device/> /// |_<Key/> /// |_<Secondary/> /// |_<Device/> /// |_<Key/> /// |_ <things/> /// |_<Primary/> /// |_<Modifier/> /// |_<Device/> /// |_<Key/> /// |_<Secondary/> /// |_<Modifier/> /// |_<Device/> /// |_<Key/> /// |_ <things/> /// |_<Primary/> /// |_<Secondary/> /// |_<ToggleOn/> /// /// Selected Keys: Use an esoteric key value (as opposed to key code) /// e.g. /// SystemMapOpen : Key_B /// GalaxyMapOpen : Key_M /// FocusRightPanel : Key_4 /// SetSpeedZero: Key_0 + Key_RightShift (modifier) /// </remarks> /// <param name="xdoc"></param> /// <param name="devicepriority"></param> /// <returns></returns> private DataTable GetKeyBindings(ref XDocument xdoc, Application.EliteDangerousDevicePriority devicepriority) { // Initialise .. string devicePriority = devicepriority.ToString(); // Datatable to hold tabulated XML contents .. DataTable keyActionDefinition = TableShape.KeyActionDefinition(); // Scan all child nodes from top-level node .. foreach (var childNode in xdoc.Element(XMLRoot).Elements()) { // can only process if child node itself has children .. if (childNode.DescendantNodes().Any()) { var xmlExtracts = from item in xdoc.Descendants(childNode.Name) where item.Element(devicePriority).SafeAttributeValue(XMLDevice) == Application.Interaction.Keyboard.ToString() && item.Element(devicePriority).Attribute(XMLKey).Value.Contains(Application.EliteDangerousBindingPrefix.Key_.ToString()) == true select new // create anonymous type for every key code .. { //--------------------------------------------------------------------------------- // Priority .. //--------------------------------------------------------------------------------- xmlNode_DevicePriority = item.Element(devicePriority).Attribute(XMLKey).Parent.Name, //--------------------------------------------------------------------------------- // Main Key Binding .. //--------------------------------------------------------------------------------- xmlNode_Device = item.Element(devicePriority).SafeAttributeName(XMLDevice), xmlNode_Key = item.Element(devicePriority).SafeAttributeName(XMLKey), DeviceType = item.Element(devicePriority).SafeAttributeValue(XMLDevice), KeyValueFull = item.Element(devicePriority).SafeAttributeValue(XMLKey), KeyValue = item.Element(devicePriority).SafeAttributeValue(XMLKey) != string.Empty ? item.Element(devicePriority).SafeAttributeValue(XMLKey).Substring(4) : string.Empty, //--------------------------------------------------------------------------------- // Modifier Key Binding (should it exist) .. //--------------------------------------------------------------------------------- xmlNode_Modifier = item.Element(devicePriority).Element(XMLModifier).SafeElementName(), xmlNode_ModifierDevice = item.Element(devicePriority).Element(XMLModifier).SafeAttributeName(XMLDevice), xmlNode_ModifierKey = item.Element(devicePriority).Element(XMLModifier).SafeAttributeName(XMLKey), ModifierDeviceType = item.Element(devicePriority).Element(XMLModifier).SafeAttributeValue(XMLDevice), ModifierKeyValueFull = item.Element(devicePriority).Element(XMLModifier).SafeAttributeValue(XMLKey), ModifierKeyValue = item.Element(devicePriority).Element(XMLModifier).SafeAttributeValue(XMLKey) != string.Empty ? item.Element(devicePriority).Element(XMLModifier).SafeAttributeValue(XMLKey).Substring(4) : string.Empty }; // insert anonymous type row data (with additional values) .. foreach (var xmlExtract in xmlExtracts) { string customKeyId = childNode.Name + D + xmlExtract.xmlNode_DevicePriority + D + xmlExtract.xmlNode_Device + D + xmlExtract.DeviceType + D + xmlExtract.xmlNode_Key + D + xmlExtract.KeyValueFull; string customModifierKeyId = string.Empty; if (xmlExtract.xmlNode_Modifier != string.Empty) { customModifierKeyId = childNode.Name + D + xmlExtract.xmlNode_DevicePriority + D + xmlExtract.xmlNode_Modifier + D + xmlExtract.xmlNode_ModifierDevice + D + xmlExtract.ModifierDeviceType + D + xmlExtract.xmlNode_ModifierKey + D + xmlExtract.ModifierKeyValueFull; } // Load final values .. keyActionDefinition.LoadDataRow(new object[] { Application.Name.EliteDangerous.ToString(), //Context Keys.KeyType.ToString(), //KeyEnumerationType childNode.Name, //BindingAction xmlExtract.xmlNode_DevicePriority, //Priority xmlExtract.KeyValue, //KeyGameValue this.gameKeys.GetValue(xmlExtract.KeyValue), //KeyEnumerationValue Keys.GetKeyCode(xmlExtract.KeyValue), //KeyEnumerationCode StatusCode.NotApplicable, //KeyActionType customKeyId, //KeyId xmlExtract.ModifierKeyValue, //ModifierKeyGameValue this.gameKeys.GetValue(xmlExtract.ModifierKeyValue), //ModifierKeyEnumerationValue Keys.GetKeyCode(xmlExtract.ModifierKeyValue), //ModifierKeyEnumerationCode customModifierKeyId //ModifierId }, false); } } } // return Datatable .. return(keyActionDefinition); }
public Table(TableShape shape, uint tableLegs, uint maxSeats) { this._shape = shape; this._tableLegs = tableLegs; this._maxSeats = maxSeats; }
public void UpdateModel(string id, TableAction action, Dictionary <UpdateKey, object> arguments) { if (action == TableAction.UpdateAll) { double x = (double)arguments[UpdateKey.X]; double y = (double)arguments[UpdateKey.Y]; repository.UpdateTableCoordinates(id, x, y); int scaleX = (int)arguments[UpdateKey.ScaleX]; int scaleY = (int)arguments[UpdateKey.ScaleY]; repository.UpdateTableScaleX(id, scaleX); repository.UpdateTableScaleY(id, scaleY); int rotateAngle = (int)arguments[UpdateKey.Angle]; repository.UpdateTableRotateAngle(id, rotateAngle); string name = (string)arguments[UpdateKey.Name]; repository.UpdateTableName(id, name); string color = (string)arguments[UpdateKey.Color]; repository.UpdateTableColor(id, color); TableShape shape = (TableShape)arguments[UpdateKey.Shape]; repository.UpdateTableShape(id, shape); Table model = repository.GetModel(id); view.Update(model, TableLayoutUpdateMode.All); } if (action == TableAction.Create) { string newId = repository.AddTable(arguments); Table model = repository.GetModel(newId); view.Update(model, TableLayoutUpdateMode.New); } else if (action == TableAction.UpdateCoordinates) { double x = (double)arguments[UpdateKey.X]; double y = (double)arguments[UpdateKey.Y]; repository.UpdateTableCoordinates(id, x, y); Table model = repository.GetModel(id); view.Update(model, TableLayoutUpdateMode.Coordinates); } else if (action == TableAction.SetSelected) { Table model = repository.GetModel(id); view.Update(model, TableLayoutUpdateMode.SetSelected); } else if (action == TableAction.SetUnselected) { Table model = repository.GetModel(id); view.Update(model, TableLayoutUpdateMode.SetUnselected); } else if (action == TableAction.Delete) { Table model = repository.GetModel(id); repository.DeleteTable(id); view.Update(model, TableLayoutUpdateMode.Delete); } else if (action == TableAction.Rotate) { repository.UpdateTableRotateAngle(id, 0); Table model = repository.GetModel(id); view.Update(model, TableLayoutUpdateMode.Rotate); } else if (action == TableAction.UpdateName) { string name = (string)arguments[UpdateKey.Name]; repository.UpdateTableName(id, name); Table model = repository.GetModel(id); view.Update(model, TableLayoutUpdateMode.UpdateName); } else if (action == TableAction.Save) { repository.Save(); } else if (action == TableAction.RevertChanges) { repository.RevertChanges(); } }
/// <summary> /// Process Elite Dangerous Config File to return all possible bindable actions /// </summary> /// <remarks> /// Keys can be in assigned with Primary or Secondary Priorities /// Format: XML /// o <Root/> /// |_ <things/> /// |_<Primary/> /// |_<Device/> /// |_<Key/> /// |_<Secondary/> /// |_<Device/> /// |_<Key/> /// </remarks> /// <param name="xdoc"></param> /// <returns></returns> private DataTable GetBindableActions(ref XDocument xdoc) { // Initialise .. string[] devicePriority = { Application.EliteDangerousDevicePriority.Primary.ToString(), Application.EliteDangerousDevicePriority.Secondary.ToString() }; // Datatable to hold tabulated XML contents .. DataTable bindableactions = TableShape.BindableActions(); // Scan all child nodes from top-level node .. foreach (var childNode in xdoc.Element(XMLRoot).Elements()) { // can only process if child node itself has children .. if (childNode.DescendantNodes().Any()) { // Get all primary devices .. var primaryDevices = from item in xdoc.Descendants(childNode.Name) where item.Element(devicePriority[0]).SafeElementName() == devicePriority[0] select new { BindingAction = item.SafeElementName(), Priority = item.Element(devicePriority[0]).SafeElementName(), DeviceType = item.Element(devicePriority[0]).SafeAttributeValue(XMLDevice) }; // Get all secondary devices .. var secondaryDevices = from item in xdoc.Descendants(childNode.Name) where item.Element(devicePriority[1]).SafeElementName() == devicePriority[1] select new { BindingAction = item.SafeElementName(), Priority = item.Element(devicePriority[1]).SafeElementName(), DeviceType = item.Element(devicePriority[1]).SafeAttributeValue(XMLDevice) }; // Perform a 'union all' ... var xmlExtracts = primaryDevices.Concat(secondaryDevices); // insert anonymous type row data (with additional values) .. foreach (var xmlExtract in xmlExtracts) { bindableactions.LoadDataRow(new object[] { Application.Name.EliteDangerous.ToString(), //Context xmlExtract.BindingAction, //KeyAction StatusCode.NotApplicable, //KeyActionType xmlExtract.Priority, //Device Priority xmlExtract.DeviceType //Device Type binding is applied to }, false); } } } // return Datatable .. return(bindableactions); }
public void UpdateTableShape(string id, TableShape shape) { Table t = tables[id]; t.Shape = shape; }
/// <summary> /// /// </summary> private TableInfo pAddNewTable(TableShape inShape) { return((inShape == TableShape.Rectangle) ? pAddRectTable() : pAddElipseTable()); }
/// <summary> /// Adjust VoiceAttack Command key codes to match those in Elite Dangerous using Elite Dangerous command bindings as master .. /// </summary> /// <param name="eliteDangerousBinds"></param> /// <param name="voiceAttackProfile"></param> /// <param name="keyLookup"></param> /// <returns></returns> public static DataTable VoiceAttack(string eliteDangerousBinds, string voiceAttackProfile, KeyBindingAndCommandConnector keyLookup) { // Datatable to hold tabulated contents .. DataTable adjustedVoiceAttackCommands = TableShape.ConsolidatedActions(); string globalEliteDangerousBindsInternal = string.Empty; // Read bindings .. var eliteDangerous = new KeyBindingReaderEliteDangerous(eliteDangerousBinds).GetBoundCommands(); var voiceAttack = new KeyBindingReaderVoiceAttack(voiceAttackProfile).GetBoundCommands(); // Search through all defined Voice Attack bindings .. var voiceattackBindings = from va in voiceAttack.AsEnumerable() select new { KeyEnumeration = va.Field <string>(Edvard.Column.KeyEnumeration.ToString()), EliteDangerousAction = keyLookup.GetEliteDangerousBinding(va.Field <string>(Edvard.Column.KeyAction.ToString())), Action = va.Field <string>(Edvard.Column.KeyAction.ToString()), KeyValue = va.Field <string>(Edvard.Column.KeyEnumerationValue.ToString()), KeyCode = va.Field <int>(Edvard.Column.KeyEnumerationCode.ToString()), KeyActionType = va.Field <string>(Edvard.Column.KeyActionType.ToString()), KeyID = va.Field <string>(Edvard.Column.KeyId.ToString()), ModifierKeyGameValue = va.Field <string>(Edvard.Column.ModifierKeyGameValue.ToString()), ModifierKeyEnumerationValue = va.Field <string>(Edvard.Column.ModifierKeyEnumerationValue.ToString()), ModifierKeyEnumerationCode = va.Field <int>(Edvard.Column.ModifierKeyEnumerationCode.ToString()), ModifierKeyID = va.Field <string>(Edvard.Column.ModifierKeyId.ToString()), FilePath = va.Field <string>(Edvard.Column.FilePath.ToString()), Internal = va.Field <string>(Edvard.Column.Internal.ToString()) }; // .. and compare to Elite Dangerous bindings .. foreach (var voiceattackBinding in voiceattackBindings) { bool commandDefinedInEliteDangerousBindsFile = false; string updateRequirementStatus = "unknown"; string rationale = "unknown"; var elitedangerousBindings = from ed in eliteDangerous.AsEnumerable() where ed.Field <string>(Edvard.Column.KeyAction.ToString()) == voiceattackBinding.EliteDangerousAction select new { Action = ed.Field <string>(Edvard.Column.KeyAction.ToString()), KeyPriority = ed.Field <string>(Edvard.Column.DevicePriority.ToString()), KeyGameValue = ed.Field <string>(Edvard.Column.KeyGameValue.ToString()), KeyEnumerationValue = ed.Field <string>(Edvard.Column.KeyEnumerationValue.ToString()), KeyEnumerationCode = ed.Field <int>(Edvard.Column.KeyEnumerationCode.ToString()), KeyID = ed.Field <string>(Edvard.Column.KeyId.ToString()), ModifierKeyGameValue = ed.Field <string>(Edvard.Column.ModifierKeyGameValue.ToString()), ModifierKeyEnumerationValue = ed.Field <string>(Edvard.Column.ModifierKeyEnumerationValue.ToString()), ModifierKeyEnumerationCode = ed.Field <int>(Edvard.Column.ModifierKeyEnumerationCode.ToString()), ModifierKeyID = ed.Field <string>(Edvard.Column.ModifierKeyId.ToString()), FilePath = ed.Field <string>(Edvard.Column.FilePath.ToString()), Internal = ed.Field <string>(Edvard.Column.Internal.ToString()) }; // Compare matching action bindings with their assigned key value/code to evaluate which key code(s) require re-mapping .. foreach (var elitedangerousBinding in elitedangerousBindings) { commandDefinedInEliteDangerousBindsFile = true; // Assign for later use .. globalEliteDangerousBindsInternal = elitedangerousBinding.Internal; // Check for: satisfactory alignment of regular and modifier key codes .. if ( //// Matching Regular Key Codes with no Modifier Key(s) present .. ((elitedangerousBinding.KeyEnumerationCode == voiceattackBinding.KeyCode) && (elitedangerousBinding.ModifierKeyEnumerationCode == StatusCode.NotApplicableInt)) || //// Matching Regular Key Codes with matching Modifier Key(s) present .. ((elitedangerousBinding.KeyEnumerationCode == voiceattackBinding.KeyCode) && (elitedangerousBinding.ModifierKeyEnumerationCode == voiceattackBinding.ModifierKeyEnumerationCode))) { updateRequirementStatus = Edvard.KeyUpdateRequired.NO.ToString(); rationale = "ED o--o VA Key Codes are aligned"; } else { rationale = string.Empty; // Check for misaligned codes .. if (elitedangerousBinding.KeyEnumerationCode > StatusCode.EmptyStringInt) { updateRequirementStatus = Edvard.KeyUpdateRequired.YES_Elite_TO_VoiceAttack.ToString(); // Check for: misaligned key codes .. if (elitedangerousBinding.KeyEnumerationCode != voiceattackBinding.KeyCode) { rationale += string.Format("Misaligned key codes: ED[{0}] o--O VA[{1}];", elitedangerousBinding.KeyEnumerationCode, voiceattackBinding.KeyCode); } // Check for: misaligned modifier key codes .. if (elitedangerousBinding.ModifierKeyEnumerationCode != voiceattackBinding.ModifierKeyEnumerationCode) { if (voiceattackBinding.ModifierKeyEnumerationCode == StatusCode.EmptyStringInt) { rationale += string.Format("Misaligned modifier key codes: ED[{0}] o--O VA[{1}];", elitedangerousBinding.ModifierKeyEnumerationCode, "no-modifier defined"); } else { rationale += string.Format("Misaligned modifier key codes: ED[{0}] o--O VA[{1}];", elitedangerousBinding.ModifierKeyEnumerationCode, voiceattackBinding.ModifierKeyEnumerationCode); } } } // Check for unresolvable key codes .. if (elitedangerousBinding.KeyEnumerationCode == StatusCode.NoEquivalentKeyFoundAtExchange || elitedangerousBinding.KeyEnumerationCode == StatusCode.NoCodeFoundAfterExchange) { updateRequirementStatus = Edvard.KeyUpdateRequired.NO.ToString(); rationale += string.Format("Unresolvable key code for: ED[{0}];", elitedangerousBinding.KeyGameValue); } // Check for: unresolvable modifier key codes .. if (elitedangerousBinding.ModifierKeyEnumerationCode == StatusCode.NoEquivalentKeyFoundAtExchange || elitedangerousBinding.ModifierKeyEnumerationCode == StatusCode.NoCodeFoundAfterExchange) { updateRequirementStatus = Edvard.KeyUpdateRequired.NO.ToString(); rationale += string.Format("Unresolvable modifier key code for: ED[{0}];", elitedangerousBinding.ModifierKeyGameValue); } } // Append evaluated results to DataTable .. adjustedVoiceAttackCommands.LoadDataRow(new object[] { ////-------------------------------------------------------------------------- voiceattackBinding.KeyEnumeration, //KeyEnumeration ////-------------------------------------------------------------------------- updateRequirementStatus, //ReMapRequired rationale, //Rationale ////-------------------------------------------------------------------------- voiceattackBinding.Action, //VoiceAttackAction voiceattackBinding.EliteDangerousAction, //EliteDangerousAction ////-------------------------------------------------------------------------- voiceattackBinding.KeyValue, //VoiceAttackKeyValue voiceattackBinding.KeyCode, //VoiceAttackKeyCode voiceattackBinding.KeyID, //VoiceAttackKeyId voiceattackBinding.ModifierKeyEnumerationValue, //VoiceAttackKeyEnumerationValue voiceattackBinding.ModifierKeyEnumerationCode, //VoiceAttackModifierKeyCode voiceattackBinding.ModifierKeyID, //VoiceAttackModifierKeyId ////-------------------------------------------------------------------------- elitedangerousBinding.KeyPriority, //EliteDangerousDevicePriority elitedangerousBinding.KeyGameValue, //EliteDangerousKeyValue elitedangerousBinding.KeyEnumerationCode, //EliteDangerousKeyCode elitedangerousBinding.KeyID, //EliteDangerousKeyId elitedangerousBinding.ModifierKeyGameValue, //EliteDangerousModifierKeyValue elitedangerousBinding.ModifierKeyEnumerationCode, //EliteDangerousModifierKeyCode elitedangerousBinding.ModifierKeyID, //EliteDangerousModifierKeyId ////-------------------------------------------------------------------------- voiceattackBinding.Internal, //VoiceAttackInternal voiceattackBinding.FilePath, //VoiceAttackProfile elitedangerousBinding.Internal, //EliteDangerousInternal elitedangerousBinding.FilePath //EliteDangerousFilePath ////-------------------------------------------------------------------------- }, false); } // If not defined or binding space unavailable in Elite Dangerous binding file .. if (!commandDefinedInEliteDangerousBindsFile) { // Append to DataTable updateRequirementStatus = Edvard.KeyUpdateRequired.YES_VoiceAttack_TO_Elite.ToString(); rationale = string.Format("ED[{0}] not bound/bindable to a key", voiceattackBinding.EliteDangerousAction); adjustedVoiceAttackCommands.LoadDataRow(new object[] { ////-------------------------------------------------------------------------- voiceattackBinding.KeyEnumeration, //KeyEnumeration ////-------------------------------------------------------------------------- updateRequirementStatus, //ReMapRequired rationale, //Rationale ////-------------------------------------------------------------------------- voiceattackBinding.Action, //VoiceAttackAction voiceattackBinding.EliteDangerousAction, //EliteDangerousAction ////-------------------------------------------------------------------------- voiceattackBinding.KeyValue, //VoiceAttackKeyValue voiceattackBinding.KeyCode, //VoiceAttackKeyCode voiceattackBinding.KeyID, //VoiceAttackKeyId voiceattackBinding.ModifierKeyGameValue, //VoiceAttackModifierKeyValue voiceattackBinding.ModifierKeyEnumerationCode, //VoiceAttackModifierKeyCode voiceattackBinding.ModifierKeyID, //VoiceAttackModifierKeyId ////-------------------------------------------------------------------------- StatusCode.NotApplicable, //EliteDangerousDevicePriority StatusCode.NotApplicable, //EliteDangerousKeyValue StatusCode.NotApplicableInt.ToString(), //EliteDangerousKeyCode StatusCode.NotApplicable, //EliteDangerousKeyId StatusCode.NotApplicable, //EliteDangerousModifierKeyValue StatusCode.NotApplicableInt.ToString(), //EliteDangerousModifierKeyCode StatusCode.NotApplicable, //EliteDangerousModifierKeyId ////-------------------------------------------------------------------------- voiceattackBinding.Internal, //VoiceAttackInternal voiceattackBinding.FilePath, //VoiceAttackProfile globalEliteDangerousBindsInternal, //EliteDangerousInternal eliteDangerousBinds //EliteDangerousFilePath ////-------------------------------------------------------------------------- }, false); } } return(adjustedVoiceAttackCommands); }