|
Hello, my problem is how do draw an grind with GDI+, i need a grid for my furst game so the
object will be able to move in cells. that was my way:
private void GrindPaint(object sender, PaintEventArgs pea)<br />
<br />
{<br />
<br />
Graphics gfx = pea.Graphics;<br />
<br />
int space = 2,cwidth = 10, cheight =10, amount =30;<br />
<br />
Pen pen = new Pen(Color.Black);<br />
<br />
int cx=1,cy=1;<br />
<br />
<br />
for(int j = 0; j<amount; j++)<br />
<br />
{<br />
<br />
cx = 1;<br />
<br />
for(int i =0; i<amount; i++)<br />
<br />
{<br />
<br />
gfx.DrawRectangle(pen,cx,cy,cwidth ,cheight);<br />
<br />
cx = (cx+cwidth+space);<br />
<br />
}<br />
<br />
cy =(cy+cheight+space);<br />
<br />
}<br />
<br />
}<br />
<br />
My question: confused: is , is there another, better way or easier
tnx for help!!
i'm learning
|
|
|
|
|
Personally, I'd just draw lines, not rectangles.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I want to have cellspace , so i draw rectangels with distance 2px,...
is my way ok?
i know stupid questions,... but i started c# and GDI+ 1 weag ago
tnx for all replies
i'm learning
|
|
|
|
|
Your way is fine, if you see a grid, then you got what you want. If it's not drawn over and over, it doesn't matter, but unless you're making less API calls ( you didn't check the box to show <, so I couldn't read all you code ) because of the size of the boxes you draw, I thought lines may be quicker.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How can I convert a datatable in MS Access into a comma delimited text file.
thanks.
|
|
|
|
|
If you have Microsoft Access, you can open the database and do an export and choose the save as "text file" option. If you do not have Microsoft Access, then you could write a simple routine to loop the data and write each field value out to a text file.
|
|
|
|
|
|
Ok, I am trying to retrieve a list of names from the database and based upon the number of rows retrieved from the DB, I am trying to do the following:
1. Instantiate a array of command buttons.
2. Add those command buttons to the list view.
I am assuming step 2 is possible since the item property is a collection of objects, I can add anything I want to add to it. Well it works fine except instead of actual command buttons, I am seeing the following , "System.windows.forms.Buttons, Text="rwqr""
What am i doing wrong.
|
|
|
|
|
What you are trying to do is not directly possible with the listview provided with .NET. The items collection is a collection of data associated with each element in the list, not a collection of controls to be displayed within the list. By default, if no string is supplied when adding items to the collection the objects ToString method is used to get the string to display. This is why you are getting the output you are getting. There are articles here on Code Project that show listview implementations that are capable of docking other controls within the listview. Note that it's not something you will be able to do with a trivial amount of code (though not an unobtainable goal either).
|
|
|
|
|
HI dears!
i m having a finger print scanner Digital Persona U.R.U 4000. i wnt to create an application for thumb recognition. i need the guide line sdk given with it is out of my under standing. Is there any body who may help me in this regard. or some one already done such sort of work using its sdk. Waiting 4 reply anxiously
|
|
|
|
|
For something this specialized I'd look for a help forum from the hardware developer, or failing that try posting on a large broadbased forum or newsgroup, with only a few dozen heavy posters it's unlikely that anyone here will have used the same hardware you're having trouble with. YOu could also try searching sourceforge for a program doing something similar.
|
|
|
|
|
I just received my DigitalPersona SDK, for an application I'm developing, but I've had no chance to look into it yet. So, if you find something, you could write an article for CP. I would read it
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I've developed a web page in c#.Net (VS 2003).It has a page (exportExcel.aspx) with same data in a table an a button to export this data to excel. The code of the button use Response object to do it:
Response.Clear()
Response.ContentType = '...Excel...'
Response.write('...data....')
Response.flush()
It works, but the file's default name in the dialog window to save the file has aspx extension 'exportExcel.aspx', not 'xls' extension. Somebody know how put a defaul name different of the page name?
sorry my english
Thanks for your help
Carlos
|
|
|
|
|
Carlos,
I wrote this class to export a datagrid to excel, you may modify it for any other control.
<br />
public class ExportToExcel<br />
{<br />
private Page m_pPage = null;<br />
public ExportToExcel(Page pPage)<br />
{<br />
m_pPage = pPage;<br />
}<br />
<br />
public void ExportDataGrid(System.Web.UI.WebControls.DataGrid dg)<br />
{<br />
System.Web.HttpContext context = System.Web.HttpContext.Current;<br />
<br />
context.Response.Clear();<br />
context.Response.Buffer= true;<br />
context.Response.ContentType = "application/vnd.ms-excel";<br />
context.Response.Charset = "";<br />
m_pPage.EnableViewState = false;<br />
<br />
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();<br />
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);<br />
<br />
this.ClearControls(dg);<br />
dg.RenderControl(oHtmlTextWriter);<br />
<br />
context.Response.Write(oStringWriter.ToString());<br />
<br />
context.Response.End();<br />
}<br />
<br />
private void ClearControls(Control control)<br />
{<br />
for (int i=control.Controls.Count -1; i>=0; i--)<br />
{<br />
ClearControls(control.Controls[i]);<br />
}<br />
<br />
if (!(control is TableCell))<br />
{<br />
if (control.GetType().GetProperty("SelectedItem") != null)<br />
{<br />
LiteralControl literal = new LiteralControl();<br />
control.Parent.Controls.Add(literal);<br />
try<br />
{<br />
literal.Text = (string)control.GetType().GetProperty("SelectedItem").GetValue(control,null);<br />
}<br />
catch<br />
<br />
{<br />
<br />
}<br />
<br />
control.Parent.Controls.Remove(control);<br />
}<br />
<br />
else<br />
<br />
if (control.GetType().GetProperty("Text") != null)<br />
{<br />
LiteralControl literal = new LiteralControl();<br />
control.Parent.Controls.Add(literal);<br />
literal.Text = (string)control.GetType().GetProperty("Text").GetValue(control,null);<br />
control.Parent.Controls.Remove(control);<br />
}<br />
}<br />
return;<br />
}<br />
<br />
}<br />
|
|
|
|
|
To specify filename you have to add header:
response.AppendHeader("content-disposition", "inline;filename=Filename.xls");
|
|
|
|
|
|
I copy a "ReadOnly" file.
I change it's name and then go to delete it.
Problem it won't delete because it is ReadOnly (At least when I remove ReadOnly it deletes fine).
This is the error I receive:
ERROR in test System.UnauthorizedAccessException: Access to the path "c:\test\\test.dll" is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.File.Delete(String path)
at Check.RunTest.DoRun(String path) in c:\project\runtest.cs:line 38
Here is my code:
try
{
string[] testfiles = Directory.GetFiles(path);
foreach( string testfile in testfiles)
{
string testFolderName = path + @"\" + Path.GetFileName(testfile);
//Copy for short name - Name file T + extension
File.Copy(testFolderName, path + @"\T" + Path.GetExtension(testfile));
File.Delete(testFolderName);
RunProg(testFolderName,Path.GetExtension(testfile),Path.GetFileNameWithoutExtension(testfile) );
}
}
catch(Exception e)
{
Console.WriteLine("ERROR in RUNGliChk " + e.ToString());
}
Thanks
|
|
|
|
|
Yes, you can't delete a read only file. That is not an error, it's by design. If you want to delete it, you have to change the attribute first.
---
b { font-weight: normal; }
|
|
|
|
|
Can you take it one step further?
I used this code to try to change the attribute:
File.SetAttribute(path, FileAttributes. );
I could only find .ReadOnly and that's not what I want.
|
|
|
|
|
Use FileAttributes.Normal.
---
b { font-weight: normal; }
|
|
|
|
|
I am trying to track down a problem with communications and began using Mutex to combate the problem. I have various functions that each call the same Mutex:
public bool function1()<br />
{<br />
Mutex mutex = new Mutex(false, "MyMutex");<br />
mutex.WaitOne();<br />
Console.WriteLine("mutex entered");<br />
Console.WriteLine("mutex exiteded");<br />
mutex.ReleaseMutex();<br />
<br />
return Give_Status;<br />
}<br />
public bool function2()<br />
{<br />
Mutex mutex = new Mutex(false, "MyMutex");<br />
mutex.WaitOne();<br />
Console.WriteLine("mutex entered");<br />
Console.WriteLine("mutex exiteded");<br />
mutex.ReleaseMutex();<br />
<br />
return Give_Status;<br />
}<br />
According to c#Help you can call it this way and as long as it has the same name, it will work.
It is not working however. Here is a sample of the output.
mutex exited
8/8/2005 12:47:08 PM Enter WriteStream byte[]:System.Byte[],False
8/8/2005 12:47:08 PM Enter WriteBuffer
mutex entered
DummyValue
8/8/2005 12:47:08 PM Leaving WriteStream byte[]:True
8/8/2005 12:47:08 PM Enter ReadStream byte[]:5
8/8/2005 12:47:08 PM Enter readBuffer
8/8/2005 12:47:08 PM Leaving ReadStream:System.Byte[]
8/8/2005 12:47:08 PM Enter Flush()
8/8/2005 12:47:08 PM Clear Write Req. Queue = 0
8/8/2005 12:47:08 PM Clear Read Req. Queue = 0
8/8/2005 12:47:08 PM Leaving Flush()
8/8/2005 12:47:08 PM Enter WriteStream byte[]:System.Byte[],False
8/8/2005 12:47:08 PM Enter WriteBuffer
mutex exited
mutex entered
DummyValue
8/8/2005 12:47:08 PM Leaving WriteStream byte[]:True
8/8/2005 12:47:08 PM Enter ReadStream byte[]:5
8/8/2005 12:47:08 PM Enter readBuffer
8/8/2005 12:47:08 PM Leaving ReadStream:System.Byte[]
8/8/2005 12:47:08 PM Enter Flush()
8/8/2005 12:47:08 PM Clear Write Req. Queue = 0
8/8/2005 12:47:08 PM Clear Read Req. Queue = 0
8/8/2005 12:47:08 PM Leaving Flush()
8/8/2005 12:47:08 PM Enter WriteStream byte[]:System.Byte[],False
8/8/2005 12:47:08 PM Enter WriteBuffer
8/8/2005 12:47:08 PM Leaving WriteStream byte[]:True
mutex exited
mutex entered
DummyValue
mutex entered
Notice on the end here, I entered mutex without exiting!!!!
Any idea what would be causing this.
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
The code and the result does not match. In the code you use the typo "exiteded", but that is not present in the output. How much more have you changed in the code before you ran it to create the output?
You might think that I am picky, but I have several times spent time to find peoples errors where there were none, in code that was not even used...
---
b { font-weight: normal; }
|
|
|
|
|
The output is a copy paste... the code I tried to simplify.
Here is a copy paste from one of the functions (no changes)
<br />
public bool commandExitServiceMode()<br />
{<br />
Mutex mutex = new Mutex(false, "MyMutex");<br />
mutex.WaitOne();<br />
Console.WriteLine("mutex entered");<br />
<br />
if ( OpenPort() == false )<br />
Give_Status = false;<br />
else<br />
{<br />
Give_Status = false;<br />
byteToSend = new byte[3];<br />
byteToSend[0] = CMDEXITSERVICEMODE;<br />
sum_xmit_bfr(0);<br />
if(sendAndGetData(3,5))<br />
Give_Status = true;<br />
else<br />
{<br />
MessageBox.Show("Command Fail received from PCC-III to ExitServiceMode");<br />
Give_Status = false;<br />
}<br />
}<br />
Console.WriteLine("mutex exited");<br />
mutex.ReleaseMutex();<br />
<br />
return Give_Status;<br />
}<br />
There are about 10 of these different ones, all have the opening and closing mutex related lines.
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
Maybe one of your Mutex protected functions called another Mutex protected one? Because they are on the same thread, the mutex won't block and you'll enter the mutex immediately. Or maybe there is a typo in one of your Mutex constructors that causes a new Mutex to be created?
That aside, are these functions spread across processes? Mutexes are heavyweight, so I'd prefer Monitor.Enter and Exit, unless of course synchronization needs to be cross process.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I have verified that no errors in typing the construct of the Mutex. I also verified that no function calls another mutex controlled function. However, you may be on to something. In the last go around with this, I am calling the same function 4-5 times. The idea is something like:
<br />
<br />
for(int i=1; i<5; i++)<br />
{<br />
public bool mutexControlledFunction();<br />
}<br />
<br />
mutexControlledFunction()<br />
{<br />
Mutex mutex = new Mutex(false, "MyMutex");<br />
mutex.WaitOne();<br />
Console.WriteLine("mutex entered");<br />
<br />
<br />
Console.WriteLine("mutex exited");<br />
mutex.ReleaseMutex();<br />
return Give_Status;<br />
}<br />
There was one early return that I put a breakpoint on to verify that is never ran (it did not) so I know all of the mutex.ReleaseMutex() were run. My understanding is this is the way Mutex is supposed to work. I know that there can not be a typo, because it is calling the same function.
Also, I went with Mutex because it can be declared in multiple places and work together. I am not sure if Monitor has the same functionality. I have about ten functions that all need to be able to wait for the right to process. Only one of these ten can be running at the same time.
If there is a better way to do this, I am open to suggestions.
Thanks so much,
Dwayne
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|