.net

What design patterns are used in diagramming tools?

Diagram.net is good diagramming tool. I need to understand what design patterns are used by this tool so that I can understand how it works. What design patterns are used in this tool? What design patterns are generally used for diagramming tools? I would also like to know how can I use this to develop very simple diagramming tool (...

Text viewing in a delimited space

I need to visualize a text into a delimited space. If I add a simple TextBlock I have a problem: when the text is longer than the available space, it is cropped at the end. I tried to insert the TextBlock inside a Viewbox: this solution works for a text longer than the available space, but increase the size of the text when it is shorter...

Find resource for CultureInfo

Hi, I need to determine whether there is a resource file for the given CultureInfo or not. Is there an easy way? Regards ...

Virtual properties duplicated during serialization when XmlElement attribute used

The Goal: XML serialize an object that contains a list of objects of that and its derived types. The resulting XML should not use the xsi:type attribute to describe the type, to wit the names of the serialized XML elements would be an assigned name specific to the derived type, not always that of the base class, which is the default be...

Problems with binding to Window Height and Width

I have some problems when I try to bind the height and width of a window to properties in my view model. Here is a small sample app to illustrate the problem. This is the code in app.xaml.xs public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWind...

WPF Dragging a window to the desktop

I've seen some nice Adobe AIR demos where a component of the application is dragged outside of the application and dropped onto the desktop and then continues to run in a new window. This seems to be facilitated by the NativeDragManager class. Is there anything similar in WPF? How would you go about implementing this sort of functionali...

linq, selecting columns as IEnumerable<DataRow>

how can i do in linq: IEnumerable<DataRow> query = from rec in dt.AsEnumerable() where rec.Field<decimal>("column2") == 1 && foo(rec.Field<decimal>("column1")) select new { column1 = rec.Field<decimal>("column1"), column2 = rec.Field<decimal>("column2"), column3 = rec.Field<d...

Babel Obfuscator: Sample effective post build event for free version

Does anyone have a sample post build event for Babel Obfuscator I can just copy and paste into my .net assembly release build configuration? The documentation for Babel is 54 pages long, and unfortunately doesn't come with any real world samples on how to use it with Visual Studio integration. Failing that , is there a free obfuscator...

Run VB.NET on Mono

Which version of Mono do I need to convert and run the Windows applications that I developed using VB.NET that came along with .NET 3.5, in Ubuntu? ...

.NET How to detect if DirectX 10 is supported?

I would like to find out from .NET code whether DirectX 10 is supported on the machine, preferably without using managed DirectX or XNA assemblies. Thank you in advance! ...

Calling IPrincipal.IsInRole on Windows 7

We use NTLM auth in our application to determine whether a user can perform certain operations. We use the IPrincipal of their current Windows login (in WinForms applications), calling IsInRole to check for specific group memberships. To check that a user is a local administrator on the machine, we use: AppDomain.CurrentDomain.SetPrinc...

Why is my List.Sort method in C# reversing the order of my list?

I have a list of items in a generic list: A1 (sort index 1) A2 (sort index 2) B1 (sort index 3) B2 (sort index 3) B3 (sort index 3) The comparator on them takes the form: this.sortIndex.CompareTo(other.sortIndex) When I do a List.Sort() on the list of items, I get the following order out: A1 A2 B3 B2 B1 It has obviously worked...

Reading web-service information from assembly app.config file

I have a plugin architecture solution written in .NET C# 3.5, where each plug-in is an assembly loaded by the main project. Each plug-in can optionally consume web-service, so I would like to have the configuration of that plugin in its own plugin.dll.config file instead of having it in the app.config of the main project. I have been...

Implementing SSL tunnel in C#

As a part of a larger application I need to implement an SSL tunnel in C#. I was wondering if there's a better way of doing that instead of writing each step of SSL negotiation myself which sounds like reinventing the wheel. Do you know if there are any libraries that I could use to minimize the code I need to write or any tutorials whi...

Find slow/ineffecient method calls in dotnet

Hi, I'm faced with a big old stack of method calls in some legacy code, one or some of which is creating a bottleneck and really slowing things down. Is there any quick way I can get a report on which method calls are taking the time, short of running in debug, stepping through and seeing where the cursor pauses? ...

Exchange 2003 Public Folder Replica list

Hi, I am trying to update a replica list on a Exchange 2003 public folder. I am using the WMI namespace exchange_publicfolder to try and add an Exchange server (using the servers DN) to the AddReplica procedure. Every time I run this I get an invalid parameter as an exception. Below is the code that I am using to do this. WMI.C...

Performance concern when using LINQ "everywhere"?

After upgrading to ReSharper5 it gives me even more useful tips on code improvements. One I see everywhere now is a tip to replace foreach-statements with LINQ queries. Take this example: private Ninja FindNinjaById(int ninjaId) { foreach (var ninja in Ninjas) { if (ninja.Id == ninjaId) return ninja; } ...

Xslt Extension Objects- Getting Context

Hi, i'm using XsltArgumentList.AddExtensionObject with sucess. The problem is when i call the functions from the xslt, they only get the arguments i pass. How can i get the context (what node is being processed). I am using XslTransform.Transform (myXPathDoc, xslArgs, myWriter); to start the transformation.. I heard about SetContext an...

How to use ModifierKeys in a class

Hi, I need to access "ModifierKeys" from a class, not from a form (I have a reference to that form, but frm.Modifierkeys is not allowed from the class). Is that possible, and if yes, how? Thanks! ...

How to track when my application has unexpectedly shut down?

I'm writing an application whose purpose involves a lot of logging of different events. Among those I would also like to have an event that the application was shut down - even if unexpectedly like because of a power loss. Naturally, when the power goes out I don't get a chance to write anything anywhere. So my idea was to continuously...