|
Thanks you for replay!
Cheer's,
Alex Manolescu.
|
|
|
|
|
Alex Manolescu wrote: Does C# have a pattern for this?
Note a pattern as such, there's serialization (binary, XML), transmission using the TcpClient[^].
You came to ask for a pattern - So I guess that you'd like to compare your solution to the design pattern. I have no design-pattern, but some questions to ponder over.
* Sometimes you want to try and connect in a different way. E.g., SQL Express usually babbles over TCP/IP, but it can also babble over pipes.
* Sometimes the data is sensitive. Have you considered encryption?
* Sometimes larger transmissions get interrupted for different reasons. Can you send the serialized object in multiple pieces, say, a 100? It would be nice if the sender than could send a list with the pieces it wants' and to resend them. That way you could also show a progres-indication of what's sent.
I are Troll
|
|
|
|
|
Thanks you for replay!
I just wanted to find the best way to do what I've describe, so encryption is not my priority now.. thanks anyway for sugestion
Cheer's,
Alex Manolescu.
|
|
|
|
|
Another approach would be to use the Memento[^] design pattern. You could create a data structure that represents the state of you class but is much more lightweight and send it (using binary serialization) instead. The receiver would then create a new object from the data structure.
|
|
|
|
|
Thanks you for replay!
I think i'll give it a try, and compare the performances. You have wake my interest for this pattern, you get a 5
Cheer's,
Alex Manolescu.
|
|
|
|
|
Take a look at protocol buffers too. Here[^] is a .NET implementation of that.
Best wishes,
Navaneeth
|
|
|
|
|
Yes! this is what I'm looking for
Thanks you Navaneeth!
I'll give it a try and see how it works.
Cheer's,
Alex Manolescu
|
|
|
|
|
I am writing a program that involves capturing an area of the screen and saving it as an image. I know that I can use g.CopyFromScreen, which uses three arguments: Point upperLeftSource, Point upperLeftDestination, and Size blockReigonSize. The first and last I understand, but the upperLeftDestination is something a mystery to me. Additionally, I have been unable to save the captured image. I know of a few different methods that I could use, but it seems to me that none of them allow you to say what it is that you want to save. I am fairly inexperienced, so reasonably simple answers would be great.
|
|
|
|
|
|
Actually, I'm using some of that code in my project. Thanks, though.
|
|
|
|
|
Hi,
In
Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockReigonSize)
a rectangle gets copied, its size is blockReigonSize, the rectangle gets copied from the screen starting at upperLeftSource(to the right and down), and it gets copied into the Graphics (which could have any size) starting at upperLeftDestination(also to the right and down).
|
|
|
|
|
According to MSDN[^] upperLeftDestination is the point at which you want to start copying into the graphics object - which makes sense. If it wasn't provided, then the copy would always take place at the top left corner of the graphics output - with it you can offset it by (say) 100 pixcels down, by 200 pixcels in.
To copy, display and save it:
Bitmap b = new Bitmap(picBig.Width, picBig.Height);
Graphics g = Graphics.FromImage(b);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), b.Size);
picBig.Image = b;
b.Save(@"C:\Screendump.bmp");
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Thank you. That's exactly what I needed to know. Well, almost. You see, I'm copying the image from a Shockwave Flash object, so axShockwaveFlash1.Image doesn't exist. What exactly is picBig?
|
|
|
|
|
In Griff's example, "picBig" is just an image control in your application, so you can display what you captured. It's not really necessary if you only want file output.
Note that his code does not require any sort of source object... All you need are coordinates. If you're getting it from an ActiveX control, just use that control's coordinates, translated to SCREEN coordinates (PointToScreen() ), and make sure it's visible (If it's minimized or hidden by another window, it won't work).
|
|
|
|
|
Ian Shlasko wrote: In Griff's example, "picBig" is just an image control in your application, so you can display what you captur
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Hello.
I've created a text encryption algorithm and it works fine. The problem is I don't know how to encrype a file. Can anyone tell me how to do that? I don't want any code just some tips.
Thanks in advance.
|
|
|
|
|
1.) Read the file into a byte[] and convert into base64 string.
2.) Encrypt the text using algo and write it back.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
|
Sokka93 wrote: I've created a text encryption algorithm and it works fine.
Would you like us to take a look at that? It's very easy to make mistakes with that..
By the way, why did you make a new one? It's usually much safer to use a public algorithm that has been extensively analyzed..
|
|
|
|
|
Because I'm going to use it to enroll a competition. All I'll do is to create a random encryption algorithm. It works with text but the problem is I create the key and I can't think any way of giving the key to someone. Because the key is random too. So I decided to use it to encrypte files.
|
|
|
|
|
Are there any restrictions on the format of your key or is it just a number? If it's just a number, you could use Diffie-Hellman key exchange right (so your key won't be leaked in any way)
|
|
|
|
|
No not just numbers. Letters and numbers. BTW Is it a problem for a key to be long? Are there any restrictions about it? Because the key can be so long. My algorith decides Its length according to the lenght of the text. So the key might be so long. I plan to put the text into a cube and turn it according to random numbers. Like The Cube Of Rubik. ANd I'm thinking of saving all the moves and create a key with it.
|
|
|
|
|
note: I apologize in advance for any errors I may make.
Letters are numbers too of course, but I meant that if your key has a specific format then you have to do an extra step to compress your key to raw binary (and you have to be able to reverse that operation from any binary string), otherwise the result of the DH-exchange is "not a key"
For DH-exchange the key can be arbitrarily long, but when it's several KB's long it becomes somewhat slow (prohibitively slow for 10KB+)
|
|
|
|
|
Hi
I am struggling with a c# event in my asp.net project.
The code I have is:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
case DataControlRowType.DataRow:
DataRowView myDataRowView = (DataRowView)e.Row.DataItem;
if (Convert.ToSingle(myDataRowView["Difference"]<2.5))
{
((Image)e.row.FindControl("ImageRating")).ImageUrl == "~/Images/Bad.png";
}
if (Convert.ToSingle(myDataRowView["Difference"]=2.5))
{
((Image)e.row.FindControl("ImageRating")).ImageUrl == "~/Images/Average.png";
}
else
((Image)e.row.FindControl("ImageRating")).ImageUrl == "~/Images/Good.png";
break;
}
}
I get errors:
Operator '<' cannot be applied to operands of type 'object' and 'double'
'System.Web.UI.WebControls.GridViewRowEventArgs' does not contain a definition for 'row' and no extension method 'row' accepting a first argument of type 'System.Web.UI.WebControls.GridViewRowEventArgs' could be found (are you missing a using directive or an assembly reference?)
Any ideas?
The datatype for difference is float in the database
Basically what I need is, If the value in column "Difference" is less than 2.5, display the image Bad.png in the rating column.
If the value of "Difference" is equal to 2.5, display the image Average.png in the rating column.
If the value of "Difference" is greater than 2.5, display the image Good.png in the rating column.
Andy
|
|
|
|
|
if you want compare equal you need to use '==' instead of single '=' (without quotes) as you did in your example
also you use:
Convert.ToSingle(myDataRowView["Difference"]<2.5)
while it shoud be:
Convert.ToSingle(myDataRowView["Difference"])<2.5
you used <2.5 within method Convert.ToSingle() instead inside IF statement
|
|
|
|