|
I have a gif file with 3 pictures, next to next in one image. Seperated by black lines.
Each picture has a width of 100pix, the black seperation line has 2 pix. Max width is 306.
Now I want to copy the first picture into the imagebox. How can I copy the first picture into the imagebox?
I never have worked with sprites, so I don't know how to get this.
|
|
|
|
|
It's seems that your problem is to separate one peace of entire image from other. If there is width of each peace is constant it will be very easy, but if not, you need to "search for black line"...
What exactly you want to know?
|
|
|
|
|
I know exactly the positions.
1st 1-300
2nd 303-603
3rd 606-906
no dynamic problem, all pictures positions are placed logical, like sprites.
|
|
|
|
|
there is your code, I believe it works
<br />
Image src = Image.FromFile();<br />
<br />
Graphics gr = Graphics.FromImage(src);<br />
<br />
Point point = new Point(1, 0);<br />
<br />
for (int i=0; i<3; i++)<br />
{<br />
Bitmap bitmap = new Bitmap(300, , gr);<br />
<br />
gr.DrawImageUnscaled(src, point);<br />
<br />
point.Offset(303, 0);<br />
<br />
bitmap.Save("filename.bmp", System.Drawing.Imaging.ImageFormat.Bmp);<br />
}<br />
|
|
|
|
|
thx
|
|
|
|
|
Hi,
I need to implement node copy/paste functionality in my treeview control. What is a good way of accomplishing this?
Thanx
|
|
|
|
|
Hi,
You can not "copy" nodes but you can clone them using the
myTree.Nodes[i].Clone() method
Playing with this you can implement what you need
|
|
|
|
|
Thanx, but if I'm looking for sort of 'simple' copy/paste, namely just duplicating a node visually using keys 'cntrl C' and 'cntrl V', do I need to catch a 'keyPress' event or is there another way of doing it?
|
|
|
|
|
You can use the KeyDown event
|
|
|
|
|
Hello,
How can I get the last node in the hierarchy of a treeview?
Thanks
|
|
|
|
|
If you mean the last child, then:
someParentTreeNode.LastNode
or
int c = treeView1.Nodes.Count
treeView1.Nodes[c-1];
|
|
|
|
|
Thx for replying but that wont work
i = Tree.GetNodeCount(true) will return the number of nodes in the tree including the sub trees, but Nodes[i] will throw an exception as Node.Nodes contains only the nodes in the node collection of the node Im searching (yeah its confusing). Say the tree has 500 nodes but only 4 at first level, doing this:
n = Tree.GetNodeCount(true);
TreeNode last = Tree.Nodes[n]; // exception because Tree.Nodes has 4 elements and Im trying to get the 500th.
what I need is the LAST node in the last level of the tree.
|
|
|
|
|
Well, then you may need to use recursion. You can try something like this to get to the deepest node of the tree:
private void DepthSearch(TreeNodeCollection nodes, int depth)
{
int newDepth = depth;
for(int i = 0; i < nodes.Count; i++)
{
if(nodes[i].NextNode == null)
{
//your code here;
}
newDepth++;
this.TreeSearch(nodes[i].Nodes, newDepth);
}
}
so,
calling DepthSearch(TreeView.Nodes, 0) and inserting code (where it says 'your code') that populates some data structure with the current node and the depth, should give you the ability to compare the depths and choose the deepest node.
|
|
|
|
|
TreeView1.Nodes[TreeView1.Nodes.Count - 1];
|
|
|
|
|
I need help... Here's my situation:
I have an array as:
string[] Array_A;
byte[] Array_B;
The data inside the array looks like so:
Array_A: Array_B:
0x5628, 0
0x0818, 1
0x56EE, 0
0x56EE, 0
Now.. I want to add the DISTINCT values of Array_A to an 'Array_List', or collection, or dictionary
This new 'List' will look like so:
COL_A COL_B
0x5628, 0
0x0818, 1
0x56EE, 0
... note that the values in the B column do not matter at this point. They will be updated by another process, which leads me to my next situation.
I need to update the B column by referencing the values in the A column.
void UpdateArrayList(string strCheckThis, byte bData)
{
if(strCheckthis == Col_A) COL_ B = bData
}
That code is really bad in that I have no idea to know what row I am actually updating, but it gives you the basic idea of what I need to accomplish.
So that's it in a nutshell.. I need to Add, Update and Remove rows in this arraylist (or Collection, or Dictionary =)
The last question is: Which object fits this method best?
ANY help anyone can offer will be met with swift and decisive praise and adoration...
Thank you in advance
Ray
|
|
|
|
|
Use a hash table. Use the Add method to add the values, with the string as key, and the byte as value. Use the ContainsKey method first to check if it already exists in the table, so you don't add duplicates. To retrieve the values, use the Item method.
---
b { font-weight: normal; }
|
|
|
|
|
Ok.. so far so good!
Here's what I have:
Hashtable table = new Hashtable(); //-- Simple enough!
Here's the data:
table.Add("0x5628","0x5628, 0, 0");
table.Add("0x0818","0x0818, 1, 0");
table.Add("0x56ED","0x56ED, 4, 0");
Now, I want to enumerate through each element, and "Do stuff" with it... I thought this might work:
foreach ( object item in table)
{
MessageBox.Show((string)item.ToString());
//-- Do other stuff
}
...alas, though... it only displays a message as to what the object is, not what it contains. Ideally, I want to return a string from each element:
"0x5628, 0, 0"
From here I can parse it to my heart's desire... I just can't seem to get to the data portion. Any ideas?
|
|
|
|
|
You are calling the ToString() method on the object before you typecast it. That will use the Object.ToString() method that just returns the name of the class.
You have to typecast the object before you call any methods on it:
((string)item).ToString()
The call to ToString is of course completely superflous on a string object. Just remove it:
(string)item
---
b { font-weight: normal; }
|
|
|
|
|
Hi.
Have a remote object. This class has a method that generates and returns an image. I want to set this image to a picture box, on the client.
E.g:
picBox.Image = remObj.GetImage();
But when I run this code I get the following error:
“cannot find field nativeImage”
This error comes from 'System.Drawing.Image'
How can I stop this error?
How can I set the picture box image to an image created by the remote object?
Please note that I do not need help creating an image, just setting it to the picture box image from the remote object.
I am using C#, but I will be grateful for any assistance
Thank you for any help...
|
|
|
|
|
Note that there is a known bug in .NET remoting when trying to transfer large amounts of data over in a single call. The bug has been reported to exist when transferring 2MB or more of data in a single call, but I've found it to occur with less data than that.
Instead of transferring the entire image over in a single call, transfer a stream of bytes over in a single call, then call stream.Read(...) to read bytes incrementally in multiple calls. Once all the bytes are transferred over, you can reconstruct the image on the client and set the picture box's image accordingly.
See this article[^] for more information.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Hi everyone,
I need help using WebRequest and WebResponse.
Scenario: I want to send some data to a server and recieve it's response.
Code:
<br />
<br />
WebRequest myWebRequest = WebRequest.Create(sURL);<br />
<br />
myWebRequest.Method = "POST";<br />
myWebRequest.ContentType = "text/xml";<br />
<br />
string postdata = xmlcontent;<br />
<br />
ASCIIEncoding encoding = new ASCIIEncoding();<br />
<br />
byte[] postdatabytes = encoding.GetBytes(postdata);<br />
<br />
Stream requeststream = myWebRequest.GetRequestStream();<br />
<br />
requeststream.Write(postdatabytes, 0, postdatabytes.Length);<br />
<br />
myWebRequest.Timeout=10000;<br />
<br />
WebResponse myWebResponse= myWebRequest.GetResponse();
The GetResponse method just won't connect to the server, we have a connection log to see incoming requests.
Funny thing is that when I create a simply request without a request stream, it WILL connect to the server, through gets an error due to empty xml in the request.
Maybe there's a problem with the Stream?
-- modified at 9:45 Thursday 15th September, 2005
|
|
|
|
|
You can't just put xml in the data you post. That is not valid data in a request. If the request is invalid, it probably won't even register as a request in the log.
Put the data in the proper format for a request:
string postdata = "AnyKeyName=" + Server.UrlEncode(xmlcontent);
---
b { font-weight: normal; }
|
|
|
|
|
dont forget:
<br />
WebResponse myWebResponse= myWebRequest.GetResponse(); <br />
myWebResponse.Close();<br />
i had the same problem some time before
cu
|
|
|
|
|
hi, maybe u can help me, i'll apreciate!
first, sorry about my english.
I have some problems with security policy, and i duno the best workaround for that..
- I just finish a "installer.exe" (a WinApp in C#), this installer perform some process, do something on regedit, create virtual directory, things like that.
- This installer.exe stay on share directory on intranet server, our customers will put this installer on their intranet servers. So anybody should be able to exec the \\myserver\installers\intaller.exe or some like that...
- When the guys on their own station wanna run that installer, in specifics points they get the "System.Security.SecurityException" error
I workaroud this problem in my machine setting the .Net security policy to full trust.
BUT, no one wants to set the security policy in his machine, cause is boring, or they dont know how do that, and a installer shoul be convenient...
some body know ohter way to workaround this problem???
tanks!!
blitzkrieg bop!!
|
|
|
|
|
Hi!
You can create an msi file with security settings from the "Microsoft .NET Framework 1.1 Configuration" control panel and then install this together with your installer.
But you should not just set internet zone to "Full Trust" (as this will open a huge security hole!), but rather strong-name your installer and then only trust this assembly.
There's also (at least) an article here on CP dealing with code access security[^]
Regards,
mav
|
|
|
|
|