import com.supermap.framework.events.BaseEventDispatcher;
import com.xt.hb.events.NavigationEvent;
import com.xt.hb.utils.CommonUtility;
import com.xt.hb.views.ResShowModel;

import flash.events.MouseEvent;
import flash.geom.Point;
import flash.utils.getDefinitionByName;

import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.core.IVisualElement;
import mx.managers.PopUpManager;

import spark.components.Image;

import com.xt.hb.views.TCKZModel;
import com.xt.hb.utils.RemoteUtils;
import mx.rpc.events.AbstractEvent;
import mx.rpc.events.FaultEvent;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import com.tcb.ConvertListToXML;

public var resShowModel:ResShowModel;



[Bindable]
public var tckzVisible:Boolean=false;

[Bindable]
public var MC:String="";
[Bindable]
public var Type:String="";

[Bindable]
public var M_ZYZS_TCKZ_XML:XML=new XML();


/**
 * 导航栏点击事件
 * 
 * 
 * */
private function navigationMenu(e:NavigationEvent):void
{
	if(!e.data)
		return;
	var param:String = e.data.toString();
	switch(param)
	{
		case "leftMenu":
		{
			showResModel();
			break;
		}
		case "leftHide":
		{
			this.moveLeftPanal();
			break;
		}
		case "rightMenu":
		{
			this.initRightMenu();
			break;
		}
		default:
		{
			break;
		}
	}
}

/**
 * 资源展示左侧导航栏显示
 */ 
private function showResModel():void
{
	this.titleWin.removeAllChildren();
	
	if(!this.resShowModel)
	{
		this.resShowModel = new ResShowModel();
	}
	else
	{
		this.resShowModel.loadLayersAndFeatures();
	}
	this.titleWin.x = 0 - this.resShowModel.width;
	//this.resShowModel.initPage();
	
	this.titleWin.addElement(this.resShowModel);
	
	
	var img:Image = new Image();
	img.source = "flexResources/arrowLeft1.png";
	img.visible = false;
	img.useHandCursor=true;  
	img.buttonMode=true;
	img.addEventListener(MouseEvent.CLICK,hideLeftModel);
	this.titleWin.addElement(img);
	
	this.moveFlag1 = false;
	this.moveLeftPanal();
}

/**
 * 图层控制
 */
public function showTCKZModel():void
{
	var x:Number = FlexGlobals.topLevelApplication.stage.stageWidth - 300;
	var y:Number = 120;
	CommonUtility.showTitleWindow(this.tckzModel,false,x,y);
}

/**
 * 资源展示左侧导航栏显示
 */ 
private function initRightMenu():void
{
	RemoteUtils.callRemote("mapConfigCtl","queryMapList",function(e:AbstractEvent):void{
		if(e is FaultEvent){
			trace("error");
		}else {
			var tcArr:ArrayCollection = ResultEvent(e).result as ArrayCollection;
			FlexGlobals.topLevelApplication.M_ZYZS_TCKZ_XML = 
				new ConvertListToXML().getXMLByList(tcArr,"id","fid","ALL");
			initMap();
		}
	});
}


