コード例 #1
0
		/// <summary>Searches the current animated properties for the named property on the given element.</summary>
		/// <param name="animating">The element being animated.</param>
		/// <param name="property">The CSS property to look for. Note: Must not be a composite property such as color-overlay.
		/// Must be a full property such as color-overlay-r.</param>
		/// <returns>An AnimatedProperty if it was found; Null otherwise.</returns>
		public static AnimatedProperty GetAnimatedProperty(Element animating,string property){
			
			// Grab the inner index:
			int innerIndex=Css.Value.GetInnerIndex(ref property);
			
			// Get the property:
			return GetAnimatedProperty(animating,CssProperties.Get(property),innerIndex);
		}
コード例 #2
0
		/// <summary>Removes the given element value from this lookup.</summary>
		/// <returns>True if the cache should also be removed.</returns>
		public bool Remove(string key,Element ele){
			
			AttributeLookupLink chain;
			if(!Lookup.TryGetValue(key,out chain)){
				return false;
			}
			
			AttributeLookupLink previous=null;
			
			// Scan the chain looking for ele:
			while(chain!=null){
				
				if(chain.Element==ele){
					// Chop it out.
					
					if(previous==null){
						
						// Removing the first one.
						
						if(chain.Next==null){
							
							// Obliterate it!
							Lookup.Remove(key);
							
							if(Lookup.Count==0){
								// Remove this cache.
								return true;
							}
							
							return false;
							
						}else{
							
							// We're going to keep this link in the lookup, 
							// rather than removing it and putting the next one in instead.
							
							chain.Element=chain.Next.Element;
							chain.Next=chain.Next.Next;
							
						}
						
					}else{
						
						previous.Next=chain.Next;
						
					}
					
				}
				
				previous=chain;
				chain=chain.Next;
				
			}
		
			return false;
			
		}
コード例 #3
0
		/// <summary>Gets or finds the parent select tag that this option belongs to.</summary>
		/// <param name="element">The element to check if it's a select.</param>
		/// <returns>The select tag handler if found; null otherwise.</returns>
		private SelectTag GetSelect(Element element){
			if(element==null){
				return null;
			}
			if(element.Tag=="select"){
				return (SelectTag)(element.Handler);
			}
			return GetSelect(element.parentNode);
		}
コード例 #4
0
		/// <summary>Gets the index for the given element.</summary>
		/// <param name="element">The element to look for.</param>
		/// <returns>The index of the element.</returns>
		public int GetSelectID(Element element){
			if(Options==null){
				return -1;
			}
			
			for(int i=0;i<Options.Count;i++){
				if(Options[i]==element){
					return i;
				}
			}
			
			return -1;
		}
コード例 #5
0
		/// <summary>Gets all inputs from the given element, adding the results to the given list.</summary>
		/// <param name="results">The list that all results are added to.</param>
		/// <param name="element">The element to check.</param>
		private void GetAllInputs(List<Element> results,Element element){
			List<Element> kids=element.childNodes;
			if(kids==null){
				return;
			}
			for(int i=0;i<kids.Count;i++){
				Element child=kids[i];
				if(child.Tag=="input"||child.Tag=="select"||child.Tag=="textarea"){
					results.Add(child);
				}else{
					GetAllInputs(results,child);
				}
			}
		}
コード例 #6
0
		/// <summary>Searches the current animated properties for the named property on the given element.</summary>
		/// <param name="animating">The element being animated.</param>
		/// <param name="property">The CSS property to look for. Note: Must not be a composite property such as color-overlay.
		/// Must be a full property such as color-overlay-r.</param>
		/// <returns>An AnimatedProperty if it was found; Null otherwise.</returns>
		public static AnimatedProperty GetAnimatedProperty(Element animating,CssProperty property,int innerIndex){
			
			if(FirstProperty==null){
				return null;
			}
			
			AnimatedProperty current=FirstProperty;
			
			while(current!=null){
				if(current.Animating==animating && current.PropertyInfo==property && current.InnerIndex==innerIndex){
					return current;
				}
				
				current=current.PropertyAfter;
			}
			
			return null;
		}
コード例 #7
0
		/// <summary>Adds the given element to this lookup.</summary>
		public void Add(string key,Element ele){
			
			// Create link:
			AttributeLookupLink link=new AttributeLookupLink(ele);
			
			// Already got a link?
			AttributeLookupLink chain;
			if(!Lookup.TryGetValue(key,out chain)){
				
				// Add it now:
				Lookup.Add(key,link);
				return;
			}
			
			// Follow the chain to the end and add it there:
			// We do this because it's rare in comparison to finding the "first" one which is always at the front.
			while(chain.Next!=null){
				chain=chain.Next;
			}
			
			// Add to the end:
			chain.Next=link;
			
		}
コード例 #8
0
		/// <summary>Generates a new html element.</summary>
		/// <returns>A new html element.</returns>
		protected override MLElement CreateTagElement(MLLexer lexer){
			Element tag=new Element(Document,lexer,this);
			if(tag.Handler!=null && tag.Handler.Junk()){
				// Junk tag - prevent it entering the DOM.
				return tag;
			}
			AppendNewChild(tag);
			return tag;
		}
コード例 #9
0
		/// <summary>Appends the given element defined as text.</summary>
		/// <param name="text">The element as text, e.g. "<div id='someNewElement'>".</param>
		/// <returns>The newly created element.</returns>
		public Element appendChild(string text){
			Element element=new Element(text,this);
			AppendNewChild(element);
			return element;
		}
コード例 #10
0
		/// <summary>Removes the given child from this element.</summary>
		/// <param name="element">The child element to remove.</param>
		public void removeChild(Element element){
			if(ChildNodes!=null){
				ChildNodes.Remove(element);
			}
			
			element.ParentNode=null;
			element.RemovedFromDOM();
			Document.Renderer.RequestLayout();
		}
コード例 #11
0
		/// <summary>Creates a new element for the given document and as a child of the given parent with content to parse.</summary>
		/// <param name="document">The document that this element will belong to.</param>
		/// <param name="lexer">An MLLexer containing the tag. No children are read; Just this tag only.</param>
		/// <param name="parent">The element that this element will be parented to.</param>
		private Element(Document document,MLLexer lexer,Element parent):this(document,parent){
			ReadTag(lexer);
		}
コード例 #12
0
//--------------------------------------
コード例 #13
0
		/// <summary>Called when the element is focused.</summary>
		public override void OnFocus(){
			if(!IsTextInput()||Cursor!=null){
				return;
			}
			// Add a cursor.
			Element.appendInnerHTML("<div class='cursor'></div>");
			Cursor=Element.getElementByAttribute("class","cursor");
			CursorIndex=0;
		}
コード例 #14
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            speed        = 0f;
            ActiveScreen = UIName.Landing;
        }

        if (movementInitiated())
        {
            //nextStep();
        }

        move();

        Vector3 transl = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0f) +
                         new Vector3(0f, 0f, 25f * Input.GetAxis("Mouse ScrollWheel"));

        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
        {
            bool reverse = false;
                        #if UNITY_IOS
            reverse = true;
                        #endif
            var delts = Input.GetTouch(0).deltaPosition;
            transl -= new Vector3(reverse ? -1f * delts.y : delts.x, reverse ? delts.x : delts.y, 0f) * -0.0005f * transform.position.z;

            if (Input.touchCount == 2)
            {
                // Store both touches.
                Touch touchZero = Input.GetTouch(0);
                Touch touchOne  = Input.GetTouch(1);

                // Find the position in the previous frame of each touch.
                Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
                Vector2 touchOnePrevPos  = touchOne.position - touchOne.deltaPosition;

                // Find the magnitude of the vector (the distance) between the touches in each frame.
                float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
                float touchDeltaMag     = (touchZero.position - touchOne.position).magnitude;

                // Find the difference in the distances between each frame.
                float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;

                transl -= new Vector3(0f, 0f, deltaMagnitudeDiff * -0.0005f * transform.position.z);
            }
        }

        if (transform.position.z + transl.z > -0.5f)         //don't go down too far
        {
            transl += new Vector3(0f, 0f, -0.5f - transform.position.z);
        }

        if (movementEnabled)
        {
            transform.position += transl;
            elasticConnection.InitialMovementRelation += transl;
        }

        //show/hide the refresh button
        //Debug.Log(MapLabel.LabelCount);
        if (MapLabel.LabelCount == 0)
        {
            PowerUI.UI.document.getElementById("refreshButton").className = "button refreshButton landingButton";
        }
        else
        {
            PowerUI.UI.document.getElementById("refreshButton").className = "button landingButton hidden";
        }

        if (ActiveScreen == UIName.WhereFrom || ActiveScreen == UIName.WhereTo)         //implement a scroll-by-swipe manually
        {
            if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                string          elId  = ActiveScreen == UIName.WhereFrom ? "fromSearchResults" : "toSearchResults";
                PowerUI.Element el    = PowerUI.UI.document.getElementById(elId);
                var             touch = Input.GetTouch(0);

                Vector2 scrollAmount = touch.deltaPosition;
                //(Input.GetTouch(0).position);
                Vector2 point = touch.position - scrollAmount;
                if (el.Style.Computed.Contains((int)point.x, (int)point.y))
                {
                    scrollAmount *= 5;
                    el.scrollBy(0, (int)scrollAmount.y);
                }
            }
        }

        //Debug.Log(PowerUI.UI.document.getElementById("refreshButton").className);
    }
コード例 #15
0
		/// <summary>Creates a new element with the given tag and parent.</summary>
		/// <param name="tag">The tag, e.g. "<div id='hello'>".</param>
		/// <param name="parent">The element to parent to.</param>
		public Element(string tag,Element parent):this(parent.Document,new MLLexer(tag),parent){}
コード例 #16
0
		/// <summary>The user clicked on the given link which points to the given path.</summary>
		public virtual void OnFollowLink(Element linkElement,FilePath path){}
コード例 #17
0
		/// <summary>Creates a new UIAnimation for animating CSS and immediately animates it.
		/// See <see cref="PowerUI.Element.animate"/>.</summary>
		/// <param name="animating">The element being animated.</param>
		/// <param name="properties">The CSS property string. Each property should define the value it will be when the animation is done.</param>
		/// <param name="constantSpeedTime">How long this animation lasts for at a constant speed.</param>
		/// <param name="timeToAccelerateFor">How long this animation accelerates for. Creates smooth animations when used.</param>
		/// <param name="timeToDecelerateFor">How long this animation decelerates for. Creates smooth animations when used.</param>
		public UIAnimation(Element animating,string properties,float constantSpeedTime,float timeToAccelerateFor,float timeToDecelerateFor){
			Animating=animating;
			ElementStyle=Animating.Style;
			
			if(string.IsNullOrEmpty(properties)){
				Wrench.Log.Add("No properties given to animate!");
				return;
			}
			
			if(constantSpeedTime<0f){
				constantSpeedTime=0f;
			}
			
			if(timeToAccelerateFor<0f){
				timeToAccelerateFor=0f;
			}
			
			if(timeToDecelerateFor<0f){
				timeToDecelerateFor=0f;
			}
			
			TotalTime=(timeToDecelerateFor + timeToAccelerateFor + constantSpeedTime);
			
			ConstantSpeedTime=constantSpeedTime;
			TimeToAccelerateFor=timeToAccelerateFor;
			TimeToDecelerateFor=timeToDecelerateFor;
			
			if(TotalTime==0f){
				// Instant - probably a fault somewhere in the users request, so we won't do anything.
				Wrench.Log.Add("Instant css animation request ignored. Told to take no time to transition.");
				return;
			}
			
			if(timeToDecelerateFor==0f){
				Decelerate=false;
			}else{
				Decelerate=true;
				DecelerateAt=timeToAccelerateFor + constantSpeedTime;
			}
			
			if( properties.StartsWith(".") || properties.StartsWith("#") ){
				
				// Targeting a selector, e.g. #fadedBox
				// First, get the selector style:
				Css.SelectorStyle selector=animating.Document.getStyleBySelector(properties);
				
				if(selector==null){
					return;
				}
				
				// Animate each property:
				foreach(KeyValuePair<CssProperty,Css.Value> kvp in selector.Properties){
					
					
					// Is it a composite property?
					Css.Value value=kvp.Value;
					
					// Grab the type:
					Css.ValueType type=value.Type;
					
					if(type==Css.ValueType.Null || type==Css.ValueType.Text){
						// Can't deal with either of these.
						continue;
					}
					
					if(type==Css.ValueType.Rectangle || type==Css.ValueType.Point || type==Css.ValueType.Color){
						
						// Animate it (note that we don't need to copy it):
						AnimateComposite(kvp.Key,value);
					}else{
						
						// Animate it (note that we don't need to copy it):
						Animate(kvp.Key,-1,value,true);
					}
					
				}
				
				return;
			}
			
			string[] propertySet=properties.Split(';');
			
			foreach(string currentProperty in propertySet){
				if(currentProperty==""){
					continue;
				}
				
				string[] keyValue=currentProperty.Split(Css.Style.Delimiter,2);
				
				if(keyValue.Length!=2){
					continue;
				}
				
				string key=keyValue[0].Trim();
				
				if(key=="opacity"){
					key="color-overlay-a";
				}
				
				// Grab the inner index:
				int innerIndex=Css.Value.GetInnerIndex(ref key);
				
				// Get the property:
				CssProperty property=CssProperties.Get(key);
				
				if(property==null){
					Wrench.Log.Add("Warning: CSS property '"+keyValue[0]+"' not found during animate.");
					continue;
				}
				
				// Trim shouldn't be applied to inner-text's value, but we can't animate that anyway! This is all we need to do:
				string value=keyValue[1].Trim();
				
				// Key could be a composite property - for example padding, which needs to be broken down into it's individual inner elements (e.g. padding-left)
				
				Css.ValueType type;
				
				if(innerIndex==-1){
					type=Css.Value.TypeOf(property,ref value);
				}else{
					type=Css.Value.TypeOf(value);
				}
				
				if(type==Css.ValueType.Null || type==Css.ValueType.Text){
					// Can't deal with either of these.
					continue;
				}else if(type==Css.ValueType.Rectangle || type==Css.ValueType.Point || type==Css.ValueType.Color){
					// We have a composite property (and we're animating the whole thing).
					Css.Value tempValue=new Css.Value();
					tempValue.Set(value,type);
					
					// Animate it:
					AnimateComposite(property,tempValue);
				}else{
					Animate(property,innerIndex,new Css.Value(value,type),true);
				}
			}
		}
コード例 #18
0
		/// <summary>Submits the given form to the given path using this protocol.</summary>
		public virtual void OnPostForm(FormData form,Element formElement,FilePath path){}
コード例 #19
0
		public override bool OnAttributeChange(string property){
			if(base.OnAttributeChange(property)){
				return true;
			}
			
			if(property=="type"){
				string type=Element["type"];
				if(type==null){
					type="text";
				}
				// Change the style. This requests a layout internally.
				Element.Style.Computed.SetSelector(Css.SelectorType.Tag,"input[type=\""+type+"\"]");
				
				if(type=="radio"){
					Type=InputType.Radio;
				}else if(type=="checkbox"){
					Type=InputType.Checkbox;
				}else if(type=="vscroll"){
					Type=InputType.VScroll;
					Element.innerHTML="<scrollup><vscrolltab><scrolldown>";
				}else if(type=="hscroll"){
					Type=InputType.HScroll;
					Element.innerHTML="<scrollleft><hscrolltab><scrollright>";
				}else if(type=="submit"){
					Type=InputType.Submit;
					SetValue("Submit");
				}else if(type=="button"){
					Type=InputType.Button;
				}else if(type=="hidden"){
					Type=InputType.Hidden;
				}else{
					Type=InputType.Text;					
					Hidden=(type=="password");
				}
				
				return true;
			}else if(property=="maxlength"){
				
				string value=Element["maxlength"];
				
				if(string.IsNullOrEmpty(value)){
					// It's blank - set it to the default.
					MaxLength=int.MaxValue;
				}else{
					// Parse the maximum length from the string:
					if(int.TryParse(value,out MaxLength)){
						// Clip the value if we need to:
						if(Value!=null && Value.Length>MaxLength){
							SetValue(Value);
						}
					}else{
						// Not a number!
						MaxLength=int.MaxValue;
					}
				}
				
				return true;
			}else if(property=="target"){
				TargetName=Element["target"];
				TargetElement=null;
				return true;
			
			}else if(property=="checked"){
				
				// Get the checked state:
				string state=Element["checked"];
				
				// Awkwardly, null/ empty is checked.
				// 0 or false are not checked, anything else is!
				
				if( string.IsNullOrEmpty(state) ){
					
					Select();
					
				}else{
					state=state.ToLower().Trim();
					
					if(state=="0" || state=="false"){
						
						Unselect();
						
					}else{
						
						Select();
						
					}
					
				}
				
				RequestLayout();
				return true;
			}else if(property=="value"){
				SetValue(Element["value"]);
				return true;
			}else if(property=="content"){
				SetValue(Element["content"],true);
				return true;
			}
			return false;
		}
コード例 #20
0
		/// <summary>Called when the element is unfocused/blurred.</summary>
		public override void OnBlur(){
			if(Cursor==null){
				return;
			}
			// Remove the cursor:
			Cursor.parentNode.removeChild(Cursor);
			Cursor=null;
		}
コード例 #21
0
		/// <summary>Adds the given element to the children of this element.</summary>
		/// <param name="element">The child element to add.</param>
		public void appendChild(Element element){
			// Append:
			AppendNewChild(element);
			// And update it's css by telling it the parent changed.
			// This affects inherit, height/width etc.
			element.style.Computed.ParentChanged();
		}
コード例 #22
0
		public override void OnTagLoaded(){
			// Append the text,dropdown and button.
			
			// Grab the options:
			Options=Element.childNodes;
			// Clear the childnodes - this prevents the .innerHTML below clearing the list we just grabbed.
			Element.childNodes=null;
			// Clear the innerHTML of our dropdown and write in the new content (e.g. the button/dropdown itself).
			Element.innerHTML="<span style='height:100%;'></span><ddbutton>";
			// Next, grab the element we want from our new innerHTML.
			// Text, for showing the current selection.
			DisplayText=Element.childNodes[0];
			
			if(Options!=null){
				// Find the selected option, if there is one:
				for(int i=Options.Count-1;i>=0;i--){
					Element element=Options[i];
					OptionTag optionTag=element.Handler as OptionTag;
					
					if(optionTag!=null && optionTag.Selected){
						// Found the selected option. The last option is used (thus we go through it backwards).
						// Must be done like this because this tags innerHTML won't be available until this occurs for the select to display.
						SetSelected(element);
						break;
					}
				}
			}
			
			if(SelectedIndex!=-1){
				return;
			}
			// Nothing had the selected attribute (<option .. selected ..>); if it did, it would have SetSelected already.
			// We'll select the first one by default, if it exists.
			// -2 Prompts it to not call onchange, then set index 0.
			SetSelected(-2);
		}
コード例 #23
0
		/// <summary>Adds the given element to the children of this element.
		/// Note that this does not update CSS; it should be used for new elements only.</summary>
		/// <param name="element">The child element to add.</param>
		public void AppendNewChild(Element element){
			if(element==null){
				return;
			}
			
			element.ParentNode=this;
			
			element.Document=Document;
			
			if(Document.AttributeIndex!=null){
				// Index element if needed:
				element.AddToAttributeLookups();
			}
			
			if(ChildNodes==null){
				ChildNodes=new List<Element>();
			}
			
			ChildNodes.Add(element);
			Document.Renderer.RequestLayout();
		}
コード例 #24
0
		/// <summary>Sets the option at the given index as the selected one.</summary>
		/// <param name="index">The index of the option to select.</param>
		/// <param name="element">The element at the given index.</param>
		/// <param name="runOnChange">True if the onchange event should run.</param>
		private void SetSelected(int index,Element element,bool runOnChange){
			if(index==SelectedIndex){
				return;
			}
			
			SelectedIndex=index;
			
			if(index<0||element==null){
				// Clear the option text:
				DisplayText.innerHTML="";
			}else{
				DisplayText.innerHTML=element.innerHTML;
			}
			
			// Call onchange, but only if the dropdown didn't auto select this option because it's starting up.
			if(runOnChange){
				Element.Run("onchange");
			}
		}
コード例 #25
0
		/// <summary>Creates a new html word element.</summary>
		/// <param name="document">The document this word will belong to.</param>
		/// <param name="parent">The parent html element. Should be a TextElement.</param>
		/// <param name="text">The text of this word.</param>
		public WordElement(Document document,Element parent,string text):base(document,parent){
			SetTag("word");
			
			// Words are CSS driven:
			style.innerText=text;
		}
コード例 #26
0
    void initUI()
    {
        UIName startScreen = activeScreen;

        //hide everything except for what you're starting on
        System.Array all = System.Enum.GetValues(typeof(UIName));
        foreach (UIName u in all)
        {
            if (u != startScreen)
            {
                hideScreen((UIName)u);
            }
        }

        //set up events for the map screen
        trackedEvents["startDirections"] = delegate(PowerUI.UIEvent mouseEvent){
            resetGUI();
            ActiveScreen = UIName.WhereFrom;
        };


        PowerUI.UI.document.getElementById("getDirectionsButton").OnClick += trackedEvents["startDirections"];

        PowerUI.UI.document.getElementById("backToLandingButton").OnClick += delegate(PowerUI.UIEvent mouseEvent){
            ActiveScreen = UIName.Landing;
        };

        var floorSelectDiv = PowerUI.UI.document.getElementById("floorSelectDiv");

        for (int i = 0; i < MapMaker.floors.Length; i++)
        {
            PowerUI.Element nEl = new PowerUI.Element("div");
            nEl.className   = "button floorSelectButton";
            nEl.textContent = i == 0 ? "Ground floor" : "Floor " + i;
            var k = i;            //we don't want a reference to the old variable gunking up the works
            nEl.OnClick += delegate(PowerUI.UIEvent mouseEvent){
                floorSelectDiv.childNodes[MapMaker.ActiveFloor != null ? MapMaker.ActiveFloor.Id - 1 : 0].className = "button floorSelectButton";
                MapMaker.ActiveFloor = MapMaker.floors[k];
                nEl.className        = "button floorSelectButton floorSelectButtonHighlighted";
            };
            floorSelectDiv.AppendNewChild(nEl);
        }
        floorSelectDiv.childNodes[MapMaker.ActiveFloor != null ? MapMaker.ActiveFloor.Id - 1 : 0].className = "button floorSelectButton floorSelectButtonHighlighted";

        //set up events for the landing screen
        PowerUI.UI.document.getElementById("browseButton").OnClick += delegate(PowerUI.UIEvent mouseEvent){
            ActiveScreen = UIName.Map;
            startBrowse();
        };
        PowerUI.UI.Variables["refreshDisplayType"] = "block";

        PowerUI.UI.document.getElementById("refreshButton").OnClick += delegate(PowerUI.UIEvent mouseEvent){
            MapMaker.instance.startMarkerUpdate();
        };

        PowerUI.UI.document.getElementById("startButton").OnClick += trackedEvents["startDirections"];

        //set up events for the where from? page
        PowerUI.UI.document.getElementById("backToStartButton").OnClick += delegate(PowerUI.UIEvent mouseEvent){
            ActiveScreen = UIName.Landing;
        };

        PowerUI.UI.document.getElementById("fromLobbyButton").OnClick += delegate(PowerUI.UIEvent mouseEvent){
            poiFrom      = (MapLabel.MapLabels != null && MapLabel.MapLabels.ContainsKey(103)) ? MapLabel.MapLabels[103] : poiMarkers[0];
            ActiveScreen = UIName.WhereTo;
            PowerUI.UI.Variables["fromLabel"] = poiFrom.Label;
        };

        trackedEvents["fromListener"] = delegate(PowerUI.UIEvent keyEvent){
            //Debug.Log(keyEvent.keyCode);
            string term = PowerUI.UI.document.getElementById("fromSearch").value;
            if (term == null)
            {
                term = "";
            }


            List <MapLabel> search = MapLabel.Search(poiMarkers, term);

            var resultDiv = PowerUI.UI.document.getElementById("fromSearchResults");
            resultDiv.innerHTML = "";

            foreach (MapLabel m in search)
            {
                MapLabel        ml  = m;
                PowerUI.Element nEl = new PowerUI.Element("div");
                nEl.className   = "button searchResult";
                nEl.textContent = ml.Label;
                nEl.style.width = (PowerUI.UI.document.getElementById("fromSearch").pixelWidth - 50) + "px";
                nEl.OnClick    += delegate(PowerUI.UIEvent mouseEvent){
                    poiFrom      = ml;
                    ActiveScreen = UIName.WhereTo;
                    PowerUI.UI.Variables["fromLabel"] = ml.Label;
                };
                resultDiv.AppendNewChild(nEl);
            }
        };
        PowerUI.UI.document.getElementById("fromSearch").OnKeyUp += trackedEvents["fromListener"];

        //set up events for the where to? page
        PowerUI.UI.document.getElementById("backToFromButton").OnClick += delegate(PowerUI.UIEvent mouseEvent){
            ActiveScreen = UIName.WhereFrom;
        };

        trackedEvents["toListener"] = delegate(PowerUI.UIEvent keyEvent){
            //Debug.Log(keyEvent.keyCode);
            string term = PowerUI.UI.document.getElementById("toSearch").value;
            if (term == null)
            {
                term = "";
            }


            List <MapLabel> search = MapLabel.Search(poiMarkers, term);

            var resultDiv = PowerUI.UI.document.getElementById("toSearchResults");
            resultDiv.innerHTML = "";

            foreach (MapLabel m in search)
            {
                MapLabel        ml  = m;
                PowerUI.Element nEl = new PowerUI.Element("div");
                nEl.className   = "button searchResult";
                nEl.textContent = ml.Label;
                nEl.style.width = (PowerUI.UI.document.getElementById("toSearch").pixelWidth - 50) + "px";
                nEl.OnClick    += delegate(PowerUI.UIEvent mouseEvent){
                    poiTo        = ml;
                    ActiveScreen = UIName.Confirm;
                    PowerUI.UI.Variables["toLabel"] = ml.Label;
                };
                resultDiv.AppendNewChild(nEl);
            }
        };
        PowerUI.UI.document.getElementById("toSearch").OnKeyUp += trackedEvents["toListener"];

        //set up events for the confirm page
        PowerUI.UI.document.getElementById("backToToButton").OnClick += delegate(PowerUI.UIEvent mouseEvent){
            ActiveScreen = UIName.WhereTo;
        };

        PowerUI.UI.document.getElementById("goButton").OnClick += delegate(PowerUI.UIEvent mouseEvent){
            ActiveScreen = UIName.Map;
            resetGUI();
            startNavigation();
        };

        foreach (var el in PowerUI.UI.document.getElementsByClassName("searchResults"))
        {
            int delta = el.id == "fromSearchResults" ? 375 : 275;
            el.style.height     = (Screen.height - delta) + "px";
            el.style.marginLeft = (int)(Screen.width / 2f - 300) + "px";
        }
    }
コード例 #27
0
		/// <summary>Sets the given element as the selected option.</summary>
		/// <param name="element">The option to set as the selected value.</param>
		public void SetSelected(Element element){
			// Find which option # the element is.
			// And set the innerHTML text to the option text. 
			int index=GetSelectID(element);
			
			if(index==SelectedIndex){
				return;
			}
			
			SetSelected(index,element,true);
		}
コード例 #28
0
		/// <summary>Used only by scrollbars. Gets the target element to be scrolled.</summary>
		/// <returns>The target element.</returns>
		public Element GetTarget(){
			if(TargetElement!=null){
				return TargetElement;
			}
			
			if(!string.IsNullOrEmpty(TargetName)){
				TargetElement=Element.Document.getElementById(TargetName);
			}
			
			bool isParent=false;
			
			if(TargetElement==null){
				// The parent of the scrollbar.
				TargetElement=Element.parentNode;
				isParent=true;
			}
			
			if(TargetElement!=null){
				if(Type==InputType.VScroll){
					TargetElement.VerticalScrollbar=this;
					TargetElement.VScrollbar=isParent;
				}else{
					TargetElement.HorizontalScrollbar=this;
					TargetElement.HScrollbar=isParent;
				}
			}
			
			return TargetElement;
		}
コード例 #29
0
		/// <summary>Checks if the given element is a child of this element.</summary>
		/// <param name="childElement">The element to check if it's a child of this or not.</param>
		/// <returns>True if the given element is actually a child of this.</returns>
		public bool isChild(Element childElement){
			if(ChildNodes==null){
				return false;
			}
			
			for(int i=0;i<ChildNodes.Count;i++){
				if(ChildNodes[i]==childElement){
					return true;
				}
			}
			
			return false;
		}
コード例 #30
0
		/// <summary>Creates a new text element that belongs to the given document.</summary>
		/// <param name="document">The document this element belongs to.</param>
		/// <param name="parent">The parent element for this new element.</param>
		public TextElement(Document document,Element parent):base(document,parent){
			SetTag("span");
		}
コード例 #31
0
		public override void OnFollowLink(Element linkElement,FilePath path){
			string target=linkElement["target"];
			if(target!=null && target=="_blank"){
				// Open the given url.
				Application.OpenURL(path.Url);
				return;
			}
			
			// Clear the document so it's obvious to the player the link is now loading:
			linkElement.Document.innerHTML="";
			linkElement.Document.location=path;
			
			// Load the html. Note that path.Url is fully resolved at this point:
			TextPackage package=new TextPackage(path.Url,"");
			package.ExtraData=linkElement.Document;
			package.Get(GotLinkText);
		}
コード例 #32
0
		/// <summary>Creates a new element for the given document and as a child of the given parent.</summary>
		/// <param name="document">The document that this element will belong to.</param>
		/// <param name="parent">The element that this element will be parented to.</param>
		public Element(Document document,Element parent){
			Document=document;
			ParentNode=parent;
			Style=new ElementStyle(this);
		}