|
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.
|
|
|
|
|
"Restrict that"? What on earth does that mean?
|
|
|
|
|
Means does not allow to store password
|
|
|
|
|
Means what again? "WHAT" is not allowed to store the password?
You better start typing a lot more detail into every answer you give. All you're doing is generating more questions and more confusion because nobody can get a straight up description of PRECISELY what you're trying to do.
|
|
|
|
|
Dave your interpretation skills are lacking today...
He is trying to capture passwords so he can store them and restrict the user from storing them (ie stop all those helpful browsers from capturing the passwords) although the second step is optional
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Hello,
I filled up a DataGridView from a csv file using the code as follow:
Everything works and at the start I can see my DataGridView correctly filled up by datas from csv file.
The problem is that I am not able to filter the rows by textbox or sort the column by clicking on header word.
I tried differents ways by reading solution on the web but nothings works...
can anyone suggest me some solution for this pls?
private void LoadDatabaseBtn_Click(object sender, EventArgs e)
{
string filecsv = @"D:\Database.csv";
DGV.DataSource = LoadCSV(filecsv);
DGV.Refresh();
}
public List<Client> LoadCSV(string csvfile)
{
var query = from l in File.ReadAllLines(csvfile)
let data = l.Split(',')
select new Client
{
name= data[0],
id = data[1],
tel = data[2],
addr = data[3],
city = data[4],
};
return query.ToList();
}
}
public class Client
{
public string name { get; set; }
public string id { get; set; }
public string tel { get; set; }
public string addr { get; set; }
public string city { get; set; }
}
I have an identical database .mdf, in this case I added a DataSets to my c# project and I fill up my DataGridView just by setting the ClientsTableBindingSouce as source of data
In this case I am able to sort and filter very easly the rows of the datagridview at runtime just by typing text in a textbox.
private void filternameTxt_TextChanged(object sender, EventArgs e)
{
ClientsTableBindingSource.Filter = string.Format("name LIKE '%{0}%'", filternameTxt_Text);
DGV.Refresh();
}
|
|
|
|
|
|
many thanks that s works!
I have just a last problem to fix
I have a second datagridview who is connected directly with the main database.mdf using a dataset.
I add my records to my database.mdf by using a DataGridView.
I add a row to my DGV so I click enter and so I use a "saveclick button" that I programmed to update the dataset.
The problem is that the dataset is correctly updated only if I click enter on keyboard after that I finish to insert values on the cells of the row.
If for some reasons I click my "save" button without click enter before, I lose all the datas of the rows.
So clicking enter do a sort of "row validation" that I am not able to reproduce programmatically
I tried to use SendKeys.Send("{ENTER}") but it doesent works.
How can I "validate" my row insertion programmatically in order to save correctly it on database mdf
I want do this because sometimes the user forgot to click enter before to click on "save" button and in this case the row is not taken into account and is not saved on .mdf file
|
|
|
|
|
Without seeing the actual code it is impossible to guess what needs to be done.
|
|
|
|
|
Hello Richard, I dont know if my code can be helpfull for this, btw
At runtime the user can use normally a DataGridView by filling cells with some datas.
When user write datas on a row, it is visible on the left a little pensil who inform us that we are in edit mode.
After that the user ends to write datas he should click on enter on keyboard. The enter key event do somethings (as ending edit mode, go to the next row...) that I dont understand but who is needed to "save" the row as new datas in the DataGridView.
I use the following code to export DataGridView into database.mdf file, but at runtime, an added row in DataGridView is taken into account and correctly exported to MyDatabase.mdf only if I click enter key to "validate" the datas of the row that I wrote.
sometimes I forget to click enter (the little pensil image is still shown on the left of the row when I am typing) and the following code doesent export this row on MyDatabase.mdf
I would like to wrote some code here, for "validate" programmatically the new row on the datagridview in order that it is correctly exported on the MyDatabase.mdf file even when the user forget to click enter key
private void SaveToMyDatabaseBtn_Click(object sender, EventArgs e)
{
ClientsTableAdapter.Update(dataSet.ClientsTable);
}
many thanks
|
|
|
|