|
I don't think it's possible. Maybe one of the other guys knows a way - if there is one it could be very interesting.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Not without a lot of work, I'm afraid.
With a class like
class NotifiableProperty<T>
{
T val;
public event Action PropertyChanged;
public T Value
{
get { return val; }
set { val = value; PropertyChanged(); }
}
public static implicit operator T(NotifiableProperty<T> p)
{
return p.Value;
}
}
you can do
class MyClass
{
NotifiableProperty<int> p = new NotifiableProperty<int>();
public MyClass()
{
p.PropertyChanged += new Action(() => Console.WriteLine("Changed"));
}
public int P
{
get { return p; }
set { p.Value = value; }
}
}
and then when you do
MyClass m = new MyClass();
m.P = 20;
you will see "Changed" printed on the screen.
I don't know how to automatically hook to the events, and I don't think setting up events from the base class is a good idea, as there is the possibility that derived class members wouldn't have been initialized at that point. Maybe use reflection inside the derived class?
|
|
|
|
|
I think another way to phrase this question is
How about a way to override the set; method for a property
In VS2008 you don't need to specify a private field for properties and can just use
public int myprop {get;set;}
So if I could figure out how to override that set method, maybe thats where I could add change event handler.
|
|
|
|
|
I want to print a multipage tiff image. I want first to get a print preview but when I want to get more pages to the printdocument I only get the last page of the image.
Can anyone help me to solve this problem?
code:
Image image = Image.FromFile(@strBestandsPad);
AfbeeldingFormaat abf = new AfbeeldingFormaat();
Point puntPagina = new Point(0, 0);
int intPaginas = image.GetFrameCount(FrameDimension.Page);
int i = 0;
if (intPaginas > 1)
{
while(i < intPaginas)
{
e.HasMorePages = true;
Rectangle rec = new Rectangle(0, 0, 763, 1084);
image.SelectActiveFrame(FrameDimension.Page, i);
Image newImage = image;
newImage = abf.FixedSize(nieuwImage, 763, 1084); // set image to A4 page size
e.Graphics.DrawImage(nieuwImage, rec);
i++;
}
}
else
{
e.HasMorePages = false;
}
thanks,
|
|
|
|
|
Did you ever get this answered? I am looking for this solution now.
Peace.
|
|
|
|
|
No, but I've the answer.
With this metho I size the image to the wright size. You can put this method in a seperate class.
<br />
public Image FixedSize(Image imgPhoto, int Width, int Height)<br />
{<br />
int sourceWidth = imgPhoto.Width;<br />
int sourceHeight = imgPhoto.Height;<br />
int sourceX = 0;<br />
int sourceY = 0;<br />
int destX = 0;<br />
int destY = 0;<br />
<br />
float nPercent = 0;<br />
float nPercentW = 0;<br />
float nPercentH = 0;<br />
<br />
nPercentW = ((float)Width / (float)sourceWidth);<br />
nPercentH = ((float)Height / (float)sourceHeight);<br />
<br />
<br />
if (nPercentH < nPercentW)<br />
{<br />
nPercent = nPercentH;<br />
destX = (int)((Width - (sourceWidth * nPercent)) / 2);<br />
}<br />
else<br />
{<br />
nPercent = nPercentW;<br />
destY = (int)((Height - (sourceHeight * nPercent)) / 2);<br />
}<br />
<br />
int destWidth = (int)(sourceWidth * nPercent);<br />
int destHeight = (int)(sourceHeight * nPercent);<br />
<br />
Bitmap bmPhoto = new Bitmap(Width, Height, PixelFormat.Format24bppRgb);<br />
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);<br />
<br />
Graphics grPhoto = Graphics.FromImage(bmPhoto);<br />
grPhoto.Clear(Color.White);<br />
grPhoto.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;<br />
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;<br />
grPhoto.SmoothingMode = SmoothingMode.AntiAlias;<br />
grPhoto.PixelOffsetMode = PixelOffsetMode.HighQuality;<br />
grPhoto.CompositingQuality = CompositingQuality.HighQuality;<br />
<br />
grPhoto.DrawImage(imgPhoto,<br />
new Rectangle(destX, destY, destWidth, destHeight),<br />
new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),<br />
GraphicsUnit.Pixel);<br />
<br />
grPhoto.Dispose();<br />
return bmPhoto;<br />
}
The next thing I did was to create class that derive from printdocument.
The next part of code:
public class PrintImage : PrintDocument<br />
{<br />
private int currentPage;<br />
<br />
private int numberOfPages;<br />
<br />
private Image imageToPrint;<br />
<br />
public Image ImageToPrint<br />
{<br />
get<br />
{<br />
return this.imageToPrint;<br />
}<br />
<br />
set<br />
{<br />
this.imageToPrint = value;<br />
this.numberOfPages = this.imageToPrint.GetFrameCount(FrameDimension.Page);<br />
}<br />
}<br />
<br />
protected override void OnBeginPrint(PrintEventArgs e)<br />
{<br />
base.OnBeginPrint(e);<br />
<br />
this.currentPage = 0;<br />
<br />
if (this.imageToPrint == null)<br />
{<br />
throw new ArgumentNullException("ImageToPrint");<br />
}<br />
}<br />
<br />
protected override void OnPrintPage(PrintPageEventArgs e)<br />
{<br />
AfbeeldingFormaat afb = new AfbeeldingFormaat();;<br />
base.OnPrintPage(e);<br />
<br />
this.ImageToPrint.SelectActiveFrame(FrameDimension.Page, this.currentPage);<br />
<br />
using (var bmp = new Bitmap(this.imageToPrint))<br />
{<br />
Image image;<br />
<br />
image = afb.FixedSize(bmp, e.PageBounds.Width, e.PageBounds.Height);<br />
<br />
e.Graphics.DrawImage(image, e.PageBounds);<br />
<br />
e.HasMorePages = ++this.currentPage < this.numberOfPages;<br />
}<br />
}<br />
}
And then the last part to print.
<br />
PrintDocument printDocument = new PrintImage { ImageToPrint = Image.FromFile(path) };<br />
<br />
var ppd = new PrintDialog<br />
{<br />
Document = printDocument<br />
};<br />
<br />
if (ppd.ShowDialog() == DialogResult.OK)<br />
{<br />
<br />
printDocument.Print();<br />
<br />
}<br />
<br />
I hope this helps you.
|
|
|
|
|
A bit TMI, but your code does contain the answer, which is here (after selecting the active frame on the image, simply create a new bitmap from it and use that bitmap to print to the graphics object):
protected override void OnPrintPage(PrintPageEventArgs e)
{
base.OnPrintPage(e);
this.ImageToPrint.SelectActiveFrame(FrameDimension.Page, this.currentPage);
using (var bmp = new Bitmap(this.imageToPrint))
{
e.Graphics.DrawImage(bmp, e.PageBounds);
e.HasMorePages = ++this.currentPage < this.numberOfPages;
}
}
|
|
|
|
|
Hi,
How save a picture from a WebCam Stream to .bmp
The camera has a fixed resulution of 2MP.
I want to write it in C#.
thanks
|
|
|
|
|
Safe from what, the rain? just give it an umbrella
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
You'll have to consult the documentation on the library you're using to get the video from the webcam.
|
|
|
|
|
Which documentation? I don't know how to start, which library should I take?
|
|
|
|
|
Contact the manufacturer of the webcam to see if they put out a SDK (Software Development Kit) that you can use. It should come with the libraries and the documentation on how to use them.
|
|
|
|
|
hello all can any body help me to convert class to dll file
|
|
|
|
|
Set project output type to Class Library
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
|
Yeah Visual Studio can help you do that. i.e. you IDE would be the best place to start, you basically want to compile your project as a .DLL file
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Next time please do googling before posting any question
anyways here we go
use the following command from command prompt of visual studio
csc /target:library File.cs
if you are usinf visual studio IDE use following steps to do so
1.goto file->new ->project
2.select class library
3.Provide name to class library
4.click ok
4.write down your class in file opened
5.build the project
6.you will get your dll in path application dir/bin/debug
so simple
|
|
|
|
|
&Hello,
How we can send the e-mails witch c#? thank you verry mutch.
|
|
|
|
|
At least click me[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
With MailMessage and SmtpClient.
MailMessage mm = new MailMessage("from", "to", "subject", "body");
SmtpClient sc = new SmtpClient("mail server", port);
sc.Send(mm);
|
|
|
|
|
abbd wrote: the e-mails witch
she sounds scary
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
nah my firewall is working...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I think you need a 'waterwall' for witches
Unless you burn them at the stack!!!
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
abbd wrote: witch c#
Is this the upcoming version of C#? Where did you download it?
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
You can do somesing like this:
private string login = "test@ukr.net";
private string password = "test";
private string smtp_host = "smtp.ukr.net";
int port = 465;
public Mailer()
{
System.Net.Mail.SmtpClient mysmtp = new SmtpClient();
mysmtp.Host = smtp_host;
mysmtp.Port = port;
mysmtp.EnableSsl = true;
mysmtp.Credentials = new System.Net.NetworkCredential(login, password);
MailAddress from = new MailAddress("test@ukr.net", "user anonimus =)");
MailAddress to = new MailAddress("to@mathcentre.com.ua");
MailMessage msg = new MailMessage(from, to);
msg.Subject = "programm test";
msg.Body = "test!!!!!!!!!\n see ya!";
mysmtp.Send(msg); // this code works but I dont now how use certificates that
//used by some mail-servers =(
}
|
|
|
|