|
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
|
|
|
|
|
|
There seems to be no direct way to databind to a StatusBarPanel; I've run across some incomplete code samples that advises using a method to create a property for the statusBarPanel and then use the new property to databind to the dataset. The problem is I don't know how to proceed from there. Any help greatly appreciated.
Code Snippet ==========================================================
public string StatusBarPanel1Text
{
get
{
return statusBarPanel1.Text;
}
set
{
statusBarPanel1.Text = value;
}
}
|
|
|
|
|
In you Form do the following
StatusText st = new StatusText();
st.StatusBarPanel1Text = "HELLO";
this.statusBar1.DataBindings.Clear();
this.statusBar1.DataBindings.Add( new Binding("Text", st, "StatusBarPanel1Text"));
Declare the class
public class StatusText
{
private string str;
public string StatusBarPanel1Text
{
get
{
return str;
}
set
{
str = value;
}
}
}
|
|
|
|
|
Hi,
Thanks for responding to my issue; I tried your suggestion and it doesn't seem to work for me. I get no errors but the statusBarPanel remains unaffected.
|
|
|
|
|
I'm trying to modify one of my company's deployment projects. I've added a dialog to prompt the user to enter a server name. But I don't know how to get this value and do anything with it. Also, I'm trying to find any way to actually change the design of the dialog, is there a way to do this? Any help or links to good tutorials would be appreciated. Thanks in advance.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
BlackDice wrote:
I've added a dialog to prompt the user to enter a server name.
Have you done this via adding a "Textboxes" user interface window to the User Interface screen? If so, go to the properties window and you will see, in addition to BannerBitmap, BannerText, and BodyText, 4 possible edit values.
Each of the 4 edit values have a label, a property name (use this to then retrieve the input at a later time), and a boolean visible. You can make 3 of them invisible if you only need the first one. You will notice in Edit1Property, the default value is "EDITA1"
So for instance, if you are wanting to do something with the server name during the "Install" phase, you would do the following:
(1) Add a class library to your setup project's solution;
(2) Mark that class as an installer project through an attribute (MSFT[^])
(3) Open the Custom Actions editor window, and right-click on Install
(4) Add your output for your class library
(5) Get the Properties for that new entry under Install, and look at the CustomActionData field.
(6) Add a string to pass in such as /f1=[EDITA1]
Back in the class...
(7) Override the Install method
(7a) Call base.Install()
(7b) Call Context.Parameters["f1"] to get the value
That may not be completely accurate, but may give you more stuff to search for on google.
|
|
|
|