|
|
Simple, i would create a new image ... (am not sure if the syntax is grammatically correct since i'm not using an ide but the concept is really easy)
something like this:
PictureBox _Add = new PictureBox();....
then load an image from url into the _Add
byte[] imageData = DownloadData(Url);
MemoryStream stream = new MemoryStream(imageData);
Image img = Image.FromStream(stream);
stream.Close();
_Add.Image = img;
FlowPanel.Contorls.Add(_Add);
|
|
|
|
|
Less than 10 seconds of Googling revealed this[^] open source project.
/ravi
|
|
|
|
|
Hello,
I wants to create a system for colleges and universities to view their entire campus online(CCTV), so i have decided to create asp.net website to view all the connected DVRs(Digital Video Recorder). i need more than one DVR to be connected to the Website, and then that can be accessible by selecting its ID or Name. i am able to access single DVR in the web browser through internet but i want it to be accessible in my ASP.net website and i want some option like selecting DVR to view among connected DVRs.
Please tell me where to start i am new to this and i am very excited to make this system as my final year project. please give me your Experienced Solutions.
Thanks..
Thanks
|
|
|
|
|
Please be more specific with what you need help with. "How do I do it" is way too vague to be answered in a couple of forum posts.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi everybody,
Since few days, I try to read certificates on my Smart card by using Compact Framework 3.5 on Windows Mobile 6. I've already succedded to do this on a desktop application by using the following code :
X509Store test = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
test.Open(OpenFlags.ReadOnly);
if (test.Certificates.Count > 0)
{
foreach (X509Certificate2 cert in test.Certificates)
{
MessageBox.Show("Certificate: " + cert.ToString());
}
}
Unfortunately, this code doesn't work on my mobile application: it me indicates that there are no certificate while my smart card contains two certificates!
What happens? Have you got an idea? Have you already encounter the same issue?
Thank you by advance for your help!
Best regards
|
|
|
|
|
Hi,
Finally to get certicates and public keys stored on my Smart Card, I have used directly the APDU's commands and It works fine! Commands are launched by using Winscard.dd.
Best regards
|
|
|
|
|
Appointments {
startTime
EndTime
Index
}
here we will get a List<appointments> values. now I have to compare the 'EndTime' from first item with 'StartTime' in second item.
Ex. there are appointments available from 8-8-30 , 8.30-9 , 9-9.30, 9.30-10
Expected Result is 8-9 , 9-10 if end time from first Item and start time in sencond item matches.
please leads to achieve to this functionality.
|
|
|
|
|
So you only want to combine two adjacent items, even if the third item starts at the same time as the second item ends?
Something like this should do the trick:
public static IEnumerable<Appointment> CombineAdjacentAppointments(
this IEnumerable<Appointment> appointments,
Func<Appointment, Appointment, Appointment> combineAppointments)
{
Appointment previous = null;
foreach (Appointment current in appointments)
{
if (previous == null)
{
previous = current;
}
else if (previous.EndDate != current.StartDate)
{
yield return previous;
previous = current;
}
else
{
yield return combineAppointments(previous, current);
previous = null;
}
}
if (previous != null)
{
yield return previous;
}
}
...
var combinedAppointments = ListAllAppointments().CombineAdjacentAppointments((first, second) => new Appointment
{
StartTime = first.StartTime,
EndTime = second.EndTime,
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
As I interpret the question, you want to get adjacent appointments that are in a list of appointments. The following LINQ query produces an IEnumerable collection that contains List<Appointment> objects:
var appointments = new List<Appointment>();
appointments.Add(new Appointment{ index = 1, startTime = new DateTime(...), endTime = new DateTime(...) });
appointments.Add(new Appointment{ index = 2, startTime = new DateTime(...), endTime = new DateTime(...) });
appointments.Add(new Appointment{ index = 3, startTime = new DateTime(...), endTime = new DateTime(...) });
...
var adjacentAppointments = from a in appointments
from b in appointments
where a.endTime == b.startTime
select new List<Appointment> { a, b };
The adjacentAppointments will have type of IEnumerable<List<Appointment>>.
modified 4-Aug-14 8:10am.
|
|
|
|
|
I have a simplified C code witch can extract text from pdf, and write into a file in XML format. The code is based on MuPDF library.
/*
* mudraw -- command line tool simplified
*/
#include "mupdf/fitz.h"
#include "mupdf/pdf.h"
int main(int argc, char **argv)
{
fz_document *doc = NULL;
fz_context *ctx;
fz_page *page;
fz_device *dev = NULL;
fz_text_sheet *sheet = NULL;
fz_text_page *text = NULL;
fz_cookie cookie = { 0 };
fz_output *out = NULL;
char buf[512];
FILE *file;
ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
doc = fz_open_document(ctx, "c:\test\test.pdf");
page = fz_load_page(doc, 0);
sheet = fz_new_text_sheet(ctx);
text = fz_new_text_page(ctx);
dev = fz_new_text_device(ctx, sheet, text);
fz_run_page(doc, page, dev, &fz_identity, &cookie);
fz_free_device(dev);
file = fopen(buf, "c:\test\test.xml");
out = fz_new_output_with_file(ctx, file);
fz_print_text_page_xml(ctx, out, text);
fz_free_text_page(ctx, text);
fz_free_text_sheet(ctx, sheet);
fz_free_page(doc, page);
fz_close_document(doc);
fz_close_output(out);
fz_free_context(ctx);
fclose(file);
}
My question is how can I implement this in C# with P/Invoke?
I tried the following C# code, but it does'n work. Can anybody help me?
using System.IO;
using System;
using System.Runtime.InteropServices;
using Test.Helpers;
namespace Test
{
public static class Test
{
const uint FZ_STORE_DEFAULT = 256 << 20;
public static void CopyTextPage()
{
const float zoomFactor = 1.0f;
var ctm = new Matrix();
var currentDpi = DpiHelpers.GetCurrentDpi();
var zoomX = zoomFactor * (currentDpi.HorizontalDpi / DpiHelpers.DEFAULT_DPI);
var zoomY = zoomFactor * (currentDpi.VerticalDpi / DpiHelpers.DEFAULT_DPI);
ctm.A = zoomX;
ctm.D = zoomY;
var context = NativeMethods.NewContext(IntPtr.Zero, IntPtr.Zero, FZ_STORE_DEFAULT);
var stream = NativeMethods.OpenFile(context, @"c:\test\test.pdf");
var document = NativeMethods.OpenDocumentStream(context, ".pdf", stream);
var page = NativeMethods.LoadPage(document, 0);
using (var filestream = File.Create(@"C:\test\test.xml"))
{
var text = NativeMethods.NewTextPage(context);
var sheet = NativeMethods.NewTextSheet(context);
var dev = NativeMethods.NewTextDevice(context, sheet, text);
if (filestream.SafeFileHandle != null)
{
var header = filestream.SafeFileHandle.DangerousGetHandle();
var output = NativeMethods.NewOutputFile(context, header);
NativeMethods.RunPage(document, page, dev, ctm, IntPtr.Zero);
NativeMethods.PrintTextPage(context, output, text);
NativeMethods.FreeOutputFile(output);
}
NativeMethods.FreeDevice(dev);
NativeMethods.FreeTextSheet(context, sheet);
NativeMethods.FreeTextPage(context, text);
}
NativeMethods.FreePage(document, page);
NativeMethods.CloseDocument(document);
NativeMethods.CloseStream(stream);
NativeMethods.FreeContext(context);
}
private static class NativeMethods
{
const string DLL = "libmupdf.dll";
[DllImport(DLL, EntryPoint = "fz_new_context", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr NewContext(IntPtr alloc, IntPtr locks, uint max_store);
[DllImport(DLL, EntryPoint = "fz_free_context", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr FreeContext(IntPtr ctx);
[DllImport(DLL, EntryPoint = "fz_open_file_w", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr OpenFile(IntPtr ctx, string fileName);
[DllImport(DLL, EntryPoint = "fz_open_document_with_stream", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr OpenDocumentStream(IntPtr ctx, string magic, IntPtr stm);
[DllImport(DLL, EntryPoint = "fz_close", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CloseStream(IntPtr stm);
[DllImport(DLL, EntryPoint = "fz_close_document", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CloseDocument(IntPtr doc);
[DllImport(DLL, EntryPoint = "fz_free_device", CallingConvention = CallingConvention.Cdecl)]
public static extern void FreeDevice(IntPtr dev);
[DllImport(DLL, EntryPoint = "fz_free_page", CallingConvention = CallingConvention.Cdecl)]
public static extern void FreePage(IntPtr doc, IntPtr page);
[DllImport(DLL, EntryPoint = "fz_load_page", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr LoadPage(IntPtr doc, int pageNumber);
[DllImport(DLL, EntryPoint = "fz_run_page", CallingConvention = CallingConvention.Cdecl)]
public static extern void RunPage(IntPtr doc, IntPtr page, IntPtr dev, Matrix transform, IntPtr cookie);
[DllImport(DLL, EntryPoint = "fz_new_text_sheet", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr NewTextSheet(IntPtr ctx);
[DllImport(DLL, EntryPoint = "fz_free_text_sheet", CallingConvention = CallingConvention.Cdecl)]
public static extern void FreeTextSheet(IntPtr ctx, IntPtr sheet);
[DllImport(DLL, EntryPoint = "fz_new_text_page", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr NewTextPage(IntPtr ctx);
[DllImport(DLL, EntryPoint = "fz_free_text_page", CallingConvention = CallingConvention.Cdecl)]
public static extern void FreeTextPage(IntPtr ctx, IntPtr page);
[DllImport(DLL, EntryPoint = "fz_new_text_device", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr NewTextDevice(IntPtr ctx, IntPtr sheet, IntPtr page);
[DllImport(DLL, EntryPoint = "fz_print_text_page_xml", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr PrintTextPage(IntPtr ctx, IntPtr file, IntPtr page);
[DllImport(DLL, EntryPoint = "fz_new_output_with_file", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr NewOutputFile(IntPtr ctx, IntPtr file);
[DllImport(DLL, EntryPoint = "fz_close_output", CallingConvention = CallingConvention.Cdecl)]
public static extern void FreeOutputFile(IntPtr file);
}
}
internal struct Matrix
{
public float A, B, C, D, E, F;
}
}
|
|
|
|
|
tmiklos67 wrote: but it does'n work. Can anybody help me? Maybe. But you'll need to explain what you mean by "it doesn't work".
/ravi
|
|
|
|
|
The code product no output (file). I'm not sure, but I think the problem is how the file handler passing as pointer...
|
|
|
|
|
In your C code you have:
ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
doc = fz_open_document(ctx, "c:\test\test.pdf");
In your C# you have:
var context = NativeMethods.NewContext(IntPtr.Zero, IntPtr.Zero, FZ_STORE_DEFAULT);
var stream = NativeMethods.OpenFile(context, @"c:\test\test.pdf");
var document = NativeMethods.OpenDocumentStream(context, ".pdf", stream);
var context = fz_new_context(IntPtr.Zero, IntPtr.Zero, FZ_STORE_DEFAULT);
var stream = fz_open_file_w(context, @"c:\test\test.pdf");
var document = fz_open_document_with_stream(context, ".pdf", stream);
Why the difference?
|
|
|
|
|
Very good observation. The C code is working and the C# don't.
Maybe this is the solution and I don't need to use the OpenDocumentStream.
Thanks, I will try your tipp.
|
|
|
|
|
My email is:- vivek.1370@gmail.com
And second iemail is:- vivekpalmailbox@gmail.com
private void ExportToWord()
{
int s1;
for(s1=0;s1<3;s1++)
{
string strForPrint = "";
//first student detail
strForPrint += " S.J.S. PUBLIC SCHOOL" + "\n";
strForPrint += "An English Medium Co-educational School Based on C.B.S.E. Curriculum" + "\n\n\n\n\n";
pic_logo_sjs.Image.Save("E:\\myimage\\myimage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
Word.Application wordApp = new Word.Application();
wordApp.Visible = false;
Word.Document doc = wordApp.Documents.Add();
doc.InlineShapes.AddPicture("E:\\myimage\\myimage.doc");
// strForPrint += richTextBox1.Text + "\r\n";
strForPrint += " REPORT BOOK" + "\n";
strForPrint += " Session 2014-2015" + "\n\n";
strForPrint += "Student Name : " + txt_stu_name.Text + "\r\t\r\t\r\t";
strForPrint += "Roll No : " + txt_roll.Text + "\n\n";
strForPrint += "Class : " + txt_class.Text + "\t";
strForPrint += "Section : " + txt_section.Text + "\t";
strForPrint += "Scholar No : " + txt_scholar.Text + "\r\n\r\n\r\n";
strForPrint += "Date Of Birth : " + txt_dob.Text + "\r\n\r\n\r\n";
strForPrint += "Mother's Name : " + txt_mother.Text + "\r\n\r\n\r\n";
strForPrint += "Father's Name : " + txt_father.Text + "\r\n\r\n\r\n";
strForPrint += "Address : " + txt_address.Text + "\r\n\r\n\r\n\n\n\n\n";
strForPrint += "Tear here line-----------------------------------------------------------" + "\r\n";
//second student detail
strForPrint += " S.J.S. PUBLIC SCHOOL" + "\n";
strForPrint += "An English Medium Co-educational School Based on C.B.S.E. Curriculum" + "\n\n\n\n\n";
strForPrint += " REPORT BOOK" + "\n";
strForPrint += " Session 2014-2015" + "\n\n";
strForPrint += "Student Name : " + txt_name1.Text + "\t\t\t";
strForPrint += "Roll No : " + txt_roll1.Text + "\r\n\r\n";
strForPrint += "Class : " + txt_class1.Text + "\r\t";
strForPrint += "Section : " + txt_section1.Text + "\r\t";
strForPrint += "Scholar No : " + txt_scholar1.Text + "\r\n\r\n\r\n";
strForPrint += "Date Of Birth : " + txt_dob1.Text + "\r\n\r\n\r\n";
strForPrint += "Mother's Name : " + txt_mother1.Text + "\r\n\r\n\r\n";
strForPrint += "Father's Name : " + txt_father1.Text + "\r\n\r\n\r\n";
strForPrint += "Address : " + txt_address1.Text + "\r\n\n";
//First student marks
strForPrint += Exam_I_Term.Text + "\n\n";
strForPrint += "\r\t\r\t" + label1.Text + "\n\n";
strForPrint += lbl_sub.Text + "\r\t" + lbl_english.Text + "\r\t" + lbl_evs.Text + "\r\t" + lbl_hindi.Text + "\r\t" + lbl_math.Text + "\r\t" + lbl_total_marks.Text + "\r\t\n\n";
strForPrint += lbl_marks.Text + "\r\t\r" + lbl_fa_1_english.Text + "\r\t\r\t" + lbl_fa_1_evs.Text + "\r\t\r\t" + lbl_fa_1_hindi.Text + "\r\t\r\t" + lbl_fa_1_math.Text + "\r\t\r\t" + lbl_fa_1_total.Text + "\r\t\r\t\n\n";
strForPrint += lbl_grade.Text + "\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_fa_1_grade.Text + "\r\n\n";
strForPrint += lbl_attendance.Text + "\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_fa_1_attendance.Text + "\r\n\n\n\n";
strForPrint += lbl_dash_teacher.Text + "\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_dash_principal.Text + "\r\n";
strForPrint += lbl_teacher_signature.Text + "\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_principal_signature.Text + "\r\n\n\n";
strForPrint += "\r\t\r\t\r\t\r\t" + lbl_grading_norm_index.Text + "\r\n\n";
strForPrint += lbl_A_outstainding.Text + "" + lbl_B_Excellent.Text + "" + lbl_C_very_good.Text+ "\r\n\r\n";
strForPrint += lbl_D_good.Text + "\r\t\r\t\r\t" + label3.Text + "\r\n\n\n\n\n\n\n";
//second student marks
strForPrint += Exam_I_Term1.Text + "\n\n";
strForPrint += "\r\t\r\t" + label1_1.Text + "\n\n";
strForPrint += lbl_sub1.Text + "\r\t" + lbl_english1.Text + "\r\t" + lbl_evs1.Text + "\r\t" + lbl_hindi1.Text + "\r\t" + lbl_math1.Text + "\r\t" + lbl_total_marks1.Text + "\r\t\n\n";
strForPrint += lbl_marks1.Text + "\r\t\r" + lbl_fa_1_english1.Text + "\r\t\r\t" + lbl_fa_1_evs1.Text + "\r\t\r\t" + lbl_fa_1_hindi1.Text + "\r\t\r\t" + lbl_fa_1_math1.Text + "\r\t\r\t" + lbl_fa_1_total1.Text + "\r\t\r\t\n\n";
strForPrint += lbl_grade1.Text + "\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_fa_1_grade1.Text + "\r\n\n";
strForPrint += lbl_attendance1.Text + "\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_fa_1_attendance1.Text + "\r\n\n\n\n";
strForPrint += lbl_dash_teacher1.Text + "\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_dash_principal1.Text + "\r\n";
strForPrint += lbl_teacher_signature1.Text + "\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_principal_signature1.Text + "\r\n\n\n";
strForPrint += "\r\t\r\t\r\t\r\t" + lbl_grading_norm_index1.Text+ "\r\n\n";
strForPrint += lbl_A_outstainding1.Text + "\r\t" + lbl_B_Excellent1.Text + "\r\t" + lbl_C_very_good1.Text + "\r\n\r\n";
strForPrint += lbl_D_good1.Text + "\r\t\r\t\r\t" + label3.Text + "\r\n\n";
label2.Text = "hello.......";
label2.ForeColor = Color.Green;
Encoding utf16 = Encoding.GetEncoding(1254);
byte[] output = utf16.GetBytes(strForPrint);
FileStream fs = new FileStream(sfd.FileName, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(output, 0, output.Length); //write data into file
bw.Flush();
bw.Close();
fs.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
sfd.Filter = "Word Documents (*.doc)|*.doc";
if (sfd.ShowDialog() == DialogResult.OK)
{
ExportToWord();
}
}
|
|
|
|
|
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
The only people who are interested in your email addresses in a public forum are spammers. Nobody is going to email you directly except them.
|
|
|
|
|
I have three mouse events hooked up to an image control. (MouseLeftButtonDown, MouseMove, MouseLeftButtonUp).
I want to draw a rectangle by click - drag - release.
The Down and move events always do the trick, but only sometimes does the MouseLeftButtonUp event fire.
I don't know why.
What could be the problem?
[EDIT]Not solved yet, but if I release very quickly after a move it works, when I'm too slow, it doesn't.[/EDIT]
[SOLUTION]
This is somewhat weird. The workflow is that on MouseDown I create a Rectangle and ad it to the Canvas control.
In Mousemove I update this rectangle to follow my cursor. When I release the button, the cursor is on the Rectangle, not on the image. The solution is to add an event handler to the created rectangle and bubble it further to the image handler .
[/SOLUTION]
modified 30-Jul-14 5:41am.
|
|
|
|
|
Your mouse is f**ked?
Hardware problems aside, it's not at all obvious from that little exactly what is causing the problem - but you might be better off asking in the WPF forum[^] (for that I assume it to be) - it is not something I've seen in a WinForms app, which doesn't have those events anyway!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
As a matter of fact, I just solved the issue the moment you replied.
I'll update the question
|
|
|
|
|
I've got to bookmark that one it is sure to come back and bite me on the arse sometime. It is so OBVIOUS when explained.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
tell me about it
|
|
|
|
|
Thanks in advance
I have an asp.net web application which integrates with Google API and oauth2 authentication. I have completed authentication part, now what I want really is , I need to display user's google drive files and folders in my application as it is listed in Google Drive and also I need to download files.
Need your help.
|
|
|
|
|
The documentation[^] seems to be a good place to start. The Children section seems like a reasonable bet.
|
|
|
|
|