How to ease the transition from WinForms to WPF

I'm working on a large Winforms application dealing with large amounts of data exposed through grids. I see us eventually moving completely to an MV-VM & WPF implementation but now we're still closer to a ball-of-mud than anything resembling loose coupling. As we evolve toward cleaner separation of concerns, what are some specific patterns we can implement while still in the WinFor

如何简化从WinForms到WPF的转换

我正在处理大型Winforms应用程序,处理大量通过网格公开的数据。 我看到我们最终完全转向了MV-VM和WPF的实现,但现在我们更接近于泥巴球而不是类似松散耦合的任何东西。 随着我们逐渐走向更清晰的关注点分离,我们可以在仍然处于WinForms世界的情况下实现哪些特定模式,但是一旦我们采用WPF下挫,会产生更平滑的过渡? 具体来说,是否有任何关于如何以近似WPF / MVVM的方式利用WinForms有限绑定和事件处理的指导? 建议您

Detect when a USB device is connected in C

I am new to C and am trying to write a program that syncs files on my computer to a USB device. It currently works my me cd'ing to the directory that the device mounts to and typing "myprog init" which creates a .myprog file. The idea then is that when a USB device is connected my program checks for the .myprog file, if it finds it then it syncs. Problem is that I can't figur

检测USB设备连接到C时

我是C新手,正在尝试编写一个程序,将我的计算机上的文件同步到USB设备。 它目前正在运行我的CD到设备加载到的目录并键入创建.myprog文件的“myprog init”。 然后这个想法是,当连接USB设备时,我的程序检查.myprog文件,如果它找到它然后它同步。 问题是,我无法弄清楚如何检测新的USB设备何时连接。 我正在编写用于Linux的程序(我正在使用Ubuntu 9.04)并使用GCC。 谢谢你的帮助 :) 查看udev文档(编写udev规则)。

How do ADO.NET DataTable Constraints affect performance?

Do constraints on a DataTable (eg PrimaryKey & UniqueContraint) make Selects more efficient in the same way that they would in SQL Server? Or is their only purpose to enforce rules on the data? myDT.Constraints.Add("PK", myDT.Columns["UniqueID"], true); //add a primary key myDT.Constrinats.Add(new UniqueConstraint(new DataColumn[] { //add a unique constraint for UserID myDT.Columns["Use

ADO.NET DataTable约束如何影响性能?

对DataTable(例如PrimaryKey和UniqueContraint)的约束是否使选择效率更高,方式与SQL Server中的方式相同? 或者是他们对数据执行规则的唯一目的? myDT.Constraints.Add("PK", myDT.Columns["UniqueID"], true); //add a primary key myDT.Constrinats.Add(new UniqueConstraint(new DataColumn[] { //add a unique constraint for UserID myDT.Columns["UserID"], myDT.Columns["UniqueID"] })); 在通过UniqueID或Us

Implementing OpenID: identifying users

Company I work for wants to publish an internal website to the outside world, but also wants to identify the visitors in some easy way. Some functionality will be visible for all visitors but most must be visible for authenticated visitors. (And some functionality is restricted to admin-visitors.) While management is considering to implement our own authentication system, I've suggested to

实施OpenID:识别用户

我公司的工作是希望向外部世界发布一个内部网站,但也想通过一些简单的方式来识别访问者。 某些功能对所有访问者都是可见的,但大多数必须对经过验证的访问者可见。 (一些功能仅限于管理访问者。)虽然管理层正在考虑实施我们自己的身份验证系统,但我建议只使用现有的已有技术,并使用户名/密码的管理远离我们。 (因为当我们谈论安全性时,我们只是业余爱好者,认证需要很好。) 所以我开始使用Google的OpenID并检查他们

Is "else if" faster than "switch() case"?

Possible Duplicate: Is there any significant difference between using if/else and switch-case in C#? I'm an ex Pascal guy, currently learning C#. My question is the following: Is the code below faster than making a switch? int a = 5; if (a == 1) { .... } else if(a == 2) { .... } else if(a == 3) { .... } else if(a == 4) { .... } else .... And the switch: int a =

“else if”比“switch()case”更快吗?

可能重复: 在C#中使用if / else和switch-case之间有什么显着差异? 我是一名前Pascal家伙,目前正在学习C#。 我的问题如下: 下面的代码比开关更快吗? int a = 5; if (a == 1) { .... } else if(a == 2) { .... } else if(a == 3) { .... } else if(a == 4) { .... } else .... 而开关: int a = 5; switch(a) { case 1: ... break; case 2: ... b

Inheriting from a generic contract in WCF

More WCF woes... :) All my workflows implement the same 3 methods. After a lot of copy and paste, I decided to make them inherit from the same interface: [ServiceContract(Namespace = "http://schema.company.com/messages/")] public interface IBasicContract<TRequest, TResponse> where TRequest : class where TResponse : class { [OperationContract(Name = "GetReport", Action = "http:

从WCF中的通用契约继承

更多WCF的困扰...... :) 我所有的工作流程都实现了相同的3种方法。 经过大量的复制和粘贴之后,我决定让它们从相同的接口继承: [ServiceContract(Namespace = "http://schema.company.com/messages/")] public interface IBasicContract<TRequest, TResponse> where TRequest : class where TResponse : class { [OperationContract(Name = "GetReport", Action = "http://schema.company.com/messages/GetR

Reference generic comment

I was wondering if it is possible to reference a dynamic generic class name in a comment and have it conditionally resolved in the IDE? Simple base class example: // <summary> // Retrieves all <T> members from the database. // </summary> public void GetAll<T>() { //magic } If I now inherit from this class and happens to be class User then I'd like to have IntelliS

参考通用评论

我想知道是否可以在注释中引用动态泛型类名并在IDE中有条件地解决它? 简单的基类示例: // <summary> // Retrieves all <T> members from the database. // </summary> public void GetAll<T>() { //magic } 如果我现在继承这个类,并且恰好是类用户,那么我想让IntelliSense将我的评论显示为“从数据库中检索所有用户成员”。 这可能吗? 无法让Intellisense自动编写用于特定呼叫的通用类型的

Filtering the files shown in OpenFileDialog based on content?

Is there a way to modify the behavior of the OpenFileDialog so that it looks inside the files in the folder it opens to and then ignores certain ones based on their content? One example would be to open to a folder full of Zip files but only show the ones that contain a certain file. From the documentation, there's the HookProc but I'm not exactly sure how I'd use it. Please not

基于内容过滤OpenFileDialog中显示的文件?

有没有办法修改OpenFileDialog的行为,以便它查看打开到的文件夹中的文件,然后根据其内容忽略某些文件中的文件? 一个例子是打开一个完整的Zip文件的文件夹,但只显示包含某个文件的文件夹。 从文档中,有HookProc,但我不确定如何使用它。 请注意,如果可能的话,我意识到这将是一个相对缓慢的操作。 目前我不关心性能。 谢谢! 我不会忽视OpenFileDialog的复杂性。 构建一个真正有效的程序并不容易。 当你建立你

How to save HTML in XML file using Linq to XML?

I am trying to use Linq to XML to save & retrieve some HTML between an XML file and a windows forms application. When it saves it to the XML file the HTML tags get xml encoded and it isn't saved as straight HTML. Example HTML: <P><FONT color=#004080><U>Sample HTML</U></FONT></P> Saved in XML File: &lt;P&gt;&lt;FONT color=#004080&gt

如何使用Linq to XML将XML保存在XML文件中?

我正在尝试使用Linq到XML来保存和检索XML文件和Windows窗体应用程序之间的一些HTML。 当它将其保存到XML文件时,HTML标记将被xml编码,并且不会保存为直接的HTML。 HTML示例: <P><FONT color=#004080><U>Sample HTML</U></FONT></P> 保存在XML文件中: &lt;P&gt;&lt;FONT color=#004080&gt;&lt;U&gt;Sample HTML&lt;/U&gt;&lt;/FONT&gt;&

Custom config elements collection in Web.config

Intro I'm developing a WebApp built on C# ASP.NET. I've been researching creating a "Custom Configuration" section with child elements in the Web.config file, and I've hit a bit of a snag when it comes to consuming the keys/values in the data. I seem to be going round in circles and I don't know how to tackle the issue I'm having. Situation I have a few dif

Web.config中的自定义配置元素集合

介绍 我正在开发一个基于C#ASP.NET的Web应用程序。 我一直在研究用Web.config文件中的子元素创建一个“自定义配置”部分,并且当涉及到消费数据中的键/值时,我遇到了一些障碍。 我似乎围绕着圈子,而且我不知道如何解决我遇到的问题。 情况 我在<connectionStrings>部分的Web.Config文件中定义了几个不同的连接字符串。 它们用于开发,测试和实时数据库。 <connectionStrings> <add name="connect