问题列表 - 第40610页

使用Rx确定鼠标拖动结束的正确方法是什么?

我正在慢慢学习如何使用WPF的.NET Reactive Extensions.有一些初学者的例子说明编写拖放或绘图例程是多么简单,但它们都非常简单.我试图更进一步,对我而言,"正确"方式是什么并不明显.

这些例子都告诉你如何从定义事件流MouseDown,MouseMove以及MouseUp

var mouseDown = from evt in Observable.FromEvent<MouseButtonEventArgs>(..., "MouseDown")
                select evt.EventArgs.GetPosition(...);

var mouseMoves = from evt in Observable.FromEvent<MouseEventArgs>(..., "MouseMove")
                 select evt.EventArgs.GetPosition(...);

var mouseUp = Observable.FromEvent<MouseButtonEventArgs>(..., "MouseUp");
Run Code Online (Sandbox Code Playgroud)

然后如何在a期间轻松完成任务MouseDrag(这将显示从起始拖动点到当前鼠标位置创建的矩形的坐标)

var mouseDrag = from start in mouseDown
                from currentPosition in mouseMoves.TakeUntil(mouseUp)
                select new Rect(Math.Min(start.X, currentPosition.X),
                                Math.Min(start.Y, currentPosition.Y),
                                Math.Abs(start.X - currentPosition.X),
                                Math.Abs(start.Y - currentPosition.Y));

mouseDrag.Subscribe(x =>
             {
                 Info.Text = x.ToString();
             });
Run Code Online (Sandbox Code Playgroud)

我的问题是,在鼠标拖动结束时完成任务的"正确"方法是什么?最初,我以为我可以这样做:

mouseDrag.Subscribe(
     onNext: x =>
             {
                 Info.Text = x.ToString();
             },
     onCompleted: …
Run Code Online (Sandbox Code Playgroud)

c# wpf .net-4.0 system.reactive

2
推荐指数
1
解决办法
1409
查看次数

MYSQL按案例排序问题

我有这样一个数据库:

-------------------------------------------------------------------
|   id_one   |   id_two   |   timestamp_one   |   timestamp_two   |
-------------------------------------------------------------------
|     27     |     35     |        9:30       |        NULL       |
-------------------------------------------------------------------
|     35     |     27     |        NULL       |        9:35       |
-------------------------------------------------------------------
|     27     |     35     |        9:34       |        NULL       |
-------------------------------------------------------------------
|     35     |     27     |        NULL       |        9:33       |
-------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

我需要拉4行

ORDER BY 'timestamp_one' if 'id_one'=27 or 
ORDER BY 'timestamp_two' if 'id_one'=27
Run Code Online (Sandbox Code Playgroud)

这是我现在的声明:

SELECT * FROM tablename 
WHERE id_one=27 OR id_two=27 
ORDER BY 
  CASE WHEN id_one=27 THEN timestamp_one …
Run Code Online (Sandbox Code Playgroud)

mysql

19
推荐指数
2
解决办法
6万
查看次数

使用_bstr_t在函数中传递BSTR*类型的参数

这样做的正确方法是什么:

_bstr_t description;
errorInfo->GetDescription( &description.GetBSTR() );
Run Code Online (Sandbox Code Playgroud)

要么:

_bstr_t description;
errorInfo->GetDescription( description.GetAddress() );
Run Code Online (Sandbox Code Playgroud)

在哪里IError:GetDescription定义为:

HRESULT GetDescription (BSTR *pbstrDescription);
Run Code Online (Sandbox Code Playgroud)

我知道我可以轻松地做到这一点:

BSTR description= SysAllocString (L"Whateva"));
errorInfo->GetDescription (&description);
SysFreeString (description);
Run Code Online (Sandbox Code Playgroud)

谢谢

c++ bstr

9
推荐指数
2
解决办法
4624
查看次数

将数字2D数组保存到图像

最近我一直在C中进行一些数值方法编程.对于错误修复和故障排除,很好地对所发生的事情进行一些直观表示.到目前为止,我一直在将数组区域输出到标准输出,但这并没有提供太多信息.我也和gnuplot一起玩了一下,但我不能得到它只保存图像,而不是坐标系和所有其他的东西.

所以我正在寻找一个教程或者一个库来向我展示如何将数组从c保存到图像中,能够保存到彩色图像会特别好.从数值到颜色的转换不是问题,我可以计算出来.如果有人指出我在这个领域的一些有用的库的方向,那将是一件好事.

最好的祝福

c image numerical-methods

7
推荐指数
1
解决办法
3508
查看次数

为什么它跳出程序?

我刚开始学习C++.

当我执行我的代码时,它跳出程序没有任何错误.为什么?

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

  char s1[20],s2[10];
  cout<<" enter a number : ";
  cin.get(s1,19);
  cout<<" enter a number : ";
  cin.get(s2,9);

  cout<<s1<<"/n"<<s2;

  getch();

}
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
145
查看次数

任何在Eclipse中隐藏注释的方法

有谁知道是否有可能在Eclipse中隐藏java注释?有什么技巧可以尝试吗?

java eclipse

22
推荐指数
2
解决办法
2万
查看次数

Extjs treepanel:如何在叶节点上删除节点

有人知道如何启用拖放到treepanel的叶节点上吗?

我的场景与此完全相同:http://dev.sencha.com/deploy/dev/examples/tree/reorder.html 但我还需要将项目附加到叶节点.

谢谢

extjs treepanel

2
推荐指数
1
解决办法
7427
查看次数

Codeigniter未选中复选框值=空白?

我有这个数据库,我必须捕获很多是/否的问题,用户的首选方法是复选框.一切都按照应有的方式运作,除非涉及到后悔和展示价值观.未选中框返回值"0"

无论如何要么忽略并且不在报告中显示"0"或者将默认值从"0"更改为空白"

php checkbox codeigniter filter

2
推荐指数
1
解决办法
9226
查看次数

将MySQL的CURRENT_TIMESTAMP传递给Zend_DB更新语句

使用Zend_DB的更新语句时,如何传递mysql的CURRENT_TIMESTAMP?以下似乎不起作用.

我有这样的事情:

            $update = array(
                'Name'        =>  'John',
                'DT_Modified'   =>  'CURRENT_TIMESTAMP'
            );

            $db->update('usertable', $update );
Run Code Online (Sandbox Code Playgroud)

运行如下所示的查询:

UPDATE usertable SET Name='John', DT_Modified = CURRENT_TIMESTAMP

php zend-framework zend-db

2
推荐指数
1
解决办法
1799
查看次数

在JPA/hibernate中映射UUID的问题

根据文档,hibernate 3.6应该支持java.util.UUID类型.但是当我将其映射为:

@Id protected UUID uuid;
Run Code Online (Sandbox Code Playgroud)

我得到以下异常:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [test-applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:529) ~[spring-orm-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:495) ~[spring-orm-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:656) ~[spring-orm-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:629) ~[spring-orm-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:147) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:338) ~[spring-orm-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    ... …
Run Code Online (Sandbox Code Playgroud)

java uuid hibernate jpa

27
推荐指数
4
解决办法
5万
查看次数