|
Hello everyone, I want it to read the contents of the txt file I selected from the list box and then draw a picture in the picturebox according to the values it gets from the txt file. can you please help?
|
|
|
|
|
Help with what? You haven't asked a question; you've just given us a vague requirement.
You need to start by deciding what syntax your text file is going to use.
You then need to write the code to parse the file and convert the contents to some form of actionable information.
Finally, you will need some code to take the parsed information and turn it into a drawing.
So far, you don't appear to have done any of these steps.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
C# windows will list the txt files in the file path I gave in the listbox I created on the form.
When I select one of the txt files listed, it will read the coordinates in the content of this file line by line and draw in the picturebox.
|
|
|
|
|
I see. So you've totally ignored the advice I gave you, and have still made precisely no effort.
Whilst we're happy to help you fix the code you've written, nobody here is going to do all the work for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Use turtle graphics. Read the equivalent (turtle) "command codes" (that you create) from a text file.
GitHub - nakov/TurtleGraphics.NET: C# Turtle Graphics library - for teaching kids to code
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
And?
What have you tried?
Where are you stuck?
What help do you need?
Just posting the end result without telling us where you are at the moment doesn't help anyone - we have no idea what existing design we have to fit into!
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
2yvdecv.jpg[^]
I designed the form you see in the picture and I list the files in the file path I specified in the Listbox. It needs to read the content of the file with Streamreader and draw a picture in the picturebox accordingly. I'm reading the file but I can't draw the picture.
DirectoryInfo dir = new DirectoryInfo(@"C:\\Users\\BS\Desktop\\Yeni_klasör");
DirectoryInfo[] dirs = dir.GetDirectories();
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
listBox1.Items.AddRange(files);
}
StreamReader str = new StreamReader(listBox1.SelectedItem.ToString());
string satir;
List<string> veriler2 = new List<string>();
while ((satir = str.ReadLine()) != null)
{
veriler2.Add(satir);
}
I have a code block like this. I want it to read the numbers in the txt file and draw a picture in millimeters accordingly. Can you help me please?
|
|
|
|
|
And you STILL haven't explained what syntax the text file contains, nor what you have tried, nor where you are stuck.
Nobody can help you if you don't give us the information we need to help you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I forgot I'm sorry. I am converting dxf file to txt format. The content of this txt file is as follows:
Is an example
Line
0
0
100
0
False
0
Line
100
0
100
100
False
0
Line
100
100
0
100
False
0
Line
0
100
0
200
False
0
How can I draw a picture according to the value it receives after reading this file?
|
|
|
|
|
Member 15570952 wrote: How can I draw a picture according to the value it receives after reading this file?
It all depends on the meaning of these values!
|
|
|
|
|
Forget the drawing for now.
You have to create a parser for the file. That parser is going to create an object "graph", which is the list of commands your drawing code is going to interpret to tell it what/how to draw.
You have to ask yourself what does each line in the file mean and convert those items to data structures. For example, the parser is going to com across a line with "Line" in it. To create a Line structure, you need to know the X and Y coordinates of both endpoints of the line, so you need four values. The parser should expect those four values on the lines after "Line". Read those values and place them into the structure. Once the values are filled in, add the structure to a List that holds those structures. This list is what the drawing code is going to need to tell it what to do.
What odes the "False" and the "0" after it mean? Your parser is going to have to deal with those too, as appropriate.
Why do you need to do this? Because of the way Windows works. Windows calls your app to tell it to draw itself, and your window needs the data to redraw itself over and over again. For example, if another window is dragged over the top of your window, Windows will tell your app to redraw itself repeatedly, as the other window is being dragged over the top of yours.
|
|
|
|
|
Message Closed
modified 25-Jun-22 13:13pm.
|
|
|
|
|
Not getting it ... What was your post? In some other thread?
|
|
|
|
|
Hello there , I want to create a simple paint application (photo editor tool) in winforms C# which should draw basic shapes (Rectangle, Ellipse, Line and Arrow only). Also, it should draw a transparent text box to write text and all these shapes including the text should be draggable or movable i.e. we should be able to select a shape or text and move it to other location on the screen. Further more it should have undo, redo, save and save as options also.
In simple words, it should have:
(rectangle, ellipse, line , arrow, text , undo, redo, save, save as, movement of shapes)
Using : C#- Winforms
|
|
|
|
|
And?
What have you tried?
Where are you stuck?
What help do you need?
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
This sounds like you are planning to have some fun writing code. Before you start writing any code, make a list of your requirements so that you don't lose focus. A word of advice; when dealing with shapes, make them separate shape classes, and make it so that the responsibility of drawing the shape belongs with the shape itself. I would tend to start with an abstract shape class, like this:
public abstract class BaseShape
{
public event EventHandler ShapeInvalidated;
private int? x;
public int? X
{
get { x = value; }
set
{
x = value;
Invalidate();
}
}
private int? y;
public int? Y
{
get { y = value; }
set
{
y = value;
Invalidate();
}
}
private int? width;
public int? Width
{
get { width = value; }
set
{
width = value;
Invalidate();
}
}
private int? height;
public int? Height
{
get { height = value; }
set
{
height = value;
Invalidate();
}
}
private int zorder;
public int ZOrder
{
get { zorder = value; }
set
{
zorder = value;
Invalidate();
}
}
private bool CanPaint()
{
return x.HasValue and y.HasValue && height.HasValue && width.HasValue && height.Value > 0 && width.Value > 0;
}
public void Invalidate()
{
if (CanPaint)
{
ShapeInvalidated?.Invoke(this, null);
}
}
public abstract void Paint();
}
public class Rectangle : BaseShape
{
public override void Paint()
{
}
} In general, you would want a shape manager class to actually manage the shapes on the screen. The shape manager would receive the ShapeInvalidated event and call the Paint method on each shape using the ZOrder to control the order the items are painted so you can create overlapping shapes.
|
|
|
|
|
Be careful. Just because you put the word "simple" in your app description, that in no way means writing the code will be "simple".
To start with, I would just start with an app that lets you drop a couple of shapes on the canvas and lets you move them around. Once you get this done correctly, the rest becomes easier.
|
|
|
|
|
Since there was no question, one wonders why you posted in the first place.
Simple Paint Application in C#
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
How Can We capture Html Input Controls value of any website using windows application c#
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?
That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have a keylogger functionality windows application that captures every keystrokes
But I doesn't know how to capture particular html input control type
How can I do
|
|
|
|
|
Keyloggers are almost always used for malicious purposes. Nobody here will help you build malware.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Particularly when they want to access "Input Controls value of any website" ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
It sounds like you're trying to capture user passwords as they type them. You can right off with that.
|
|
|
|
|
I does not want to store password but i want to detect so that I can restrict that.
|
|
|
|