|
|
How can I display drgged object's shadow (or faded image) with the mouse pointer? Thanks.
|
|
|
|
|
You can change the cursor if you have a static image you want to show under the mouse. Otherwise, you need to draw it yourself.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If i make a stream of some sort out of it, and write to the stream, will the online file be edited?
I don't suspect so. Is there something i can do to do this?
|
|
|
|
|
Sure - if you have FTP write access, you can read the file, change it, and write it back.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Excellent, im so happy... well y'know.
|
|
|
|
|
when i'm looking at a value and using console.writeline(byte[0]); to print the output of a network stream. i am getting a 69 printed to the screen. is this an octal number or the binary number 69? 01000101?
|
|
|
|
|
It is 69 in decimal (01000101 binary). I don't know how/if C# can display octal.
A byte array is just a bunch of bytes - numbers that can range between 0-255 decimal, 00000000 to 11111111 binary, or 000-377 octal.
HTH,
Mike
|
|
|
|
|
If it was octal, it wouldn't have a 9 in it. If it was binary, then it wouldn't have a 6 OR a 9 in it.
I would have thought byte was a keyword and couldn't be an array name...
If you're worried, use ToString and pass it a format so you know what it is.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi All,
I have a product which I am planning on distributing to a few Beta testers. I thought it would be a good idea to incorporate some sort of licensing/registration scheme for it, so I can control it, have a trial version that expires after a certain period of time, etc. Does anyone have any experience with licensing solutions that can be used with .NET components?
Thanks,
Aaron
|
|
|
|
|
I'm trying to get a delegate to a property. Tip 2, solution 2 of the article linked below gives a way to do it. It works but a typo in the propertyName wouldn't be detected until runtime.
http://www.codeproject.com/csharp/csharptips.asp
<br />
private MySetDelegate xSetter = (MySetDelegate)Delegate.CreateDelegate(<br />
typeof(MySetDelegate), targetObject, "set_X");
I'm looking to replace the "set_X" parameter with the equivilant of "set_" + GetPropertyName(targetObject.X) , but having never used reflection before I don't know how to implement GetPropertyName or the equivilant.
|
|
|
|
|
Maybe I misunderstood the question, but you already have the property name (targetObject.X). Why do you need it again?
BTW, you can also achieve the same effect by creating a delegate to PropertyInfo.SetValue[^]. The code would then look like
class Test
{
int x;
public int X
{
get {return x;}
set {x = value; }
}
}
delegate void XDelegate(object obj, object value, object[]index);
static void Main(string[] args)
{
Test t = new Test();
PropertyInfo propertyInfo = t.GetType().GetProperty("X");
XDelegate xdel = new XDelegate(propertyInfo.SetValue);
xdel(t, 2, null);
Console.WriteLine(t.X);
}
|
|
|
|
|
S. Senthil Kumar wrote: Maybe I misunderstood the question, but you already have the property name (targetObject.X). Why do you need it again?
The issue with entering it into the code as a string is that typos aren't detected until runtime. This has burned me severa; times already.
Thanks for the delegate example. The only one I was able to find left the impression that it only would work with classes that supported the Invoke method, which mine did not.
|
|
|
|
|
dan neely wrote: The issue with entering it into the code as a string is that typos aren't detected until runtime.
A very valid concern, but that's the cost of using reflection and runtime method invocation, I guess. You have to make assumptions that cannot be verified at compile time. Instead of hardcoding a string, you could, for example, get all properties on a class and access the nth property, but that assumes new properties are always added at the end.
|
|
|
|
|
.NET newbie question
I have a Collection object that I would like to copy into another collection object.
The collection is of type:
System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationRule>
The Collection.CopyTo method requires that I provide an array and an index. The question is: How do I syntactically express the array portion of the target collection.
I can't do this, because param 1 is a Collection:
Collection1.CopyTo(Collection2, 0)
I hoped I could do something like this to specify the array, but alas no:
Collection1.CopyTo(Collection2[], 0)
Is there a way I can do this or do I have to enumerate the contents of Collection1 and Add to Collection2?
Thanks
|
|
|
|
|
Well, you could always do
Collection2.Clear();
Collection2.AddRange(Collection1);
|
|
|
|
|
No such method (AddRange) on the Collection class.
|
|
|
|
|
My bad. I assumed you were using the List class. Looks like you have no other option other than looping over and copying elements.
|
|
|
|
|
Such is life in .NET.
Times like this I miss things like memcpy and void **
~
|
|
|
|
|
I have a windows control that I need to show in a web browser. I know that you can load a control in a browser using this method:
<br />
<object id="MyControl" classid="MyControl.dll#MyNameSpace.MyControl"><br />
</object><br />
However, the control I need to show, isn't very small and I noticed that the clients machine doesn't save a copy of the control on their computer (only as a temp file). I would like the control to act like an ActiveX where the control gets downloaded on the clients machine once, and not everytime the user browses to site.
I have also tried exposing the control for COM and tried (as you can see, I compressed the control in a CAB file):
<br />
<OBJECT CLASSID="clsid:1A41BBAF-9059-37AF-BCEF-CC8BB318D4CC"<br />
CODEBASE="MyControl.cab#version=1,0,0,0" ID="MyControl" ><br />
</OBJECT><br />
Using this method the control gets downloaded to the clients machine, it is still a .NET assembly it doesn't get registered on the client machine, and thus doesn't get envoked.
Does anyone have any ideas, or am I missing something?
Thanks in advance
Jeremy
|
|
|
|
|
Hello,
I have a problem, my application is drawing a simple text in the middle of a window, but the text is rotated by a user-defined angle. The problem is I cant make the text appear in the middle (the rotating makes the point change its location. My code looks like follows:
<br />
graphics.RotateTransform(-rotateAngle);<br />
graphics.DrawString(mystring, myfont, myBrush, drawpoint, new StringFormat());<br />
I know I should put a graphics.TransformTranslate(_x,_y) - BUT I HAVE NO IDEA HOW TO FIGURE OUT THE POINTS for that purpose (before the locatin I was simply using X=width/2-measurestring/2, Y=height/2-measurestring/2). Any one know the maths for that ?
|
|
|
|
|
You need to do a TranslateTransform to change the point of rotation.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sorry - I see you know to translate - use Graphics.MeasureString to get the size of the string you want to draw.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
well, I actually use the MeasureString and TranslateTransform, but the problem is that Im drawing the string in that way
- Rotate the graphics by an user-specified angle
- Draw text
- Rotate the graphics back to the previous position
After this three steps I got an imaged and a text drawn on it on an angle I specified. The only problem is that I want to draw the text lets say in the middle and Im not sure how to get the coordinates of the point that after the rotating back the text will be at the middle of the image.
Its actually a math matter, but Im not sure how to solve it.
|
|
|
|
|
seq- wrote: - Rotate the graphics by an user-specified angle
- Draw text
- Rotate the graphics back to the previous position
Where are you using the Translate ?
You need to move the image so that 0,0 is the centre of the point of rotation you want to achieve.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|