|
|
Ok then, chances are you've got an invalid xml file (did you change the class since it was last serialized?). See if an error is being thrown in your catch clause.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Okay on exception I get "There is an error in xml document (2,2)".
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Sounds like the xml file is corrupted. Try deleting the existing (possibly old) xml file, save a new one, and try loading it. Do you still get the error?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Hey my parents live in chaska, and my sisters in Eden Praire
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
|
I am doing this:
<br />
public class CommBaseSettings <br />
{<br />
public string port = "COM1:";<br />
public int baudRate = 2400;<br />
public Parity parity = Parity.none;<br />
public int dataBits = 8;<br />
..........<br />
public void SaveAsXML(Stream s)<br />
{<br />
XmlSerializer sr = new XmlSerializer(this.GetType());<br />
sr.Serialize(s, this);<br />
}<br />
<br />
public static CommBaseSettings LoadFromXML(Stream s)<br />
{<br />
return LoadFromXML(s, typeof(CommBaseSettings));<br />
}<br />
<br />
protected static CommBaseSettings LoadFromXML(Stream s, Type t)<br />
{<br />
XmlSerializer sr = new XmlSerializer(t);<br />
try<br />
{<br />
return (CommBaseSettings)sr.Deserialize(s);<br />
}<br />
catch<br />
{<br />
return null;<br />
}<br />
}<br />
}<br />
But it returns null even though I know the file exists
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
|
it's up above
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I am trying to implement a generic class, where the Generic type is a primitive type (uint, double, etc.). The class has a member variable that is an array of the generic type. In a member method, I want to access the array using pointers, but the compiler gives me the error:
Cannot take the address of, get the size of, or declare a pointer to a managed type ('T')
Is there any way to constrain the generic to be for a primitive type? Or is there any other workaround to accomplish this goal?
Below is the pseudo-code.
Thanks in advance!
class Image<T><br />
{<br />
T _pixels[];<br />
<br />
public Image<T> Cut(int top, int left, int width, int height)<br />
{<br />
unsafe<br />
{<br />
fixed(T* p = _pixels)
{<br />
...<br />
}<br />
}<br />
}<br />
}
Kim
|
|
|
|
|
Due to a limitation of the current generics implementation: there's no way to tell you're dealing with primitives. This may prove difficult for you, because you'll get this error as long as the compiler doesn't know you're dealing with primitives. It maybe be better to simply create specialized classes that contains integer, double, and so on.
I know there are some articles on this limitation, perhaps those will give you some insight.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Hi,
I have a statusbar with text. What I'm trying to do is make the text appear in the form of a tooltip whever text is too large to fit into the length of the statusbar panel. How can I accomplish that?
Thank you in advance.
|
|
|
|
|
Where do you want to display the ToolTip? Do you need the ToolTip on the mouse hover event of the statusbar panel?
|
|
|
|
|
Yes, just a basic tooltip unless there is a better way of displaying the text that is not completely visible in the statusbar.
|
|
|
|
|
All you need is drag drop a ToolTip object from the toolbox.
this.toolTip1.SetToolTip(this.StatusBarPanel1, "hello");
|
|
|
|
|
That's the easy part, well, actually statusbar panel has it's own tooltip. What I'm trying to figure out is how to know when to activate the tooltip, in other words, when the text is not completely visible.
Thanx
|
|
|
|
|
SendMessage SB_GETRECT on StatusBarPanel will give you the width of the SattusBar.
private const int WM_USER = 0x0400;
private const int SB_GETRECT = WM_USER + 10;
[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int left;
public int top;
public int right;
public int bottom;
}
RECT Rectangle;
SendMessage(this.StatusBar1.Handle.ToInt32, SB_GETRECT, Panel, Rectangle)
Graphics.MeasureString() will compute the pixel length.
Compare the lengths and if the text is clipped display the ToolTip.
|
|
|
|
|
"...Graphics.MeasureString() will compute the pixel length..."
Does it mean that I have to take over the drawing of the statusbar and catch a painting event in order to use this?
Thanx for all the help.
|
|
|
|
|
|
Thanx for your time. I was looking for something like 'DrawMode' in order to take over the painting, but nothing like this exists for this control. How and what event am I looking for to catch?
Thank you
|
|
|
|
|
In the StatusBarPanel you can
this.Parent.DrawItem += new StatusBarDrawItemEventHandler(Parent_DrawItem);
private void Parent_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
{
//Do the measure String
}
Anyway I will also make a demo app.
|
|
|
|
|
Here is a part of my code. I'm using e.Panel.Width to get the width of the panel. Is there a difference between this and what you suggested?
...this.statusBar1.Panels[0].Style = StatusBarPanelStyle.OwnerDraw;
this.statusBar1.DrawItem += new StatusBarDrawItemEventHandler(Parent_DrawItem);
...
private void Parent_DrawItem(object sender, StatusBarDrawItemEventArgs e)
{
SizeF stringSize = e.Graphics.MeasureString(e.Panel.Text, e.Font);
...
From here on I'm using stringSize.Width and e.Panel.Width, but when visually panel ends where the text ends their actual widths are very different, eventhough visually they are the same.
Why such difference?
Thank you for all the help
|
|
|
|
|
is there any way i can use a font in a form with out installing it on the machine may be as an embedded resource or like that...
|
|
|
|
|
How would I declare an array of pens and how would I access their attriblutes after I've declared?
Pen [] penArray = new ??.....
|
|
|
|
|
Pen[] penArray = new Pen[] { new Pen( Color.Blue ), new Pen( Color.Black ) };
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|