|
I have a property in a class, lets pretend that its called Foo.Message . Now i only want the class [or classes derived from] Bar to be able to get/set the property, but i want all other classes to be able to get the property. can this be done?
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Nnamdi Onyeyiri wrote:
Now i only want the class [or classes derived from] Bar to be able to get/set the property, but i want all other classes to be able to get the property. can this be done?
Nope
For some reason MS decided not to let the get/set methods have different visibility modifiers.
James
"The elastic retreat rings the close of play as the last wave uncovers
the newfangled way.
But your new shoes are worn at the heels and
your suntan does rapidly peel and
your wise men don't know how it feels to be thick as a brick."
"Thick as a Brick" from Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
Damn. I think im gonna pay a visit to Redmond
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
i created a class that i use as a display when errors occure in my program (in place of the messageboxclass). my question is how can import let alone play the standard messagebox sounds (like for question,asterisk,error,ect).
thanks alot.
jesse m
|
|
|
|
|
You can get the wave files configured on the system by looking at the following registry branch:
HKCU - AppEvents - Schemes - Apps
Under there you will see a series of 'System' settings:
SystemAsterisk
SystemExclamation
SystemHand
SystemQuestion
As far as playing them, I belive that you are stuck using the windows MM APIs or some other method. I am not sure if the .NET framework has a set of methods to play waves or not.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
Could you maybe derive your class from the MessageBox class?
Why waste time learning when ignorance in instantaneous
-Hobbes
|
|
|
|
|
Hi All,
I'm stuck with a problem serializing and de-serializing an array. I'm hoping somebody will be able to help me with. I'm trying to serialize an array of my custom class Query to a file. But when I check the file, I can only see one query in there. And when I try to de-serialize it I get an error saying Object doesn't implement IConvertable.
Does anyone have any idea what I am doing wrong? I've put the code below, maybe yee'd like to compile it and check what’s going wrong?
Thanks,
Donal
using System;<br />
using System.IO;<br />
using System.Runtime.Serialization;<br />
using System.Runtime.Serialization.Formatters.Soap;<br />
using System.Collections;<br />
<br />
<br />
<br />
namespace ProjQueryManager<br />
{<br />
class QueryManager<br />
{<br />
public QueryList qList;<br />
string sourceFile = @"C:\source1.dta";<br />
<br />
public QueryManager()<br />
{<br />
qList = new QueryList();<br />
}<br />
<br />
public bool CheckQuerySourceFile()<br />
{<br />
return true;<br />
}<br />
<br />
public void addQuery(Query QueryInfo)<br />
{<br />
qList.Add(QueryInfo);<br />
}<br />
<br />
public bool LoadFile()<br />
{<br />
FileStream inStream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read);<br />
StreamReader sReader = new StreamReader(inStream);<br />
SoapFormatter soapReader = new SoapFormatter();<br />
if(qList != null)<br />
qList = null;<br />
qList = (QueryList) soapReader.Deserialize(inStream);<br />
inStream.Close();<br />
<br />
foreach(Query q in qList)<br />
q.PrintInfo();<br />
return true;<br />
}<br />
<br />
<br />
public bool SaveQuerys()<br />
{<br />
FileStream outStream = new FileStream(sourceFile, FileMode.OpenOrCreate, FileAccess.Write);<br />
try<br />
{<br />
SoapFormatter soapWriter = new SoapFormatter();<br />
soapWriter.Serialize(outStream, qList);<br />
outStream.Close();<br />
}<br />
catch(SerializationException sem)<br />
{<br />
outStream.Close();<br />
Console.WriteLine(sem.ToString());<br />
}<br />
<br />
return true;<br />
}<br />
<br />
public bool SaveQuerys2()<br />
{<br />
try<br />
{<br />
ArrayList temp = new ArrayList();<br />
temp.Add("howdy");<br />
temp.Add("partner");<br />
<br />
FileStream outStream = new FileStream(sourceFile, FileMode.OpenOrCreate, FileAccess.Write);<br />
SoapFormatter soapWriter = new SoapFormatter();<br />
soapWriter.Serialize(outStream, temp);<br />
}<br />
catch(SerializationException sem)<br />
{<br />
Console.WriteLine(sem.ToString());<br />
}<br />
<br />
return true;<br />
}<br />
<br />
<br />
<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
QueryManager myQM = new QueryManager();<br />
Query qi = new Query();<br />
<br />
qi.name = "Query 1";<br />
qi.description = "The first Query";<br />
qi.SQL = "Selecr dfg dfg fdsfdsg gfds";<br />
myQM.addQuery(qi);<br />
<br />
qi.name = "Query 2";<br />
qi.description = "The second Query";<br />
qi.SQL = "Selecr dfg dfg fdsfdsg gfds";<br />
myQM.addQuery(qi);<br />
<br />
qi.name = "Query 3";<br />
qi.description = "The third Query";<br />
qi.SQL = "Selecr dfg dfg fdsfdsg gfds";<br />
myQM.addQuery(qi);<br />
<br />
<br />
<br />
<br />
myQM.SaveQuerys();<br />
<br />
}<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
<br />
[Serializable]<br />
public class Query : ISerializable<br />
{<br />
public string name;<br />
public string description;<br />
public string SQL;<br />
<br />
public Query()<br />
{<br />
}<br />
<br />
public Query(string qname, string qdesc, string qSQL)<br />
{<br />
name = qname;<br />
description = qdesc;<br />
SQL = qSQL;<br />
}<br />
<br />
public Query(SerializationInfo serInfo, StreamingContext streamContext)<br />
{<br />
name = serInfo.GetString("name");<br />
description = serInfo.GetString("description");<br />
SQL = serInfo.GetString("SQL");<br />
}<br />
<br />
public void PrintInfo()<br />
{<br />
Console.WriteLine("name: " + name);<br />
Console.WriteLine("description: " + description);<br />
Console.WriteLine("SQL: " + SQL);<br />
}<br />
<br />
public void GetObjectData(SerializationInfo serInfo, StreamingContext streamContext)<br />
{<br />
serInfo.AddValue("name", name);<br />
serInfo.AddValue("description", description);<br />
serInfo.AddValue("SQL", SQL);<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
[Serializable()]<br />
public class QueryList : IEnumerable, ICollection, ISerializable<br />
{<br />
protected ArrayList TheQueryList;<br />
<br />
public QueryList()<br />
{<br />
TheQueryList = new ArrayList();<br />
}<br />
<br />
public QueryList(SerializationInfo serInfo, StreamingContext streamContext)<br />
{<br />
try<br />
{<br />
<br />
ArrayList aL = new ArrayList();<br />
TheQueryList = (ArrayList)serInfo.GetValue("TheQueryList", aL.GetType());<br />
}<br />
catch(InvalidCastException e)<br />
{<br />
Console.WriteLine("Line 265: " + e.Message + "\n \n \n");<br />
}<br />
}<br />
<br />
public int Add(Query QueryInfo)<br />
{<br />
return TheQueryList.Add(QueryInfo);<br />
}<br />
<br />
public void GetObjectData(SerializationInfo serInfo, StreamingContext streamContext)<br />
{<br />
serInfo.AddValue("TheQueryList", TheQueryList.GetType());<br />
}<br />
<br />
public Query getQueryAt(int index)<br />
{<br />
if(TheQueryList.Count < index)<br />
return (Query) TheQueryList[index];<br />
else<br />
{<br />
Query temp = new Query("Index out of range", "null", "null");<br />
return temp;<br />
}<br />
}<br />
<br />
<br />
public int Add(string name, string description, string statement)<br />
{<br />
Query sQI = new Query(name, description, statement);<br />
return TheQueryList.Add(sQI);<br />
}<br />
<br />
<br />
<br />
public int Count<br />
{<br />
get<br />
{<br />
return TheQueryList.Count;<br />
}<br />
}<br />
<br />
public bool IsSynchronized<br />
{<br />
get<br />
{<br />
return TheQueryList.IsSynchronized;<br />
}<br />
}<br />
<br />
public object SyncRoot<br />
{<br />
get<br />
{<br />
return TheQueryList.SyncRoot;<br />
}<br />
}<br />
<br />
public void CopyTo(Array dest, int index)<br />
{<br />
TheQueryList.CopyTo(dest, index);<br />
}<br />
<br />
public void Clear()<br />
{<br />
TheQueryList.Clear();<br />
}<br />
<br />
<br />
public IEnumerator GetEnumerator()<br />
{<br />
return new QueryListEnumerator(TheQueryList);<br />
}<br />
<br />
public class QueryListEnumerator : IEnumerator<br />
{<br />
ArrayList TheQueryList;<br />
IEnumerator TheEnumerator;<br />
<br />
public QueryListEnumerator(ArrayList QLT)<br />
{<br />
this.TheQueryList = QLT;<br />
TheEnumerator = QLT.GetEnumerator();<br />
}<br />
<br />
public object Current<br />
{<br />
get<br />
{<br />
return TheEnumerator.Current;<br />
}<br />
}<br />
<br />
public bool MoveNext()<br />
{<br />
return TheEnumerator.MoveNext();<br />
}<br />
<br />
public void Reset()<br />
{<br />
}<br />
}<br />
<br />
}
|
|
|
|
|
Hello all, I'm fairly new to the C# and windows programming world, been stuck in the console too long..but anyways, im trying to write a collabseable groupbox type control, with a +/- in the top left of the groupbox, then allowing it to expand/collapse like a treenode..can anyone point me in the direction of where i need to start at? Thanks alot! ..i've read through alot of the tutorials but im still not sure on how i would make the list collapse and re-expand ..using OnPaint() i did have the +/- working with the MouseDown() event so that it changed from a + to a - correctly, but that was inheriting from System.Windows.Forms.GroupBox and using OnPaint() and OnMouseDown() ..thanks for any help you might be able to give me!
|
|
|
|
|
|
Yep that's actually what I've ended up doing so far..Using a panel is there any reason i shouldn't be able to draw a borderline around the whole thing and then encase the text in the middle of that borderline, to pretty much emulate a groupbox? Thanks alot for your help!!
|
|
|
|
|
I'm developing an application that charts data from an online real-time data vendor. I'd like to split the program into two main parts: 1) a server part that logs into and maintains the connection to the data feed, and 2) a charting/analysis part that charts and applies algorithms to the data.
The minimum requirement is once the server part is developed, I want to be able to: 1) login, 2) open a chart, 3) close the chart, 4) edit and recompile the charting code in visual studio without having to logoff. 4) open the chart again with the new edits operational.
The ideal senerio would be to not only stay logged on while editing and recompiling the charting code, but also not have to close the chart first. On recompile the edits would automatically be updated into the open chart.
It would seem that the server will need to be an exe and the charting a dll. In C# it looks like to accomplish dynamic loading and unloading of the charting dll, the charting dll will need to be in its own application domain.
I've studied Eric Gunnerson's MSDN article "AppDomains and Dynamic Loading" and this seems to be close to what I'm after. However his approach seems overly complex. I'm hoping to find a simpler way and hopefully some examples to implement my above stated minimum requirement and/or the ideal senerio.
Mark Clifton's Application Automation Layer also looks interesting.
Any thoughts/sugestions/examples would be greatly appreciated.
thanks,
Brian Dalby
|
|
|
|
|
If you need to unload and reload to the same type, the only way of doing it is with app domains.
You can sometimes get away with serializing the name of the type (chart1, chart2, chart3) when you modify it, and only load the new type. It's a bit ugly, however, and has more memory usage.
|
|
|
|
|
|
Hello,
For work I need to make a web based application.
I know JAVA applets will do what I want (this needs to be more like a windows prog and less like a web page)... does C# have anything like a JAVA applet???
Thanks,
Brian Hudson
|
|
|
|
|
|
Look up embedding .NET controls in a web page. It only works in IE 6, maybe in 5.x but I'm not sure.
Deploying a Runtime Application Using Internet Explorer[^]
James
"The elastic retreat rings the close of play as the last wave uncovers
the newfangled way.
But your new shoes are worn at the heels and
your suntan does rapidly peel and
your wise men don't know how it feels to be thick as a brick."
"Thick as a Brick" from Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
I am trying to create my first control and I don't understand what is going on, or why it isn't working. The control is simply going to paint a line through the center of a textbox. When I override the OnPaint method here, the MessageBox doesn't show up when I add the control to a test form and neither does the line, however everything compiles fine. Any suggestions? BTW, I am setting the property of the _borderlinecolor in the test example.
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
SolidBrush b = new SolidBrush(this._borderlinecolor);
Pen p = new Pen(b, 2);
p.Color = this._borderlinecolor;
e.Graphics.DrawLine(p, 0, this.Height/2, this.Width, this.Height/2);
MessageBox.Show("Hey, I just painted.");
}
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
I had exactly the same problem with OnPaint and classes derived from TextBoxes; it simply doesn't seem to run it.
Never did figure out why, MS don't seem to want you to inherit from TextBox or RichTextBox, so there's no documentation. I think the answer is to inherit from TextBoxBase but I'm not 100% sure. I ended up selecting the text I wanted to highlight because it was an internal project and that was enough; I do intend to fix it at some point though.
Paul
Pleasently caving in, I come undone - Queens of the Stone Age, No One Knows
|
|
|
|
|
Paul Riley wrote:
I had exactly the same problem with OnPaint and classes derived from TextBoxes; it simply doesn't seem to run it.
Well, at least I am glad that I'm not the only having a problem with this.
Paul Riley wrote:
I think the answer is to inherit from TextBoxBase but I'm not 100% sure.
When I tried that I got this error:
System.Windows.Forms.TextBoxBase.TextBoxBase() is inaccessable due to its protection level
Thanks for the repsonse.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Showing a messagebox in such functions is much like debugging code while having the current window DC handle on air. Read : this does not work.
I suggest to put text in the output console instead.
Also, be sure to call the OnPaint base class implementation.
|
|
|
|
|
S.Rod, thanks again, seems like I am running into brickwall after brickwall today. I made changes like you suggested and it looks like the following now, however I am still not getting anything even printed in the output console, any ideas?
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
SolidBrush b = new SolidBrush(this._borderlinecolor);
Pen p = new Pen(b, 2);
p.Color = this._borderlinecolor;
e.Graphics.DrawLine(p, 0, this.Height/2, this.Width, this.Height/2);
Console.WriteLine("I just painted....");
base.OnPaint(e);
}
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
I don't have .NET at work. Will look the details later tonight.
In the mean time, an obvious question : did you put a breakpoint in that ?
|
|
|
|
|
.S.Rod. wrote:
In the mean time, an obvious question : did you put a breakpoint in that ?
Yes, it seems as if it just doesn't work. I don't know, I think I am going to take a break for a few minutes and come back and look at it again. Thanks again.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
This is something that someone else had seen, Stan Shannon I think. The problem is that windows handles all of the painting for textboxes so the OnPaint method is never called.
There is a VB.NET article on control SubClassing using the NativeWindow class, I think that would give you the OnPaint method again.
Let me know if that works,
James
"The elastic retreat rings the close of play as the last wave uncovers
the newfangled way.
But your new shoes are worn at the heels and
your suntan does rapidly peel and
your wise men don't know how it feels to be thick as a brick."
"Thick as a Brick" from Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
I'm experiencing exactly the same problem, has anyone found a solution for this yet??
Please let me know!
Many thanks!
Richard
|
|
|
|
|