.net

use of ".*?" in .NET regex

Possible Duplicate: Difference between .? and . for regex I was reading this question, and noticed that many of the regular expressions in the answers used .*? to match intermediate text, rather than just .*. To my mind, using .* will match any character zero or more times. Adding ? would be superfluous, as it would just mod...

Irregular PNG button's click event in WPF

Hi, I need an irregularly shaped button in WPF. I am doing it in this way using XAML: <Button Name="toggleButton" Click="toggleButton_Click" Canvas.Left="177" Canvas.Top="0"> <Button.Template> <ControlTemplate> <Image Source="ball.png" /> </ControlTemplate> </Button.Template> </Button> My ball.png image is a PNG ima...

Dragging a window in WPF using DragMove method and click handler on the same button.

Hi, I need a button for two purposes: - Users can drag the application's window using the button - Users can simply click the button to toggle visibility of some other element in the window. The button is a PNG image. I am trying to do it in the following way: XAML: <Button Name="toggleButton" Click="toggleButton_Click" Canvas.Left=...

Where do I start if I want to program something that can change the configuration of Keyboard/Mouse in Windows?

Configuration as in the options you see in the Keyboard/Mouse settings under Windows. I have some .NET programming experience. ...

Getting a fully qualified type name from a string .Net C#

I have a string such as "Int", "Double", "DateTime" etc. How do I get the fully qualified name from this string? ...

General .NET MVC2 questions.

I am just getting into .NET MVC2 (.NET in general even) and I am having a hard time getting familiar with the "flow" of things. The MVC framework, I get.. for the most part. The part that I am getting tripped up on is applying standard programming practices to .NET MVC. For example public ActionResult Index() { var dataContext = new...

C# to VB.NET Code Converter

Hello, I need a C# to VB.NET code converter, and I'm willing to pay. I want something that's ultra convenient, as I want to reduce the amount of copy/paste that I have to do... so could anybody give me some tips to what is out there? I want processing in bulk too, and to support the latest operations (LINQ, new VB inline-function supp...

Symbolic Names for COMException HRESULT Error Codes in .NET

I would like to be able to use the standard symbolic names for HRESULTs returned by COM components in my .NET code. For example, I'd like to be able to write code like this: try { someComObject->DoSomething(); } catch (COMException ex) { if (ex.ErrorCode == E_FAIL) { HandleFail(); } else if (ex.ErrorCode == E_OU...

Returning more than one image from a .NET web service

Hello people, I'm able to return an image as byte array from my .NET web service.. My question is this, what if i want to return more than a single image in one request. For example, my web method currently looks something like this: public byte[] GetImage(string filename) BUT what I'm trying to work out is how i would achieve somet...

Mapping factory methods with anonymous functions/delegates using Dictionary for faster lookup?

Currently, I have a static factory method like this: public static Book Create(BookCode code) { if (code == BookCode.Harry) return new Book(BookResource.Harry); if (code == BookCode.Julian) return new Book(BookResource.Julian); // etc. } The reason I don't cache them in any way is because BookResource is sensitive to cultu...

Passing COM objects as parameters in C#

Given the following code, can someone explain why I can pass a COM object as a value parameter but not as a reference parameter? private void TestRelease() { Excel.Workbook workbook = excel.ActiveWorkbook; ReleaseVal(workbook); // OK ReleaseRef(ref workbook); // Fail } private void ReleaseVal(Object obj) { if (o...

Can I create a generalized method to release COM objects?

Given the following code, will the ReleaseCOMObj() method release the original COM object, or will it implicitly create a copy and release that? private void TestRelease() { Excel.Workbook workbook = excel.ActiveWorkbook; // do stuff ReleaseComObj(workbook); } private static void ReleaseComObj(Object obj) { if (obj != n...

Windowsless application, threads and Invoke()

Let's suppose I have windowsless application: only NotifyIcon is presented. So I've created the only NotifyIcon that I need. But when I had a Form1 class I could use form1.Invoke(action) to perform actions from another thread. And what should I do now? UPD: this is an answer: we should Invoke() a menu itself if (mnuTrayMenu.InvokeRequi...

Causing another application to copy data to clipboard

I'm trying to programmatically make an external WinForms application copy its data to the clipboard, and it's driving me crazy. Since pressing Ctrl-C in the application does the right thing, I've been trying to send ctrl-c using my C# application to the other application. Here is my sequence of commands. I compared the messages using S...

How to simulate Keyboard Events in Code in not active window?

How to simulate Keyboard Events in Code in not active window? How to use SendWait() without SetForegroundWindow()? SendWait example: http://msdn.microsoft.com/en-us/library/ms171548.aspx ...

How to brand and license source code?

I have a open source .NET application. I want to brand it with my website and offer users to purchase a license to remove it. But how can I do this if I give out the source code? What is the best way to do this without effecting performance too? ...

XNA Exclusively Lockable Input Handling

I'm writing an XNA application which requires input directed to only one input event handler, which is the object that is currently locked, i.e. game, menu, console, etc. What is the best way to do this? I've thought about creating an IInputReceiver interface (with methods such as HandleInput) that attaches into a central input manager ...

Run garbage collector from command line?

Is it possible to run .NET garbage collector from command line, e.g. without writing code? ...

How to create a form with a border, but no title bar? (like volume control on Windows 7)

In Windows 7, the volume mixer windows has a specific style, with a thick, transparent border, but no title bar. How do i recreate that window style in a winforms window? I tried setting Text to string.Empty, and ControlBox to false, which removes the titlebar, but then the border also disappears: ...

REST WCF Authentication

Hi, I'm building a self-hosting WCF service, which exposes 2 end-points for each service SOAP REST the SOAP uses WS-* SOAP authentication (authentication header) How can i go about implementing REST authentication? I thought about some sort of login method which will return a cookie of some sort, but i cant think of how to make th...