|
I wonder if Roger is any less baffled now?
|
|
|
|
|
Nope. But the discussion is interesting.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Thanks, Dave. That's much clearer!
I've since done a bit more experimenting, and come up with something very similar, though I've left the implementation as a class rather than a struct. I posted only a portion of the code, and some items need to be modifiable at run time. My thinking is that it makes no sense to build a single purpose triangle for use in a single control if, with a bit more effort, I can make one that I can make dance around the screen and do barrel rolls if a later app needs it. For the moment I need only a triangle that points up, one that points down, and a diamond shape that slides along the line between them to show progress. But who knows what loony ideas I'll have for it later?
The debate about whether to create a new Triangle for each change or modify a single instance was interesting. I'm still thinking about that. My thought was to make it self-contained, with its own OnPaint handler and to include some sort of notification mechanism to make it respond to changes in the containing control. I'm still thinking about that, and doing more research and experimentation, since I don't yet know how to do either.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I've been thinking about this too - a possible solution to the dilemma would be to have a Draw method something like this
public void Draw(PointF offset, float rotationAngle)
{ This would allow a rectangle of the given parameters to be immutable, but allow the drawing to be controlled as you wish - in otherwords, the Triangle representation in memory could be identical for two triangles but the drawing could differ as required. You could even include a drawScale parameter etc. So long as they are part of the drawing process and not an integral part of the Triangle then I don't see a problem.
More food for thought!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I like the way you're thinking!
I do need to spend more time thinking about this; I just thought it would be a good way to get started in using the GDI+ functions to make a few basic shapes. Things grew from there.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hi,
I am trying to upload an image and resize it. the image being uploaded will be saved in photos and thumbs directory. I have given network service and iusr_machinename write access to both folders. the upload works fine in local machine its just when i try to upload via a remote server i get error "A generic error occurred in GDI+."
below are my codes for upload click event. please help
try
{
String file = "";
String thumb = "";
if (flUpload.PostedFile.ContentLength > 0)
{
file = flUpload.FileName;
thumb = "";
String[] strNew = file.Split('.');
strNew[0] = DateTime.Now.Ticks.ToString();
file = strNew[0] + "." + strNew[1];
thumb = strNew[0] + "_t." + strNew[1];
ImageName = file;
ImagePath = Server.MapPath("~/photos") +"\\"+ ImageName;
Response.Write(ImagePath);
ImageThumbName = thumb;
ImageThumbPath = Server.MapPath("~/thumbs") + "\\" + ImageThumbName;
Response.Write(ImageThumbPath);
using (System.Drawing.Image Img = new Bitmap(flUpload.FileContent))
{
Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, 100);
Size ImageSize = NewImageSize(Img.Height, Img.Width, 500);
using (System.Drawing.Image ImgThnail = new Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height))
{
ImgThnail.Save(ImageThumbPath, Img.RawFormat);
ImgThnail.Dispose();
}
using (System.Drawing.Image Img1 = new Bitmap(Img, ImageSize.Width, ImageSize.Height))
{
Img1.Save(ImagePath, Img.RawFormat);
Img1.Dispose();
}
Img.Dispose();
}
}
public Size NewImageSize(int OriginalHeight, int OriginalWidth, double FormatSize)
{
Size NewSize; double tempval;
if (OriginalHeight > FormatSize && OriginalWidth > FormatSize)
{
if (OriginalHeight > OriginalWidth)
tempval = FormatSize / Convert.ToDouble(OriginalHeight);
else
tempval = FormatSize / Convert.ToDouble(OriginalWidth);
NewSize = new Size(Convert.ToInt32(tempval * OriginalWidth), Convert.ToInt32(tempval * OriginalHeight));
}
else
NewSize = new Size(OriginalWidth, OriginalHeight); return NewSize;
}
|
|
|
|
|
Check if you have access rights to save to the shared / network folder.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
what do you mean. not sure how i do that as the website is hosted remotely and its with the hosting provider.
|
|
|
|
|
|
Happy new year...
I have a list of objects I would like to use to populate a datagridview. I would somehow like to have each row bound to a specific object.
I can see how that object class can be added as a datasource, but I'm not sure how to get the objects from my list added as a row.
Anyone care to help? Also, is this the right direction?
Thanks for your time.
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:14am.
|
|
|
|
|
Before the grid is populated, there are no rows to enumerate in the grid.
If the class is used as a datasource, adding rows 'dgView.Rows.Add()' creates an exception stating 'Rows cannot be programmatically added to the DataGridView's row collection'
I'm using the class as the view bindng source. If this is correct, how do I get the list of obects into the grid?
If there is a different approach that would be better than what I'm attempting, please comment.
Thank you for your time.
modified on Sunday, January 3, 2010 12:04 PM
|
|
|
|
|
You can retrieve the object via DataBoundItem property.
|
|
|
|
|
Hi frnds ... I was trying to connect a database which has an extension of .mdf .... but in the crystal report this extension is not filtered ... I want to know how to connect this .mdf file ... Please help
Thank you
|
|
|
|
|
i need some guidance regarding c# winsock programming, im a beginner in programming and network applications. i understand the client/server idea.
server -> socket() bind() listen() accept() {send() recv()} close()
client -> socket() connect() {send() recv()} close()
--
i also know Socket.Connected Property to test if connected.
--
where i am having difficulty is in both server and client how to implement send() and recv() [events]. i know how to send and receive but to do it while keeping the connection seems to very vague in google links.
most examples on google just creat the connection and may send some data or receive some data and the connection is closed.
the while(true) on server runs in a loop and accepts new connections.
i need to know how to implement send and recv (events) so the connected clients and server can keep on exchanging data using the same connection.
lots of the web examples have the server running in a loop and the client makes a new connection whenever data needs to be sent, it doesn't seem efficient to me.
i have also seen server loop running on its own thread to avoid gui lockups but there also the actual communication seems vague.
so. i would like info on how to handle send and recv in a structured manner.
thanks for reading and a very happy new year to you.
---------------------
my current approach is wrong, it concerns blocking.. i should be using .NET asynchronous socket programming.
thanks.
modified on Saturday, January 2, 2010 1:36 PM
|
|
|
|
|
You need another thread which accepts messages from clients and process it. Take a look at this[^] MSDN page.
New year wishes to you too.
Best wishes,
Navaneeth
|
|
|
|
|
.NET makes this stuff pretty straight forward.
Server side, use a TcpListener to accept incoming connections from the client. Once accepted, which gives you a TcpClient, the ususal practice is to create a new thread and pass it the TcpClient and let it do its server side stuff. If the connection is likely to be brief, use the ThreadPool.
On the client, just use a TcpClient to connect to the server.
Generally, the connection stays open until either end closes it, or it *may* get closed due to inactivity timeouts - not sure.
You can attach a NetworkStream to the TcpClient at both ends, so you just end up with a duplex stream you can read and write to.
Cassini is a little web server from the early days of .NET which allowed people to develop ASP.NET applications. Have a look at the source of that for some patterns. http://blogs.msdn.com/dmitryr/archive/2005/09/27/474534.aspx[^]
Regards,
Rob Philpott.
|
|
|
|
|
Hi all...
At runing the following function i get the exeption "Arithmetic operation resulted in an overflow", an exeption arises from the underlining line of code :
public static int OnesSum(byte[] bytes, int start, int len)
{
MemoryStream memStream = new MemoryStream(bytes, start, len);
BinaryReader br = new BinaryReader(memStream);
Int32 sum = 0;
UInt16 val;
while (memStream.Position < memStream.Length -1)
{
val = (UInt16)IPAddress.NetworkToHostOrde(br.ReadInt16());
sum += val;
}
// if we have a remaining byte we should add it
if (memStream.Position < len)
{
sum += br.ReadByte();
}
// fold the sum into 16 bits
while((sum >> 16) != 0)
{
sum = (sum & 0xffff) + (sum >> 16);
}
return sum;
}
|
|
|
|
|
Have you tried making val an Int32 (and performing the appropriate cast when that method returns it?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi,
The problem here is the cast to UInt16 which fails when the IPAddress byte order reversal method returns a negative value. Overflow checking must be disabled to allow the 16 bit result which is typed as Int16 to be successfully assigned to an unsigned type. Use the unchecked keyword to do this.
val = unchecked((UInt16)IPAddress.NetworkToHostOrder(br.ReadInt16()));
Alan.
|
|
|
|
|
Alan N wrote: val = unchecked((UInt16)IPAddress.NetworkToHostOrder(br.ReadInt16()));
That will always return 0.
The unchecked (UInt16) cast throws away the higher-order bits - but NetworkToHostOrder just swapped the byte order, so ALL the input bits will be thrown away.
I'm not sure what he wanted to do in the first place.
|
|
|
|
|
Not really, the overload with a short as input also has a short as result, so he's really just casting a short to an ushort
|
|
|
|
|
Oh, I didn't know there were multiple overloads. I thought it was for 32-bits only (as that's the size of an IPAddress), casting from int to ushort.
|
|
|
|
|
In that case you would have been right, of course
I suppose this overload can be useful for port numbers, I'm not sure why there is an overload for longs as well though..
|
|
|
|
|
I have written a User Control and made it dll from a classLibrary Project.
This User Control get the Name of the Form (in Project that we use this dll) in textbox1 and then do something with the controls on this form. Now my question is how i can Cast textbox1.Text (of this user control) to Form ?
|
|
|
|