|
Good answer. To provide a little more help to the newbie who asked the question: In C#, the convention (and what IDEs produce) is that event handlers are written in the form class, so this refers to the form and not to the source of the event. The sender parameter is the source of the event (e.target, to make a JavaScript analogy), but you will need to cast it to a type that you know it must be.
In addition, for event handlers which are fired only off one control, you can simply refer to that control in the event handler. E.g.
LinkLabel myLinkLabel;
Form1(){
myLinkLabel = new LinkLabel();
myLinkLabel.Text = "/thing.exe";
myLinkLabel.Click += (s,e) => {
Process.Start(((LinkLabel)s).Text);
};
}
(I wrote the event handler as a lambda delegate, for .Net 3.0 and up, but the same things apply if you write it as a normal method.)
Edit: ... but missed out the semicolon at the end of the delegate assignment.
modified on Tuesday, May 3, 2011 10:40 AM
|
|
|
|
|
See this wud work for sure
System.Diagnostics.Process.Start(((LinkLabel)sender).Text);
modified on Thursday, May 5, 2011 5:58 AM
|
|
|
|
|
It's bad enough having questions in txtspeak. Answers should be in grammatical English.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Sorry Sir i am just new at it
modified on Thursday, May 5, 2011 6:11 AM
|
|
|
|
|
Hello dear friends.
Thanks to Ranjan.D article about How To Send and Receive SMS using GSM Modem[^] I could modify his program and adapt it to my small application which needed to send a command line from a pc via sms to a digital device and this device will returns a value which is received in the PC and stored in a database.
The question is, how could I do to send this command via SMS to multiple devices and get all the answers you need in one pc.
I read something about "SMS Gateway" but the truth is that I'm not excited about the idea of having to make a payment for this service in addition to what I already paid to the telephone operator for the chip's and sending messages.
Whould you give some ideas????
|
|
|
|
|
when I have a BitmapSource I can easily
BitmapSource img = ...;
using (var stream = new FileStream("scene.png", FileMode.Create))
{
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(img));
encoder.Save(stream);
}
Unfortunately D3DImage is not a BitmapSource !
So.. how could I save my D3DImage to a PNG file?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
modified on Monday, May 2, 2011 1:37 PM
|
|
|
|
|
I'm using SharpDX[^] so I have a fully managed DirectX environment.
I figured it out!
Just for the info, here is how!
class Program
{
unsafe static void Main(string[] args)
{
using (var d3d2d = new D3D11_2D1())
{
d3d2d.Reset(250, 250);
var sc = new Scene_11() { Context = d3d2d.Drawing };
var scw = new SceneDwrite() { Context = d3d2d.Text };
var rargs = new RenderArgs();
d3d2d.BeginRender(rargs);
sc.Render(rargs);
scw.Render(rargs);
d3d2d.EndRender(rargs);
Save1(d3d2d);
}
}
unsafe private static void Save1(D3D11_2D1 d3d2d)
{
var wb = GetBitmap(d3d2d.Drawing.BackBuffer);
using (var stream = new FileStream("scene.png", FileMode.Create))
{
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(wb));
encoder.Save(stream);
}
}
unsafe private static void Save2(D3D11_2D1 d3d2d)
{
using (var teximg = GetCopy(d3d2d.Drawing.BackBuffer))
Resource.ToFile(teximg.Device.ImmediateContext, teximg, ImageFileFormat.Png, "scene.png");
}
unsafe private static WriteableBitmap GetBitmap(Texture2D tex)
{
int w = tex.Description.Width;
int h = tex.Description.Height;
var wb = new WriteableBitmap(w, h, 96.0, 96.0, PixelFormats.Bgra32, null);
wb.Lock();
uint* wbb = (uint*)wb.BackBuffer;
var db = GetDataBox(tex);
db.Data.Position = 0;
for (int y = 0; y < h; y++)
{
db.Data.Position = y * db.RowPitch;
for (int x = 0; x < w; x++)
{
var c = db.Data.Read<uint>();
wbb[y * w + x] = c;
}
}
wb.AddDirtyRect(new Int32Rect(0, 0, w, h));
wb.Unlock();
return wb;
}
private static DataBox GetDataBox(Texture2D tex)
{
var db = GetDataBox(tex, 1);
return GetDataBox(tex, tex.Description.Height * db.RowPitch);
}
private static DataBox GetDataBox(Texture2D tex, int size)
{
using (var teximg = GetCopy(tex))
return tex.Device.ImmediateContext.MapSubresource(
teximg
, 0
, size
, MapMode.Read
, MapFlags.None);
}
private static Texture2D GetCopy(Texture2D tex)
{
var textimgdesc = tex.Description;
textimgdesc.SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0);
textimgdesc.Usage = ResourceUsage.Staging;
textimgdesc.BindFlags = BindFlags.None;
textimgdesc.CpuAccessFlags = CpuAccessFlags.Read | CpuAccessFlags.Write;
var teximg = new Texture2D(tex.Device, textimgdesc);
tex.Device.ImmediateContext.CopyResource(tex, teximg);
return teximg;
}
}
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi Experts ,
Could you help me in using safeHandle instead of IntPtr.I am trying to fix CA2006 reliability warning, but MSDN is lacking of examples.
|
|
|
|
|
SafeHandle[^]
I know nothing , I know nothing ...
RIP Osama Bin Laden, you were thorn in USA throat ,
And you will always be ...
|
|
|
|
|
Bonjour,
je voudrai savoir comment enregistrer un chemin de fichier pdf dans la base de données.j'ai déja fait un code d' enregistrer mais au moment ou je clique sur le bouton "enregistrer, tous les autres champs s'ajoutent dans la base de données sql server 2008 sauf le chemin qui ne s'ajoute pas,son champs reste vide .voilà mon code du bouton enregistrer
try
{//je clique sur le bouton parcourir qui me permet de choisir le pdf à choisir et après son chemin s'affiche dans listbox
if (listBox1.Text == "" || txtLibellé.Text == "" || cbtheme.Text == "")
MessageBox.Show("remplisser d'abord les zones vides!!");
else if (o.Verifier(" Document ", " chemin ", listBox1.Text) == true)
{
MessageBox.Show("existe deja");
}
else
{
o.exec("Insert into Document Values ('" + listBox1.Text + "','" + txtLibellé.Text + "','" + dateTimePicker1.Text + "','" + cbtheme.Text + "')", false);
MessageBox.Show(" c'est enregistré!!!");
Liste();
o.ligne = o.dt.Rows.Count - 1;
}
}
catch (Exception Ex)
{
MessageBox.Show("" + Ex);
}
|
|
|
|
|
هذا الموقع بل الإنجليزية
Perhaps now you understand the importance of keeping the website in one Language, in our case English. This isn't the UN after all.
While we are at at it:
Marking something as urgent is rude (Read the FAQs) - it might be to you, it isn't to us, and we are unpaid.
You have not formatted the code so we can't read it (See the FAQs)
|
|
|
|
|
|
I have no idea what you said, but you need to read up on SQL injection attacks.
|
|
|
|
|
|
immer ist alles dringend!
I cannot remember: What did I before google?
|
|
|
|
|
Thomas Krojer wrote: immer ist alles dringend!(everything is always urgent)
You are right. And CP becomes their emergency room.
Ignorance of the ability brings disability.
|
|
|
|
|
hi.
i need codes in c# for recording video with webcam.
this program have 3 buttons
1.turn on webcam
2.record
3.save the recordes
|
|
|
|
|
A little effort via Google and you will find them. You may also like to check this[^] out, especially point 2.
The best things in life are not things.
|
|
|
|
|
naalgo wrote: i need codes in c# for recording video with webcam.
I'll build it for $5000.
I are Troll
|
|
|
|
|
I'll build it for $4999, but I won't do as good a job as Eddy
|
|
|
|
|
5000? 11900! You offerd it to cheap!!
I cannot remember: What did I before google?
|
|
|
|
|
Thomas Krojer wrote: 5000? 11900! You offerd it to cheap!!
I tried to undercut all other offerings, but as you can see it didn't work
I are Troll
|
|
|
|
|
Here are some codes you may find useful:
using System;
using System.Collections.Generic;
The rest I leave as an assignment for you.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
|
You could always buy a webcam, install the software that goes with it, finds the appropriate dll's, reverse engineer them, re-format them to your coding standards, framework and language and then compile.
V.
|
|
|
|
|