|
Sorry, but the link is for C++ not C#...
Daniel Rühmer
Application engineer for Measurement Software
|
|
|
|
|
sorry, my mistake.
|
|
|
|
|
|
I am writting a windows service in .net 4.0 for monitoring purposeson regular intervals.
How is it possible to send an email from within this windows service please?
Thanks
|
|
|
|
|
|
I use this:
public static void
SendEmail
(
string Sender
,
string Recipient
,
string Subject
,
string Body
,
string SmtpServer
,
System.IO.FileInfo[] Files
)
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage ( Sender , Recipient ) ;
if ( Files != null )
{
System.Text.StringBuilder temp = new System.Text.StringBuilder ( Body ) ;
temp.Append ( string.Format
(
"\n\n{0} attached file{1}:"
,
Files.Length
,
Files.Length==1?"":"s"
) ) ;
foreach ( System.IO.FileInfo att in Files )
{
if ( att != null )
{
temp.Append ( "\n" + att.Name ) ;
if ( att.Exists )
{
msg.Attachments.Add ( new System.Net.Mail.Attachment ( att.FullName ) ) ;
}
else
{
temp.Append ( " -- does not exist!" ) ;
}
}
}
Body = temp.ToString() ;
}
msg.Subject = Subject ;
msg.Body = Body ;
System.Net.Mail.SmtpClient cl = new System.Net.Mail.SmtpClient ( SmtpServer ) ;
cl.UseDefaultCredentials = true ;
cl.Send ( msg ) ;
return ;
}
|
|
|
|
|
Here's how you bind to Dependency Property "CtrlXOffset" -
<UserControl x:Class="..."
x:Name="MyCtrl"
...
<aaa.SomeControl Name="xamTSChart" HorizontalAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch">
<aaa.SomeControl.RenderTransform>
<TranslateTransform
X="{Binding Path=CtrlXOffset, ElementName=MyCtrl, Mode=OneWay}"
Y="0" />
</aaa.SomeControl.RenderTransform>
</aaa.SomeControl>
...
</UserControl>
This is cool - I get the result I wanted.
However, can I do this with regular CLR Properties? How'd I rewrite the binding expression?
Thanks
http://en.csharp-online.net/WPF_Concepts%E2%80%94Dependency_Property_Implementation[^]
dev
|
|
|
|
|
You don't need to rewrite the binding expression. The binding engine also binds to POCO as well. BTW, you should have asked this in the WPF/Silverlight forum.
|
|
|
|
|
|
i use VS2005(C#2.0) and OS is Winxp.
i find some code like this:
[DllImport("dxva2.dll", EntryPoint = "GetMonitorTechnologyType", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetMonitorTechnologyType(
IntPtr hMonitor, ref NativeStructures.MC_DISPLAY_TECHNOLOGY_TYPE pdtyDisplayTechnologyType);
but i don't know how use it to get the local machine's monitor type.
Thank you!!!
modified on Monday, December 6, 2010 4:42 AM
|
|
|
|
|
A quick google using your subject line as the search term gave this at MSDN: How to detect display type : CRT or LCD ?[^] as the top link, which includes full source code.
Perhaps you should consider improving your Google-Fu?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
yes, i google it.the answer's development is vs2008,and i try to tranlate it to vs2005
but failed.but i think it should use the code just i pasted.
|
|
|
|
|
That code shouldn't be too difficult to convert down into a 2005 project/class. If you have specific problems related to this, perhaps you could post those issues to the Q&A section for specific answers which are much more difficult to present here in the forum.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
scoket wrote: i find some source like this
You "found" source? At what site have you uncovered it?
I are Troll
|
|
|
|
|
just a joke.i have update my content.
|
|
|
|
|
HI, Thanks in Advance.
In Our project we need to send SMS for alert . but default we can acheive send sms through some Gateway using internet. but in our case we need to send without internet connection . our application use only with in the network ( LAN ). Please give me some idea if u have . can we done using GPRS connection. please give some more idea ...
Thanks...
|
|
|
|
|
|
|
I'm having trouble understanding how to declare events inside interfaces so that the event handler receives my objects that are sent when I raise the events.
The documentation makes it look as if I am limited to using EventArgs as my args parameter. Is this true?
What if I want my args parameter to be my own derived object?
public interface IDrawingObject
{
event EventHandler OnDraw;
}
public class Shape : IDrawingObject, IShape
{
event EventHandler PreDrawEvent;
event EventHandler PostDrawEvent;
}
public class Subscriber1
{
public Subscriber1(Shape shape)
{
IDrawingObject d = (IDrawingObject)shape;
d.OnDraw += new EventHandler(d_OnDraw);
}
void d_OnDraw(object sender, EventArgs e)
{
Console.WriteLine("Sub1 receives the IDrawingObject event.");
}
}
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Oh I see. I can declare my own args class derived from EventArgs, and then use that with the EventHandler<> form.
Thanks, I think that solves the problem for me.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello,
I'm implement some UI application.
The problem i have is how to fire events between two threads ?
Thread A (ui main window/wpf) launch thread B (console app project) with the logic of the app. here i have some recursive algorithm, which generate some question to the user.
Then by event i fire this question to the main ui window and update the ui with the relevant question <b>(any other way to do it ?)</b>
After the user see the question he needs to insert some answer, and according to this input the recursive algorithm continue it's execution.
The problem is how to idle the recursive execution (while the user decide what to answer...)
I was thinking to use background-worker/busy waiting, but is it possible to fire events between threads ?
Thanks for help
|
|
|
|
|
I haven't done any WPF yet, however I use BGW a lot in WinForms. A BackgroundWorker has a ReportProgress method, which is fine for reporting information back to the user. Seems to fit what you are looking for.
|
|
|
|
|
if i understand you correctly, i update my ui by using backgroundWorker.ReportProgress and in order to send user's response, i idle my algorithm with busy waiting ?
|
|
|
|
|
Sorry, I clearly wasn't paying attention here. ReportProgress() will cause the OnProgressChanged event to be fired on the main thread, however it basically is an output method, and it will not wait for anything, so it isn't what you want. As others have pointed out, your overall design seems cumbersome.
|
|
|
|