|
My propertyGrid looks a bit jumble up...
I have used [CategoryAttribute("abc")] but it is still messy.
How can i arrange my attribute(up or down) to my preperences in the property grid when it is in "categorized" view?
Thank you in advance.
|
|
|
|
|
You need to create a TypeConverter for your object and override the GetProperties() method
[TypeConverter(typeof(MyClassConverter))]<br />
public class MyClass <br />
{<br />
...<br />
}<br />
<br />
public class MyClassConverter : TypeConverter<br />
{<br />
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)<br />
{<br />
<br />
PropertyDescriptorCollection collection = TypeDescriptor.GetProperties(typeof(MyClass), attributes);<br />
<br />
string[] s = new string[3];<br />
s[0] = "XYZPropertyName";<br />
s[1] = "ABCPropertyName";<br />
s[2] = "IJKPropertyName";<br />
<br />
return collection.Sort(s);<br />
}<br />
}
So when you look at the properties of MyClass in the property grid, they appear in the specified order
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
I assume MyClass is the propertygrid.SelectedObject class.
Then i do like what u told but the code:
string[] s = new string[3];
s[0] = "XYZPropertyName";
s[1] = "ABCPropertyName";
s[2] = "IJKPropertyName";
i follow exactly cause i don't know what is it?
My program runs the same before and after i added this code.
Please help again, i m very beginner...
Thanks so much for helping.
|
|
|
|
|
I assume MyClass is the propertygrid.SelectedObject class.
Yes.
Instead of
public class MyClassConverter : TypeConverter
try replacing it with
public class MyClassConverter : ExpandableObjectConverter
instead
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
I change the content of the function to just:
PropertyDescriptorCollection collection = TypeDescriptor.GetProperties(typeof(GraphicsProperties), attributes);
return collection.Sort();
I manage to sort it aphabetically, propertygrid is more neat now. Thanks a lot!
|
|
|
|
|
Is polling really the only way to get information about a clients connection status. I am work on an application where more the one client is connected to my server app. and I need a notification when a client disconnects. Can anyone help me?
|
|
|
|
|
Hello,
Did anybody tryed to get a reference to a DCOM server, located on some remote machine using C#.NET??? It would be nice if one shares he's knowledege with me.
Vad
|
|
|
|
|
try:
Type t = Type.GetTypeFromProgID("ProgId","RemoteServerName");<br />
Object o = Activator.CreateInstance(t);<br />
Typelib or proxy stup for the DCOM component would need to be registerd on the local machine...
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
Thanx a lot, looks correct.
|
|
|
|
|
Hi,
I've also this type of problem. How can I run the server on a remote machine ?
I discover DCOM - COM programmation (in .Net) and I've just be able for the moment to create a client - server on the same machine and the server is instancied by the client. (1 instance of server by client).
I would like to run the server on a remote machine, and call it with clientS and to get then only one instance of the server.
Thks a lot
Denis
|
|
|
|
|
My problem is that i trye to move some bit's from one byte in spacific position to another byte in the same position
EX.
Byte :A = 11111111
Byte :B = 00000000
let us say that i want to move the last 4 bits in A to the last 4 bits in B my result should be
A = 11111111
B = 00001111
and thatnks verey much
|
|
|
|
|
|
thanks you for your answer
but i found a problem onit it give me a error message which say that the int cannt be converted to byte
where is the problem here i try to solve it
thanks again
|
|
|
|
|
|
Hi
Im using C#,ASP.NET
I Pass Form Instance of a WebForm to another class(.cs) and Hide the Controls in the webform.I can do this by calling the method of .cs in Page Load.I have to do this for many webforms.In this case i have to copy all method calls in all WebForms Page Load.
If I can Get the Form Instance of Requesting WebForm in Global.asax.cs it would be easy so that i can have the Method Call in GLobal.asax.cs file's Application_BeginRequest Method.
Please Help me in This.
Thanks in Advance.
Regards,
Rajesh Thomas.
|
|
|
|
|
Hello all.
I have a little problem, rooted in the fact that I'm a newbie coder.
To get down to business, what I'm trying to do is this:
I have a list of status codes that I use, for example:
BLAH = 1
FEMALE = 2
POISONED = 4
FOO = 8
BAR = 16
etc...
HIDDEN = 128
and I then construct a status indication code from that. Say for example that I am Hidden (128) and Poisoned (4) then that would yeild 132. See where I'm going with this?
Well, the problem I have is reversing it. How do I check if I am poisoned? Some voice int he back in my head is tellingme something about XORing backand forth, but I have no clue where to start with that. I really want to avoid 300 if checks to see if the poisoned person happens to be female, or god forbids, also hidden.
What I want is that once a status is detected in the total 1-byte (0-255) code it should toggle an assigned bool accordingly, for example - status 4 should set isPoisoned = true.
Any easy way to do this?
I'd be eternally grateful.
|
|
|
|
|
Sure, it's quite easy.
First, you should define an enum with your status flags:
[Flags]
public enum Status
{
Hidden = 1,
Poisoned = 2,
Sleeping = 4
} In your class you can have an attribute for the status:
protected Status characterStatus; and, if you like, properties for the single flags:
public bool IsHidden
{
get { return (characterStatus & Status.Hidden) == Status.Hidden; }
set {
if (value)
characterStatus |= Status.Hidden;
else
characterStatus &= ~Status.Hidden;
}
}
Regards,
mav
|
|
|
|
|
Thanks for the reply, it was very helpful.
However, I'm still not sure how to process the numerical status "summary". Because it is an int when I read it I'm not sure how to process it as a "compacted" list of Statuses.
For example, I get "132" so I try to set characterStatus to that, which is "Status" and not "int" so I'm a bit lost there.
To explain more in depth what I'm doing here... I'm writing a little program that reads certain memory addresses of a game, and should display a little window with colored boxes indicating whether I'm, say, poisoned or not (green box if so, red otherwise).
The status byte is therefor 0-255, and I have to make "sense" of that, in term of enumerated statuses. Perhaps I'm going about it the wrong way.
|
|
|
|
|
|
In which way are you going to "process" the status? It's a list of values that can be OR'ed to form an integer, nothing more, nothing less.
In the example, if you want to set several status bits in one go, you can write
characterStatus = Status.Poisoned | Status.Sleeping; which is equivalent to writing
characterStatus = 6; In order to colorize a box you'd write something like
Color boxColor = IsPoisoned ? Color.Green : Color.Red; with the IsPoisoned property implemented similar to IsHidden in my previous posting.
The reason you're getting integer values when you query the characterStatus is that Enum s are based on integers (Int32 IIRC) by default. You can use different data types (for example Int16 or byte ) if you write
public enum Status : byte Regards,
mav
|
|
|
|
|
Hi all,
I've used VS.NET to add my own counter category, but it's only on my machine! If I run my app on anohter machine, the category's not there. How do I create the category on other machines?
Do I have to build some kind of setup project to do it, or do I have to do it in my code: something that creates the category on app-startup and removes it on app-shutdown.
thanks...
/=/=/=/= Sagmam =\=\=\=\
|
|
|
|
|
hi
I'm a Korean student.
I'm studing C# and image processing.
I am reading a book, the book's name is GDI+ Programming wrote by you.
I'm studnig 16bit RAW image file.
But I did'nt display on screen.
How can i do?
please help and detail information.
-----my programming source is here -----
FileStream fs = File.Open(strFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
BufferedStream buf = new BufferedStream (fs);
BinaryReader r = new BinaryReader(buf);
Bitmap bitmaps = new Bitmap (_Define._ImageWidth, _Define._ImageHeight, PixelFormat.Format16bppGrayScale);// .Format48bppRgb);
BitmapData bmData = bitmaps.LockBits (new Rectangle(0, 0, _Define._ImageWidth, _Define._ImageHeight), ImageLockMode.ReadWrite, PixelFormat.Format16bppGrayScale);
bitmaps.UnlockBits (bmData);
UInt16 *p = (UInt16 *)(void *)bmData.Scan0.ToPointer();
UInt16 swap;
int nTotal = _Define._ImageHeight*_Define._ImageWidth;
byte [] data = new byte [nTotal];
try
{
int nPer = nTotal / 10;
int nCnt = 0;
for(int y = 0; y < nTotal; y++) // 원본을 로드하기위한 For문...
{
if (y%nPer == 0) {
pLoading._Percent = nCnt;
nCnt += 10;
pLoading.Refresh ();
}
swap = (UInt16)(r.ReadInt16 ());
*(p) = swap;
p++;
}
}
catch(Exception fo)
{
MessageBox.Show(fo.ToString());
}
// m_pPanel is View
MDProcess.ImageObject pImage = new ImageObject (m_pPanel);
pImage._ImageName= strFileName;
pImage._rcBound = InitImagePT (iFiles);
pLoading._Percent = 100;
pLoading.Refresh ();
m_alImageList.Add (pImage);
pLoading._Counter = i;
pLoading._Total = alFiles.Count;
pLoading.Refresh ();
bitmaps.Dispose ();
fs.Flush ();
buf.Close ();
fs .Close ();
r.Close ();
|
|
|
|
|
i want to write a HighLight porgram, but i do not know how to match this string :
/*123adfadfr55543sttttt
adfdafeefefefefe
ddddghhhh*/
|
|
|
|
|
|
I don't understand - why do you need regex to match a constant string ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|