private void InitializeControls(PuzzleTag form) { controlMap = new ControlMap(form); controlProvider = new ControlProvider.ControlProvider(controlMap); customButtonsCollection = new ButtonsCollection(controlMap); customButtonsCollection.InitializeByButtonNameAttribute("custom"); }
void OnMapLoadHandler(ControlMap map) { if (FPSControlSystemInfo.GetPlatform() != FPSControlPlatform.Ouya) return; //if (map is OuyaControlMap) { /*proceed...*/ } //else { Debug.LogWarning("NOT OUYA MAP!"); return; } OuyaControlMap ouyaMap = (OuyaControlMap) map; ouyaMap.look.Initialize(this, this); ouyaMap.movement.Initialize(this, this); ouyaMap.crouch.Initialize(this); ouyaMap.defend.Initialize(this); ouyaMap.fire.Initialize(this); ouyaMap.interact.Initialize(this); ouyaMap.jump.Initialize(this); ouyaMap.reload.Initialize(this); ouyaMap.run.Initialize(this); ouyaMap.scope.Initialize(this); ouyaMap.weapon1.Initialize(this); ouyaMap.weapon2.Initialize(this); ouyaMap.weapon3.Initialize(this); ouyaMap.weapon4.Initialize(this); ouyaMap.weaponToggle.Initialize(this); }
private void Start() { controlMap = new ControlMap(); controlMap.Enable(); controlMap.Player.Jump.performed += ctx => print("pogo pogo pogo"); }
public override bool GetButtonPressed(ControlMap button) { if (mIsDeviceAvailable) { switch (button) { case ControlMap.System: return(mDevice.GetPressDown(SteamVR_Controller.ButtonMask.System)); case ControlMap.Menu: return(mDevice.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)); case ControlMap.Touchpad: return(mDevice.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)); case ControlMap.Trigger: //return mDevice.GetHairTriggerDown(); return(mDevice.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)); case ControlMap.Grip: return(mDevice.GetPressDown(SteamVR_Controller.ButtonMask.Grip)); } } return(false); }
public override bool GetButtonReleased(ControlMap button) { if (mIsDeviceAvailable) { switch (button) { case ControlMap.System: return(false); case ControlMap.Menu: return(false); case ControlMap.Touchpad: return(Input.GetMouseButtonUp(2)); case ControlMap.Trigger: return(Input.GetMouseButtonUp(0)); case ControlMap.Grip: return(Input.GetMouseButtonUp(1)); } } return(false); }
void Start() { _E = GetComponent<EnergyManager>(); _Controls = GameObject.Find("Controls").GetComponent<ControlMap>(); _pSys.enableEmission = false; thisT = transform; _Sheild.SetActive(false); }
private void Awake() { cam = GetComponentInChildren <Camera>().transform; pivot = transform.GetChild(0); map = new ControlMap(); map.Enable(); controller = GetComponent <CharacterController>(); //Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; print("say my name"); }
private void SetDefaultControls() { if (m_Controller.pPlayerIndex == GameData.PlayerIndex.PLAYER1) { m_ControlMap = ControlMap.ASWD_KEYS; } else { m_ControlMap = ControlMap.ARROW_KEYS; } }
// Use this for initialization void Start() { _curPower = 0; _bGunner = GetComponent <BeamGunner>(); CreateBulletPool(); _controls = GameObject.Find("_GameRegistry").GetComponent <ControlMap>(); _data = GameObject.Find("_GameRegistry").GetComponent <DataMap>(); _nextFireTime = Time.time + fireRate; _health = maxHealth; _cam = Camera.main.transform; _mouseMode = _data.GetBool("MouseMode"); }
public void MarkupTagLookupFindsContext() { CleanupTest(); ControlFactory fact = ControlFactory.CreateControlFactory(key, System.Reflection.Assembly.GetExecutingAssembly()); ControlMap map = null; ParseContext context = null; Assert.IsTrue(fact.TryGetControlMap("nest:Child", out map, out context)); Assert.AreEqual(typeof(NestedContext), context.ContainerControlType); //ParseContext context = fact.GetControlContextGroup( }
private string GetPlayerControl(ControlMap map) { switch (map) { case ControlMap.ASWD_KEYS: return("P1_"); case ControlMap.ARROW_KEYS: return("P2_"); default: return(""); } }
void LoadSettings() { _texQualityNames.Clear(); _texQualityNames.Add("Full"); _texQualityNames.Add("Half"); _texQualityNames.Add("Quarter"); _texQualityNames.Add("Eight"); GameObject gameReg = GameObject.Find("_GameRegistry"); _data = gameReg.GetComponent <DataMap>(); _controls = gameReg.GetComponent <ControlMap>(); _setControls = _controls; //Gameplay _mouseMode = _data.GetBool("MouseMode"); //Audio _bgmVol = _data.GetFloat("BGM_Vol"); _sfxVol = _data.GetFloat("SFX_Vol"); _masterVol = _data.GetFloat("Master_Vol"); //Video _vSync = _data.GetBool("VSync"); _resHeight = _data.GetInt("Res_Height"); _resWidth = _data.GetInt("Res_Width"); _resRefresh = _data.GetInt("Res_Refresh"); _AA = _data.GetInt("Anti_Aliasing"); _aniso = _data.GetBool("Aniso_Filtering"); _texQuality = _data.GetInt("Tex_Quality"); _fullscreen = _data.GetBool("Fullscreen"); _resolutions = Screen.resolutions; int i = 0; foreach (Resolution r in _resolutions) { Debug.Log(r.width + ":" + _resWidth + " | " + r.height + ":" + _resHeight + " | " + r.refreshRate + ":" + _resRefresh); if (r.width == _resWidth) { if (r.height == _resHeight) { if (r.refreshRate == _resRefresh) { _resIndex = i; break; } } } i++; } }
public KeyCode GetKeyCode(string keyName) { KeyCode key = KeyCode.None; if (!controlNames.Contains(keyName)) { ControlMap tmp = RegisterDefaultControls(this); controlNames = tmp.controlNames; controlKeys = tmp.controlKeys; } else { key = controlKeys[controlNames.IndexOf(keyName)]; } return(key); }
public override Vector2 GetAxis(ControlMap axis) { if (mIsDeviceAvailable) { switch (axis) { case ControlMap.Touchpad: return(mDevice.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0)); case ControlMap.Trigger: return(mDevice.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis1)); } } return(Vector2.zero); }
public ControlMap RegisterDefaultControls(ControlMap _Controls) { //Debug.Log("Resetting Controls"); _Controls.Clear(); _Controls.RegisterKey("Ability", KeyCode.Space); _Controls.RegisterKey("Up", KeyCode.W); _Controls.RegisterKey("Down", KeyCode.S); _Controls.RegisterKey("Left", KeyCode.A); _Controls.RegisterKey("Right", KeyCode.D); _Controls.RegisterKey("Percise Move", KeyCode.LeftShift); _Controls.RegisterKey("Pause", KeyCode.Escape); _Controls.RegisterKey("Cancel", KeyCode.Escape); _Controls.RegisterKey("Toggle Editor", KeyCode.E); _Controls.RegisterKey("Advance", KeyCode.Space); return(_Controls); }
// Use this for initialization void Start() { if (Application.isEditor) { //PlayerPrefs.SetString("loadPath", "C:/Users/Khamraj/Documents/New Unity Project/Assets/Levels/Custom/New Level.lvl"); } _controls = GameObject.Find("_GameRegistry").GetComponent <ControlMap>(); if (!_currentLevel.Load(PlayerPrefs.GetString("loadPath"))) { _loadFail = true; } PlayerPrefs.SetString("loadPath", ""); _nextWaveTime = Time.time + waveDelay; if (_loadFail) { Destroy(GameObject.FindGameObjectWithTag("Player")); } }
void CreatePlayFeild() { //Cache Track Count _trackCount = _song.trackCount; //Assign default controls _controls = new ControlMap().AddMap(new KeyMap(), _trackCount); //Assign track positions for (int i = 0; i <= _trackCount; i++) _basePositions.Add(Vector2.zero); //Get beat width float beatWidth = beatObject.GetComponent<Image>().rectTransform.rect.width; //Calculate track spacing; float fullWidth = beatWidth + trackSpacing; //Create all beats for (int i = 0; i < _trackCount; i++) { List<Beat> track = _song.tracks[i].beats; _basePositions[i] = new Vector2(((i - ((_trackCount - 1f) / 2f)) * fullWidth), Screen.height); foreach (Beat b in track) { b.startPosition = _basePositions[i].y; Transform beatP; Image B = Utils.CreateUIImage(beatObject, _basePositions[i], beatCanvas, out beatP); if (b.duration <= 0) b.Create(B); else { //Create long beat float trailLenght = Mathf.Lerp(_basePositions[i].y, hitZoneOffset, b.duration / leadTime); Image trail = Utils.CreateUIImage(trailImage, new Vector3(0, 0, 0), beatP); trail.color = _song.tracks[i].color; trail.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, trailLenght); b.Create(B, trail); } B.color = _song.tracks[i].color; } //Create Track lanes Vector2 pos = new Vector2(_basePositions[i].x, hitZoneOffset); Image trackI = Utils.CreateUIImage(trackImage, pos, UIcanvas); trackI.color = _song.tracks[i].color; //Assign default keys to controlmap _controls.AddKey(KeyCode.Space, i, _trackCount); } }
// Use this for initialization void Start() { _controls = GameObject.Find("_GameRegistry").GetComponent <ControlMap>(); if (PlayerPrefs.GetString("editorMode") == "load") { if (_currentLevel.Load(PlayerPrefs.GetString("loadPath"))) { _currentLevel.LevelName = PlayerPrefs.GetString("creating"); _currentLevel.Author = PlayerPrefs.GetString("name"); CreateWave(); } } else { _currentLevel.LevelName = PlayerPrefs.GetString("creating"); _currentLevel.Author = PlayerPrefs.GetString("name"); CreateWave(); } }
public void AutoLoadNegroniFrameworkConfig() { CleanupTest(); string key = "testFactory"; Assert.IsFalse(ControlFactory.IsFactoryDefined(key), "Factory already defined"); ControlFactory cf = ControlFactory.GetControlFactory(key); Assert.IsNotNull(cf); Assert.Greater(cf.GetControlCount(ParseContext.DefaultContext), 5); Assert.IsFalse(cf.LoadErrors.Count > 0, "Load errors encountered"); ControlMap map = cf.GetControlMap("ASpecialContainer"); Assert.IsNotNull(map); Assert.IsFalse(map.ControlType == typeof(GadgetLiteral)); }
public void StartHidInputListening(DeviceConnection connection, DeviceInformation deviceInfo) { if (_bluetoothConnection.IsDeviceConnected) { if (_timer == null) { _timer = new DispatcherTimer(); _timer.Tick += new EventHandler <object>(async(sender, arg) => { RemoteCtrl = ControlMap.GetDataFromHidInputReport(_hidConnection.Report); await _bluetoothConnection.Send(RemoteCtrl); }); _timer.Interval = TimeSpan.FromMilliseconds(50); } _timer.Start(); } }
public ControlMap RegisterDefaultControls(ControlMap _Controls) { Debug.Log("Resetting Controls"); _Controls.Clear(); _Controls.RegisterKey("Accelerate", KeyCode.W); _Controls.RegisterKey("Deccelerate", KeyCode.S); _Controls.RegisterKey("SteerLeft", KeyCode.A); _Controls.RegisterKey("SteerRight", KeyCode.D); _Controls.RegisterKey("RollLeft", KeyCode.Q); _Controls.RegisterKey("RollRight", KeyCode.E); _Controls.RegisterKey("Respawn", KeyCode.R); _Controls.RegisterKey("PowerControl", KeyCode.LeftShift); _Controls.RegisterKey("UseAbility", KeyCode.Space); _Controls.RegisterKey("LookBack", KeyCode.Tab); _Controls.RegisterKey("ToggleScreenLock", KeyCode.Escape); _Controls.RegisterKey("TargetingMode", KeyCode.Mouse1); _Controls.RegisterKey("ChangeShip", KeyCode.C); _Controls.RegisterKey("ActivateSheild", KeyCode.LeftControl); return _Controls; }
void LoadInputSettings() { Debug.Log("Loading Configs"); string configPath = Application.dataPath+"/KeyConfigs.txt"; string dataPath = Application.dataPath+"/DataConfigs.txt"; if(File.Exists(configPath)) { _Controls.LoadMap(File.ReadAllLines(configPath)); } else { Debug.Log("Creating Config File"); StreamWriter configFile = File.CreateText(configPath); _Controls = _Controls.RegisterDefaultControls(_Controls); string[] controlMapping = _Controls.GetMap(); foreach(string s in controlMapping) { configFile.WriteLine(s); } configFile.Flush(); } if(File.Exists(dataPath)) { _Data.LoadMap(File.ReadAllLines(dataPath)); }else { Debug.Log("Creating Data File"); StreamWriter dataFile = File.CreateText(dataPath); _Data = _Data.RegisterDefaultData(_Data); string[] dataMapping = _Data.GetMap(); foreach(string s in dataMapping) { dataFile.WriteLine(s); } dataFile.Flush(); } }
public void LoadAllCFGs() { ControlMap cMap = gameObject.GetComponent <ControlMap>(); DataMap dMap = gameObject.GetComponent <DataMap>(); if (File.Exists(Application.dataPath + "/data.cfg")) { dMap.LoadData(); Debug.Log("Loaded Data File"); } else { dMap = RegisterDefaultData(dMap); } if (File.Exists(Application.dataPath + "/controls.cfg")) { cMap.LoadData(); Debug.Log("Loaded Controls File"); } else { cMap = RegisterDefaultControls(cMap); } }
/// <summary> /// Adds the fileName as a new layer to the map, returning the new layer. /// </summary> /// <param name="fileName">The string fileName of the layer to add</param> /// <returns>The IMapLayer added to the file.</returns> public virtual IMapLayer AddLayer(string fileName) { return(ControlMap.AddLayer(fileName)); }
void Start() { _Controls = GameObject.Find("Controls").GetComponent<ControlMap>(); }
// Use this for initialization void Start() { curTarget = FWDTarget; thisTransform = transform; _Controls = GameObject.Find("Controls").GetComponent<ControlMap>(); }
/// <summary> /// Get the current axis. For 1D axis, use X /// </summary> public abstract Vector2 GetAxis(ControlMap axis);
// Use this for initialization void Start() { Inst = GetComponent<Movement>(); _Controls = GameObject.Find("Controls").GetComponent<ControlMap>(); _Data = GameObject.Find("Controls").GetComponent<DataMap>(); LoadInputSettings(); //Screen.lockCursor = true; wayPoints = GameObject.Find("wp0").GetComponent<WaypointReg>().GetWayPoints(); if(ControlMode == _ControlMode.AI) { // Inst.thisCam.enabled = false; // Inst.thisCam.GetComponent<AudioListener>().enabled = false; if(GetComponent<HUD>() != null) GetComponent<HUD>().enabled = false; } if(Inst == null) Inst = GetComponent<Movement>(); }
/// <summary> /// Check if given button is held down /// </summary> public abstract bool GetButtonDown(ControlMap button);
/// <summary> /// Check if button was pressed from last frame /// </summary> public abstract bool GetButtonPressed(ControlMap button);
//Options Menu Window void OptionsMenu(int windowID) { float left = 40; float top = 80; float pad = 5; float lh = 40; float width = (Screen.width / 2) - 150; if (windowID == 5) //Gameplay { GUI.skin = list; _windowScrollPos[4] = GUI.BeginScrollView(new Rect(left, top, width, 500), _windowScrollPos[4], new Rect(0, 0, width, 500)); GUI.Label(new Rect(0, (lh + pad) * 0, 500, lh), "Player Name"); _playerName = GUI.TextField(new Rect(0, (lh + pad) * 1, 250, lh), _playerName); _mouseMode = GUI.Toggle(new Rect(0, (lh + pad) * 2, 250, lh), _mouseMode, "Mouse Controlled Mode"); GUI.EndScrollView(); if (GUI.Button(new Rect(left, 420, width / 2, 64), "Apply")) { PlayerPrefs.SetString("name", _playerName); _data.RegisterData("MouseMode", _mouseMode); SaveSettings(); } if (GUI.Button(new Rect((width / 2) + left + pad, 420, width / 2, 64), "Revert")) { LoadSettings(); _playerName = PlayerPrefs.GetString("name"); } } if (windowID == 6) //Audio { lh = 40; GUI.skin = list; _windowScrollPos[4] = GUI.BeginScrollView(new Rect(left, top, width, 500), _windowScrollPos[4], new Rect(0, 0, width, 500)); GUI.Label(new Rect(0, (lh + pad) * 0, 500, lh), "Master Volume - " + Round(_masterVol, 100)); _masterVol = GUI.HorizontalSlider(new Rect(0, (lh + pad) * 1, 250, lh), _masterVol, 0, 100); GUI.Label(new Rect(0, (lh + pad) * 2, 500, lh), "Master Volume - " + Round(_bgmVol, 100)); _bgmVol = GUI.HorizontalSlider(new Rect(0, (lh + pad) * 3, 250, lh), _bgmVol, 0, 100); GUI.Label(new Rect(0, (lh + pad) * 4, 500, lh), "Master Volume - " + Round(_sfxVol, 100)); _sfxVol = GUI.HorizontalSlider(new Rect(0, (lh + pad) * 5, 250, lh), _sfxVol, 0, 100); GUI.EndScrollView(); if (GUI.Button(new Rect(left, 420, width / 2, 64), "Apply")) { _data.RegisterData("BGM_Vol", _bgmVol); _data.RegisterData("SFX_Vol", _sfxVol); _data.RegisterData("Master_Vol", _masterVol); SaveSettings(); } if (GUI.Button(new Rect((width / 2) + left + pad, 420, width / 2, 64), "Revert")) { LoadSettings(); _bgmVol = _data.GetFloat("BGM_Vol"); _sfxVol = _data.GetFloat("SFX_Vol"); _masterVol = _data.GetFloat("Master_Vol"); } } if (windowID == 7) //Video { GUI.skin = list; if (_resolutions == null) { _resolutions = Screen.resolutions; } _windowScrollPos[4] = GUI.BeginScrollView(new Rect(left, top, width, 340), _windowScrollPos[4], new Rect(0, 0, width - 16, ((lh + pad) * 10f) + lh + 25)); _vSync = GUI.Toggle(new Rect(0, (lh + pad) * 0, 250, lh), _vSync, "VSync"); GUI.Label(new Rect(0, (lh + pad) * 1f, 250, lh), "Resolution"); if (GUI.Button(new Rect(0, ((lh + pad) * 1.5f), 400, 64), _resolutions[_resIndex].width + "x" + _resolutions[_resIndex].height + " " + _resolutions[_resIndex].refreshRate + "Hz")) { _resIndex++; if (_resIndex > _resolutions.Length - 1) { _resIndex = 0; } } _fullscreen = GUI.Toggle(new Rect(0, (lh + pad) * 3f, 400, lh), _fullscreen, "Fullscreen"); GUI.Label(new Rect(0, (lh + pad) * 4f, 400, lh), "Anti-Ailiasing"); if (GUI.Button(new Rect(0, (lh + pad) * 4.5f, 400, 64), _AA + "x")) { if (_AA == 0) { _AA = 1; } _AA *= 2; if (_AA > 8) { _AA = 0; } } _aniso = GUI.Toggle(new Rect(0, (lh + pad) * 6f, 400, lh), _aniso, "Anisotropic Filtering"); GUI.Label(new Rect(0, (lh + pad) * 7f, 400, lh), "Texture Quality"); if (GUI.Button(new Rect(0, (lh + pad) * 7.5f, 400, 64), _texQualityNames[_texQuality])) { _texQuality++; if (_texQuality > 3) { _texQuality = 0; } } GUI.Label(new Rect(0, (lh + pad) * 9f, 400, lh), "Pixel Light Count: " + _pixelLights); _pixelLights = (int)GUI.HorizontalSlider(new Rect(20, (lh + pad) * 10f, 350, lh), _pixelLights, 1, 100); GUI.EndScrollView(); if (GUI.Button(new Rect(left, 420, width / 2, 64), "Apply")) { _data.RegisterData("VSync", _vSync); _data.RegisterData("Res_Width", _resolutions[_resIndex].width); _resWidth = _resolutions[_resIndex].width; _data.RegisterData("Res_Height", _resolutions[_resIndex].height); _resHeight = _resolutions[_resIndex].height; _data.RegisterData("Res_Refresh", _resolutions[_resIndex].refreshRate); _resRefresh = _resolutions[_resIndex].refreshRate; _data.RegisterData("Fullscreen", _fullscreen); _data.RegisterData("Anti_Aliasing", _AA); _data.RegisterData("Aniso_Filtering", _aniso); _data.RegisterData("Tex_Quality", _texQuality); _data.RegisterData("PixelLights", _pixelLights); SaveSettings(); } if (GUI.Button(new Rect((width / 2) + left + pad, 420, width / 2, 64), "Revert")) { LoadSettings(); //_vSync = _data.GetBool("VSync"); } } if (windowID == 8) { if (_listeningTo >= 0) { ListenToKeys(); } lh = 64; pad = 0; GUI.skin = list; _windowScrollPos[4] = GUI.BeginScrollView(new Rect(left, top, width, 340), _windowScrollPos[4], new Rect(0, 0, width - 16, ((lh + pad) * _setControls.controlKeys.Count))); for (int i = 0; i < _setControls.controlKeys.Count; i++) { GUI.Label(new Rect(0, (lh + pad) * (i), 250, lh), _setControls.controlNames[i]); if (GUI.Button(new Rect(width / 3.5f, (lh + pad) * (i), 250, lh), _setControls.controlKeys[i].ToString())) { _listeningTo = i; Screen.lockCursor = true; } } GUI.EndScrollView(); if (GUI.Button(new Rect(left, 420, width / 2, 64), "Apply")) { _controls = _setControls; SaveSettings(); } if (GUI.Button(new Rect((width / 2) + left + pad, 420, width / 2, 64), "Revert")) { _controls.LoadData(); LoadSettings(); } } }
/// <summary> /// Check if button was released from last frame /// </summary> public abstract bool GetButtonReleased(ControlMap button);
public override Vector2 GetAxis(ControlMap axis) { //TODO: emulate certain axis if needed return(Vector2.zero); }
/// <summary> /// Handle processing within markup contexts consisting only of defined-tag context. /// For processing markup which may contain custom tag templates or recognizes Literal sections, /// use the method <c>HandleOsContainerTagParse</c>. /// </summary> /// <param name="reader"></param> /// <param name="markup"></param> /// <param name="trace"></param> private void HandleContextParse(XmlReader reader, string markup, TracePosition trace) { bool isStartElement = (XmlNodeType.Element == reader.NodeType); bool isEndElement = (XmlNodeType.EndElement == reader.NodeType); if (XmlNodeType.Whitespace == reader.NodeType) { return; } TraceContainerTagInfo containerInfo = trace.GetCurrentContainerTag(); Type t = typeof(GadgetLiteral); //default control type for current tag if (isStartElement || isEndElement) { //if null tag, this is in a ContentBlock ?? //if (String.IsNullOrEmpty(containerInfo.Tag)) //{ // containerInfo.Tag = "Content"; //} if (isEndElement) { int prevCurrentPosition = trace.CurrentPosition; trace.CurrentPosition = markup.IndexOf("</" + reader.Name, trace.CurrentPosition); if (prevCurrentPosition == trace.CurrentPosition && !trace.PriorLoopWasStartElement && reader.Name == trace.PreviousEndTag) { trace.CurrentPosition = markup.IndexOf("</" + reader.Name, trace.CurrentPosition + 1); } trace.PreviousStartTag = null; trace.PriorLoopWasStartElement = false; trace.PreviousEndTag = reader.Name; //check for non-container tag if (trace.InNonContainerControl) { if (reader.Name == trace.CurrentNonContainerTagInfo.Tag && reader.Depth == trace.CurrentNonContainerTagInfo.NodeDepth) { trace.CurrentPosition = GetEndOfTagPosition(markup, trace.CurrentPosition); trace.FlushNonContainerTagOffset(); return; } else { return; } } ControlMap curMap; if (trace.IsInitialized()) { curMap = MyControlFactory.GetControlMap(trace.CurrentOffset.OffsetKey); } else { //special case for CustomTag parsing //Add in a missing context and container if (trace.InStaticTag && trace.StaticTagStartPosition == 0) { trace.StaticTagStartPosition = GetEndOfTagPosition(markup, 0); } trace.AddChildOffset(0, MyControlFactory.GetContextGroupOffsetKey(trace.Context)); //push first element as container tag, if empty if (null == containerInfo.Tag) { trace.AddCurrentNodeAsContainerTag(ControlFactory.GetTagName(markup), 0); containerInfo = trace.GetCurrentContainerTag(); } //this is questionable //curMap = MyControlFactory.GetControlMap(GadgetLiteral.DefaultOffsetKey); curMap = MyControlFactory.GetControlMap(t); } if (reader.Name == containerInfo.Tag && reader.Depth == containerInfo.NodeDepth) { //if (AllowLiteralTags(trace.Context)) //{ //check for final static tag if (trace.InStaticTag) { trace.FlushLiteralControlOffset(); } // } //set closing position SetAscendTraceTree(markup, trace, curMap.IsContextGroupContainer); return; } else if (MyControlFactory.AllowCustomTags(trace.Context) && IsCustomTagDefined(reader.Name)) { //handle closing custom tag so it isn't interpreted as a static t = typeof(CustomTag); } else { //advance to end of current close tag to handle final static script tag //we're in a nested tag that is a static, but the same as the container tag //watch to make sure this is not in error if (reader.Name == containerInfo.Tag) { trace.CurrentPosition = GetEndOfTagPosition(markup, trace.CurrentPosition); } } } else if (isStartElement) { int prevCurrentPosition = trace.CurrentPosition; trace.CurrentPosition = markup.IndexOf("<" + reader.Name, trace.CurrentPosition); if (prevCurrentPosition == trace.CurrentPosition && trace.PriorLoopWasStartElement && reader.Name == trace.PreviousStartTag) { trace.CurrentPosition = markup.IndexOf("<" + reader.Name, trace.CurrentPosition + 1); } trace.PreviousStartTag = reader.Name; trace.PriorLoopWasStartElement = true; trace.PreviousEndTag = null; if (trace.InNonContainerControl) { return; } string fullTag = markup.Substring(trace.CurrentPosition, GetEndOfTagPosition(markup, trace.CurrentPosition) - trace.CurrentPosition); t = MyControlFactory.GetControlType(fullTag, trace.Context); //if custom tag, register it if (ControlFactory.InheritsFromType(t, typeof(CustomTagTemplate))) { string custTag = ControlFactory.GetTagAttributeValue(fullTag, CustomTagTemplate.ATTRIBUTE_TAGDEF); RegisterCustomTag(custTag); } //Look for a custom tag if it is a literal. Then continue or exit if (t == typeof(GadgetLiteral)) { if (MyControlFactory.AllowCustomTags(trace.Context)) { if (IsCustomTagDefined(reader.Name)) { t = typeof(CustomTag); } } if (!MyControlFactory.AllowLiteralTags(trace.Context) && t != typeof(CustomTag)) { return; } } //Look for a non-container control and set value, if required if (t != typeof(GadgetLiteral)) { if (!ControlFactory.InheritsFromType(t, typeof(BaseContainerControl)) && !trace.InNonContainerControl && !reader.IsEmptyElement) { trace.SetCurrentNodeAsNonContainerTag(reader.Name, reader.Depth, MyControlFactory.GetOffsetKey(t, trace.Context)); return; } else if (trace.InStaticTag) //Flush a pending static tag { trace.FlushLiteralControlOffset(); } OffsetItem tempOffset = trace.AddChildOffset(trace.GetLocalPosition(), MyControlFactory.GetOffsetKey(t, trace.Context)); trace.CurrentPosition = GetEndOfTagPosition(markup, trace.CurrentPosition); if (reader.IsEmptyElement) { tempOffset.EndPosition = (trace.GetLocalPosition()); trace.PreviousStartTag = null; trace.PriorLoopWasStartElement = false; } else { //check to see if we're moving into a new context ControlMap curMap = MyControlFactory.GetControlMap(tempOffset.OffsetKey); if (curMap.IsContextGroupContainer) { if (trace.Context.ContainerControlType != curMap.ControlType) { trace.ParseContextStack.Push(new ParseContext(curMap.ControlType)); } //push current as container tag, if empty trace.AddCurrentNodeAsContainerTag(reader.Name, reader.Depth); } else if (ControlFactory.InheritsFromType(curMap.ControlType, typeof(BaseContainerControl))) { trace.AddCurrentNodeAsContainerTag(reader.Name, reader.Depth); } } } } } else { trace.PreviousEndTag = null; trace.PreviousStartTag = null; trace.PriorLoopWasStartElement = false; } //Look for non-container controls if (trace.InNonContainerControl) { return; } //Look for static elements if (!MyControlFactory.AllowLiteralTags(trace.Context)) { return; } else if (t == typeof(GadgetLiteral)) { if (!trace.InStaticTag) { trace.StaticTagStartPosition = trace.CurrentPosition; trace.InStaticTag = true; } return; } }
public ButtonsCollection(ControlMap controlMap) { this.controlMap = controlMap; this.collection = new Dictionary <int, CustomButton>(); }