.net-3.0

blurred opacity

蓝咒 提交于 2019-11-29 01:14:03
问题 I need to create a transparent blurred background. Lets suppose I have a border with a white blurry transparent background. Everything that is behind the border is blurred. I'm trying to avoid dependencies; I'm currently using .NET 3.0, and want it to run with XP too. Mockup image: 回答1: A VisualBrush can be used to get close to what you want, but has some limitations. As long as you only need the glass effect within the window (and not be an effect over other windows) and that the placement

How do I write an XML string to a file?

北城余情 提交于 2019-11-28 09:41:05
I have a string and its value is: <ROOT> qwerty <SampleElement>adsf</SampleElement> <SampleElement2>The text of the sample element2</SampleElement2> </ROOT> How can I write this string to a file using C# 3.0? Thanks in advance. Try this: string s = "<xml><foo></foo></xml>"; XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(s); xdoc.Save("myfilename.xml"); Has the added benefit that the load will fail if your XML is invalid. File.WriteAllText("myFile.xml",myString); You'll have to use CDATA section . More specifically, create a XmlCDataSection using XmlDocument.CreateCDataSection and supply

C#: Downloading a URL with timeout

放肆的年华 提交于 2019-11-28 04:36:07
What's the best way to do it in .NET? I always forget what I need to Dispose() (or wrap with using ). EDIT: after a long time using WebRequest , I found out about customizing WebClient . Much better. Syncronous Way: var request = HttpWebRequest.Create("http://www.contoso.com"); request.Timeout = 50000; using (var response = request.GetResponse()) { //your code here } You can also have the asynchronous way: using System; using System.Net; using System.IO; using System.Text; using System.Threading; public class RequestState { // This class stores the State of the request. const int BUFFER_SIZE =

When creating a new GUI, is WPF the preferred choice over Windows Forms? [closed]

↘锁芯ラ 提交于 2019-11-27 16:33:33
Most restrictions and tricks with windows forms are common to most programmers. But since .NET 3.0 there is also WPF available, the Windows Presentation Foundation. It is said that you can make "sexy applications" more easy with it and with .NET 3.5 SP1 it got a good speed boost on execution. But on the other side a lot of things are working different with WPF. I will not say it is more difficult but you have to learn "everything" from scratch. My question: Is it worth to spend this extra time when you have to create a new GUI and there is no time pressure for the project? WPF enables you to

When creating a new GUI, is WPF the preferred choice over Windows Forms? [closed]

元气小坏坏 提交于 2019-11-27 04:09:07
问题 Most restrictions and tricks with windows forms are common to most programmers. But since .NET 3.0 there is also WPF available, the Windows Presentation Foundation. It is said that you can make "sexy applications" more easy with it and with .NET 3.5 SP1 it got a good speed boost on execution. But on the other side a lot of things are working different with WPF. I will not say it is more difficult but you have to learn "everything" from scratch. My question: Is it worth to spend this extra

How do I write an XML string to a file?

走远了吗. 提交于 2019-11-27 03:05:19
问题 I have a string and its value is: <ROOT> qwerty <SampleElement>adsf</SampleElement> <SampleElement2>The text of the sample element2</SampleElement2> </ROOT> How can I write this string to a file using C# 3.0? Thanks in advance. 回答1: Try this: string s = "<xml><foo></foo></xml>"; XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(s); xdoc.Save("myfilename.xml"); Has the added benefit that the load will fail if your XML is invalid. 回答2: File.WriteAllText("myFile.xml",myString); 回答3: You'll have

C#: Downloading a URL with timeout

懵懂的女人 提交于 2019-11-27 00:32:10
问题 What's the best way to do it in .NET? I always forget what I need to Dispose() (or wrap with using ). EDIT: after a long time using WebRequest , I found out about customizing WebClient . Much better. 回答1: Syncronous Way: var request = HttpWebRequest.Create("http://www.contoso.com"); request.Timeout = 50000; using (var response = request.GetResponse()) { //your code here } You can also have the asynchronous way: using System; using System.Net; using System.IO; using System.Text; using System

What's the difference between IQueryable and IEnumerable

女生的网名这么多〃 提交于 2019-11-26 16:57:26
I'm confused as to the difference. Being fairly new to .Net, I know I can query IEnumerables using the Linq extensions. So what is this IQueryable and how does it differ? See also What is the difference between IQueryable[T] and IEnumerable[T]? that overlaps with this question. Richard Szalay IEnumerable<T> represents a forward-only cursor of T . .NET 3.5 added extension methods that included the LINQ standard query operators like Where and First , with any operators that require predicates or anonymous functions taking Func<T> . IQueryable<T> implements the same LINQ standard query operators,

When creating a new GUI, is WPF the preferred choice over Windows Forms? [closed]

余生长醉 提交于 2019-11-26 15:31:51
Most restrictions and tricks with windows forms are common to most programmers. But since .NET 3.0 there is also WPF available, the Windows Presentation Foundation. It is said that you can make "sexy applications" more easy with it and with .NET 3.5 SP1 it got a good speed boost on execution. But on the other side a lot of things are working different with WPF. I will not say it is more difficult but you have to learn "everything" from scratch. My question: Is it worth to spend this extra time when you have to create a new GUI and there is no time pressure for the project? WPF enables you to

Can I use extension methods and LINQ in .NET 2.0 or 3.0?

家住魔仙堡 提交于 2019-11-26 09:56:27
问题 When I try to add an extension method using the .NET 2.0 or 3.0 runtime, I get the error: Cannot define a new extension method because the compiler required type \'System.Runtime.CompilerServices.ExtensionAttribute\' cannot be found. Are you missing a reference to System.Core.dll? But I can\'t find System.Core in the list of available references when I try to add it to the project. What do I need to do to be able to use extension methods and in turn LINQ on in my projects? 回答1: Extension