O.K. this is just out of interest as I've decided to use GDI+ but I was wondering if anyone knows how to double buffer a direct draw window as part of a standard windows application. The problem as I understand it is that for the double buffering to work the device needs to be exclusive which means it needs to be full screen and I've tried and failed to create a back buffer and then draw the data to the back buffer before drawing the back buffer to a primary buffer. Note though that you can't set up the back buffer as a true back buffer because of the exclusive problem so it was set up up as an offscreen surface.
So anyone with any ideas that might just be stupid enough to work?
1) Create a bitmap the size of the area to be painted.
2) Create a Graphics from the bitmap, using Graphics.FromImage.
3) Use the Graphics object's drawing functions to draw on the bitmap.
4) Use Graphics.DrawImageUnScaled to draw the bitmap onto the screen.
"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
I've always passed around a reference to an instance of a Logger in most apps that I've developed. There has to be a better way. What do you guys do? I'd like to make a single instance that can be used anywhere in the program. Should I be considering a Singleton design pattern.... ???
I don't need anything fancy. All I need to do is:
Is it possible to make an instance global to a namespace?
Inherit a class from System.Diagnostics.TraceListener. On application start, add an instance of this class to the System.Diagnostics.Trace.Listeners and/or System.Diagnostics.Debug.Listeners collections.
Every time you use Trace.Writexxx or Debug.Writexxx, it will be logged through your class. If you change/expand your logging facilities at some time, you don't have to change any client code, just your TraceListener.
I am launching a cmd prompt via my C# app that runs "net stop mssqlserver /y". This works in Debug mode, but the compiled application opens the cmd window and then closes it immediately without executing the line. Anyone else experienced this?
Attatching debug app exe when solution in debug mode also fails to complete the operation
Is it possible to easily swap values of primary key column between two rows of one DataTable object? I've been trying it like this;
DataRow dr1=dt.Rows.Find(5); //dt being a DataTable instance<br />
DataRow dr2=dt.Rows.Find(10);<br />
dr1.EndEdit(); //this will throw an exception, <br />//because dr2's PK still has a value of 10<br />
Same thing happens with dt.AcceptChanges();
Is there a way how to achieve this? Any clues are highly appreciated!
DataRow dr1=dt.Rows.Find(5); //dt being a DataTable instance
dr1["item_Id"]=-1; // or any unused value
(Repeated from our private email so that others searching for this answer will find it.)
Ever have one of those problem that just eats at you? Well your situation has bugged me for some time because I just knew there had to be an easier, more elegant way. There is......
The problem was that BeginEdit calls for the two DataRow objects were disabling the constraints for the respective rows, but once you called EndEdit for one DataRow, the primary key value for that first row conflicted with the (not yet committed) second DataRow object. Therefore, I had to assume that there was a higher level way of turning off constraints - either the DataRowCollection or the DataTable. Finally, I found the DataTable::BeginLoadData and DataTable::EndLoadData method, which turn off and on, respectively, constraint checking and index maintenance for the entire table.
<font color=green>// switch the primary keys for your two DataRow objects</font><br />
Note: You mentioned the fact that someone suggested turning constraints off for the entire DataSet. As this technicall will work, using BeginLoadData and EndLoadData will affect only one table instead of all the tables for a given DataSet.
Before editing your DataRows, set DataSet.EnforceConstraints to false.
dt.DataSet.EnforceConstraints = false;
// Edit your Rows// EndEdit
// If you violated any constraints, like PKs,// this statement will throw an exception.
dt.DataSet.EnforceConstraints = true;