.net-4.0

Why I can't detect touch screen?

血红的双手。 提交于 2019-12-14 02:21:08
问题 I'm using this C#(wpf) code to detect touch screen on return Tablet.TabletDevices.OfType<TabletDevice>().Any(dev => dev.Type == TabletDeviceType.Touch) But it is not working. Tablet.TabletDevices Count is always 0. I'm using extension touch monitor(use USB connect PC for touch detect) Is there any better way to check if current PC has touch screen or not? Thanks. Update1: I don't know why but even when I remove the touch screen USB and monitor, GetSystemMetrics(SM_MAXIMUMTOUCHES) still

Disable Keyboard globally for a WPF Window

若如初见. 提交于 2019-12-13 21:44:50
问题 I need to disable Keyboard Input for all UI elements except one or 2 exceptions. Thing is, I need the arrow keys for controlling so I added a KeyEventHandler on the MainWindow level and added another for UI Elements like Tab Items, Textbox so that they ignore the Input when they got the focus. I ended up with a pretty buggie control. I still can browse e.g. thru tab items, the control event sometimes doesn't fire. I need a more reliable way to do this.. Any suggestions are appreciated! 回答1:

Console app that opens a new window for each thread started by background worker

白昼怎懂夜的黑 提交于 2019-12-13 21:22:42
问题 I have a console application that starts multiple different threads. The main console app will poll a service and based on responses it will spawn one or more background threads using the BackgroundWorker class. At the moment each of these threads do a console.writeline to the sole default console window opened as it normally does for a console application. This makes it too confusing to follow the progress of any one thread. I want to be able to spawn a separate window with each of them

Entity Framework 4 with POCO entities in different assemblies with associations that span assemblies

断了今生、忘了曾经 提交于 2019-12-13 19:49:05
问题 Is it possible to have such a scenario? Entity Framework 4 POCO entities in different assemblies with associations between them (that span multiple assemblies) ? 回答1: As I see it now, without making something that loads entities from the other assemblies in that unit of work, the scenario is not possible. 来源: https://stackoverflow.com/questions/4783716/entity-framework-4-with-poco-entities-in-different-assemblies-with-associations

What is the correct way to update the UI in WPF from a thread dispatched from Task Factory?

大憨熊 提交于 2019-12-13 18:45:58
问题 I am trying to update the UI from one of my thread dispatched via Task.Factory . I have having hard time properly updating my UI. Here is the behavior I am observing: Task.Factory.StartNew(() => { // UI does get updated from here. }).ContinueWith(task => { // UI does *not* get updated from here. }); What is the proper way to update the UI within a thread dispatched with Task Factory ? Here is my actual code for your reference: private string CurrentProcess { set { _eventAggregator.GetEvent

Why does System.Numerics.BigInteger not have a Parse method in Silverlight 4.0, but does in .Net 4.0?

半世苍凉 提交于 2019-12-13 17:31:50
问题 I've come across a weird discrepancy between BigInteger s used by .Net 4.0 and Silverlight 4.0; In .Net, BigInteger has a Parse and TryParse method where as in the Silverlight version, it does not have either of these. If you look at the .Net version of System.Numerics in Reflector, you also see that when you disassemble the code, every single method is just empty, and it lacks the BigIntergerBuilder and friends of the Silverlight version: public static BigInteger Parse(string value) { } What

Passing a Command to a Comm Port Using C#'s SerialPort Class

余生颓废 提交于 2019-12-13 16:57:15
问题 I'm currently trying to pass a specific command from an example test application written in VB6. In VB6 the command looks like: Comm1.Output = "UUT_SEND ""REMS\n"" " + Chr(10) Currently I'm trying to figure out how to pass that same data via C#'s SerialPort class. 回答1: sending stuff out the serialport is relatively straight forward.... var serialPort = new SerialPort("COM1", 9600); serialPort.Write("UUT_SEND \"REMS\\n\" \n"); To get any responses you will have to hook the DataReceived event.

Dropdownlist Datasource and adding extra item from C#

喜你入骨 提交于 2019-12-13 14:41:22
问题 I have a DropDownList that is associated with a DataSource in the aspx page. I need to add one more item when the page is loaded. My Code: <asp:LabelDropDownList ID="ddlVisualTemplate" runat="server" LabelText="Visual Template:" DataSourceID="VisualTemplateDataSource" DataTextField="Name" DataValueField="Id" AutoPostBack="true" OnSelectedIndexChanged="ddlVisualTemplate_SelectedIndexChanged"/> <asp:EntityDataSource ID="VisualTemplateDataSource" runat="server" ConnectionString="name=Entities"

How to use the read/writeable local XML settings?

青春壹個敷衍的年華 提交于 2019-12-13 14:05:24
问题 I found something similar to what I need here: http://www.codeproject.com/KB/cs/PropertiesSettings.aspx But it does not quite do it for me. The user settings are stored in some far away location such as C:\documents and settings\[username]\local settings\application data\[your application] , but I do not have access to these folders and I cannot copy the settings file from one computer to another, or to delete the file altogether. Also, it would be super-convenient to have the settings xml

Using ToList() on Enumerable LINQ query results for large data sets - Efficiency Issue?

情到浓时终转凉″ 提交于 2019-12-13 12:27:53
问题 I've been making a lot of use of LINQ queries in the application I'm currently writing, and one of the situations that I keep running into is having to convert the LINQ query results into lists for further processing (I have my reasons for wanting lists). I'd like to have a better understanding of what happens in this list conversion in case there are inefficiencies since I've used it repeatedly now. So, given I execute a line line like this: var matches = (from x in list1 join y in list2 on