|
Karthik Gaekwad wrote: I'm using the principle of serial loopback
I don't think you can use a principle I think you have to actually have a loopback.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
led Mike,
You are correct. I am using loopback to solve the problem, but my recieve thread won't fire, even if I have the recieve wait for a message.
Hope that clears it up. Any suggestions?
-Karthik
|
|
|
|
|
And the solution is....
After you write to the port using a serial port object, use the readExisting method. DO NOT CLOSE THE PORT and then OPEN the port again to read. There is nothing stored in the buffer at that point.
I can be so dumb sometimes. That's what I get for trying to modularize my program.
|
|
|
|
|
Nice work, thanks for posting the solution.
|
|
|
|
|
Hello,
Directory.Exists(“\\localhost\c$”) and Directory.Exists(“\\localhost\SomeLocalShare”) and Directory.Exists(“\\127.0.0.1\c$”) and Directory.Exists(“\\127.0.0.1\SomeLocalShare”) all stop returning true once the network goes down. I know this seems obvious but how is it I can still resolve the local instance of SQL server? My question is how do I resolve a UNC name (assuming it is localhost) if the network is down, disabled, or non existent on Windows Xp pro and Better?
I was thinking of a virtual port maybe or a virtual Nic.
Any help will be very much appreciated
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
Okay, maybe this is really a silly question but why do you need to resolve a UNC to the localhost/local system? I'm trying to figure out what purpose this would serve and for the life of me I don't get it.
Here's why I'm a bit lost: The localhost/local system is a known quantity and therefore you can write your code to use local system drive paths for accessing any information.
Mike Poz
|
|
|
|
|
I’m writing a tablet app that has start up parameters in a Db. Some of the parameters are UNC paths to data libraries that may or may not be local. Some tables will have a constant connection to the LAN, others will be disconnected piroticly. I’ll know in advance the ones that are mobile and set the data stores to be local in the Db. I want to use the same logic in both connected and disconnected environments. (I’m able to assume that the app was started with either a connection to the Db or a copy of the data needed locally) Also how Universal is a naming convention if it Only works in a connected environment. In the real world 25 drives are not enough. I think the whole industry should do away with the idea of local letters and move completely to UNC \\Device\share\path.
One idea I had was to find where windows holds its share info and find the local resource that way. In the db I’d have \\computerName\share so I could parse it out and compare to this list. In computer management Win still know what it is sharing even with no NIC
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
HahnTech wrote: One idea I had was to find where windows holds its share info and find the local resource that way.
That's maintained in the registry under HKLM here:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares
You'll find keys with each share name, and their data value contains permissions and local path to the share.
This assumes your use account has the permissions to at least read this information.
HahnTech wrote: I’ll know in advance the ones that are mobile and set the data stores to be local in the Db.
If you will know in advance what is local and what is remote, then it sounds to me like you need to have some error checking with some "if - else" blocks to deal with when your "directory.exists()" fails to return true.
If(Directory.Exists(\\localhost\c$)
{
Connect(\\localhost\c$\datbase);
}
else
{
//try a possible local path using C:\
or
//pop an error stating that the database is unavailable
}
Either way this is basically an error handling issue where you need to fail gracefully when your "directory.exists" returns false.
Mike Poz
|
|
|
|
|
Thanks for the Reg Keys. I'll look into that solution.
This is not an error handling problem. This is a windows problem with not Fully utilizing UNC. There is no way to convert the parts of a UNC name into a local path. A properly normalized db will have separate columns for device, share, and path (UNC: \\DeviceName\ShareName\Path) so its not as simply as If UNCpath exists Else just use local. That would require restructuring the Db. And as you probably know that’s not always an option.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
Hi,
Is it posible to implement a class inheritet from eg. int string .. types
thx
|
|
|
|
|
int and string are both sealed. You cannot inherit from a sealed class.
You could try implementing a class to wrap an int or a string though that might meet you needs.
|
|
|
|
|
|
string-> NO
public sealed class String
int (Int32) is a struct. Does not support inheritance
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Why on earth would you want to?
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
how can i have ellips form
MD_NADA
|
|
|
|
|
|
Hi everyone!
I've got a problem, coding in C#!
I have to create some PictureBox controls at runtime and the number of these will be specified at runtime too. Next, I should be able to target them by the name.
I mean I have to be able to generate the names as I need, at runtime, something like this:
<br />
for(int x = 0; x < xCount; x++){<br />
for(int y = 0; y <yCount; y++){<br />
public PictureBox "PictureBoxX"+x.ToString()+Y+Y.ToString() = new PictureBox();<br />
}<br />
}<br />
and then I should be able to access the control by its name and also be able to assign its properties!
There is a function in Javascript and Actionscript that make the object accesible at runtime by generating its name:
<br />
piece3 = "dangerous";<br />
x = 3; <br />
y = eval("piece" add x);<br />
trace(y);
or
<br />
name1 = "mike";<br />
name2 = "debbie";<br />
name3 = "logan";<br />
for(i = 1; i <= 3; i++) {<br />
trace (eval("name" add i));
but I couldn't find such a thing in C#!
Please help me with this! ((
Sojaner!
|
|
|
|
|
Would something like this help:
PictureBox temp = new PictureBox();
temp.Name = "PictureBoxX" + x.ToString();
MyForm.Controls.Add(temp);
Then to use your PictureBox:
PictureBox temp = (PictureBox) MyForm.Controls["PictureBoxX" + x.ToString()];
This will give you a mechanism for retrieving your PictureBoxes using a string, but it's not quite the same as eval in JavaScript, but it's probably safer.
-- modified at 17:28 Tuesday 27th June, 2006
|
|
|
|
|
Thanx a million, taking time to answer!
I've not tested it yet, but I'm almost sure it would work.
Sojaner!
|
|
|
|
|
Why do you think that you have to access the references to the picture boxes by name?
C# is not a script language, so there are no dynamic creation of variables. Use an array, a list, or a dictionary.
---
b { font-weight: normal; }
|
|
|
|
|
Thanx a million, taking time to answer!
Do you mean using a 2 dimention array of PictureBox controls?
And you mean, when coding in C#, from the beginning, you have to plane every object and other things and there is no way to decide what to do at runtime, like scripting languages?
|
|
|
|
|
Sojaner wrote: Do you mean using a 2 dimention array of PictureBox controls?
How you store the references depends on how you want to access them. If they are arranged in rows and columns in the form doesn't mean that you have to use a two dimensional array to keep track of them.
And you mean, when coding in C#, from the beginning, you have to plane every object and other things and there is no way to decide what to do at runtime, like scripting languages?
Yes. I have never really seen that as a limitation, though.
There are a lot of neat data structures like arrays, lists, linked lists, sorted lists, dictionaries, sorted dictionaries, queues and stacks that you can use to store data. A dictionary actually resembles what a script language uses to handle all variables.
I've built a lot of rather advanced web sites in VBScript too, and never needed to create variables dynamically there either. I believe that the Eval command is pretty much like the Goto command; it's never really needed, and your code gets better if you avoid it.
---
b { font-weight: normal; }
-- modified at 15:41 Wednesday 28th June, 2006
|
|
|
|
|
Yep, you are damn right!
I think I've got the point.
Thanx a million.
I tried what you told and everything went right.
Here is the code I wrote to solve the problem, do you like it?
PictureBox[,] pictureBoxes;
private void Form1_Load(object sender, EventArgs e)
{
pictureBoxes = new PictureBox[20, 20];
for (int x = 0; x < 20; x++)
{
for (int y = 0; y < 20; y++)
{
pictureBoxes[x, y] = new PictureBox();
pictureBoxes[x, y].Name = "pictureBoxX" + x.ToString() + "Y" + y.ToString();
pictureBoxes[x, y].Width = 10;
pictureBoxes[x, y].Height = 10;
pictureBoxes[x, y].Left = x * 10;
pictureBoxes[x, y].Top = y * 10;
pictureBoxes[x, y].BorderStyle = BorderStyle.FixedSingle;
pictureBoxes[x, y].Click += new EventHandler(PictureBox_Click);
this.Controls.Add(pictureBoxes[x, y]);
}
}
}
void PictureBox_Click(object sender, EventArgs e)
{
PictureBox temp = (PictureBox)sender;
ChangeColor(temp);
}
void ChangeColor(PictureBox pictureBox)
{
Random random = new Random();
Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
Graphics graphic = Graphics.FromImage(bitmap);
SolidBrush brush = new SolidBrush(Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)));
graphic.FillRectangle(brush, new Rectangle(0, 0, pictureBox.Width, pictureBox.Height));
pictureBox.Image = bitmap;
}
Sojaner!
|
|
|
|
|
I would use a local variable to reference the picturebox that is created, so that I don't have to access it in the array all the time:
PictureBox pictureBox;
pictureBox = new PictureBox();
pictureBox.Name = "pictureBoxX" + x.ToString() + "Y" + y.ToString();
pictureBox.Width = 10;
pictureBox.Height = 10;
pictureBox.Left = x * 10;
pictureBox.Top = y * 10;
pictureBox.BorderStyle = BorderStyle.FixedSingle;
pictureBox.Click += new EventHandler(PictureBox_Click);
this.Controls.Add(pictureBox);
pictureBoxes[x, y] = pictureBox
You have forgotten to call Dispose on the Graphics object and the SolidBrush object when you are done with them.
Also, you should check if there already is an image in the picturebox, so that you can call Dispose on in after you replaced it.
---
b { font-weight: normal; }
|
|
|
|
|
Hi guys, I have an mdi form and I am trying to open a web form from one of the click events. The click event is for Contact us and I would like to open a web form that I have created, called contactus.aspx. How do I open the web form from the mdi form? Please help!!!
sasa
|
|
|
|