|
Check out System.Reactive
.NET Foundation Reactive Extentions[^]
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
hi, does in c# exist a type of variable that is like pointers in c++?
I mean, in c++, if I use a pointer to a byte, I can add 1 to this pointer and, in this way, move it along all the array, in c#, is there a way to do a similar thing?
Thank you.
|
|
|
|
|
Yes. They are called "pointers": Pointer types - C# Programming Guide | Microsoft Docs[^]
Do note that you need to specify unsafe for yoru code in order to use them, and you need to take precautions that the memory won't be moved by the GC while you are using the pointers. If you don't need 'em, don't use 'em: and that's "real need" not "I need this to be like my C++ code".
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
There's no need to do things like that in c#, so if you find yourself doing things like that then you probably need to rethink your solution and find one more suitable to the language.
|
|
|
|
|
Just declare a byte[] type and you can access the content in a similar way, although by index value rather than using pointer arithmetic.
|
|
|
|
|
|
Yes. Pointers do exist in C#
Refer this link for pointers in C#: Pointers in C#
modified 25-Oct-19 4:28am.
|
|
|
|
|
Mucking around with DataGridView, DataTable, DataView: this works, but, I suspect there's a better way to do this:
private void btnSave_Click(object sender, EventArgs e)
{
if (dt != null)
{
DataTable dtbl = dt.Clone();
if (dView != null)
{
foreach (DataRowView vrow in dView)
{
dtbl.ImportRow(vrow.Row);
}
}
dtbl.WriteXml(... filepath goes here .xml ... );
}
}
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
How about using the ToTable method on the view?
DataView.ToTable Method (System.Data) | Microsoft Docs[^]
if (dt != null)
{
DataTable dtbl = dView != null ? dView.ToTable() : dt.Clone();
dtbl.WriteXml(...);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thanks !
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Hallo, I'm trying to extract images from pdf.
The problem is with some images that, in pdf, are with the attribute Predictor. I think that, with this attribute, the resultant bytes are to be decoded with png algorith, but I don't find it.
Another problem is with images that are with 8 bit indexed, in the pdf file I don't file the palette, as in other pdf files. Is there someone who is expert with pdf images? I hope my question is understandable. Thank you.
|
|
|
|
|
Hi,
you seem to be peeking into the PDF file to extract what you need, and that is bound to give you surprises when several different PDF sources are involved.
There is another way to approach things, that may or may not meet your needs: using something like Ghostscript[^] you can get an image of a particular page of a PDF document (in any resolution you want), then operate on that.
The advantage is you don't need to deal with all the possible ways PDF stores/creates images; the disadvantages are (1) you only get the resolution you asked for and (2) if all you need is a picture you still have to locate it and extract it from the page image.
Hope this helps.
|
|
|
|
|
How to use ghostscript?i have installed it but i don't understand how to run it.
|
|
|
|
|
Ghostscript can be ran in a separate process; it takes parameters from its command line. It is one of the many programs that explain their parameters by running it with a /h, -h or -help argument in a command window.
Here is a method I once used, you would have to adapt it to your needs of course.
using System.Diagnostics;
using System.IO;
...
string toolsFolder=@"...";
...
private Bitmap getPngImageFromPDF(int resolution, int pageNumber, string pageName, string inName) {
string args=" -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 "+
"-r" + resolution + " -sPageList=" + pageNumber + " -sOutputFile=" + pageName + " " + inName;
string cmd=Path.Combine(toolsFolder, "gswin32c.exe");
ProcessStartInfo psi=new ProcessStartInfo(cmd, args);
psi.CreateNoWindow=true;
if (!withDebug) psi.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden;
Process proc=Process.Start(psi);
proc.WaitForExit();
Bitmap bm=(Bitmap)Image.FromFile(pageName);
return bm;
}
Notes:
1. pageName is the name of the file that will be generated by ghostscript.
2. the generated file will be locked as long as the generated bitmap is alive.
3. you should Dispose() of the bitmap when you no longer need it.
|
|
|
|
|
I am not able to generate the png file, the file should have generated in the same folder of the pdf files?
|
|
|
|
|
If you have trouble with ghostscript, run it manually first, i.e. from inside a Command Prompt (you can copy/paste command lines into it) and look at what it tells you. Only when you're satisfied should you start using C# code and the Process class.
The easiest way to get the folder issues sorted is by putting the ghostscript exe and your C# exe in the same folder (say "Debug"); I expect ghostscript will then use paths relative to that ("Debug") folder.
NB: there is nothing to install about ghostscript, you can put the exe anywhere, as long as it can be found (e.g. because its folder is added to the PATH environment variable, or because it is in your "current directory"). Alternatively you can tell the Process class where it is, that is what my toolsFolder did.
Warning: if you specify a full or partial path for the output, you probably must make sure the folder exists before running ghostscript. And the output location must be writeable, so special folders such as C:\Program Files\ are a no-no.
I can't help you any further, it is all standard Windows behavior as far as I know.
|
|
|
|
|
In C#.Net. Drag and drop control groupBox1 while run time how to write code ?
|
|
|
|
|
|
I took a look at the link you sent for drag-and-drop controls, but I haven't found an example yet
|
|
|
|
|
The first link gives a complete walkthrough. Maybe you need to study it in closer detail.
|
|
|
|
|
|
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
AvalonEdit by icsharpcode[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I have the error shows an exception occur when I try ho Handel foreach function
var results = new List<result>();
foreach (var item in jsonData.items)
{
results.Add(new Result
{
Title = item.title,
Link = item.link,
Snippet = item.snippet,
});
}
And I got this error System.NullReferenceException: Object reference not set to an instance of an object.
please help
|
|
|
|
|
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.
Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null - which means that there is no instance of a class in the variable.
It's a bit like a pocket: you have a pocket in your shirt, which you use to hold a pen. If you reach into the pocket and find there isn't a pen there, you can't sign your name on a piece of paper - and you will get very funny looks if you try! The empty pocket is giving you a null value (no pen here!) so you can't do anything that you would normally do once you retrieved your pen. Why is it empty? That's the question - it may be that you forgot to pick up your pen when you left the house this morning, or possibly you left the pen in the pocket of yesterdays shirt when you took it off last night.
We can't tell, because we weren't there, and even more importantly, we can't even see your shirt, much less what is in the pocket!
Back to computers, and you have done the same thing, somehow - and we can't see your code, much less run it and find out what contains null when it shouldn't.
But you can - and Visual Studio will help you here. Run your program in the debugger and when it fails, VS will show you the line it found the problem on. You can then start looking at the various parts of it to see what value is null and start looking back through your code to find out why. So put a breakpoint at the beginning of the method containing the error line, and run your program from the start again. This time, VS will stop before the error, and let you examine what is going on by stepping through the code looking at your values. And it's very unlikely for that code to be generating the exception, unless there is something very, very wrong with the data being returned.
So start with the debugger, and verify the exact line that generates the error. If it is that line, then you need to load the returned HTML into a string and have a close look at that. It may be as simple as there is nothing sensible returned because you aren't loading it into a browser that has a valid Agent string, or logged in user...
But we can't do that - we don't have your code, we don't know how to use it if we did have it, we don't have your data. So try it - and see how much information you can find out!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|