Insert text into images

Asked

Viewed 120 times

1

I have a Switch that according to the given status it plays an image, but I would also like to play the numbering of that status in the image (that text that usually when we touch the image it appears). I wonder if there is any property that does this. Follow the code I made.

          switch (codParc)
                {
                    case 1:
                        imgStats.ImageUrl = "../images/yellowStatus.png";
                        break;
                    case 2:
                        imgStats.ImageUrl = "../images/yellowStatus.png";
                        break;
                    case 4:
                        imgStats.ImageUrl = "../images/greenStatus.png";
                        break;
                    default:
                        imgStats.ImageUrl = "../images/neutralStatus.png";
                        break;
                }

To get a sense of what the image has to present, it would be more or less that:

inserir a descrição da imagem aqui

  • Webforms, WPF. Winforms, MVC?

  • @jbueno Webforms

  • @Danielnicodemos, which component you are using to set the image?

  • @Danielnicodemos you mean Tooltip?

  • @Pedrofilipe I am using the System.Web.UI.Webcontrols library of the Image class and Drawing.

  • @Marconi This is my question, which is the library to play a text in the image, similar to the logic I’m using there. For example: imgStats.Imageurl ="..."; imgStats.Imagetext ="blablabla"; break; I don’t know if Tooltip meets this condition. If satisfied, tell me how please :)

  • 1

    @Danielnicodemos the Example given by Diéfani can help you.

Show 2 more comments

2 answers

2

Tooltip does what you need, below is an example of how you would look without the Switch.

<asp:Image ID="Imagem1" runat="server"
       AlternateText="Smiley Face"
       ImageAlign="left"
       ToolTip="Status da numeração"
       ImageUrl="../images/yellowStatus.png" />

0


Improving the response by colleagues in the comments and subsequent responses of colleagues, the code will look like this:

switch (codParc)
                {
                    case 1:
                        imgStats.ImageUrl = "../images/yellowStatus.png";
                        imgStats.ToolTip = "1";
                        break;
                    case 2:
                        imgStats.ImageUrl = "../images/yellowStatus.png";
                        imgStats.ToolTip = "2";
                        break;
                    case 4:
                        imgStats.ImageUrl = "../images/greenStatus.png";
                        imgStats.ToolTip = "4";
                        break;
                    default:
                        imgStats.ImageUrl = "../images/neutralStatus.png";
                        break;
                }

Where the status text is generated according to the Switch.

  • 1

    use the edit button to edit your question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.