Click here to Skip to main content
15,898,035 members
Home / Discussions / C#
   

C#

 
Questionc# hook - counting keystrokes on the keyboard Pin
Member 1097549730-Dec-18 5:09
Member 1097549730-Dec-18 5:09 
AnswerRe: c# hook - counting keystrokes on the keyboard Pin
OriginalGriff30-Dec-18 5:13
mveOriginalGriff30-Dec-18 5:13 
GeneralRe: c# hook - counting keystrokes on the keyboard Pin
Member 1097549730-Dec-18 5:14
Member 1097549730-Dec-18 5:14 
JokeRe: c# hook - counting keystrokes on the keyboard Pin
Luc Pattyn30-Dec-18 5:14
sitebuilderLuc Pattyn30-Dec-18 5:14 
GeneralRe: c# hook - counting keystrokes on the keyboard Pin
Member 1097549730-Dec-18 5:18
Member 1097549730-Dec-18 5:18 
AnswerRe: c# hook - counting keystrokes on the keyboard Pin
Gerry Schmitz30-Dec-18 8:40
mveGerry Schmitz30-Dec-18 8:40 
AnswerRe: c# hook - counting keystrokes on the keyboard Pin
Eddy Vluggen30-Dec-18 23:15
professionalEddy Vluggen30-Dec-18 23:15 
QuestionDgv vertically its possible? Pin
Member 1097549730-Dec-18 4:43
Member 1097549730-Dec-18 4:43 
AnswerRe: Dgv vertically its possible? Pin
OriginalGriff30-Dec-18 4:55
mveOriginalGriff30-Dec-18 4:55 
GeneralRe: Dgv vertically its possible? Pin
Member 1097549730-Dec-18 5:11
Member 1097549730-Dec-18 5:11 
GeneralRe: Dgv vertically its possible? Pin
OriginalGriff30-Dec-18 5:17
mveOriginalGriff30-Dec-18 5:17 
QuestionSearch file remotely C# Pin
Member 1410307028-Dec-18 21:55
Member 1410307028-Dec-18 21:55 
AnswerRe: Search file remotely C# Pin
pkfox28-Dec-18 22:33
professionalpkfox28-Dec-18 22:33 
GeneralRe: Search file remotely C# Pin
#realJSOP30-Dec-18 2:53
professional#realJSOP30-Dec-18 2:53 
AnswerRe: Search file remotely C# Pin
BillWoodruff29-Dec-18 1:05
professionalBillWoodruff29-Dec-18 1:05 
AnswerRe: Search file remotely C# Pin
#realJSOP30-Dec-18 2:56
professional#realJSOP30-Dec-18 2:56 
AnswerRe: Search file remotely C# Pin
Gerry Schmitz30-Dec-18 8:28
mveGerry Schmitz30-Dec-18 8:28 
QuestionUsing A FileStream As A Texture? Pin
SawmillTurtle26-Dec-18 17:54
SawmillTurtle26-Dec-18 17:54 
I'm still learning C# and I have a long way to go. I wanted to dive into MonoGame because tinkering with game design has been a hobby of mine since I started learning QBasic at the age of 14. I don't want to use their Content Pipeline to load content, because I'd like to figure out how to load custom resources as needed. Someone on Stack Overflow commented HERE that they use FileStreams to load textures directly. I set about trying to figure out how to do that, and I've gotten this far:

C#
FileStream fs = new FileStream("stars.jpg", FileMode.Open);
byte[] readString = new byte[fs.Length];
fs.Read(readString, 0, (int)fs.Length);


I have no idea if that code even works, because I haven't gotten to a point where running it would yield any visible results. It seems sound, so once I get the file data in the readString array, I need a way to use it as texture data. I tried casting:

C#
object o = (object)readString;
background = (Texture2D)o;


I already know that isn't going to work. I don't even need to run it to figure that one out. I read a little in the MonoGame Reference and thought about using Texture2D.SetData as shown HERE, but I'm not sure how to proceed or even if I'm headed in the right direction. The syntax they provide doesn't really clarify anything.


C#
public void SetData<T>(
    T[] data
) where T : ValueType, new()


There's an array here, but I'm not sure what it's asking for. Can I provide SetData with the byte array?

C#
background.SetData(readString);


Your help would be most appreciated, and it would go a long way towards helping me advance in my learning.

Thanks. Smile | :)

-Turtle

modified 27-Dec-18 0:00am.

AnswerRe: Using A FileStream As A Texture? Pin
Richard MacCutchan26-Dec-18 22:31
mveRichard MacCutchan26-Dec-18 22:31 
Questionhow to extract text from text file and store it in a variable using c# Pin
Syed_Owais24-Dec-18 20:54
professionalSyed_Owais24-Dec-18 20:54 
AnswerRe: how to extract text from text file and store it in a variable using c# Pin
OriginalGriff24-Dec-18 21:04
mveOriginalGriff24-Dec-18 21:04 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
Dave Kreskowiak25-Dec-18 4:46
mveDave Kreskowiak25-Dec-18 4:46 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
OriginalGriff25-Dec-18 5:00
mveOriginalGriff25-Dec-18 5:00 
AnswerRe: how to extract text from text file and store it in a variable using c# Pin
Dave Kreskowiak25-Dec-18 4:46
mveDave Kreskowiak25-Dec-18 4:46 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
BillWoodruff27-Dec-18 16:17
professionalBillWoodruff27-Dec-18 16:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.