.net

Unit testing XNA: Do I need to Mock my GraphicsDevice

I'm fooling around with the XNA framework. To help me around I made a helper class that looks like this: ActorHolder + SpriteBatch (SpriteBatch) + ContentManager (ContentManager) - drawables (IList<IDrawable>) - updatables (IList<IUpdatable>) + ActorHolder(GraphicsDevice, ContentManager) + Draw(GameTime) + Update(GameTime) + AddActor(I...

Slickest way to put objects into separate lists based on a property value.

I have a collection of objects and am curious about the way you would separate them into two lists - one list will have everything of a specific type, the other will have the remainder. One way I thought of doing it is: var typeXs = (from o in collectionOfThings where o.Type == "typeX" select o); var notTypeXs = (from o in collectionOfT...

Deferred loading of TreeView in .NET

This is a System.Windows.Forms.TreeView, not a WPF or Web TreeView. I must be missing something, because I can't believe this is that difficult. I've got a TreeView on my form. Loading all the data to populate the TreeView is very slow, so I want to load just the top-level nodes and then fill in the children as the user expands nodes. ...

Why does List<T>.Sort method reorder equal IComparable<T> elements?

I have a problem with how the List Sort method deals with sorting. Given the following element: class Element : IComparable<Element> { public int Priority { get; set; } public string Description { get; set; } public int CompareTo(Element other) { return Priority.CompareTo(other.Priority); } } If I try to ...

Using log4net and where to implement it and usign with elmah?

Hi there, does anyone have experience with log4net, i have been looking at elmah which is great. But i wanted a little bit more control i.e. to use logging not only in asp.net but also in wpf. Anway i decided to take a look at log4net. I have 2 clients, (wpf and asp.net) that both share business logic. Should i be raising events in ...

Qt versus WPF/.NET

My company is trying to make the decision between using Qt/C++ for our GUI framework or migrating to .NET and using WPF. We have up to this point been using MFC. It seems that .NET/WPF is technically the most advanced and feature-rich platform. I do, however, have several concerns. These include: Platform support Framework longevit...

NHibernate and Multiple Database backends - Architecture question

Hello, I have a project that is supposed to run on different (at least 2) databse backends, so users can choose (currently between MSSQL and SQLite). I've just started learning NHibernate, following the tutorial on NHForge. Now, my current Architecture looks like this: MyProject.DAL Contains NewsItem and INewsItemRepository. NewsItem...

.Net 3.5 database access

Hi everyone, I guess I'm old school, when I architect a project I still think of writing a database layer that includes use of objects like datareaders and datasets... But it seems to me that Microsoft had to come up with better tools since my last project in 2.0, something that would hide all the pipping labor and keep the developer fo...

How does NameScope in WPF works ?

I'm having a strange behavior with NameScopes in WPF, I have created a CustomControl called FadingPopup which is a child class of Window with nothing special inside. <Window.Resources> <local:FadingPopup> <Button Name="prec" Content="ahah"></Button> <Button Content="{Binding ElementName=prec, Path=Content}"></Button> <...

Looking for a tool to help me analyze and understand others' code

I am looking for a tool to help me to more quickly grasp someone else's code. Usually I am working with 10-15 method call chunks scattered across 3-5 modules (DLLs or .NET assemblies). What I am after is a tool which could be used to draw an annotated call diagram in 10-30 minutes. I think it should look like a some kind of combination...

C# Create a hash for a byte array or image

Duplicate How do I generate a hashcode from a byte array in c# In C#, I need to create a Hash of an image to ensure it is unique in storage. I can easily convert it to a byte array, but unsure how to proceed from there. Are there any classes in the .NET framework that can assist me, or is anyone aware of some efficient algori...

How to Perform Asynchronous File Reads in C# 2.0?

I have an application which needs to loop through all the lines in text files, over gigabytes in size. Some of these files have 10's or 100's of millions of lines. An example of my current (and synchronous) reading, looks something like... using (FileStream stream = new FileStream(args[0], FileMode.Open, FileAccess.Read, FileShare.R...

Transparency key and Vista

I'm trying to use transparency key. According to the documentation, you're supposed to be able to use this to put "holes" in the Application where you're supposed to be able to click through the transparent areas in the application and work (eg. "click" on things behind it). However, in Vista Ultimate 64bit , I can't. The following code ...

Which hash function should I choose?

The .NET framework ships with 6 different hashing algorithms: MD5: 16 bytes (Time to hash 500MB: 1462 ms) SHA1: 20 bytes (1644 ms) SHA256: 32 bytes (5618 ms) SHA384: 48 bytes (3839 ms) SHA512: 64 bytes (3820 ms) RIPEMD: 20 bytes (7066 ms) Each of these functions performs differently; MD5 being the fastest and RIPEMD being the slowes...

Remove whitespace from number within text in VB.NET

Hi, I have text like this format "term: 156^^^:^^59 datainput" Or "term: 156^^^:59 datainput" or "term: 156:^^^59" The "^" represented white space. Notice the white space between the the two numbers and the colon. There 2, 3, 4 or even 7 white space between the two number. I want to remove these white space so that the text can b...

PDF and Graph using C#

Hi, I am developing windows service in .net using c# language. The service have to generate report in PDF format. The report should have graph in it. I like to know how can we create PDF file and add graph in it. Thanks, P.Gopalakrishnan ...

Hosting CLR versus using ClrCreateManagedInstance - what are the benefits?

I have successfully implemented interop beftween Win32 application and managed .Net dll as described here. But I also read here that it is possible to host the entire CLR inside of the unmanaged process. So my question is: why would you do that? It is somewhat more complex than just use an object - what benefits you gain for this price ...

How to implement 'undo' operation in .net windows application?

Assume that, a win form has certain input fields and user enters/re-enters some data. How to retain data previously entered by 'undo' operation? Just I want to know the best way to accomplish it. ...

i want to pop up my own dialog(which save file on server without asking the target path location) instead of adobe's save as dialog.

Can we override the Save As dialog of Adobe Photoshop? How we can override? What will be your approach? Actually I want to pop up my own dialog (which save file on server without asking the target path location) instead of Adobe's Save As dialog. ...

Run .NET exe in linux

Is there any way to run the .NET exe (of a winform app) in Linux without building the code in linux? In fact I don't have the code for some of the utilities I developed earlier and would like to run them in linux. Related to : http://stackoverflow.com/questions/797093/feasibility-of-c-development-with-mono ...