|
Hi All,
Can any one help me how to interact with Dallas IButton, how to recognise whether the button is present or not and read the data from the iButton, my requirement is to allow the user to login to the application if the IButton is present and valid, logout the user once the ibutton is removed from the slot.
Note: the iButton is a physical device for the user
Thanks in Advance
Krishna
|
|
|
|
|
For third-party hardware or software you should consult with the manufacturer. This site is intended more for general help with technologies listed in the forums page (like C# here on this forum). It's unlikely that anyone who regularily responds here would know much about it, but the manufacturer site may have more developer information or you might even be able to find a newsgroup or unofficial site talking about the technology in question.
This is especially true since you're asking about application programming interfaces to the hardware, which should be documented either in product documentation for the device or in a separate, downloadable software development kit from the manufacturer's web site.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
why is this simple operation giving me so much trouble?
also when it tried to load the xml, it attempts to connect to the internet to get to the dtd. can i avoid this?
the error i get at the moment is 'root element missing';
i did try and create this template using XmlNodes but i couldnt find a way to add the doctype node, if anyone can shed any light on that, that may be the way to do it.
<pre>
private XmlDocument LoadStrictXhtmlTemplate()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<?xml version='1.0' ?>");
doc.LoadXml("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
doc.CreateComment(this.m_CreatedComment);
doc.LoadXml("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
doc.LoadXml("<head>");
doc.LoadXml("<title>" + this.m_Title + "</title>");
doc.LoadXml("</head>");
doc.LoadXml("<body>");
doc.LoadXml("</body>");
doc.LoadXml("</html>");
return doc;
}
</pre>
kind regards,
g00fy
|
|
|
|
|
Well, you can't use LoadXML[^] repeatedly to load parts of a single XML document. You need to use it like
string x = "<?xml version='1.0' ?>";
x += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "http:
...
doc.LoadXML(x);
You might want to use StringBuilder instead of string to build the XML document..
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
of course,
stupid mistake on my part, thank you for being so kind to my .
obviously it must still connect to the internet to verify the DTD as well unless i copy that local, but for this application, it is not imperative that the html be validated strict.
kind regards,
g00fy
my final solution is as follows for anyone elses reference.
private XmlDocument LoadStrictXhtmlTemplate()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("<?xml version='1.0' ?>");
// next line commented out as it takes about 10 seconds to throw the WebException
//sb.AppendLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
// Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
sb.AppendLine("<!-- " + this.m_CreatedComment + " -->");
sb.AppendLine("<html>"); // xmlns=\"http://www.w3.org/1999/xhtml\">");
sb.AppendLine("<head>");
sb.AppendLine("<title>" + this.m_Title + "</title>");
sb.AppendLine("</head>");
sb.AppendLine("<body id=\"start\">");
sb.AppendLine("</body>");
sb.AppendLine("</html>");
XmlDocument doc = new XmlDocument();
doc.LoadXml(sb.ToString());
return doc;
}
|
|
|
|
|
Hi everyone,
I am newbie in C# and I have a doubt in retrieving the values from database based on search criteria. It is working well in vb.net but i am facing problem in C# i am writing the codes both in vb.net and c# please anyone help me where i am going wrong....
vb.net code:
connectdb()
cmd.commandtext="select * from Emp where sno="& val(textbox1.text)
da.selectcommand=cmd
da.fill(ds,"Emp")
for each dr in ds.tables("Emp").Rows
If val(textbox1.text)=dr.Item(0) then
textbox1.text=dr.item(0)
textbox2.text=dr.item(2)
textbox3.text=dr.item(2)
textbox4.text=dr.item(3)
end if
next
con.close()
C# code:
try
{
dbconnect();
Cmd.CommandText = " Select * from Emp where Empno=" + Convert.ToInt32(TextBox1.Text);
da.SelectCommand = Cmd;
da.Fill(ds, "Emp");
dt=ds.Tables["Emp"];
foreach ( DataTable table in ds.Tables )
{
foreach (DataRow dr in ds.Tables["Emp"].Rows) {
if (Convert.ToInt32(TextBox1.Text) = row["Empno"].ToString())
{ TextBox1.Text = row["Empno"].ToString;
TextBox2.Text = row["Name"].ToString;
TextBox3.Text = row["Dept"].ToString;
TextBox4.Text = row["Salary"].ToString;
}
}
}
catch (Exception ex)
{
Response.Redirect(ex.Message);
}
Con.Close();
}
the error in c# is that 'row' is not a member of data.
What is the equivalent code of dr.item in vb.net to c#
anyone please help me
thanks inadvance
|
|
|
|
|
1. If you're going to use only the Emp table, why recurse through all that is in the DataSet? Just do
foreach(DataRow dr in dt)
{
}
2. Also, you've put a WHERE clause in your SELECT query itself, so why do you want to check it in the loop?
3. When you create the query, check if it's indeed a number, and then simply append it to the query.
4. ToString() is a method. I don't know how you were able to compile your code.
5. You're using a very dangerous way of creating queries. Google for sql injection attacks .
HTH.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
hi thanx for responding after i modified my code as u said like this
foreach (DataRow dr in ds.Tables["Emp"].Rows)
{
if (Convert.ToInt32(TextBox1.Text) = dr["Empno"].ToString())
{
TextBox1.Text = dr["Empno"].ToString();
TextBox2.Text = dr["Name"].ToString();
TextBox3.Text = dr["Dept"].ToString();
TextBox4.Text = dr["Salary"].ToString();
}
}
I am getting the following errors at if statement
Cannot implicitly convert type 'int' to 'bool'
Cannot implicitly convert type 'string' to 'int'
The left-hand side of an assignment must be a variable, property or indexer
Help me plz
thanx
|
|
|
|
|
In your VB Example you were iterating over the Rows in the Emp table:
for each dr in ds.tables("Emp").Rows
In your C# example, you are itterating over the Tables in the dataset
foreach ( DataTable table in ds.Tables )
and then itterating over the Rows in the Emp table
foreach (DataRow dr in ds.Tables["Emp"].Rows)
which is pointless, because you only read from the Emp table! So you'll be reading once for every table in your dataset.
Your real problem is that as above you named the rows dr , but then you try to read from a variable called row
<br />
TextBox1.Text = row["Empno"].ToString
In addition, C# requires the use of the open and closed brackets for method calls (one small difference from VB, which allows you to call methods without parenthesis)
|
|
|
|
|
another one
Convert.ToInt32(TextBox1.Text) = row["Empno"].ToString()
this is the wrong way round - it should simply be
TextBox1.Text = row["Empno"].ToString()
|
|
|
|
|
hi thanx for responding after i modified my code as u said like this
foreach (DataRow dr in ds.Tables["Emp"].Rows)
{
if ((TextBox1.Text) = dr["Empno"].ToString())
{
TextBox1.Text = dr["Empno"].ToString();
TextBox2.Text = dr["Name"].ToString();
TextBox3.Text = dr["Dept"].ToString();
TextBox4.Text = dr["Salary"].ToString();
}
}
I am getting the following errors at if statement
Cannot implicitly convert type 'string' to 'bool'
help me plz
thanx
|
|
|
|
|
Equality is a double equals in C#
if ((TextBox1.Text) = dr["Empno"].ToString())
should be
if ((TextBox1.Text) == dr["Empno"].ToString())
|
|
|
|
|
hi
thanx, it is working thanx for ur suggestion
thanxonce again
|
|
|
|
|
What is Schema.ini?(Know little,want more)...
I want to export a database content to textfile...For implementing this, how schema.ini helps in defining the text qualifiers for the different type of fields....(ie. in case of Strings "",in case of Numbers no qualifiers...)
Kindly help me...
-- modified at 0:00 Friday 16th December, 2005
|
|
|
|
|
Ok, this is a simple question, but I've tried and looked and just can't seem to come up with an answer...
In my VB6 app, I can create an array of controls simply by copy and pasting for the default "do you want to make this object an array" prompt...
In C#, I get no prompt, and no menu option (that I can see.. maybe I'm blind) to make an array.
I simply want to be able to create an array of x number of checkboxes (or any control, for that matter) in a panel so I can cycle through them with an iteration statement... What am I missing? If this involves more code than using iteration would save, just tell me and I'll move on.
Thanks in advance.
|
|
|
|
|
Ok...
I found the C# tutorial on how to create a group of controls from a string array... Is this the only way to create and use an array of controls? I'd really much prefer to have them available at design time, not to mention having to plot their location every time I want to create another array of controls. I find it hard to believe that .NET would make something that seems so fundamental such a pain in the arse...
|
|
|
|
|
"control arrays" per se are not supported by the VS.NET designer. However, it's easy to manually build an array containing controls that are on your form:
CheckBox[] checkBoxes=new CheckBox[]{myCheckBox1, myCheckBox2, ...};
If you need dynamically created control arrays that will be resized at runtime to an arbitrary size, you will need to create the checkboxes manually and add them to a list:
List<CheckBox> checkBoxes = new List<CheckBox>();
for(int i=0;i<myCount;i++)
{
CheckBox checkBox = new CheckBox();
checkBox.Location = new Point(10,10+(20*i));
checkBox.Size = new Size(50, 20);
checkBox.TabIndex=i;
checkBox.Text="CheckBox "+i.ToString();
panel.Controls.Add(checkBox);
checkBoxes.Add(checkBox);
}
|
|
|
|
|
I need to write a program which can draw rectangle by mouse. User can draw a rectangle by click left mouse button and drag mouse, when user release left mouse button, rectangle will be drawn.
I can draw rectangle, but now I want to check when I move mouse, program can show me the mouse is inside a rectangle or not.
I use an RectangleArray which inherits from CollectionBase to store all drawn rectangle. In mouse move method, I loop through this array and use Contains method of Rectangle class to check the mouse inside or not.
But I don't understand while I only can check the position of mouse if it is inside the first rectangle I drawn (label4 only change value when I move the mouse inside the first rectangle). If I show a message box, label4 can change its value when I move the mouse inside any rectangle.
private void picImage_MouseMove(object sender, MouseEventArgs e)
{
Point mousePoint = new Point(e.X, e.Y);
foreach (Rectangle rect in rects)
{
if (rect.Contains(mousePoint))
{
label4.Text = "In rect";
break;
}
else
{
label4.Text = "Not in rect";
}
}
}
Can anybody help me? Thanks a lot!
I'm ...
a fan of Manchester United
a fan of Ozzy Osbourne
a King of Nothing
|
|
|
|
|
Windows - including controls (which are client windows) - are only sent messages such as mouse move messages when the mouse is over them or the mouse is captured (I'll get to that in a second). Forms that parent controls such as your label can receive mouse events for their children, which actually happens anyway since the parent control will dispatch messages to their children. This is why the label only knows about mouse movement within its client region.
In order to be notified when the mouse moves outside of the control you need to capture the mouse. See http://msdn2.microsoft.com/en-us/library/ms171545(en-US,VS.80).aspx[^] for general information, making note of the following:Only the foreground window can capture the mouse. When a background window attempts to capture the mouse, the window receives messages only for mouse events that occur when the mouse pointer is within the visible portion of the window. Also, even if the foreground window has captured the mouse, the user can still click another window, bringing it to the foreground. When the mouse is captured, shortcut keys do not work. Try the following sample:
public class Form1 : Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox checkBox1;
public Form1()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label1.Location = new System.Drawing.Point(33, 98);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(221, 33);
this.label1.TabIndex = 0;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label1.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
this.label1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(36, 135);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(97, 17);
this.checkBox1.TabIndex = 1;
this.checkBox1.Text = "Capture mouse";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
label1.Text = e.Location.ToString();
}
private void label1_MouseLeave(object sender, EventArgs e)
{
if (!label1.Capture)
{
label1.Text = string.Empty;
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
label1.Capture = checkBox1.Checked;
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Maybe my description has some confusion for you. Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace RFCart
{
public partial class Main : Form
{
private int drawMode;
private bool mouseIsInShelf;
private Shelf currentShelf;
private ShelfArray shelfs = new ShelfArray();
private void Main_Load(object sender, EventArgs e)
{
drawMode = Constant.SHELF_MODE;
}
private void picImage_MouseDown(object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Left:
Point mousePoint = new Point(e.X, e.Y);
if (drawMode == Constant.SHELF_MODE)
{
currentShelf = new Shelf();
currentShelf.StartPoint = mousePoint;
}
break;
}
}
private void picImage_MouseUp(object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Left:
Point mousePoint = new Point(e.X, e.Y);
if (drawMode == Constant.SHELF_MODE)
{
currentShelf.EndPoint = mousePoint;
shelfs.Add(currentShelf);
picImage.Invalidate();
}
break;
}
}
private void picImage_MouseMove(object sender, MouseEventArgs e)
{
Point mousePoint = new Point(e.X, e.Y);
foreach (Shelf shelf in shelfs)
{
if (shelf.Contains(mousePoint))
{
mouseIsInShelf = true;
break;
}
else
{
mouseIsInShelf = false;
}
}
}
private void picImage_Paint(object sender, PaintEventArgs e)
{
foreach (Shelf shelf in shelfs)
{
shelf.Draw(e.Graphics, Color.Red);
}
}
}
}
Shelf.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace RFCart
{
class Shelf
{
private Rectangle boundRectangle;
private Point startPoint;
private Point endPoint;
public Point StartPoint
{
get
{
return startPoint;
}
set
{
startPoint = value;
}
}
public Point EndPoint
{
get
{
return endPoint;
}
set
{
endPoint = value;
}
}
public Rectangle BoundRectangle
{
get
{
return boundRectangle;
}
set
{
boundRectangle = value;
}
}
public void Draw(Graphics graphics, Color color)
{
int width = Math.Abs(EndPoint.X - StartPoint.X);
int height = Math.Abs(EndPoint.Y - StartPoint.Y);
int x = Math.Min(StartPoint.X, EndPoint.X);
int y = Math.Min(StartPoint.Y, EndPoint.Y);
boundRectangle = new Rectangle(x, y, width, height);
GraphicsPath path = new GraphicsPath();
Pen pen = new Pen(color, Constant.PEN_WIDTH);
path.AddRectangle(boundRectangle);
graphics.DrawPath(pen, path);
pen.Dispose();
}
public bool Contains(Point point)
{
return boundRectangle.Contains(point);
}
}
}
ShelfArray.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace RFCart
{
class ShelfArray : CollectionBase
{
public void Add(Shelf shelf)
{
List.Add(shelf);
}
public Shelf this[int index]
{
get
{
return (Shelf)List[index];
}
set
{
List[index] = value;
}
}
}
}
After I draw 2 rectangles, when I move mouse into the first rectangle, mouseIsInShelf will change to true. But when I move the mouse into the second rectangle, mouseIsInShelf still false. I think it should be true.
Help me more! Thanks a lot!
I'm ...
a fan of Manchester United
a fan of Ozzy Osbourne
a King of Nothing
|
|
|
|
|
hello, i have a string that i need data to be extracted from, but i do not know much about regex. can someone please show me how to do this? thanks.
i start with this string:
[09.17.2005 15:22:58] VIOLATION (GAME INTEGRITY) #20006: ^r||^cS^rF^cO^r||^cSin^rner (slot #6) Violation (GAME INTEGRITY) #20006 [dfcbd87f99e62f4915732e0b26f804e9(VALID:78) 87.211.1.131:27960] i need to extract the following information, and save it in a new string string1, string2, string3, etc.:
09.17.2005 15:22:58
always starts as 2nd character and ends as 20th character
GAME INTEGRITY
always starts as 33rd character, ends at first ) after it starts
20006
always starts 3 characters after the (GAME INTEGRITY), and is 5 digits long
^r||^cS^rF^cO^r||^cSin^rner
name, always starts 2 characters after the 20006, and ends at the (slot #
dfcbd87f99e62f4915732e0b26f804e9
32-digit long GUID, starts at 2nd character after the 2nd (last) #2006 (or 5 digit ID)
87.211.1.131
the ip, starts 1 character after (VALID:78) where 78 is a number between 1 and 9999
thanks for the help, hopefully there is a way of doing this.
sam kline
<a href="http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450">YES</a>
|
|
|
|
|
\[(.{19})\]([^)]+\)).{2}(.{5}):\s*([^\(]*)\(slot #[\d]+\) [^\d]*\d{5}^\w*(.{32})[^\)]*\)\w*([\d\.]*)
That should work, but to be honest, Expresso threw a fit and stopped giving me any more than 4 match groups ( but kept on working while I worked through the regex ). The matches should all be grouped, so you need just iterate through the groups to get them all.
If you google and download Expresso, you'll find it's very useful for working on RegEx.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi, could you please give me an example of how to open an executable file on remote machine using WMI? I have worked on it for a whole day without any result. Thank you in advance.
Erick
|
|
|
|
|
There are problems with what you're doing. The first of which, a process launched on a remote computer cannot be interactive. This means that you won't see it appear on the desktop, but it will show up in the remote machine's Task Manager.
You can read more about it here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi I wat to pass objects than have ToString(strig Format) and Parse(string value) in method's parameter.
So I want to know what interface use for pass double, int, datetime, etc. that have these methods
public void AddFormat( iteface? param,string format)
{
this.txtValue.Text = param.ToString(format);
}
public object GetValue()
{
return myObject.Parse(this.txtValue.Text);
}
Thank you
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|