|
I am thinking of this certificate as SAMPLE..
Certificate Sample
I want to know how can I print a name and fill the (For) field using C# then print on this image so the final will be a new image?
|
|
|
|
|
Using either guesswork or a paint program, work out the size and placement in pixels of the area you want to write in.
Then, with your image loaded into an Image derived control such as a Bitmap called myBlankCertificate
using (Graphics g = Graphics.FromImage(myBlankCertificate))
{
g.DrawString(myCertificateOwnersNameString,
fontIWantTheNamePrintedIn,
brushColourAndSoForth,
rectanglefIFoundEarlier);
} You may want to play with the Graphics.Clip region, but that is up to you.
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
Hi,
By default sql server will accept date format of mdy.is it possible to change the format to dmy.
SET DATEFORMAT dmy
GO
INSERT tDateOrder (d) VALUES ('31/1/04')
GO
INSERT tDateOrder (d) VALUES ('2/28/04')
by executing the above statement im getting the below error.
(1 row(s) affected)
Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
is it possible to change the database format as dmy permanently? and also it should change only for this particular database.
Regards
Kanna
|
|
|
|
|
Wrong forum!You should better post your question to General database forum.
Dotnetkanna wrote: INSERT tDateOrder (d) VALUES ('2/28/04')
It isn't valid date,[EDIT]if the date format is dmy which means day/month/year. [/EDIT]
An year contains 12 months not 28.You may consider change to query to:
<br />
INSERT tDateOrder (d) VALUES ('28/2/04')<br />
Life is a stage and we are all actors!
|
|
|
|
|
You shouldn't be passing strings to the database for dates. If you use parameterized queries the conversion happens for you automatically.
Parameterized Queries[^] This example only shows text, but if you use the following syntax it will do all the type checking before it gets to the database.
cmd.Parameters.Add("@MyDate", SqlDbType.DateTime);
cmd.Parameters["@MyDate"].Value = yourDateTimeVariable;
This is also the recommended way to do queries to prevent SQL injection attacks becuase it also handles things like single quotes and other things you would have to escape manually.
|
|
|
|
|
I am doing Project in OPC.In that project,when ever user create Group means,it has to create in Database also in runtime.I am using Sql Server 2005 and C#.My Question is how to create table with four columns in database at run time using c#.I am waiting for your reply.
Thanks and Regards
M.Raghu
|
|
|
|
|
You could always just write the SQL to create a table and execute it using a SqlCommand , but a better way to do it would be to use Sql Server Management Objects (SMO).
private void MakeMyTable()
{
string connectionString = "...";
using (SqlConnection connection = new SqlConnection(connectionString))
{
Server server =
new Server(new ServerConnection(connection));
Database db = server.Databases["MyDatabase"];
Table newTable = new Table(db, "MyTestTable");
Column pk = GetColumn(newTable, "id", DataType.Int, false);
pk.Identity = true;
pk.IdentitySeed = 1;
pk.IdentityIncrement = 1;
newTable.Add(pk);
DataType varchar = new DataType(SqlDataType.NVarChar, 50);
newTable.Add(GetColumn(newTable, "Name", varchar, false));
newTable.Add(GetColumn(newTable, "Nickname", varchar, true));
newTable.Add(GetColumn(newTable, "Title", varchar, false));
Index index = new Index(newTable, "PK_MyTestTable");
index.IndexKeyType = IndexKeyType.DriPrimaryKey;
index.IndexedColumns.Add(new IndexedColumn(index,"id"));
newTable.Indexes.Add(index);
newTable.Create();
}
}
private Column GetGolumn(Table tb, string columnName, DataType type, bool isNullable)
{
Column column = new Column(tb, columnName);
column.DataType = type;
column.Nullable = nullable;
}
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hello,
I have developed an desktop application in C#.NET Framework(3.5). My client is using the application on different OS like(Xp, Seven, Vista). I have developed the app and did over all testing on XP. Now some features of app are not working on Seven and Vista for which i need to do some extra work. Is there any piece of code in c# by which i can check which operating system is installed and them my app according to that OS.
Thanks in Advance,
Asfand
|
|
|
|
|
Take a look at System.Environment.OSVersion .
System.Environment.OSVersion.Version.Major will return one of the following:
4 = Windows 95, 98, ME or NT 4.0
5 = Windows 2000, XP or 2003 Server
6 = Vista, Windows 7 or 2008 Server
Then query the System.Environment.OSVersion.Version.Minor
See the following for detailed break down of version numbers of Windows OS.
Life Rocks 2.0[^]
MSDN[^]
|
|
|
|
|
You can use Environment.OSVersion to get the OperatingSystem back. From this you can determine whether or not it's a Vista+ system with a simple check:
public bool IsVistaOrHigher
{
get { return OSVersion.Version.Major >= 6);
} If the application can run in compatibility mode though, this is potentially unreliable. Another way to do this is to use a method that only exists in a Vista (or greater) OS to determine it. Here's another example that demonstrates it:
public bool IsVistaOrHigher
{
get
{
return IsVistaOrHigherHelper();
}
}
private bool IsVistaOrHigherHelper()
{
IntPtr hModule = LoadLibrary("Kernel32.dll");
if (hModule != null)
{
IntPtr proc = GetProcAddress(hModule, "MoveFileTransactedA");
return proc.ToInt32() != 0;
}
return false;
} I used part of the Kernel Transaction Manager (KTM) to do this - you can use any new API to accomplish the same.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
What you change depends on what your app is doing. If properly written, you shouldn't need to check the O/S version to modify the apps behavior.
|
|
|
|
|
Dave is absolutely right. First make sure you have to know which OS version your app is running on. Oftentimes people think they need to know while they really don't. A typical example would be the use of special folders, such as "My Documents", which seems to be located at different locations on different Windows versions. However there is a simple way to get that path without worrying about the OS version at all; that too is inside the Environment class.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
While this is good advice, there are certain occassions where this check does count. Suppose you want to use the Kernel Transaction Manager, for instance. If your application runs on Vista+ it will work, but it won't on XP. You should be able to provide a graceful degrade mechanism at this point.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I fully agree, feature detection is part of, well, decent behavior. But it is Microsoft's duty to hide those tiny changes that don't bring much, and make things needlessly hard, and sometimes they do provide a solution, with people not always aware of it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Luc Pattyn wrote: make things needlessly hard
A perfect description.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Very true, but I don't think the OP is using anything platform specific.
|
|
|
|
|
Why do you make that assumption? The OP has not posted anything about that...
|
|
|
|
|
Call it an "educated guess".
|
|
|
|
|
I think this code help you.
RegistryKey KEY = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
string version= KEY.GetValue("ProductName").ToString();
|
|
|
|
|
Hello experts,
I'm currently developing a UserControl in which I have a browseable Image property.
What is the correct approach to dispose this image?
Should my UserControl dispose of it when it gets disposed?
That would create a potential problem if the Image is used elsewhere around the application.
But then again, not doing so means taking the chance that the image is not disposed.
Thanks in advance,
Shy.
|
|
|
|
|
Shy Agam wrote: That would create a potential problem if the Image is used elsewhere around the application.
Only if you used the same instance of the image elsewhere. If you do, I would look to using a weak reference[^] on the image.
Shy Agam wrote: Should my UserControl dispose of it when it gets disposed?
In my opinion, yes.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi Pete,
I always have been, and still am, struggling with this question. Here is a simple example:
I create a UserControl that holds a PictureBox;
I create a modal Form holding two such UserControls and some Buttons
Initially the Form loads one image and shows it in both UC.
then:
scenario 1: I press a button and another image gets loaded in one of the UCs (the original image remains in use in the other UC)
scenario 2: I press another button and one UserControl should vanish (the image remains in use in the other UC)
scenario 3: I press yet another button, it closes the Form (the image is no longer referenced).
So who should be calling Image.Dispose()?
It can't be the UC, as it does not "own" the image.
It shouldn't be the Form, as it will be very vulnerable as soon as the use cases get a bit complex.
So we need some pattern here that automates/hides the problem.
FWIW: the problem vanishes if one never assigns the same image to different UCs, which implies each UC shows a different instance of Image (possibly showing the same thing though), but I want to avoid loading the same image twice if I can reliably do so.
And I don't see how a WeakReference will help me; I know how to use them to possibly keep an object alive, as in a user-created cache. However here the PictureBoxes want to be sure they have the image at hand that they are supposed to show, nothing is supposed to be weak here.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Wow, talk about going way beyond the original problem. Right, here are some thoughts based on work we've done with this in the past.
If you want to show the same image in multiple locations then you don't make the lifetime of the image the responsibility of the items that are showing it. In other words, I'd have an ImageManager class that contained the image. When the controls want the image, then I would return a clone of that image to the control instead - the control can then happily dispose of that image. The lifetime of the ImageManager is then independent of the user control and can be maintained as a WeakReference.
We have used this technique successfully in several projects and it's worked well for us.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Yeah, that is what I was afraid of, another Manager.
Thanks. I was still hoping a ready-made solution existed.
Acutally, you now said it can't be the UC's responsibility. That is a change of heart from before[^]. The UC, being a component, is open to reuse.
Pete O'Hanlon wrote: going way beyond the original problem
curiosity. the ambition to learn. generalization. advancement. you name it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|