|
If he referenced the project, it'd already be loaded. Next, this assembly will not be unloaded. Then there's the slower Activator.
I didn't feel like changing that, as I'd use strong-typing to get the initial string;
string formClassName = typeof(frm1).Name;
Depends; if it has to be a plugin, I'd understand. For all other problems, I'd go for the simple solution.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
thanks all for your awnsering.
it works.
this code works good.
string formName = "ToCreate.Form1";
var asm = Assembly.Load("ToCreate");
Type formType = asm.GetType(formName);
Form f = (Form) Activator.CreateInstance(formType);
f.Show();
thanks,thaks specially to Ed Hill _5_
|
|
|
|
|
Dear fiends my question is much long but please help me solve my problem.
i m completely stuck hear.
I m tried to extract images from pdf using itexsharp but when i extract them the images looks like convert to negative form, I think my pdf containing high quality images. I used following code sample for extract images from pdf.
private static List<system.drawing.image> ExtractImages(String PDFSourcePath)
{
List<system.drawing.image> ImgList = new List<system.drawing.image>();
try
{
RAFObj = new iTextSharp.text.pdf.RandomAccessFileOrArray(PDFSourcePath);
PDFReaderObj = new iTextSharp.text.pdf.PdfReader(RAFObj, null);
for (int i = 0; i <= PDFReaderObj.XrefSize - 1; i++)
{
PDFObj = PDFReaderObj.GetPdfObject(i);
if ((PDFObj != null) && PDFObj.IsStream())
{
PDFStremObj = (iTextSharp.text.pdf.PdfStream)PDFObj;
iTextSharp.text.pdf.PdfObject subtype = PDFStremObj.Get(iTextSharp.text.pdf.PdfName.SUBTYPE);
if ((subtype != null) && subtype.ToString() == iTextSharp.text.pdf.PdfName.IMAGE.ToString())
{
byte[] bytes = iTextSharp.text.pdf.PdfReader.GetStreamBytesRaw((iTextSharp.text.pdf.PRStream)PDFStremObj);
if ((bytes != null))
{
try
{
System.IO.MemoryStream MS = new System.IO.MemoryStream(bytes);
MS.Position = 0;
System.Drawing.Image ImgPDF = System.Drawing.Image.FromStream(MS, true, true);
//System.Drawing.Bitmap ImgPDF = (Bitmap)System.Drawing.Image.FromStream(MS, true, false);
ImgList.Add(ImgPDF);
MS.Flush();
}
catch (Exception)
{
}
}
}
}
}
PDFReaderObj.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return ImgList;
}
public static void WriteImageFile(string sourcePDFpath, string targetpath)
{
try
{
// Get a List of Image
List<system.drawing.image> ListImage = ExtractImages(sourcePDFpath);
for (int i = 0; i < ListImage.Count; i++)
{
try
{
System.Drawing.Imaging.EncoderParameters parms = new System.Drawing.Imaging.EncoderParameters(1);
parms.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 0);
System.Drawing.Imaging.ImageCodecInfo jpegEncoder = ImageCodecInfo.GetImageEncoders().Single(p => p.CodecName.Contains("JPEG"));
ListImage[i].Save(targetpath + "\\Image" + (i + 1).ToString().PadLeft(3, '0') + ".Jpeg", jpegEncoder, parms);
}
catch (Exception ex)
{
throw ex;
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
But this solution is not worked for my purpose. So i found a another program call 'pdfimages' is support to extract images from pdf, this exe extract images from pdf in .ppm format so i passed the command line argument to this exe and make exe to work and after the exe executed i convert ppm files to jpeg from my application.
This work for my task nicely. But i have another problem now. When i converted the image the quality of the image is reduced.
When extracting image from Pdf writer it shows.
Bit Depth : 32
Horizontal Resolution : 296dpi
Vertical Resolution : 296dpi
But my images it shows
Bit Depth : 24
Horizontal Resolution : 96dpi
Vertical Resolution : 96dpi
I need to extract images from pdf with the same quality, can anyone tell me a method for do my task...?
|
|
|
|
|
Suggest you send tech support questions to iTextSharp, and whoever wrote pdfImages.
Second: examine the many apparent answers to your question here:[^].
best, Bill
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr
|
|
|
|
|
Thanks Bill, for your reply......I'll try that..
|
|
|
|
|
Hi,
I wanted to know is there any way to read the Device instance id through c# code.
I have a PCI card and I wanted to read the device instance id of it.
Thanks,
Pavan.
|
|
|
|
|
C# does not talk directly to PCI cards. It's possible to read the one from the harddisk using WMI and Admin-rights, you'd have to try to check whether your PCI-card vendor supports that too.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
Hi everyone!
We have developed a desktop application. Now the client says that if someone pay directly into his paypal account, he need IPN data and store the data into his mysql databas table. It's a desktop application so how is it possible and which paypal Payment method is best for it and how to do it.
If you have code then please give it to me.
|
|
|
|
|
Here have some Google foo[^] look at the first couple of hits!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
sharmaravi123 wrote: Now the client says that if someone pay directly into his paypal account, he need IPN data and store the data into his mysql databas table
Meaning that the payment goes through the application or that the application is supposed to collect a payment posted to paypal from some other source?
|
|
|
|
|
No one will make payment from our desktop application.
Customer will pay from our website or from paypal website directly. When he pay, We need to get ipn data aucomatically and insert customer data in database.
I have made aspx page which will get data and post data on web service. Aspx page will post data to web service and there we will insert the data in database.
Am I doing write?????????
|
|
|
|
|
Paypal used to have a notification service of some sort. You had to be a merchant account and you needed to talk to them (email or phone) to get it turned on for the account.
I can't say if that is still true.
|
|
|
|
|
I need a image control, it should implement as below:
1. user can draw circle, line on image
2. user can write text on image
3. the text or graphic draw by user can be move before saving
4. user can redo some operation
Yes, it sound like we need a editor like photoshop.
Anyone knows this control even not for free(hopeing not too expensive) or any solution. Control of OpenSource is better.
|
|
|
|
|
Easily made; start out with a UserControl , that's your container where all other stuff is dropped in. Next, if the user needs a circle, create a circle-control and put it in the container. If the user needs a text, put the text on a label and put it in the container. Having them all in controls means that the user can manipulate them, and that the parts are nicely layered. Otherwise, It'd be hard to remove a line if it actually crosses the circle
Undo and redo are a different pattern, we'll look into that once this part is solved. If you want to look ahead anyway, Google for "Memento pattern".
--edit
Member 3769446 wrote: I need a image control, it should implement as below:
I assumed that you would be doing the implementation part
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
You are describing a drawing control on which movable drawn objects, text, shapes, and lines, can be drawn, moved, saved, re-done. And, I'd guess you'd want control over Foreground and Background color of Text, and BorderColor and FillColor of shapes, as well as line color. And: being able to change z-order ?
This is not a simple Paint program scenario.
If you search here on CodeProject, you will find some examples of such projects.
best, Bill
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr
|
|
|
|
|
Hi im currently developing an web based application, i have installed an ajax toolkit and would like to be notified when someone inserts or updates a field in the database on my website.(Basically push technology or feeds)
Im hoping to have a "new customer added" on my website so everyone that views the page knows a new customer has been added.
Im currently using sql server 2008 R2 management studio and c# (asp.net).
Thanks guys.please reply asap.
Regards
H
|
|
|
|
|
Any 'push technology' on a website is a fake. HTTP doesn't support push. Therefore you should pick the fake which puts the least stress on your system for the desired effect. Also, databases don't really support events very well, so pushing notifications from there is not easy, and since you have to store them somewhere waiting for an AJAX request, it's not useful either.
I'm assuming that you record the date of registration with a customer. I further assume that you have some kind of ping mechanism in your web app (i.e. at some interval you make an AJAX request to a server script which checks for updates); if not, first you should set that up (a setInterval call to send a request).
So what you want to do is:
- store the last time a user checked for this type of update. This is probably in the session, as you don't usually want to spam a user with 100 'new customer' notifications when they log on, but for some updates (e.g. PMs) you do want to put up the blinking 'You have 100 new PMs' notice then. If it's persistent, you want to have a database table (lastuserupdates or something like that) to record this.
- in your ping response server script, you want to get the relevant updates, i.e.
select count(*) from customer where date>@session.LastCheckedCustomerUpdates
... and send that information as part of the ping response. JSON is common for this, or you can use a simple text format. E.g. updates = {newcustomers:1}. Obviously, if you want more than just a number notification you can select other data too. - That script should also update the last-checked-time so the customer isn't reported as new the next time as well.
- The JavaScript AJAX response handler for the ping should do something intelligent with the information. A simple thing is to add news items to a scrolling ticker type of display.
|
|
|
|
|
public Country(string cAbs, string cName)
{
this._country = cName;
this._abs = cAbs;
}
private void btnOk_Click(object sender, EventArgs e)
{
Country myCountry = new Country();
CountryList countries = new CountryList();
countries.Add(new Country("AE", "United Arab Emirates"));
countries.Add(new Country("AF", "Afghanistan"));
countries.Add(new Country("AQ", "Antarctica"));
countries.Add(new Country("AR", "Argentina"));
countries.Add(new Country("AT", "Austria"));
countries.Add(new Country("AU", "Australia"));
countries.Add(new Country("BD", "Bangladesh"));
countries.Add(new Country("BE", "Belgium"));
countries.Add(new Country("BR", "Brazil"));
countries.Add(new Country("BS", "Bahamas"));
countries.Add(new Country("CA", "Canada"));
countries.Add(new Country("CH", "Switzerland"));
countries.Add(new Country("CL", "Chilie"));
countries.Add(new Country("CM", "Cameroon"));
countries.Add(new Country("CL", "Chilie"));
countries.Add(new Country("CN", "China"));
countries.Add(new Country("CO", "Columbia"));
countries.Add(new Country("CR", "Costa Rica"));
countries.Add(new Country("DK", "Denmark"));
countries.Add(new Country("DM", "Dominica"));
countries.Add(new Country("DO", "Domican Republic"));
countries.Add(new Country("EC", "Ecuador"));
countries.Add(new Country("EE", "Estonia"));
countries.Add(new Country("EG", "Egypt"));
countries.Add(new Country("ES", "Spain"));
countries.Add(new Country("ET", "Ethiopia"));
countries.Add(new Country("EU", "European Union"));
}
Question:
1. How to find the a country in a list?
|
|
|
|
|
Country foundCountry = CountryList.FirstOrDefault(c=>c.CountryAbreviation == this.textBox1.Text);
if (foundCountry==null)
{
}
Have you considered Using a
Dictionary<String, Country>
that would allow
CountryList.ContainsKey(this.textBox1.Text)
and
Country foundCountry = CountryList[this.textBox1.Text]
What you want to do will depend on if you have more than one item with the same abreviation
|
|
|
|
|
Just want to point out
Quote: Country foundCountry = CountryList[this.textBox1.Text]
in above code there may be chances of KeyNotFound Exception[^]
Anyway 5+
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
thanks, i should have been a little more clear, the CountryList.ContainsKey check should be called first before attempting access via CountryList[this.textBox1.Text].
Thanks for the 5
|
|
|
|
|
You can use TryGetValue (in recent .Net, but if you're already suggesting Linq then it is also available) which will do the contains check and the lookup in a single call.
Country c;
if(dict.TryGetValue(text, ref c)){
}
|
|
|
|
|
IEnumerable<country> filteredCountry = countries.Where(f => f.GetAbbreviation == "EG");
if (filteredCountry != null)
{
Country countryOne = filteredCountry.First();
}
try out the above code !!!!
|
|
|
|
|
if (filteredCountry != null)
this will not ever be null as it is assigned on the line above, but it may contain no results if there are no matches, causing First to return an InvalidOperationException.
FirstOrDefault then a null check would be safer
|
|
|
|
|