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


C# Button.ToString方法代码示例

本文整理汇总了C#中Button.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Button.ToString方法的具体用法?C# Button.ToString怎么用?C# Button.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Button的用法示例。


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

示例1: openPopup

    public void openPopup(Button button, GameObject menu, int buildingOptionIndex)
    {
        int index = getIndex (menu);//get the index of this menu which is also the index of the popup menu

        TileScript selectedTileScript = selectedTiles [index].GetComponent<TileScript>();//get the tile that will hold the building we want to build
        string buttonAsString = button.ToString().Split('(', ' ')[0];//get the button name so that it can be used to find the correct building
        GameObject building = null;
        for (int i = 0; i<buildingOptions.Length; i++) {

            //split the string to get it's name
            string buildingAsString = buildingOptions[i].ToString().Split('(', ' ')[0];//get the building name so that it can be used to find the correct building

            if(buttonAsString.Equals(buildingAsString)){//if it is the correct building
                building = buildings[i];
                break;
            }
        }

        //Get the script that holds all of the cost and growth values for the building
        BuildingScript buildingScript = building.GetComponent<BuildingScript> ();

        //Get the correct popup and make it visible
        GameObject popup = popups [index];
        popup.SetActive (true);

        //Get all popup menu elements
        Transform[] popupChildren = popup.GetComponentsInChildren<Transform> ();

        //Display resource cost text values
        Text[] resourceCostTexts = null;
        foreach (Transform t in popupChildren) {
            if(t.tag.Equals("ResourceCostText")){//find the correct element
                resourceCostTexts = t.gameObject.GetComponentsInChildren<Text>();
            }
        }
        //Add the text to the text component
        resourceCostTexts [0].text = (-buildingScript.employmentCost).ToString("+#;-#;0");
        resourceCostTexts [1].text = (-buildingScript.materialCost).ToString("+#;-#;0");
        resourceCostTexts [2].text = buildingScript.pollutionCost.ToString("+#;-#;0");
        resourceCostTexts [3].text = 0.ToString("+#;-#;0");

        //Display growth rate text
        Text[] growthRateTexts = popupChildren [3].GetComponentsInChildren<Text> (true);
        foreach (Transform t in popupChildren) {
            if(t.tag.Equals("ResourceGrowthText")){
                growthRateTexts = t.gameObject.GetComponentsInChildren<Text>();
            }
        }
        //Add the text to the text component
        growthRateTexts [0].text = buildingScript.populationGrowth.ToString("+#;-#;0");
        growthRateTexts [1].text = buildingScript.materialGrowth.ToString("+#;-#;0");
        growthRateTexts [2].text = buildingScript.pollutionGrowth.ToString("+#;-#;0");
        growthRateTexts [3].text = buildingScript.foodGrowth.ToString("+#;-#;0");

        Transform image = null;
        foreach (Transform t in popupChildren) {
            if(t.tag.Equals("Image")){//get the button from the popup elements
                image = t;
            }
        }
        Button imageButton = image.GetComponent<Button> ();
        //Destroy (image.gameObject);
        //image = Instantiate ();
        //image = Instantiate (buildingOptions[0]);
        //image.transform.SetParent(popup.transform, false);

        //Building descriptions
        Text imageDescription = image.GetComponentInChildren<Text> ();
        imageDescription.text = buildingScript.description;

        //Display appropriate message
        Text messageBar = null;
        foreach (Transform t in popupChildren) {
            if(t.tag.Equals("MessageBar")){//get the message bar from the popup elements
                messageBar = t.gameObject.GetComponent<Text>();
            }
        }
        //Do not have enough resources
        if (!GameController.gameController.sufficientResourses (0, buildingScript.materialCost, 0, 0)) {//we dont want to check pollution or food cost
            messageBar.color = Color.red;
            messageBar.text = "Do not have sufficient resources";
            return;
        }
        //Do not have enought unemployed
        if (!GameController.gameController.sufficientUnemployed (buildingScript.employmentCost)) {
            messageBar.color = Color.red;
            messageBar.text = "Do not have sufficient unemployed";
            return;
        }
        //Can build
        messageBar.color = Color.green;
        messageBar.text = "Tap building image to build";
        selectedTileScript.building = building;

        imageButton.onClick.RemoveAllListeners ();//to make sure there are no unwanted listeners
        //Set the button to call the build method of the current building if clicked
        imageButton.onClick.AddListener(() => {
            selectedTileScript.build ();
            closeMenu(menu);
            closePopup(popup);
//.........这里部分代码省略.........
开发者ID:dalightdj,项目名称:dragonfruit,代码行数:101,代码来源:BuildMenuScript.cs

示例2: clickingImage

        //----------image is clicked and color filter is set---------//
        private void clickingImage(ImageView imageView, Button takeIt)
        {
            // TODO: If one image is zoomed in multiple times, this function is also executed this amount of times.
            //		 This function should only be executed one time no matter what.

            takeIt.Click += ((object sender, System.EventArgs e) => {
                Log.Info(Tag, "takeIt Button: " + takeIt.ToString());
                if(isSelected && imagesSelected == 0 || isSelected && choosenImage == imageView) {
                    if(imagesSelected < 1) {
                        imagesSelected += 1;
                        phase = 2;
                    }
                    if (takeIt == takeItFirst) {
                        imageView.SetImageResource(Resource.Drawable.test_test);
                    }
                    if (takeIt == takeItSecond) {

                    }
                    if (takeIt == takeItThird) {
                        imageView.SetImageResource(Resource.Drawable.test_test);
                    }
                    if (takeIt == takeItFourth) {

                    }
                    Log.Info(Tag, "Images Selected: " + imagesSelected.ToString());
                    if(choosenImage != imageView) {
                        choosenImage = imageView;
                    } else {
                        choosenImage = null;
                    }
                    definingTag(imageView, true);
                    isSelected = false;
                } else if (!isSelected && imagesSelected == 1){
                    if(imagesSelected > 0) {
                        imagesSelected -= 1;
                        phase = 1;
                    }
                    if (takeIt == takeItFirst) {
                        imageView.SetImageResource(Resource.Drawable.test);
                    }
                    if (takeIt == takeItSecond) {

                    }
                    if (takeIt == takeItThird) {
                        imageView.SetImageResource(Resource.Drawable.test);
                    }
                    if (takeIt == takeItFourth) {

                    }
                    Log.Info(Tag, "Images Selected: " + imagesSelected.ToString());
                    definingTag(imageView, false);
                    isSelected = true;
                }
                if (choosenImage != null) {
                    Log.Info(Tag, "choosenImage: " + choosenImage.ToString());
                } else {
                    Log.Info(Tag, "choosen Image: null");
                }
                Log.Info(Tag, "isSelected: " + isSelected.ToString());
            });
        }
开发者ID:rhialy,项目名称:IMD3Amsterdam,代码行数:62,代码来源:NewJourney.cs

示例3: clickingImage

        //----------image is clicked and color filter is set---------//
        private void clickingImage(ImageView imageView, Button takeIt, LinearLayout fullScreen, LinearLayout downScreen)
        {
            // TODO: If one image is zoomed in multiple times, this function is also executed this amount of times.
            //		 This function should only be executed one time no matter what.

            takeIt.Click += ((object sender, System.EventArgs e) => {
                Log.Info(Tag, "takeIt Button: " + takeIt.ToString());
                if(isSelected && canBeSelected) {
                    if(imagesSelected < 1) {
                        imagesSelected += 1;
                    }
                    if (takeIt == takeItFirst) {
                        imageView.SetImageResource(Resource.Drawable.InDieBerge_confirmed);
                    }
                    if (takeIt == takeItSecond) {
                        imageView.SetImageResource(Resource.Drawable.InDenBusch_confirmed);
                    }
                    if (takeIt == takeItThird) {
                        imageView.SetImageResource(Resource.Drawable.InDieCity_confirmed);
                    }
                    if (takeIt == takeItFourth) {
                        imageView.SetImageResource(Resource.Drawable.AnDenStrand_confirmed);
                    }
                    Log.Info(Tag, "Images Selected: " + imagesSelected.ToString());
                    if(choosenImage != imageView) {
                        choosenImage = imageView;
                    } else {
                        choosenImage = null;
                    }
                    definingTag(imageView, true);
                    isSelected = false;
                    fullScreen.RemoveView(takeIt);
                    fullScreen.RemoveView(imageView);
                    imageView.SetMaxHeight (450);
                    imageView.SetMaxWidth (450);
                    downScreen.AddView(imageView);
                    Log.Info(Tag, "minimize");
                    canBeSelected = false;
                    isImageFitToScreen = true;
                } else if (!isSelected && canBeSelected){
                    if(imagesSelected > 0) {
                        imagesSelected -= 1;
                    }
                    if (takeIt == takeItFirst) {
                        imageView.SetImageResource(Resource.Drawable.InDieBerge);
                    }
                    if (takeIt == takeItSecond) {
                        imageView.SetImageResource(Resource.Drawable.InDenBusch);
                    }
                    if (takeIt == takeItThird) {
                        imageView.SetImageResource(Resource.Drawable.InDieCity);
                    }
                    if (takeIt == takeItFourth) {
                        imageView.SetImageResource(Resource.Drawable.AnDenStrand);
                    }
                    Log.Info(Tag, "Images Selected: " + imagesSelected.ToString());
                    definingTag(imageView, false);
                    isSelected = true;
                }

                if (choosenImage != null) {
                    Log.Info(Tag, "choosenImage: " + choosenImage.ToString());
                } else {
                    Log.Info(Tag, "choosen Image: null");
                }
                Log.Info(Tag, "isSelected: " + isSelected.ToString());

            });
        }
开发者ID:rhialy,项目名称:IMD3Amsterdam,代码行数:70,代码来源:NewJourneySpecificPreference.cs

示例4: buttonSquare

 private Square buttonSquare(Button button)
 {
     foreach (Square square in Squares.All)
     {
         if (button == this[square])
             return square;
     } // semi-colon not needed
     throw new ApplicationException("invalid button " + button.ToString());
     //MessageBox.Show(String.Format("invalid button {0}", button));
 }
开发者ID:evdkraan,项目名称:Conferences,代码行数:10,代码来源:Activity1.cs


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