|
hello my Article updated by myself if wants to benefit search for author Ahmad or search for xml guest book
Ahmed Erarslan
MCAD,MCDBA,MCP
MCSD.NET
|
|
|
|
|
Since you keep posting these update notifications, a quick review...
First, don't vote 5 on your own article. You come off patting yourself on the back, especially when this is not an "article." It's a few code snippets with no explanation of the theory and logic behind the code! Before you can call this an article, you've got a lot more work to do to explain what this is, what it does, the theory behind the code and why.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i've created a file .mfl.
I want by clicking of this kind of file run my own application and pass the path of the file at some internal function.
Someone can help me?
|
|
|
|
|
You need to set up a file association and you can do this programmatically by accessing the registry using the Microsoft.Win32.Registry and RegistryKey classes. Read Creating a File Association[^] in MSDN for more details.
If you plan on deploying your application, I suggest you create a Windows Installer project in your solution to install your project output files. You can create file associations in the product by following the direction in File Types Management in Deployment[^] in the Visual Studio .NET product documentation.
When a user double-clicks the file with your registered extension it is passed as the first argument to your Main function, so you could do something like in the following example:
class MainForm
{
static void Main(string[] args)
{
MainForm form = new MainForm();
if (args.Length > 0) form.OpenDocument(args[0]);
Application.Run(form);
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
Hi! could any one tell me. How to take an array as a input parameter in method by web service? I have tried to many time but I got the error about primitive data type.
Thanks in advance.
|
|
|
|
|
|
Could be a lot of things...
Usually you mean how you interact with something...
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
You can read more about interfaces in the C# language specification at http://msdn.microsoft.com/library/en-us/csspec/html/vclrfcsharpspec_13.asp[^].
As it says, an interface is a contract. If you implement an interface a caller knows that your implementation class supports certain methods, properties, and events (in .NET; other languages or framework interfaces may not expose all these things). This and extending classes are what allow you to use polymorphism in code, which helps you create plug-in application and many other application frameworks like COM/OLE (on which Windows is built), distributed computer models, and many other technologies.
So, you could have what's known as a class factory to generate classes that implement a certain interface so that you don't have to bind to a specific class at runtime:
public interface IPlugin
{
string Name { get; }
void DoAction(object context);
}
internal class PluginFactory
{
static IPlugin CreatePluginInstance(string name)
{
switch (name.ToLower())
{
case "helloworldplugin":
return new HelloWorldPlugin();
case "notepadstarter":
return new NotepadStarter();
default:
throw new NotSupportedException("No plugin found.");
}
}
}
public class HelloWorldPlugin : IPlugin
{
public string Name { get { return "Hello World Plugin"; } }
public void DoAction(object context)
{
MessageBox.Show("Hello, world!");
}
}
public class NotepadPlugin: IPlugin
{
public string Name { get { return "Notepad Starter"; } }
public void DoAction(object context)
{
string filename = null;
if (context is string) filename = context as string;
Process.Start("notepad.exe", filename);
}
}
internal class Example
{
static void Main(string[] args)
{
string name = string.Empty;
if (args.Length > 0) name = args[0];
IPlugin plugin = PluginFactor.CreatePluginInstance(name);
Console.WriteLine("Starting \"{0}\"...", plugin.Name);
plugin.DoAction(args.Length > 1 ? args[1] : null);
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Please, I want to know how to assign colors to different regions in the gray scale image, based on the gray level of the region's pixels?
thanks,
--M.Sami
BASKOTA
|
|
|
|
|
Coloring a gray-scale image with any decent quality is not a straight forward color-assignment to luminescence process typically. To learn the details about how it's done professionally I recommend doing a search for something like coloring gray-scale images[^].
To actually implement this in .NET, you use the System.Drawing.Bitmap class. When dealing with pixel-by-pixel transformations you might consider calling Bitmap.LockBits , which locks the object in memory so it isn't moved around and gives you a BitmapData object you can use unsafe code to access pixels. Only do this if you're sure you're handling memory correctly and efficiently, and be sure to call Bitmap.UnlockBits when finished.
For a great overview of unsafe transformations of graphics in .NET - as well as safe transformations - read Christian Graus's article, Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters[^].
As an aside, try to steer clear of unsafe code in .NET. It is there for interoperability but requires special permissions and leaves your code unverifiable, which is a safety net for your users. That's part of what being "managed code" is all about.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi guys,
I have an edit box with text and want to set the focus to that edit box but putting the text cursor at the end of the existing string.
I am probably just being stupid here but I cannot find any reference to this in the Microsoft help. If you just set the focus to that window the cursor appears at the beginning of the existing text (I'm talking about using SetFocus here not clicking on the window with the mouse).
Can anyone shed some light on this. Any help much appreciated.
Richard
|
|
|
|
|
I assume you're talking about a TextBox?
TextBox1.SelectionStart = TextBox1.Text.Length;
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sorry, should have mentioned that this is using the standard Windows API. No classes or MFC. Is there an equivalent to that code in the API?
Richard
|
|
|
|
|
You are asking in the C# forum. Try the Visual C++ forum insted.
It's been years since I last used the Windows API, but if I remember correctly, there is a EM_SETSELSTART message or something like that. Search, it isn't that difficult.
[EDIT: You're looking for the EM_SETSEL[^] message.]
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi, I was wondering if anyone would be able to help me.
I am currently using a standard RichTextBox to use for input, but if the mouse pointer was used to reposition the cursor, I need to find the last occurance of a particular text pattern prior to the cursors new position.
Thanks in advance.
Dave
|
|
|
|
|
Sounds like a job for a regular expression. The RichTextBox's .SelectionStart property will tell you where the insertion point is, if .SelectionLength is 0.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So I can find the position, but how about getting the last instance before this position, is there anyway to search for a regex back from a certain point?
|
|
|
|
|
Just return the string up to the position the cursor is at
string searchThis = RTB1.Text.Substring(1, position);
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
All,
I am creating a program the inventories computer with wmi. I have a class file that contains all of my wmi queries. I have a textbox on the main windows form to enter a computer name into. What would be the best way to transfer that name to the class file that contains all of my queries, so that it can be used in the wmi connection string.
Eric
|
|
|
|
|
That depends on how your wrote your code and how your using your class. If your creating a seperate instance of your class for every machine your going to scan, then the easiest way would be to pass the string to the constructor of your class and have the constructor tuck the string away in a private variable so it can be used later to build the connection and/or query strings.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I got the jist of what you are saying, but I am having trouble finding a way to actually reference the text in the textbox on my main form. I am not sure what needs to be written on the Form page, to actually pass the textbox.text.
Hope this makes some sense.
Eric
|
|
|
|
|
You're kidding, right?
string myText = TextBox1.Text;
myWMIClass myWMI = new myWMIClass(myText);
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
As bad as that may have sounded, you have extremely helped me figure out some things I have been having trouble getting a handle on.
Please do understand my stupidity.
ERic
|
|
|
|
|
Hi All,
I need to detect when a key has been pressed on the keyboard or a button on the mouse.
This solution has to work on Windows 98 and up. Actually, my solution is using SetWindowsHookEx with WH_MOUSE_LL and WH_KEYBOARD_LL, but it works only on NT and up. I have read WH_KEYBOARD_LL and WH_MOUSE_LL isn't supported by Windows 98/ME.
any ideas for Windows 98?
Thanks,
Bego
|
|
|
|