|
Thanks for the Help!!
I am going to check into that also.. But now I found out the bill acceptor has a serial mode.. So I'm trying to learn how to read the data coming in now..
This is all new to me! Some how I have to create a listener so that at any given time I can insert a Bill into the acceptor and it will credit my game while the game is running...
(geesh what fun)
MOZ
|
|
|
|
|
My project had the option of using the serial port, I found the parallel port easier to deal with.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Also, check out the NTPort library. I used that one, it's really good. It comes with good C# examples also.
If you want to use .net 2.0 there is a SerialPort class in the System.IO.
/\ |_ E X E GG
|
|
|
|
|
Hey Thanks for the Help!!
I am going to check into that.. But now I found out the bill acceptor has a serial mode.. So I'm trying to learn how to read the data coming in now..
This is all new to me! Some how I have to create a listener so that at any given time I can insert a Bill into the acceptor and it will credit my game while the game is running...
(What fun huh?) lol
MOZ
|
|
|
|
|
as I understand it, Events are "syntactic sugar" around delegates, not (much) more.
Where comes the "soft requirement" from that an events args should be (object sender, EventArgs e) ? Doesn't make much sense to me.
It does make sense to include the sender - but why not inside the EventArgs? And a base class that provides no common functionality, and does not serve as an identification tag (like an exception class would do)?
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
the "event" keyword is not exactly extra. if u want intellisense and designer to work properly you have to have it in.
method(object sender, args e) is just the standard, u can do whatever u want for a method signiture.
|
|
|
|
|
peterchen wrote:
It does make sense to include the sender - but why not inside the EventArgs?
An interesting idea. I have always used the "sender, args" signature pattern. But, I don't see how making a slightly smarter EventArgs would complicate things.
However, I'd wager that most people will state that they tend toward the “advised“ approach because it is the common pattern used in the framework.
Hey don't worry, I can handle it. I took something. I can see things no one else can see. Why are you dressed like that?
- Jack Burton
|
|
|
|
|
There isn't anything that REALLY REQUIRES that you have a delegate signature of (object sender, EventArgs e) within your program, except where the definer of the delegate says 'this is my signature'. In fact you could have a solution like such:
public event MyEventHandler MyEvent;
public delegate void MyEventHandler(MyEventArgs e);
In this case, the users of your object subscribing to that event would create the type of signature you mention.
But I would imagine at the philosophical level: who the sender is, is not really an argument to the event but an external value. The arguments to a mouse event would contain mouse-specific arguments and knowing that it was sent by a listbox is not a relevant argument. Thus it is an external parameter to the event arguments.
This signature left intentionally blank
|
|
|
|
|
Does C# offer single cast delegates in any way, or is there a "standard" solution for implementing them? (I guess a wrapper around a delegate can pretty much do that, but maybe I'm missing something else)
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
peterchen,
Have you considered exposing the delegate as a property? By doing this you could leverage the idea that there is only one method to which delegate will refer. Granted, I've never done this myself but a rough idea would be......
namespace peterchen
{
public delegate void PeterChensHandler(......)
public class EventSource
{
private PeterChensHandler _pcHandler;
public PeterChensHandler TheDelegate
{
get{.....}
set{.....}
}
...................
...................
}
public class EventSink
{
...................
...................
...................
void DoSomethig(...)
{
if( m_EventSource.TheDelegate != null)
{
m_EventSource.TheDelegate(....)
}
}
}
}
</code>
Like I said, this is just a rough idea that I'd have to develop a bit more.
Hey don't worry, I can handle it. I took something. I can see things no one else can see. Why are you dressed like that?
- Jack Burton
|
|
|
|
|
Tried that, but this doesn't disable "+=" - Syntax. I could reject any delegate with more than one binding at runtime, but that's not really a nice solution.
I thought of wrapping the delegate in a class to enforce this contraint, but (short of generics) I'd have to write a separate class for each delegate, which is a pain.
maybe I should rather use an Interface for the sink - but that's inconvenient for the client of the class, as many of the methods/callbacks can go by defaults.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
My situation is i'm trying to do some stuff with overriding WndProc but don't know what cases to be checking for cause i don't know what number goes with what message... Is their some magical list of them somewhere?
|
|
|
|
|
Ugh nvm googeling brought me back here
this article has a pretty good list heh.
http://www.codeproject.com/csharp/IMessageFilterArticle.asp
|
|
|
|
|
The constants for the Windows messages are defined in the C++ header files (*.h). They're normally installed with Visual Studio .NET. Just search for files with the name *.H and containing the text of the message your looking for, for example: WM_HSCROLL or WM_MOUSEDOWN. I doubt you'll find a site with all of the constants because there are thousands of them...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi there..
How do I code the syntax :
myTable.Columns["mycolumnName"].myProperty = "value";
I have
a table class 'myTable' that inherits from System.Data.DataTable.
a column class 'myColumn' inherits from System.Data.Datacolumn.
As it is now I don't have acces to 'myProperty' that is a member of 'myColumn'.
-To get access I first have to convert it to 'myColumn' see below ???
((myColumn) myTable.Columns["mycolumnName"]).myProperty = "value";
thx..
|
|
|
|
|
If you derive from DataColumnCollection , override its indexer to return an instance of myColumn instead of DataColumn , and override the Columns property in myTable to use your new custom column collection, you can avoid the cast.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Charlie,
I'm not quite sure I undestand your suggestion..
pls, give me a sample..
Thx.
|
|
|
|
|
Hi meyi
What you have done is correct. That is defining two different class myTable from System.Data.DataTable and myColumn from System.Data.DataColumn.But did you make the columns propery of you class myTable as myColumn.If you didn’t still it is the type of DataColumn even that class is your’s.Thatswhy you need to cast it as myColumn to access myProperty. So you verify the datatype of Column property of myTable.
Still you have the same problem send your complete code I will try to fix it.
Feel free to contact me.
tnx..;)
M.Sendilkumar
Senior Software Engineer
TVS Infotech Ltd
Chennai,India.
|
|
|
|
|
Hi SendilKumar
As you can see in the code, the properties 'Id' and 'Name' in Debtable class.. -I have the same problem with the property 'Columns' that is derived from the System.Data.DataTable
I have to use casting to System.Data.DataColumn
If you can solve this issue lots of my headaqe wil be gone
Thx..
//My BaseTable
using System;
using System.Data;
using System.Reflection;
using System.Collections;
namespace Data
{
///
/// Summary description for BaseTable.
///
public abstract class BaseTable : System.Data.DataTable
{
#region contructors
public BaseTable(string name) : base(name)
{
this.InitializeComponent();
}
#endregion contructors
#region methods
///
/// Initiate all columns owned by the Table.
///
private void InitColumns()
{
IEnumerator columns = this.GetType().GetProperties().GetEnumerator();
PropertyInfo property;
columns.Reset();
while(columns.MoveNext())
{
property = (PropertyInfo) columns.Current;
if(property.PropertyType.ToString() == typeof(Column).ToString())
property.GetValue(this, null); //Just call the getter of the property to initiate the instance
}
}
private void InitializeComponent()
{
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
//
// BaseTable
//
this.InitColumns();
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
}
#endregion methods
#region properties
public abstract System.Data.DataTable DataTable
{
get;
}
#endregion properties
}
}
//My Column
using System;
using System.Data;
using System.Reflection;
using System.Collections;
namespace Data
{
///
/// Summary description for Column.
///
public class Column : DataColumn
{
private bool systemColumn = false;
private bool indexColumn = false;
public Column(): base()
{
}
public Column(string name, string caption, TypeCode dataType): base(name,TypeCode2Type(dataType))
{
this.Caption = caption;
this.DataType = TypeCode2Type(dataType);
}
public Column(string name, string caption, TypeCode dataType, bool mandatory): base(name,TypeCode2Type(dataType))
{
this.Caption = caption;
this.DataType = TypeCode2Type(dataType);
this.AllowDBNull = mandatory;
}
public Column(string name, string caption, TypeCode dataType, int maxLength): base(name,TypeCode2Type(dataType))
{
this.Caption = caption;
this.DataType = TypeCode2Type(dataType);
if(dataType == TypeCode.String)
this.MaxLength = maxLength;
}
public Column(string name, string caption, TypeCode dataType, int maxLength, bool mandatory): base(name,TypeCode2Type(dataType))
{
this.Caption = caption;
this.DataType = TypeCode2Type(dataType);
if(dataType == TypeCode.String)
this.MaxLength = maxLength;
this.AllowDBNull = mandatory;
}
static Type TypeCode2Type(TypeCode typeCode)
{
return Type.GetType("System."+typeCode.ToString());
}
public SqlDbType Type2SqlDbType(System.Type type)
{
if(type == TypeCode2Type(TypeCode.Boolean))return SqlDbType.Bit;
if(type == TypeCode2Type(TypeCode.Byte)) return SqlDbType.TinyInt;
if(type == TypeCode2Type(TypeCode.Int16))return SqlDbType.SmallInt;
if(type == TypeCode2Type(TypeCode.Int32)) return SqlDbType.Int;
if(type == TypeCode2Type(TypeCode.Int64)) return SqlDbType.BigInt;
if(type == TypeCode2Type(TypeCode.Decimal)) return SqlDbType.Decimal;
if(type == TypeCode2Type(TypeCode.Single)) return SqlDbType.Real;
if(type == TypeCode2Type(TypeCode.Double)) return SqlDbType.Float;
if(type == TypeCode2Type(TypeCode.Char)) return SqlDbType.NChar;
if(type == TypeCode2Type(TypeCode.String)) return SqlDbType.NVarChar;
if(type == TypeCode2Type(TypeCode.DateTime)) return SqlDbType.DateTime;
if(type == TypeCode2Type(TypeCode.Object)) return SqlDbType.Variant;
return SqlDbType.Variant;
}
#region Properties
public bool SystemColumn
{
get{return this.systemColumn;}
set{this.systemColumn = value;}
}
public bool IndexColumn
{
get{return this.indexColumn;}
set{this.indexColumn = value;}
}
#endregion Properties
}
}
//Finaly a table
using System;
using System.Data;
namespace Data.Tables
{
///
///
///
public class DebTable : Data.BaseTable, IDebTableColumns
{
public DebTable() : base("DebTable")
{
InitializeComponent();
}
public DebTable(string name) : base(name)
{
InitializeComponent();
}
private void InitializeComponent()
{
//
// DebTable
//
this.PrimaryKey = new Column[] {this.DataColumns.Id};
}
///
/// Gets the Column owned by this Table.
///
public IDebTableColumns DataColumns
{
get {return this;}
}
public override System.Data.DataTable DataTable
{
get{return (System.Data.DataTable) this;}
}
#region IDebTableColumns Members
public Column Id
{
get
{
if (this.Columns["Id"] == null)
{
this.Columns.Add(new Column("Id", "ID", TypeCode.Int32, true));
((Column) this.Columns["Id"]).Unique = true;
((Column) this.Columns["Id"]).IndexColumn = true;
}
return (Column) this.Columns["Id"];
}
}
public Column Name
{
get
{
if (this.Columns["Name"] == null)
{
this.Columns.Add(new Column("Name", "Name", TypeCode.String, 30));
}
return (Column) this.Columns["Name"];
}
}
#endregion IDebTableColumns Members
}
public interface IDebTableColumns
{
Column Id
{
get;
}
Column Name
{
get;
}
}
}
|
|
|
|
|
Hi
Let me take a day.
M.Sendilkumar
TVS Infotech Ltd
|
|
|
|
|
hi,
The answer that i am going to explain you is something different. actuall i wrote an article about datagrid formattings. If you see the code, there i am updating the value of datacolumn properties. So my suggection is the entire article you may not need. But you can see the code where i am updating the properties of tables.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
S r e e j i t h N a i r,
It's a interesting arcticle you have wrote... but unfortunately your article
doesn't answer my issue..
My problem is the property 'Columns' in myTable that is inherited from System.Data.DataTable and the return type for this property is System.Data.Column collection.
What I want is to get this property 'Columns' return, type of myColumn collection instead of System.Data.DataColumn collection.
I have uploaded my code.. prev thred..
thx.
|
|
|
|
|
How do I create a form (or other container) that can be docked to one side of the screen?
For example, the taskbar can be docked to a side. When it is docked, Windows recognizes that the virtual screen size is decreased, and maximized windows only maximize to the edge of the taskbar.
Any ideas?
|
|
|
|
|
|