|
..well, while I agree that a C# grammar is probably available somewhere and ready to be used with Flex/Bison or what have you,
I don't find "reading a grammar" such a hassle.
The fact that you mention regExes makes me wonder if you're thinking about tokenization, rather than parsing-per se.
Sure, tokenization may be a hassle, but once you solve the problem,
parsing becomes a much more manageable problem, I think.
After all, at the worst, you can do a Recursive Descent Parser (dumb, brute force kind of approach).. sure, it's probably not the fastest approach, but it works!
Anyway, good luck on finding a grammar for C# (maybe the M$ site has something like that?)..
and be sure to share when you find it
F.O.R.
|
|
|
|
|
Frank Olorin Rizzi wrote:
The fact that you mention regExes makes me wonder if you're thinking about tokenization, rather than parsing-per se.
Lexing/Parseing I refer to both allways. Where by a grammar refers to the actual parser bit. But that makes me think...why are you telling me all this? I wasnt the one asking the question.
leppie::AllocCPArticle("Zee blog");
|
|
|
|
|
hi,
i have set the DataGridColumnStyle in my datagrid of DateTimePicker control...but the problem is i unable to preserve data in cell....when i change the focus from the cell....pls tell me what should i do? code is given below...
-bhavin
using System;
using System.Data;
using System.Windows.Forms;
using System.Drawing;
// This example shows how to create your own column style that
// hosts a control, in this case, a DateTimePicker.
public class DataGridTimePickerColumn : DataGridColumnStyle
{
private DateTimePicker myDateTimePicker = new DateTimePicker();
// The isEditing field tracks whether or not the user is
// editing data with the hosted control.
private bool isEditing;
public DataGridTimePickerColumn() : base()
{
myDateTimePicker.Visible = false;
myDateTimePicker.Dock=DockStyle.Fill;
}
protected override void Abort(int rowNum)
{
isEditing = false;
myDateTimePicker.ValueChanged -=
new EventHandler(TimePickerValueChanged);
Invalidate();
}
protected override bool Commit
(CurrencyManager dataSource, int rowNum)
{
myDateTimePicker.Bounds = Rectangle.Empty;
myDateTimePicker.ValueChanged -=
new EventHandler(TimePickerValueChanged);
if (!isEditing)
return true;
isEditing = false;
try
{
DateTime value = myDateTimePicker.Value;
SetColumnValueAtRow(dataSource, rowNum, value);
}
catch (Exception)
{
Abort(rowNum);
return false;
}
Invalidate();
return true;
}
protected override void Edit(
CurrencyManager source,
int rowNum,
Rectangle bounds,
bool readOnly,
string instantText,
bool cellIsVisible)
{
DateTime value = (DateTime)
GetColumnValueAtRow(source, rowNum);
if (cellIsVisible)
{
myDateTimePicker.Bounds = new Rectangle
(bounds.X + 2, bounds.Y + 2,
bounds.Width - 4, bounds.Height - 4);
myDateTimePicker.Value = value;
myDateTimePicker.Visible = true;
myDateTimePicker.ValueChanged +=
new EventHandler(TimePickerValueChanged);
}
else
{
myDateTimePicker.Value = value;
myDateTimePicker.Visible = false;
}
if (myDateTimePicker.Visible)
DataGridTableStyle.DataGrid.Invalidate(bounds);
}
protected override Size GetPreferredSize(
Graphics g,
object value)
{
return new Size(100, myDateTimePicker.PreferredHeight + 4);
}
protected override int GetMinimumHeight()
{
return myDateTimePicker.PreferredHeight + 4;
}
protected override int GetPreferredHeight(Graphics g,
object value)
{
return myDateTimePicker.PreferredHeight + 4;
}
protected override void Paint(Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum)
{
Paint(g, bounds, source, rowNum, false);
}
protected override void Paint(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
bool alignToRight)
{
Paint(
g,bounds,
source,
rowNum,
Brushes.Red,
Brushes.Blue,
alignToRight);
}
protected override void Paint(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
Brush backBrush,
Brush foreBrush,
bool alignToRight)
{
DateTime date = (DateTime)
GetColumnValueAtRow(source, rowNum);
Rectangle rect = bounds;
g.FillRectangle(backBrush,rect);
rect.Offset(0, 2);
rect.Height -= 2;
g.DrawString(date.ToString("d"),
this.DataGridTableStyle.DataGrid.Font,
foreBrush, rect);
}
protected override void SetDataGridInColumn(DataGrid value)
{
base.SetDataGridInColumn(value);
if (myDateTimePicker.Parent != null)
{
myDateTimePicker.Parent.Controls.Remove
(myDateTimePicker);
}
if (value != null)
{
value.Controls.Add(myDateTimePicker);
}
}
private void TimePickerValueChanged(object sender, EventArgs e)
{
this.isEditing = true;
base.ColumnStartedEditing(myDateTimePicker);
}
}
|
|
|
|
|
Hello,
I have a database where I store points by memorizing their coordinated in two columns namely x and y.
I have written a method that allows the user to insert two arbitrary coordinates (x,y) and the method will return all the points in a 1,5,10,..n km radius.
With these query result I want to find the point with the smallest x coordinate, the point with the greatest x coordinate, that with the smallest y coordinate, and that with the greatest y coordinate.
I need to do this in order to be able to fit all the area that has been returned into a 200x200 pixels area.
The first idea that I got is to sort the dataset by column x and extract the first and last record, then sort again by y column and do the same.
Is there any better way to achieve this? I need fast performance because the program will be computing thousands of query from different users at the same time.
Thanks in advance,
Edo
|
|
|
|
|
Well, firstly you can use the SQL Aggregation functions MIN and MAX on the columns... i.e. SELECT MAX(xCord) FROM Coords .
If you want to tie it into one query you'll probably have to start using sub-queries.
Performance wise, I'm not sure how you'll optimise it. The only other alternative would be to re-visit the design so that if it's read-intensive that the majority of the calculations etc. are done during an insert or update, whether that's possible (and how it might be so) is dependent upon the application and design, sorry to be so vague
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
Download my PGP public key
|
|
|
|
|
I wrote to a StreamWriter sitting on top of a NetworkStream, but calling Flush() didn't help get the data to the client. I understand that NetworkStream doesn't buffer and NetworkStream. Flush doesn't actually do anything - data written did not get flushed to client.
But, it is StreamWriter.Flush() that I called. To resolve the problem, I just called Close on StreamWriter - which calls flush internally according to MSDN. Data is flushed to client side.
Any idea?
norm
|
|
|
|
|
Actually, see the constructors for StreamWriter: they do buffer, and if you use Reflector, they use a default buffer size of 1024. Try creating a StreamWriter specifying a buffer size of 0, and see if it helps.
You can do it on anything you choose - from .bat to .net - A customer
|
|
|
|
|
After you create the StreamWriter (but before using it) do the following:
<br />
myWriter.AutoFlush = true;<br />
This seems to work for me
Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript)
tatham@e-oddie.com
+61 414 275 989
|
|
|
|
|
Hi!
I wanna wrap one c/c++ library into a COM dll to use in c# or vb.
In Atl, "int*" will interept as "ref int" in c#. But i wanna it be IntPtr because I try to connect it with Bitmap's Scan0(which is a IntPtr).
Any idea or suggestion?
|
|
|
|
|
Use Managed C++
It's simple with it
|
|
|
|
|
|
Is it possible to store more than int numbers in ArrayList object. If so, how can we retrieve number of stored items? Notice that Count property is of type int , and this is my problem!
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
I think I've read somehwere that this is a known limitation of the ArrayList.
It may have been a book,
it may be outdated as of the release of .NET 2003
or I may be wrong.
But I recall something along the lines of
"yes, you are limited to store [max int] items,
but after all, if you have that many items, do you really want them in memory?"
HTH,
F.O.R.
|
|
|
|
|
Remember that int is 32bit in .NET.
This should be enough number of objects to
store in memory.
Regards,
Holger
|
|
|
|
|
ha ha - very funny!
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
What was funny about that?
I passionately hate the idea of being with it, I think an artist has always to be out of step with his time.
-Orson Welles
|
|
|
|
|
that an int is big enough....
try reading a large binary file....
byte[] BinaryReader.GetBytes(int count)
I mean what stupid idiot thought that you would never want to read more than int.max?
whay not a long??????
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
I mean what stupid idiot thought that you would never want to read more than int.max?
whay not a long??????
The same stupid idiot that knows one cannot address more than 16gb memory...
BTW Streams work with long, thus one can set the position virtually anywhere within a Stream and read a normal 4k/8k byte array at a time.
leppie::AllocCPArticle("Zee blog");
|
|
|
|
|
I would be worried about an app that loaded that much data at once. It's far more efficient to load smaller chunks and deal with them individually rather than do it all at the same time.
youd ebtter bnot be taki8ng agvantage o f my mental abilites!1
-David Wulff one night over MSN while totally plastered
|
|
|
|
|
yes, but its mean if you want to caculate the hash for a large file you have to do alot of extra work.....
though leppie did point out you can use a stream....
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
David Stone wrote:
It's far more efficient to load smaller chunks and deal with them individually rather than do it all at the same time.
Yes, that is true when all objects are available before runtime(and stored somewhere). But what if all our required objects should be created at run-time, and be stored in memory? maybe I should create an ArrayList of Arraylist s if needed!
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
Is there some sort of XOR painting that uses a Graphics object and/or takes advantage of clipping?
It seems like I'm stuck using ControlPaint.DrawReversibleFrame for drawing XOR rectangles, and it'd be a minor pain to have to write some intermediate code to handle the clipping and draw line segments...
But then again, maybe I'll just not end up using XOR mode in the end.
|
|
|
|
|
No, there isn't. But you can transform the area (invert it or whatever) using a ColorMatrix, or do direct pixel access.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
hi !
i have to delay incoming network packages.
unfortunately there are several packages within one millisecond.
i use the highPerformanceClock (by Ryan Seghers) to timestamp the packages. (it uses the kernel32: "QueryPerformanceCounter")
so how can i trigger the package-forwarding (after a delay of ex. 200ms)?
the threading.timer granularity is only 1ms.
PLEASE HELP !!!
andi
|
|
|
|
|
|