|
No, you can't, you should wrap the classes instead.
|
|
|
|
|
Hello,
i am using microsoft indexing services for searching documents. but when i search for arabic words an error occur indicating that following : --The query contained only ignored words--.
Any help was appreciated.
Regards.
dghdfghdfghdfghdgh
|
|
|
|
|
Show me the Query ,
And fix your Signature
I know nothing , I know nothing ...
|
|
|
|
|
I have an application that uses some transparent windows that are put on an other application's windows. These transparent windows contains some boxes that are meant to show some information on the windows of the other application. A need that when the use clicks on the transparent parts of my windows, mouse clicks are carried to the element that is below my transparent windows.
I use a .net Form with background color set to the transparentkey.
Everything works good under Win XP but under Vista the transparent window blocks every mouse click , it's transparent for the eyes but not for the mouse.
Anyone knows a solution?
|
|
|
|
|
i found a solution using interops
This works under Vista.
<pre>
--------------
public const int GWL_EXSTYLE = -20;
public const int WS_EX_LAYERED = 0x80000;
public const int LWA_ALPHA = 0x2;
public const int LWA_COLORKEY = 0x1;
[DllImport("user32.dll")]
static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey,
byte bAlpha, uint dwFlags);
-----------------------
//..in the form constructor
//if the win is not layered , the layered attribute needs to be speciefied in its styles
this.BackColor = Color.FromArgb(0xaf,0xaf,0xaf);
SetLayeredWindowAttributes(this.Handle, 0xafafaf, 255, LWA_COLORKEY);
|
|
|
|
|
Could you recommend me some services that allow us to generate C# code from a specification ? Thanks in advance
|
|
|
|
|
What specification?? What exactly are you trying to do?? Generate a class file from a database?? You're going to have to be pretty specific in what you you want generated and from what kind of spec.
|
|
|
|
|
Well, there is one called www.rentacoder.com
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi folks,
I have written 2 applications on my till running windows 2000. One is an epos system and the other is a "driver" which parses the text from the touch screen and moves the mouse accordingly.
I'm having a very strange issue. I have recently added network functionality to my epos app. There is a classwhich keeps retrying to connect to the server incase the network is down. What I find is that during this loop (which is run in a seperate thread from my epos app's main thread), my touchscreen driver just doesn't move the mouse or just crashes if you just wait long enough (circa 1 minute or so) with a Send/Don't Send style message "system.indexoutofrangeexception". Once the epos app connects to the server, the touch screen drivers works again (provided it hasn't crashed already...).
Here is my "connector" class used in the epos app:
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Windows.Forms;
namespace Paypoint
{
class Connector
{
Network networkinterface;
IPEndPoint ipEnd;
public Connector(Network network, IPEndPoint endpoint)
{
networkinterface = network;
network.Connected = false;
ipEnd = endpoint;
}
public void Start()
{
while (true)
{
if (networkinterface.Connected == false)
{
networkinterface.initSocket();
connect();
}
Object objData = "ping";
byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString());
networkinterface.send("ping");
Thread.Sleep(2000);
}
}
private void connect()
{
while (!networkinterface.Connected)
{
try
{
Network.m_clientSocket.Connect(ipEnd);
networkinterface.Connected = true;
}
catch
{
networkinterface.Connected = false;
Thread.Sleep(10000);
}
}
}
}
}
Here is my TouchScreen "driver". It's a small app so I've included all of it:
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.IO.Ports;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
namespace EpsonTouchPanelDriver
{
class Device
{
static SerialPort spt;
public static int x;
public static int y;
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public static void init()
{
spt = new SerialPort();
if (spt.IsOpen) spt.Close();
spt.PortName = "COM4";
spt.BaudRate = 9200;
spt.DataBits = 8;
spt.StopBits = StopBits.One;
spt.DataReceived += new SerialDataReceivedEventHandler(spt_DataReceived);
spt.Open();
}
private static void spt_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
int i = 0;
byte[] bytesToReadArray = new byte[1024];
while (spt.BytesToRead > 0)
{
bytesToReadArray.SetValue((byte)spt.ReadByte(), i);
i++;
}
string str;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
str = enc.GetString(bytesToReadArray);
if (str.Substring(0, 1) == "T")
{
char[] delimiterChars = {','};
double scalex;
double scaley;
if (str.Length > 1)
{
try
{
str = str.Substring(1, str.Length - 1);
string[] xy = str.Split(delimiterChars);
if (xy[1].Length > 4) xy[1] = xy[1].Substring(0, 4);
if (int.Parse(xy[0]) < 525) scalex = 0.61 - ((525 - int.Parse(xy[0])) * 0.0004);
else scalex = 0.61 + ((int.Parse(xy[0]) - 525) * 0.00005);
if ((1000 - int.Parse(xy[1])) < 500) scaley = 0.4873 - ((500 - (1000 - int.Parse(xy[1]))) * 0.00005);
else scaley = 0.4873 + (((1000 - int.Parse(xy[1])) - 500) * 0.00005);
x = (int)(int.Parse(xy[0]) * scalex);
y = (int)((1000 - int.Parse(xy[1])) * scaley);
if ((x > 0) && (y > 0))
{
Cursor.Position = new Point((int)x, (int)y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, Cursor.Position.X, Cursor.Position.Y, 0, 0);
Thread.Sleep(100);
}
}
catch
{
MessageBox.Show("ERROR");
}
}
}
}
}
}
I find this behaviour very strange as these are 2 different assemblies! I simply don't have the knowledge required to understand how one app can cause another to crash.
Thanks for your help. It's appreciated
**Update**
Ok so the suitation gets weirder. I have found out that during the time when my epos app is trying to connect to the server (hense also the time when to touchscreen won't work), the mouse CAN move if the "driver" Winform is in Focus (normally, it is minimised to the system tray..)
Jonny
p.s. sorry about the bad formatting
**UPDATE 2**
OK folks yet another update! If I put a Thread.Sleep(10) in my driver app just before the if statement, then it works just VERY slowly (Unuseable but hey, there's life!).
modified on Saturday, May 30, 2009 5:36 PM
|
|
|
|
|
Hi,
first of all, please fix the post with real < pre> tags so code gets shown formatted and hopefully becomes readable. (you must now have & lt; instead of < signs)
there probably are several errors:
1.
I trust spt.BaudRate = 9200; is a typo (9600 and 19200 would be normal values). AFAIK SerialPort would not even accept that odd value.
2.
from the documentation: "The DataReceived event is raised on a secondary thread when data is received from ..."
you are not allowed to touch Controls inside the DataReceived handler, it will sooner or later cause nasty behavior such as freezing GUI or hanging app.
The one correct solution is using Control.InvokeRequired and Control.Invoke; google for that.
3.
in general when messages are coming in over a serial port, the SerialPort class only understand characters, not messages, and the DataReceived event may fire and offer you one partial message, one complete message, two partial messages, whatever. So your code needs to know how to handle these. Quite often by storing it all into a buffer, then looking for entire messages, and removing them when processed.
There probably are two exceptions:
- when quiet periods in between messages exist, you could insert a Thread.Sleep at the start of the DataReceived, with a delay large enough to be sure an entire message would have been received by the time you actually read it out.
- text messages ending on NewLine (some string you can set to SerialPort.NewLine) would cause a SerialPort.ReadLine to return just one message; this means you organize a thread calling ReadLine, and not using DataReceived event at all.
Overall remark:
your code has several try-catch blocks where the information is thrown out; that is a stupid idea. Best is to have
try {...}
catch(Exception exc) {
log(exc.ToString());
}
where log would be a method able to somehow log/print/show a multiline text.
In the rare case you don't want to see a very specific exception, check for that specific one like this:
try {...}
catch(SomeVerySpecificException exc) {
}
catch(Exception exc) {
log(exc.ToString());
}
This may be relevant to the networking part, where maybe something unexpected is happening without you knowing it at all.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
Thanks you for your great reply.
I found the solution to this. My network Listener class has an infinate while loop in it (which is used when the server isn't connected) and I forgot to add a Thread.Sleep(100) so it was taking up 100% of CPU time! Silly me!!
Thanks for spotting the 9200! I've been using that the whole time. What's strange it that it hasn't caused a problem. Maybe .NET rounds it up to the correct value?
Thanks
Jonny
|
|
|
|
|
I am working on an application that uses camera(s) to detect while lane lines on different surfaces adn track them, and eventually give directions to the vehicle (two wheeled robot) so that the vehicle stays in between the lines. So far I managed to write the program so it takes color video feed and converts it to black and white, and filters the edges so it detects the edges of the lanes. I don't know where to go from here. Any suggestions?
|
|
|
|
|
Looks like a fun and interesting problem. Without knowing anything more regarding your app I would advice you to look a bit at AI and gaming AI for inspiration.
First of all I would try to create perception layer whose purpose is to present the world in a a simpler format in which your robot knows its options and operate at full speed. This may also give you as a developer ideas of how to interpret robots world and to enhance your world parsing algorithm.
Best of luck
/U
What if the world was your spoon.
What if was in your power to bend it to your liking.
What if it could provide for you whatever you asked of it.
|
|
|
|
|
I agree with Uffe Rask, this sounds like an interesting project. Now, I know very little about Robots, modern ones anyway, but I googled for line following robot algorithm and got lots of hits that sounded to me like they might be of help. Perhaps if you do the same (always assuming that you haven't already done so), you might find something that you can adapt.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
What i was thinking, was to use the edges detected and a drawn ellipse. The app will calc the distance between the two lane edges and draw an ellipse in the center of the distanc of the two white lanes. Im just not sure how to make a fast algorithm that scans the binary bitmap for white at the top of the image and then calcs the distance. Im using AForge.NET as my vido processing library. Whats a good way to scan for pixels that is fast, i am doing this at 15 frames a second.
|
|
|
|
|
As far as measuring distances, perhaps this article Range Finder[^], might have something useful. THe same guy has written a couple of other articles on Strereoscopy thet you might want to look at.
For fast image processing try this one Fast Pointerless Image Processing in .NET[^]. If you go to the CodeProject Home Page and type fast image processing in the Search Articles box, you will get lots of hits, some of them deal with Edge Detection Methods, which you might also find useful.
Good luck.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks a million bro...as always your a life saver! Thanks again to all who helped throughout the months on my project. Ill followup with my results and i might even post an article about lane tracking with robots and/or vehicles!
|
|
|
|
|
sebogawa wrote: i might even post an article about lane tracking with robots and/or vehicles
That would be really
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hello I am trying to add an event to a button that I created dynamically, but I can not get the event to trigger.
I also want to reference the button in an array of buttons, but I have been unsuccessfull.
Any Ideas? Thank you in advance.
private void btnDouglasBrowse_Click(object sender, EventArgs e)
{
if (fbdDouglasMain.ShowDialog() == DialogResult.OK)
{
tbDouglasFolder.Text = fbdDouglasMain.SelectedPath;
btnDouglasBrowse.Enabled = false;
jtnDouglasMain.FolderName = tbDouglasFolder.Text;
for (int i = 0; i < 20; i++)
{
Button buttonName = new Button();
//buttonName.Location.X = i * 20;
buttonName.Location = new Point(i * 20 + 20,530);
buttonName.Width = 20;
buttonName.Text = i.ToString();
buttonName.DoubleClick += new EventHandler(buttonName_DoubleClick); // This line
this.Controls.Add(buttonName);
}
}
}
private void buttonName_DoubleClick(object sender, EventArgs e)
{
MessageBox.Show("The calculations are complete", "My Application",MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
|
|
|
|
|
Hi,
now that is what documentation[^] is for. A Button's DoubleClick event is disabled by default.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
What I'm trying to do is insert a new record into a SQL Server 2008 database file.
So far the samples I have fount don't work. Does any one know how to do this. Below is one of that samples I did fine.
string UserConnection = Properties.Settings.Default.UsersConnectionString;
SqlConnection MyConnection = new SqlConnection(UserConnection);
MyConnection.Open();
String MyString = @"INSERT INTO UserData (Name, telnetaddr) VALUES('addr.name', 'addr.telnetaddr')";
SqlCommand MyCmd = new SqlCommand(MyString, MyConnection);
MyCmd.ExecuteScalar();
MyConnection.Close();
RMDoor.WriteLn("New Entry Added");
}
catch(SqlException e)
{
RMDoor.WriteLn(e.Message.ToString());
}
|
|
|
|
|
bigjoe11a wrote: MyCmd.ExecuteScalar();
Replace with MyCmd.ExecuteNonQuery();
hope it helps
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
Thanks how ever I did try that too. and for some reason. It just not inserting. Its not giving me any errors.
|
|
|
|
|
The problem is caused by String MyString = @"INSERT INTO UserData (Name, telnetaddr) VALUES('addr.name', 'addr.telnetaddr')"; , in particular the VALUES clause. By enclosing addr.name etc in the quotes they are treated as just another part of the string. Their values are not fetched and used, as you intended.
What you need is a parameterized SQLcommand take a look at the example here[^] and try to adapt it for your data.
Please post back if you get stuck.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Well I'm stuck. Is there a sample related to what I'm doing. This isn't going to work.
|
|
|
|