我已经玩了地图,我用它ScrollViewer在地图上移动,我希望ViewBox一起使用它PinchManipulations来放大和缩小地图.到目前为止,我已经通过设置这样做ScrollViewer的Manipulation模式control,但是这给了我一个滞后,当我放大.有没有办法让这个ViewBox和ScrollViewer更好地一起工作,从而避免滞后?我到目前为止的代码是:
ScrollViewer中:
<ScrollViewer Grid.Column ="0" Width="768" Height="380" HorizontalScrollBarVisibility="Hidden">
<Viewbox Stretch="None">
<View:Map/>
</Viewbox>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
PinchZoom:
<Grid x:Name="Map" Width="1271" Height="1381.5">
<Grid.RenderTransform>
<ScaleTransform ScaleX="{Binding Path=deltaZoom}" ScaleY="{Binding Path=deltaZoom}"/>
</Grid.RenderTransform>
<i:Interaction.Triggers>
<i:EventTrigger EventName="ManipulationStarted">
<cmd:EventToCommand Command="{Binding Path=ZoomStartedCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="ManipulationDelta">
<cmd:EventToCommand Command="{Binding Path=ZoomDeltaCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="ManipulationCompleted">
<cmd:EventToCommand Command="{Binding Path=ZoomCompletedCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我使用捏缩放的代码:
public ICommand ZoomStartedCommand { get; set; }
public ICommand ZoomDeltaCommand { get; set; } …Run Code Online (Sandbox Code Playgroud) TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
using (MemoryStream allFrameStream = new MemoryStream())
{
foreach (BitmapFrame frame in decoder.Frames)
{
using (MemoryStream ms= new MemoryStream())
{
JpegBitmapEncoder enc = new JpegBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(frame));
enc.Save(ms);
ms.CopyTo(allFrameStream);
}
}
Document documentPDF = new Document();
PdfWriter writer = PdfWriter.GetInstance(documentPDF, allFrameStream);
}
Run Code Online (Sandbox Code Playgroud)
总是allFrameStream的Length=0.但我可以看到每次迭代ms.Length=989548.我的代码中的错误是什么.为什么ms.CopyTo(allFrameStream)不工作?
我知道使用--depth选项可以使用浅子模块git submodule update.
但是,如果我跑
git submodule update --init --recursive --depth 1
Run Code Online (Sandbox Code Playgroud)
在我的项目中有几个子模块,我得到了一个fatal: reference is not a tree.所以我再次尝试过
git submodule update --init --recursive --depth 100
Run Code Online (Sandbox Code Playgroud)
哪个工作正常,但我想保持深度为1.
在我看来,--depth 1拉出子模块中的最新提交,而不是主存储库指向的提交,这就是为什么将其设置为100解决了问题,因为它提取了更长的提交列表,包括指向的提交.
不幸的是,如果是这种情况,那么我通常不能确定最新的100次提交包括我需要的提交.
我如何告诉git使用尖头提交而不是使用子模块的浅层克隆中的最新提交?
我在Windows上使用git 1.9.4.
在 Visual Studio 中使用单元测试时,可以编译对测试进行分组的播放列表。例如,当开发一个新功能时,我们只想运行相关测试而不是所有现有测试,这很有用。
然而,在我看来,播放列表只能通过显式添加/删除单元测试来“手动”维护。
这总比没有好,但如果我能根据某些标准(例如功能、测试持续时间等)“标记”我的单元测试并动态生成播放列表,那就太好了。
有没有办法使用默认测试框架在 Visual Studio 中执行类似的操作?
我刚刚在2014年构建大会上看到了Herb Sutter的一个非常有趣的演讲,名为“现代C ++:您需要知道的内容”。这是演讲视频的链接:http : //channel9.msdn.com/Events/Build/2014/2-661
演讲的主题之一是关于如何std::vector非常友好地缓存的,主要是因为它确保其元素在堆中相邻,这对空间局部性有很大的影响,或者至少这是我认为的。即使插入和删除项目也是如此。巧妙地使用std::vector可以通过利用缓存来显着提高性能。
我想尝试使用C#/。Net之类的方法,但是如何确保集合中的对象在内存中都相邻?
任何其他指向C#和.Net上的缓存友好性资源的指针也将受到赞赏。:)
的文件系统技术规范(TS)最近被合并到C++ 17标准.
同样的TS也适用于C++ 14,但在这种情况下,它在技术上只是"实验性的".然而,它被批准用于C++ 17的事实使我认为它足够成熟并且可以安全地使用它.
对将最有可能在未来升级到C++ 17 C++ 14项目时,并假设我用编译器支持这两个版本,你会建议不要使用"实验" TS,考虑到它会正式成为下一个标准的一部分?
我的问题当然延伸到未来C++版本中已被接受且可用于早期标准的任何TS.
我很难理解如何将文件传递给函数.
我有一个20个名字和20个测试分数的文件,需要由一个函数读取.然后,该函数将名称和分数分配给名为student的结构.
我的问题是如何使用适当的参数编写函数调用.?使我的函数读取文件中的数据.谢谢.
码
// ask user for student file
cout << "Enter the name of the file for the student data to be read for input" << endl;
cout << " (Note: The file and path cannot contain spaces)" << endl;
cout << endl;
cin >> inFileName;
inFile.open(inFileName);
cout << endl;
// FUNCTION CALL how do i set this up properly?
ReadStudentData(inFile, student, numStudents );
void ReadStudentData(ifstream& infile, StudentType student[], int& numStudents)
{
int index = 0;
string lastName, …Run Code Online (Sandbox Code Playgroud) 我有一个自定义控件NumericUpDowns,该控件通过处理MouseMove事件用当前鼠标坐标更新两个。
但是,我遇到了一个奇怪的情况,MouseMove即使不应该发生也触发了事件(我已经关闭了无线鼠标并禁用了触控板)。因此,MouseMove即使鼠标不移动,也会发生这种情况。
我进行了简单的检查,并验证了在这些“重影” MouseMove事件之间鼠标指针的位置没有改变。我利用了这一点,以确保仅在指针实际移动时才调用处理事件的方法,因此我能够满足我的应用程序的要求。
但是,我仍然感到困惑,因为我不了解在禁用所有鼠标/触控板后,什么会触发MouseMove事件。查看Visual Studio中的调用堆栈,在我看来,MouseMove事件的触发是“真正的”,就好像鼠标确实在移动,而不是好像它是由应用程序的其他部分触发的(例如,模拟MouseMove) 。
关于这可能是什么原因的任何建议?谢谢!
编辑:根据King King的建议,我修改了代码以在每次MouseMove检测到该消息时打印一个字符串。我注意到,当鼠标关闭并且指针悬停在控件上时,在我按Alt-Tab键在应用程序之间切换时会打印字符串。也许这与正在重绘的应用程序有关?
在 Visual Studio 2013 中调试时,我想知道PropertyChanged实现Publisher.INotifyPropertyChanged
我研究了一下,发现这应该可以调用GetInvocationList()和计算返回数组中的元素。因此,我在代码中设置了一个断点,并尝试在“立即”窗口中的一个名为publisherof 类的对象上调用此断点:Publisher
publisher.PropertyChanged.GetInvocationList()
Run Code Online (Sandbox Code Playgroud)
但是,我收到此错误消息:
The event 'System.ComponentModel.INotifyPropertyChanged.PropertyChanged' can only appear on the left hand side of += or -=
Run Code Online (Sandbox Code Playgroud)
我所做的有什么问题吗?我怎样才能访问订阅者PropertyChanged?
我仍然在用C#找到我的脚,并且有一个快速的问题一直困扰着我.
假设我写了一个类并定义了一个属性如下: -
public class Employee
{
string FirstName {get; set;}
}
class Program
{
private static object GetTheEmployee()
{
return new Employee{ FirstName = "Joe" }
}
}
Run Code Online (Sandbox Code Playgroud)
为什么在GetTheEmployee方法中使用FirstName是不可访问的,但是当我将Employee类中的FirstName'string'变量改为'public string'时,可以从Program类访问它.
我原以为如果我将类的访问修饰符声明为public,那么类中的所有变量默认都是公共的?
c# ×7
c++ ×3
.net ×2
events ×2
c#-4.0 ×1
caching ×1
git ×1
io ×1
list ×1
mouseevent ×1
mousemove ×1
playlist ×1
scrollviewer ×1
unit-testing ×1
vector ×1
visual-c++ ×1
winforms ×1
zoom ×1