当前位置: 首页>>代码示例>>C#>>正文


C# EventDelegate类代码示例

本文整理汇总了C#中EventDelegate的典型用法代码示例。如果您正苦于以下问题:C# EventDelegate类的具体用法?C# EventDelegate怎么用?C# EventDelegate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EventDelegate类属于命名空间,在下文中一共展示了EventDelegate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Post

        /// <summary>
        /// Posts an event to the control's event queue using <see cref="Control.BeginInvoke"/>.
        /// </summary>
        /// <remarks>
        /// If the control's handle is not available, the delegate will not be executed
        /// until the handle is (re-)created.
        /// </remarks>
        /// <param name="method">The method to invoke on the event thread.</param>
        public override void Post(EventDelegate method)
        {
            // Lock on the control to:
            // (1) Prevent events from being posted while the queue is being flushed.
            // (2) Prevent the control's handle from being created or destroyed while this method executes.
            using(Synchronizer.Lock(this.m_Control)) {
                if(this.Disposed) {
                    Debug.WriteLine("WARNING: Ignoring posted event since EventQueue is disposed.",
                        this.GetType().ToString() + "<" + this.m_Control.GetType().Name + ">");
                    return;
                }

                // If InvokeRequired is true, then the control has a handle and
                // we can use BeginInvoke immediately.  Otherwise, it is safe to call
                // IsHandleCreated (it would not be safe if InvokeRequired were true),
                // and if there is a handle, we can also call BeginInvoke from any thread.
                // However, if there are events waiting in our own queue (ie., we're in
                // the middle of a call to FlushEventQueue), then the event must be queued
                // to preserve execution order.
                if(this.m_Queue.Count <= 0 && (this.m_Control.InvokeRequired || this.m_Control.IsHandleCreated)) {
                    this.m_Control.BeginInvoke(method);
                }

                else {
                    // But if there is no handle, we cannot call BeginInvoke, so we'll have to
                    // wait until the control's handle is (re-)created.  Therefore, queue
                    // the delegate and its arguments until OnControlHandleCreated can use it.
                    this.m_Queue.Enqueue(method);
                }
            }
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:39,代码来源:ControlEventQueue.cs

示例2: Awake

	void Awake()
	{
		equipSprite = transform.Find("EquipBg/Sprite").GetComponent<UISprite>();
		nameLabel = transform.Find("NameLabel").GetComponent<UILabel>();
		qualityLabel = transform.Find("QualityLabel/Label").GetComponent<UILabel>();
		damageLabel = transform.Find("DamageLabel/Label").GetComponent<UILabel>();
		hpLabel = transform.Find("HpLabel/Label").GetComponent<UILabel>();
		powerLabel = transform.Find("PowerLabel/Label").GetComponent<UILabel>();
		desLabel = transform.Find("DesLabel").GetComponent<UILabel>();
		levelLabel = transform.Find("LevelLabel/Label").GetComponent<UILabel>();
		btnLabel = transform.Find("EquipButton/Label").GetComponent<UILabel>();

		closeButton = transform.Find("CloseButton").GetComponent<UIButton>();
		equipButton = transform.Find("EquipButton").GetComponent<UIButton>();
		upgradeButton = transform.Find("UpgradeButton").GetComponent<UIButton>();

		//注册按钮点击事件
		EventDelegate ed1 = new EventDelegate(this,"OnClose");
		closeButton.onClick.Add(ed1);

		EventDelegate ed2 = new EventDelegate(this,"OnEquip");
		equipButton.onClick.Add(ed2);

        EventDelegate ed3 = new EventDelegate(this,"OnUpgrade");
        upgradeButton.onClick.Add(ed3);

	}
开发者ID:vin120,项目名称:TaiDou,代码行数:27,代码来源:EquipPopup.cs

示例3: Awake

    private void Awake()
    {
        combatButton = FindButton("Combat");
        knapsackButton = FindButton("Knapsack");
        taskButton = FindButton("Task");
        skillButton = FindButton("Skill");
        shopButton = FindButton("Shop");
        systemButton = FindButton("System");

        EventDelegate ed1 = new EventDelegate(this,"OnCombatClick");
        combatButton.onClick.Add(ed1);

        EventDelegate ed2 = new EventDelegate(this,"OnKnapsackClick");
        knapsackButton.onClick.Add(ed2);

        EventDelegate ed3 = new EventDelegate(this,"OnTaskClick");
        taskButton.onClick.Add(ed3);

        EventDelegate ed4 = new EventDelegate(this,"OnSkillClick");
        skillButton.onClick.Add(ed4);

        EventDelegate ed5 = new EventDelegate(this,"OnShopClick");
        shopButton.onClick.Add(ed5);

        EventDelegate ed6 = new EventDelegate(this,"OnSystemClick");
        systemButton.onClick.Add(ed6);
    }
开发者ID:vin120,项目名称:TaiDou,代码行数:27,代码来源:BottomBar.cs

示例4: AnimateDisappear

 public void AnimateDisappear()
 {
     delegateDisappearFinish = new EventDelegate(DisappearFinish);
     TweenScale.Begin(transform.FindChild("Body").gameObject, 0.2f, new Vector3(0f, 0f, 1f));
     TweenAlpha.Begin(transform.FindChild("BG").gameObject, 0.2f, 0);
     transform.FindChild("Body").GetComponent<TweenScale>().SetOnFinished(delegateDisappearFinish);
 }
开发者ID:streetlab,项目名称:Liveball_baseball,代码行数:7,代码来源:PlayerCardAnimation.cs

示例5: SetOkButton

	public void SetOkButton (EventDelegate okFunction)
	{
		okButton.gameObject.SetActive (true);
		okButton.GetComponent<UIButton> ().onClick.Add (okFunction);
		okSet = true;

	}
开发者ID:rodsordi,项目名称:CheckSpace,代码行数:7,代码来源:Popup.cs

示例6: CreateChCard

    private void CreateChCard()
    {
        for(int idx = 0; idx < maxChCard; ++idx)
        {
            GameObject newChCard = Instantiate(chCardPrefab,
                new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0)) as GameObject;
            CharacterData chData = newChCard.GetComponent<CharacterData>();
            string tmpStr;
            jsonDataSheet[idx].TryGetValue("chName", out tmpStr);
            chData.chName = tmpStr;
            jsonDataSheet[idx].TryGetValue("chType", out tmpStr);
            chData.chType = tmpStr;
            jsonDataSheet[idx].TryGetValue("chLevel", out tmpStr);
            chData.chLevel = int.Parse(tmpStr);
            jsonDataSheet[idx].TryGetValue("detailScript", out tmpStr);
            chData.detailScript = tmpStr;
            jsonDataSheet[idx].TryGetValue("chFaceTextureName", out tmpStr);
            chData.chFaceName = tmpStr;
            chData.InitData();

            //chCard set OnClick Event
            Ed_OnClickChCard = new EventDelegate(this, "OnClickChCard");
            Ed_OnClickChCard.parameters[0].value = chData;
            newChCard.GetComponent<UIButton>().onClick.Add(Ed_OnClickChCard);

            //chCard parenting
            newChCard.transform.parent = uiGridObj.transform;
            newChCard.transform.localScale = new Vector3(1, 1, 1);
            newChCard.transform.localPosition = new Vector3(0, 0, 0);
            
        }
        uiGridObj.GetComponent<UIGrid>().Reposition();
    }
开发者ID:opk4406opk,项目名称:HELLO_MY_WORLD,代码行数:33,代码来源:ChSelectManager.cs

示例7: Awake

    public void Awake()
    {
        desLabel = transform.Find("DesLabel").GetComponent<UILabel>();
        energyLabel = transform.Find("EnergyLabel").GetComponent<UILabel>();
        energyTitleLabel = transform.Find("EnergyTitleLabel").GetComponent<UILabel>();
        btnsignleEnter = transform.Find("BtnSignleEnter").GetComponent<UIButton>();
        btnteamEnter = transform.Find("BtnTeamEnter").GetComponent<UIButton>();

        btnClose = transform.Find("BtnClose").GetComponent<UIButton>();

        tween = transform.GetComponent<TweenScale>();

        //注册按钮点击事件
        EventDelegate ed1 = new EventDelegate(this,"OnSignleEnter");
        btnsignleEnter.onClick.Add(ed1);
        EventDelegate ed2 = new EventDelegate(this, "OnClose");
        btnClose.onClick.Add(ed2);
        EventDelegate.Set(btnteamEnter.onClick, () =>
        {
            OnteamEnter();
        });
        battleController = GameManger._instance.GetComponent<BattleController>();

        battleController.OnGetTeam += this.OnGetTeam;
        battleController.OnWaitTeam += this.OnWaitTeam;
        battleController.OnCancelTeam += this.OnCancelTeam;
    }
开发者ID:1510649869,项目名称:ARPG_project,代码行数:27,代码来源:TranscriptWindow.cs

示例8: Awake

	void Awake(){
		_instance = this;
		headSprite = transform.Find ("HeadSprite").GetComponent<UISprite> ();
		levelLabel = transform.Find ("LevelLabel").GetComponent<UILabel> ();
		nameLabel = transform.Find ("NameLabel").GetComponent<UILabel> ();
		diamondLabel = transform.Find ("DiamondLabel/DiamondNumLabel").GetComponent<UILabel> ();
		coinLabel = transform.Find ("CoinLabel/CoinNumLabel").GetComponent<UILabel> ();

		tween = this.GetComponent<TweenPosition> ();
		closeButton = transform.Find ("CancelButton").GetComponent<UIButton> ();

		changeNameButton = transform.Find ("ChangeNameButton").GetComponent<UIButton> ();
		changeNameGo = transform.Find ("ChangeNameBg").gameObject;
		nameInput = transform.Find ("ChangeNameBg/NameInput").GetComponent<UIInput> ();
		sureButton = transform.Find ("ChangeNameBg/SureButton").GetComponent<UIButton> ();
		cancelButton = transform.Find ("ChangeNameBg/CancelButton").GetComponent<UIButton> ();
		changeNameGo.SetActive (false);

		EventDelegate ed = new EventDelegate(this,"OnButtonCloseClick");
		closeButton.onClick.Add (ed);

		EventDelegate ed2 = new EventDelegate (this, "OnButtonChangeNameClick");
		changeNameButton.onClick.Add (ed2);

		EventDelegate ed3 = new EventDelegate (this, "OnButtonSureClick");
		sureButton.onClick.Add (ed3);

		EventDelegate ed4 = new EventDelegate (this, "OnButtonCancelClick");
		cancelButton.onClick.Add (ed4);


		PlayerInfo._instance.OnPlayerInfoChanged += this.OnPlayerInfoChanged;
	}
开发者ID:ziyihu,项目名称:LordOfSinU3D,代码行数:33,代码来源:PlayerStatus.cs

示例9: Start

	// Use this for initialization
	void Start ()
	{
        DiaryListItem[] items = ResourceLoader.GetInstance().LoadDiaryItems();

	    int index = 0;
	    foreach (DiaryListItem diaryListItem in items)
	    {
	        diaryListItem.listIndex = index;
	        diaryListItem.transform.parent = this.transform;
	        diaryListItem.transform.localPosition = Vector3.zero;
	        diaryListItem.transform.localScale = Vector3.one;

            //동적 이벤트 생성
            UIButton uiButton = diaryListItem.GetComponent<UIButton>();
            EventDelegate eventDelegate = new EventDelegate(clickNotifyTarget, "DiaryListItemButtonPressed");
            eventDelegate.parameters[0] = new EventDelegate.Parameter();
            eventDelegate.parameters[0].obj = diaryListItem.GetComponent<DiaryListItem>();
            eventDelegate.parameters[0].expectedType = typeof(DiaryListItem);
            uiButton.onClick.Add(eventDelegate);

	        ++index;
	    }

        GetComponent<UIGrid>().Reposition();
	}
开发者ID:rjk1872,项目名称:Dress,代码行数:26,代码来源:DiaryItemContainer.cs

示例10: DownloadFileAsync

 public static void DownloadFileAsync(string remoteFilePath, EventDelegate dwnldCompletedDelegate)
 {
     var url = new Uri (SERVER + remoteFilePath);
                 var webClient = new WebClient ();
                 webClient.DownloadDataCompleted += new DownloadDataCompletedEventHandler (dwnldCompletedDelegate);
                 webClient.DownloadDataAsync (url);
 }
开发者ID:shuoguo,项目名称:cross-copy,代码行数:7,代码来源:Server.cs

示例11: changeResources

    public void changeResources(EDragonStateAction stateAction)
    {
        string branch = ConvertSupportor.convertUpperFirstChar(PlayerInfo.Instance.dragonInfo.id);
        float timeFrame = (float)getValueFromDatabase(EAnimationDataType.TIME_FRAME);
        EventDelegate callback = null;

        switch (stateAction)
        {
            case EDragonStateAction.IDLE:
                animationFrames.createAnimation(EDragonStateAction.IDLE, "Image/Dragon/Player/" + branch + "/Idle", timeFrame, true);
                break;
            case EDragonStateAction.MOVE:
                animationFrames.createAnimation(EDragonStateAction.MOVE, "Image/Dragon/Player/" + branch + "/Move", timeFrame, true);
                break;
            case EDragonStateAction.ATTACK:
                animationFrames.createAnimation(EDragonStateAction.ATTACK, "Image/Dragon/Player/" + branch + "/Attack", timeFrame, true);
                callback = new EventDelegate(controller.stateAttack.attackEnemy);
                break;
            case EDragonStateAction.DIE:
                animationFrames.createAnimation(EDragonStateAction.DIE, "Image/Dragon/Player/" + branch + "/Die", timeFrame, true);
                callback = new EventDelegate(controller.stateDie.fadeOutSprites);
                //animationFrames.addEventLastKey(new EventDelegate(controller.stateDie.fadeOutSprites), false);
                break;
        }

        object[] events = (object[])getValueFromDatabase(EAnimationDataType.EVENT);
        if (events.Length != 0)
        {
            animationFrames.addEvent(events, callback, false);
        }
    }
开发者ID:royalknight2902,项目名称:AgeOfFreedom,代码行数:31,代码来源:BabyDragonAnimation.cs

示例12: Awake

    void Awake()
    {
        task = transform.Find("task").GetComponent<UIButton>();
        skill = transform.Find("skill").GetComponent<UIButton>();
        bag = transform.Find("bag").GetComponent<UIButton>();
        combat=transform.Find("combat").GetComponent<UIButton>();
        shop = transform.Find("shop").GetComponent<UIButton>();
        system = transform.Find("system").GetComponent<UIButton>();

        EventDelegate tasked = new EventDelegate(this, "OnTask");
        task.onClick.Add(tasked);

        EventDelegate skilled = new EventDelegate(this, "OnSkill");
        skill.onClick.Add(skilled);

        EventDelegate baged = new EventDelegate(this, "OnBag");
        bag.onClick.Add(baged);
        EventDelegate.Set(combat.onClick, () =>
        {
            OnCombat();
        });
        EventDelegate.Set(shop.onClick, () =>
        {
            OnShop();
        });
        EventDelegate.Set(system.onClick, () =>
        {
            OnSystem();
        });
    }
开发者ID:1510649869,项目名称:ARPG_project,代码行数:30,代码来源:BottonBar.cs

示例13: QuitAnimation

 public void QuitAnimation(EventDelegate.Callback onComplete)
 {
     if (twPosition == null)
         twPosition = objAnimation.GetComponent<TweenPosition>();
     twPosition.PlayReverse();
     EventDelegate.Set(twPosition.onFinished, onComplete);
 }
开发者ID:tinyantstudio,项目名称:UIFrameWork,代码行数:7,代码来源:UIRankDetail.cs

示例14: Start

        public void Start()
        {
            int i = 0;

            List<Room> rooms = new List<Room>();

            rooms.Add(new House());
            rooms.Add(new Deposit());

            foreach (Room room in rooms)
            {
                GameObject newButton = NGUITools.AddChild(gameObject, BuildButton);

                newButton.transform.name = room.Name;

                newButton.GetComponentInChildren<UILabel>().text = room.Name;
                newButton.GetComponentInChildren<UI2DSprite>().sprite2D = room.GetSprite(new Position(0, 0));

                EventDelegate del = new EventDelegate(Cursor.Cursor.Instance, "BuildRoom");

                del.parameters[0].value = room;

                EventDelegate.Set(newButton.GetComponentInChildren<UIButton>().onClick, del);
            }

            GetComponent<UIGrid>().Reposition();
        }
开发者ID:luukholleman,项目名称:Imperator-Fundum,代码行数:27,代码来源:UiRoomGridFiller.cs

示例15: Start

        private void Start()
        {
            List<DressItem> dressItems = DressCreator.Instance.GetDressItemsCategory(dressCagegory);
            foreach (DressItem dressItem in dressItems)
            {
                GameObject listItem = Instantiate(Resources.Load("Object/UI/DressListItem")) as GameObject;
                listItem.transform.parent = transform;
                listItem.transform.localPosition = Vector3.zero;
                listItem.transform.localScale = Vector3.one;
                //이미지 설정
                UISprite uiSprite = listItem.GetComponent<UISprite>();
                uiSprite.atlas = atlas;
                uiSprite.spriteName = dressItem.GetComponent<UISprite>().spriteName;
                uiSprite.MakePixelPerfect();

                //동적 이벤트 생성
                UIButton uiButton = listItem.GetComponent<UIButton>();
                EventDelegate eventDelegate = new EventDelegate(clickNotifyTarget, "DressListItemButtonPressed");
                eventDelegate.parameters[0] = new EventDelegate.Parameter();
                eventDelegate.parameters[0].obj = listItem.GetComponent<DressListItem>();
                eventDelegate.parameters[0].expectedType = typeof (DressListItem);
                uiButton.onClick.Add(eventDelegate);

                //category설정
                DressListItem dressItemList = listItem.GetComponent<DressListItem>();
                dressItemList.dressCategory = dressItem.dressCategory;
                dressItemList.dressCode = dressItem.dressCode;
            }

            GetComponent<UIGrid>().Reposition();
        }
开发者ID:rjk1872,项目名称:Dress,代码行数:31,代码来源:DressItemList.cs


注:本文中的EventDelegate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。