我有一个问题..如果我有这样的事情就可以了:
try
{
lock(programLock)
{
//some stuff 1
}
}
catch(Exception ex) { //stuff 2 }
Run Code Online (Sandbox Code Playgroud)
我很好奇如果"some stuff 1"导致异常,programLock仍然保持锁定状态?
每次我写出一个其Value内存属性值不可内联的setter时,我都会诅咒API没有标记Setter该类的事实[ContentProperty("Value")],这将允许:
<Setter Property="BitmapEffect">
<Setter.Value>
<OuterGlowBitmapEffect GlowColor="#AAC" Opacity="0.2" GlowSize="1.25" />
</Setter.Value>
</Setter>
Run Code Online (Sandbox Code Playgroud)
......简化为:
<Setter Property="BitmapEffect">
<OuterGlowBitmapEffect GlowColor="#AAC" Opacity="0.2" GlowSize="1.25" />
</Setter>
Run Code Online (Sandbox Code Playgroud)
所以我的问题有点双重.首先,有没有一个很好的理由没有以这种方式配置API?其次,XamlReader即使我不控制WPF API ,有什么能阻止我以某种方式提供这些元数据吗?
我是Window Phone Apps Development的新手.所以我只是想添加启动画面当应用程序启动而不使用任何额外的页面导航用于启动画面.
我只想在我的picturebox.image上做一个选择,但这比一些有点烦人的情况变得更糟.我想到了主要图片框上的另一个图片框,但它对我来说似乎很懒散.我需要知道是否有一种方法可以在picturebox.image上创建一个选择区域(它将是半透明的蓝色区域),我将用鼠标绘制它并且它不应该改变我正在处理的图像.
样品:
// Start Rectangle
//
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
// Determine the initial rectangle coordinates...
RectStartPoint = e.Location;
Invalidate();
}
// Draw Rectangle
//
private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
Point tempEndPoint = e.Location;
Rect =
new Rectangle(
Math.Min(RectStartPoint.X, tempEndPoint.X),
Math.Min(RectStartPoint.Y, tempEndPoint.Y),
Math.Abs(RectStartPoint.X - tempEndPoint.X),
Math.Abs(RectStartPoint.Y - tempEndPoint.Y));
Invalidate(Rect);
}
// Draw Area
//
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
// Draw the rectangle...
if (pictureBox1.Image != null)
{ …Run Code Online (Sandbox Code Playgroud) 我有一个复杂的LINQ to SQL查询,它连接到两个表 - 一个很简单,工作正常,但一个相当复杂,我得到了 The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'GroupJoin
这是一个相当长的查询,我在一个有Internet访问的工作上进行开发,所以我想我会看看这个问题似乎是足够的:
join consignments in dc.Consignments
.FirstOrDefault(x => x.TripDate > dateFrom
&& x.TripDate < dateTo
&& x.DeliveryDepot == depot.Letter
&& (x.DeliveryStatus == 2 || x.DeliveryStatus == 3))
on new { Reg = s.VehicleReg, Depot = s.VehicleDepot }
equals new { Reg = consignments.VehicleReg, Depot = consignments.DeliveryDepot }
into con
Run Code Online (Sandbox Code Playgroud)
我已经确保数据类型是相同的,但它仍然无法正常工作.有任何想法吗?
如果我有这样的事情:
private readonly object objectLock = new object();
public void MethodA()
{
lock(objectLock)
{
//do something
}
}
public void MethodB()
{
lock(objectLock)
{
//do something
}
}
Run Code Online (Sandbox Code Playgroud)
如果我有2个线程并且两个都同时进入,则第一个线程调用MethodA和第二个方法B.无论哪个首先到达并锁定objectLock,我假设另一个线程在那里等待,直到objectLock不再被锁定.
在我的项目中,我想在自定义控件的一侧显示一个小徽标.由于我没有画布,我认为可能是一个将背景中的徽标放置在视觉画笔上的好主意.
<VisualBrush>
<VisualBrush.Visual>
<Rectangle Width="200" Height="200" Fill="Red" />
</VisualBrush.Visual>
</VisualBrush>
Run Code Online (Sandbox Code Playgroud)
但我现在使用的矩形不是200x200.它需要完整的可用空间.那不是我想要的.我也试过一个Viewbox并设置了stretch属性,但结果是一样的,因为最后我不需要一个简单的Rectangle,而是一个带有很多路径对象作为子项的画布.Viewbox仅支持一个孩子.
有什么方法可以解决这个问题?
我有这个字符串临时,我想,以取代\\与\
string temp = "\\h\\k";
Run Code Online (Sandbox Code Playgroud)
我已经尝试过,temp.Replace("\\", "\")但输出是hk
我想要的输出\h\k
如何更换"\\"使用"\"?
谢谢
我正在使用OpenCover来确定简单C#项目的代码覆盖率.
虽然我可以看到MSTest运行单元测试(并且成功),但生成的报告是空的.
这是我使用的命令:
opencover.console.exe -register -arch:32
-target:"%VSINSTALLDIR%\Common7\IDE\mstest.exe"
-targetargs:"/testcontainer:calculatortest.dll"
-filter:+[calculator.dll]* -output:coverage.xml
Run Code Online (Sandbox Code Playgroud)
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading calculatortest.dll...
Starting execution...
Results Top Level Tests
------- ---------------
Passed CalculatorTest.StatisticsTest.AddOccurrenceTest
Passed CalculatorTest.StatisticsTest.AvgTest
2/2 test(s) Passed
Summary
-------
Test Run Completed.
Passed 2
---------
Total 2
Results file: e:\Users\erno\Documents\Visual Studio 2010\Projects\CodeStatistics\CalculatorTest\bin\Debug\TestResults\erno_ERNO01 2011-07-01 14_27_06.trx
Test Settings: Default Test Settings
Visited Classes 0 of 0 (NaN)
Visited Methods 0 of …Run Code Online (Sandbox Code Playgroud) MSDN说"获取或设置一个可用于存储有关此元素的自定义信息的任意对象值." 这意味着我可以在这个属性中存储我想要的任何东西.
但是如果你绑定到这个属性(类型为String的属性,其值为"XYZ")并在触发条件下使用它,它就不起作用!
<Trigger Property="Tag" Value="XYZ">
<Setter Property="Background" Value="Red" />
</Trigger>
Run Code Online (Sandbox Code Playgroud)
它不会将背景设置为红色.您可以尝试将myElement假设为TextBlock!为什么会这样?