|
have you done
arraylist = new System.Collections.ArrayList; ?
wouldn't be the first time I've forgotten to do that
James
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
I CANT BELIVE THAT!!!
how did i miss that
|
|
|
|
|
Anyone know of any good articles on printing, wrapping text and pagination, etc.?
Kyle
|
|
|
|
|
Try www.gotdotnet.com.
They have some useful articles on GDI+. From my experience I would recommend using GraphicsUnit.Document (1/300 inch) as a scale mode. I tried using pure inches and encountered terrible roundoff errors in the GDI matrix transformations.
One issue I was not able to overcome with managed code was the printer's page offset. (0,0) is at the upper left corner in the print preview, but offset by some arbitrary amount when printing (presumably different for each printer.) This information can be found out with Win32, but seemingly not with Managed Code.
--
Peter Stephens
|
|
|
|
|
Because I also had trouble with inches and printers have default page units of GraphicsUnit.Display that is what I am using. Your recommendation seems to make more sense as it offers finer control so I think I will give it a try. I'll also check out the gotdotnet articles. Thanks.
Would you like the unmanaged code in C# to obtain the unprintable margins? I can copy and post it for you if you need it.
Thanks again, Kyle
|
|
|
|
|
I'm not currently working on printing, but I will probably do some in the future. So sure, if you have the Unmanaged Code handy, I can store it for future reference...
Thank you
--
Peter Stephens
|
|
|
|
|
Here's the code:
// Reference InteropServices;
using System.Runtime.InteropServices;
// define constants for the physical offset values
private const int PHYSICALOFFSETX = 112;
private const int PHYSICALOFFSETY = 113;
// Define DLL and prototype the Win32 API method
[DllImport("gdi32")]
public static extern int GetDeviceCaps(IntPtr hdc, int cap);
// get the device context handle from the graphic object that is being printed
// call GetDeviceCaps to return the offsets
// release the handle to the device context
int unprintableleft, unprintabletop;
IntPtr hdc;
hdc = e.Graphics.GetHdc();
unprintableleft = GetDeviceCaps(hdc,PHYSICALOFFSETX);
unprintabletop = GetDeviceCaps(hdc,PHYSICALOFFSETY);
e.Graphics.ReleaseHdc(hdc);
MessageBox.Show("Unprintable: " + unprintableleft + " " + unprintabletop);
Kyle
|
|
|
|
|
Does anyone know what all the lag is about when I run my C# console apps? It just seems to take ages before it actually start the programs. Is there anything I can do to minimise it?
Thanks in advance
Windows 98 (win-doze): a 32 bit Extension to a 16 bit Graphical Shell of an 8 bit Operating System originally coded for a 4 bit Processor by a 2 bit company that can't stand one bit of competition.
|
|
|
|
|
What you're experiencing is the JIT taking place. To get rid of it you can run ngen.exe on your executable to pre-JIT it. I think to run ngen you might have to sign your exe. sn -k keyfile.snk creates your keyfile, the docs tell how to get it signed (I'm not at my PC right now otherwise i could give you the code for it )
James
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
Thanks matey, ngen ran without signing the exe. And now my app runs immediately. I think all this stuff should go into an FAQ somewhere. I wonder how many other people are puzzled by the same stuff.
Thanks again, you're a great help
Windows 98 (win-doze): a 32 bit Extension to a 16 bit Graphical Shell of an 8 bit Operating System originally coded for a 4 bit Processor by a 2 bit company that can't stand one bit of competition.
|
|
|
|
|
Hi,
When I call the Directory.GetFiles() funcion, it returns an unsorted string array.
I would write a sorting algo, but if theres a class that can sort a string array can someone let me know.
cheers
|
|
|
|
|
You can use the static method System.Array.Sort(). This method has overloads for sorting an array in place, for customizing the sort order (non-case sensitive, etc.), or for just sorting sections of an array. The sorting algorithm employed is QuickSort.
--
Peter Stephens
|
|
|
|
|
Is it possible to create a toolband with C# similar to http://www.codeproject.com/useritems/toolband.asp
|
|
|
|
|
argh, can you define template classes in c#???? Or is there an alternative that Microsoft would prefer you to use?
Windows 98 (win-doze): a 32 bit Extension to a 16 bit Graphical Shell of an 8 bit Operating System originally coded for a 4 bit Processor by a 2 bit company that can't stand one bit of competition.
|
|
|
|
|
No , you can't
With luck , next c# version will support generic programming, until then ...
Cheers,
Joao Vaz
|
|
|
|
|
Templates don't exist in C#, this is coming in Version 2.
There is a "trick" that'll help you get by until then.
using System;
using T = System.Int32;
namespace Test
{
class Testing
{
public Testing()
{
Console.Writeline(typeof(T).ToString());
}
}
}
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
Thanks for the response, I wanted to port a generic tree class over to C# but looks like I can't for the minute, or maybe I can. What if the class took a type of Object?
class Testing
{
public Testing(Object arg)
{
m_Object = arg;
}
Object m_Object;
}
I'm very new to C#, but would this work? Also when is version 2 out???
Thanks again
Windows 98 (win-doze): a 32 bit Extension to a 16 bit Graphical Shell of an 8 bit Operating System originally coded for a 4 bit Processor by a 2 bit company that can't stand one bit of competition.
|
|
|
|
|
TheFLC wrote:
What if the class took a type of Object?
That would work, but you would have lots of casting to do (Object could be called the equivalent of void* in C). This is generally the reason that the technique I mentioned came up; while you'll have a specific class for each type of tree; you'll eliminate all casting.
TheFLC wrote:
Also when is version 2 out???
Not for a while, version 1.0 came out a week ago today My guess would be at least a year before version 2.0 comes out.
James
James
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
No, you can't.
The next version of the CLR will support template classes, and so will be available to all languages that want to support it, not just c#
|
|
|
|
|
the code is in the SDK,but wen i run it,nothing happened,except print "Connected xxx.xxx.xxx",it cann't receive message from the server,but the SDK say it can Receive Message From The Server,why??
The Address in SDK is:ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconnon-blockingclientsocketexample.htm
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
// State object for receiving data from remote device.
public class StateObject {
public Socket workSocket = null; // Client socket.
public const int BufferSize = 256; // Size of receive buffer.
public byte[] buffer = new byte[BufferSize]; // Receive buffer.
public StringBuilder sb = new StringBuilder();// Received data string.
}
public class AsynchronousClient {
// The port number for the remote device.
private const int port = 21;
// ManualResetEvent instances signal completion.
private static ManualResetEvent connectDone =
new ManualResetEvent(false);
private static ManualResetEvent sendDone =
new ManualResetEvent(false);
private static ManualResetEvent receiveDone =
new ManualResetEvent(false);
// The response from the remote device.
private static String response = String.Empty;
private static void StartClient() {
// Connect to a remote device.
try {
// Establish the remote endpoint for the socket.
// "host.contoso.com" is the name of the
// remote device.
IPHostEntry ipHostInfo = Dns.Resolve(Ftp.xxxx.com);
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);
// Create a TCP/IP socket.
Socket client = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
// Connect to the remote endpoint.
client.BeginConnect( remoteEP,
new AsyncCallback(ConnectCallback), client);
connectDone.WaitOne();
// Send test data to the remote device.
Send(client,"USER xxx\r\n");
sendDone.WaitOne();
// Receive the response from the remote device.
Receive(client);
receiveDone.WaitOne();
// Write the response to the console.
Console.WriteLine("Response received : {0}", response);
// Release the socket.
client.Shutdown(SocketShutdown.Both);
client.Close();
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
}
private static void ConnectCallback(IAsyncResult ar) {
try {
// Retrieve the socket from the state object.
Socket client = (Socket) ar.AsyncState;
// Complete the connection.
client.EndConnect(ar);
Console.WriteLine("Socket connected to {0}",
client.RemoteEndPoint.ToString());
// Signal that the connection has been made.
connectDone.Set();
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
}
private static void Receive(Socket client) {
try {
// Create the state object.
StateObject state = new StateObject();
state.workSocket = client;
// Begin receiving the data from the remote device.
client.BeginReceive( state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReceiveCallback), state);
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
}
private static void ReceiveCallback( IAsyncResult ar ) {
try {
// Retrieve the state object and the client socket
// from the async state object.
StateObject state = (StateObject) ar.AsyncState;
Socket client = state.workSocket;
// Read data from the remote device.
int bytesRead = client.EndReceive(ar);
if (bytesRead > 0) {
// There might be more data, so store the data received so far.
state.sb.Append(Encoding.ASCII.GetString(state.buffer,0,bytesRead));
// Get the rest of the data.
client.BeginReceive(state.buffer,0,StateObject.BufferSize,0,
new AsyncCallback(ReceiveCallback), state);
} else {
// All the data has arrived; put it in response.
if (state.sb.Length > 1) {
response = state.sb.ToString();
}
// Signal that all bytes have been received.
receiveDone.Set();
}
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
}
private static void Send(Socket client, String data) {
// Convert the string data to byte data using ASCII encoding.
byte[] byteData = Encoding.ASCII.GetBytes(data);
// Begin sending the data to the remote device.
client.BeginSend(byteData, 0, byteData.Length, 0,
new AsyncCallback(SendCallback), client);
}
private static void SendCallback(IAsyncResult ar) {
try {
// Retrieve the socket from the state object.
Socket client = (Socket) ar.AsyncState;
// Complete sending the data to the remote device.
int bytesSent = client.EndSend(ar);
Console.WriteLine("Sent {0} bytes to server.", bytesSent);
// Signal that all bytes have been sent.
sendDone.Set();
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
}
public static int Main(String[] args) {
StartClient();
return 0;
}
}
|
|
|
|
|
Are any exceptions being thrown?
James
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
Hi,
Any suggestion on handling WM_NOTIFY, LVN_ODCACHEHINT and LVN_ODFINDITEM events from C# app?
-Kasturi
|
|
|
|
|
I am just learning C# and I was wonder if there is a way to make an instance of a class that is globally availible. Anyhelp would be appreciated. Thanks.
Steve
|
|
|
|
|
Can you describe what you mean by "globally available"?
When you say that I'm thinking something to do with the GAC (Global Assembly Cache), but then you refer to an instance of a class.
James
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
Hello,
I have this private assembly, and I want to ensure that it can be used only
in my application. I have signed the assembly using strong name key pair
that I generated.
But when I am calling it dynamically (i.e. Assembly.Load) how can I ensure
security, i.e. check for the public key, so that only my application will be
able to use it coz only my application knows my public key?
Any ideas?
- Tariq
|
|
|
|