protected override void ReadViewModeValueCore() { string linkPropertyName = PropertyName.ToClientIdentifier() + "Link"; CalculatedField linkCalculatedProperty = ClientModelManager.RegisterProperty(linkPropertyName); linkCalculatedProperty.Getter = String.Format(@"var origValue = {0}; var result = origValue; if (origValue) {{ var phoneMatch = origValue.match(/\d/g); if (origValue.indexOf('@') !== -1) {{ result = 'mailto://' + origValue; }} else if(phoneMatch && phoneMatch.length === 10) {{ result = 'tel:' + origValue; }} else if(origValue.indexOf('://') == -1) {{ result = 'http://' + origValue; }} else {{ result = origValue; }} }} return result;", BindToCurrentObjectProperty()); LinkComponent linkControl = ((LinkComponent)Control); linkControl.Text = BindToCurrentObjectProperty(); linkControl.Link = BindToProperty(linkPropertyName); }
protected override object CreateViewModeControlCore() { LinkComponent editor = new LinkComponent(); editor.AddStyle("padding", "0px"); return(editor); }
public override void OnAddedToEntity() { _animator = Entity.AddComponent <SpriteAnimator>(); _animator.AddAnimationsFromAtlas(_spriteAtlas); _player = Entity.Scene.FindEntity("player"); _linkComponent = _player.GetComponent <LinkComponent>(); }
public override void setUp(GraphComponent graphComponent) { this.graphComponent = graphComponent; LinkComponent link = (LinkComponent)graphComponent; this.formBasicShape((InteractiveComponent)graphComponent); this.displaySprite("Square"); Transform middle = this.transform.Find("MiddleBody"); //makes the middle a little bit wider Vector3 localScale = middle.transform.localScale; middle.transform.localScale = new Vector3(localScale.x, 1.5f, localScale.z); Vector3 moveDirection = new Vector3(0, -.45f, 0); if (graphComponent.GetType() == typeof(GraphOutput)) { moveDirection.y = -moveDirection.y; } middle.localPosition = moveDirection; //adds the canvas to the component SpriteRenderer rend = middle.GetChild(0).GetComponent <SpriteRenderer>(); rend.transform.localScale = Vector3.one; string labelPrefabName = "LGBridgeLabel"; GameObject labelPrefab = (GameObject)SceneResouces.SceneObjects["Default"][typeof(GameObject)][labelPrefabName]; GameObject labelGameObject = GameObject.Instantiate(labelPrefab); labelGameObject.transform.SetParent(rend.transform, false); labelGameObject.transform.localPosition = Vector3.zero; RectTransform labelRect = labelGameObject.GetComponent <RectTransform>(); labelRect.sizeDelta = new Vector2(rend.bounds.size.x, rend.bounds.size.y); labelGameObject.transform.GetChild(0).GetComponent <Text>().text = link.getName(); float panelWidth = labelRect.rect.width; float panelHeight = labelRect.rect.height; //so the text is not upside down if (link.Rotation > 1) { labelGameObject.transform.Rotate(new Vector3(0, 0, 180)); } }
public void Run() { foreach (var i in filter) { if (filter.GetEntity(i).Has <LinkComponent>()) { LinkComponent linkComponent = filter.Get1(i); if (linkComponent.link.Has <ValueComponent>()) { ref var value = ref linkComponent.link.Get <ValueComponent>(); // value.value += 1; } else { Debug.Log("no value component !"); } } }