我是WPF的新手.我有这个问题.我绑定列表项做listBox.我在列表框上有自己的风格.ListBox项包含Image和textBlocks.它运作良好.鼠标悬停在此项目上时,我需要对listBox项目进行缩放.我尝试使用触发器,但我不知道如何调整listBox项目的大小.
C#代码:
namespace ListBoxStyle
{
public partial class MainWindow : Window
{
public class User {
public String Id { get; set; }
public Boolean IsFriend { get; set; }
public Uri ImageUri { get; set; }
public User(String azetId, Boolean isFriend, string imageUri)
{
Id = azetId;
IsFriend = isFriend;
ImageUri = new Uri(imageUri);
}
public override string ToString()
{
return Id;
}
}
public static class Users
{
public static IEnumerable<User> GetUsers()
{
var users = new List<User> …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现扩展类P的类C的__ mul __方法.类P具有__ mul __的实现,但这仅适用于该类型的元素(P()*P()).
所以在C __ mul __中我希望在参数为float时为float实现简单乘法.当它不是我想要使用P的__ mul __ ..但这导致问题,如在P的__ mul __那是"返回P(某事)"..
因此,基本上它们最初是C型的事实在一些操作之后就会丢失.
以下代码更好地解释了该问题.
任何想法解决这个?
class MyFloat(object):
def __init__(self, a):
self.a = a
def __mul__(self, other):
return MyFloat(self.a * other.a)
def __repr__(self):
return str(self.a)
class MyFloatExt(MyFloat):
def __init__(self, a):
MyFloat.__init__(self, a)
def __add__(self, other):
return MyFloatExt(self.a + other.a)
def __mul__(self, other):
if type(other) == (int, long, float):
return MyFloatExt(self.a * other)
else:
return MyFloat.__mul__(self, other)
a = MyFloatExt(0.5)
b = MyFloatExt(1.5)
c = a + b
print c … 亲爱的女士们和先生们.在逐步完成MS .NET代码时,我偶然发现了这篇文章:
try { } finally
{
// Called in a finally because it needs to run uninterrupted in order to maintain consistency.
queued = IOThreadScheduler.current.ScheduleCallbackHelper(callback, state);
}
Run Code Online (Sandbox Code Playgroud)
有趣的伎俩.任何人都可以捐出一个解释吗?谢谢.
我尝试运行以下内容:
select *
from tax.tax_payer@reis tp
left outer join re_right@reis r on (tp.tin = r.tin or tp.tin = r.tin_a1 or tp.tin = r.tin_a2)
where (r.right_status = -1 or r.right_status is null)
--and r.right_id is not null
and tp.je_id = 12;
Run Code Online (Sandbox Code Playgroud)
但继续得到
ORA-00933:SQL命令未正确结束.
如果我删除评论它工作正常,但为什么?
我有一个简单的脚本,基本上做了很多db操作.现在我需要升级数据库,我需要在同一个事务中包含一个函数创建.
BEGIN TRY --Start the Try Block..
BEGIN TRANSACTION -- Start the transaction..
-- HERE I need to add one function like
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FuctionTest]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[FuctionTest]
GO
CREATE FUNCTION FuctionTest
(
@inputVal int
)
RETURNS int
AS
BEGIN
RETURN (Select Id from [dbo].[test] where Id=@inputVal)
END
UPDATE MyChecking SET Amount = Amount - @Amount
WHERE AccountNum = @AccountNum
UPDATE MySavings SET Amount = …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 JDialog 上制作 JButton,但是该按钮将覆盖整个 JDialog,对此有什么帮助吗?它看起来是这样的:

这就是我创建 JDialog 和 JButton 的方法:
class MenuStoreHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = (int) dim.getWidth();
int screenHeight = (int) dim.getHeight();
JDialog g = new JDialog();
g.setTitle("The Store");
g.setSize(200, 200);
g.setLocation(screenWidth / 2 - 150, screenHeight / 2 - 150);
JButton b = new JButton("Buy");
b.addActionListener( new StoreItem1Handler() );
b.setVisible(true);
g.add(b);
g.setVisible(true);
}
}
Run Code Online (Sandbox Code Playgroud)
我将发布完整的 MrStan.class,如下:
package Progress;
public class MrStan extends JPanel{
private Timer timer = new Timer(); …Run Code Online (Sandbox Code Playgroud) 我尝试用Java以编程方式发送POST请求并获得以下异常:
"org.apache.http.client.HttpResponseException:Forbidden"
但是,如果我使用此表单在浏览器中发送请求:
<form method=post action="http://gametest.phpnet.us">
<p>Type : <input type=text name=request_type>
<p>Name : <input type=text name=user_name>
<p>Password : <input type=text name=user_password>
<p><input type=submit name=send value=Send>
</form>
Run Code Online (Sandbox Code Playgroud)
一切正常(尝试使用任何名称和密码,类型必须"注册",服务器必须返回xml" <code>0</code>").
这是java代码的示例:
HttpParams defHttpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(defHttpParams, 5000);
HttpConnectionParams.setSoTimeout(defHttpParams, 5000);
String mServerUrl = "http://gametest.phpnet.us/index.php";
DefaultHttpClient mClient = new DefaultHttpClient(defHttpParams);
HttpPost postMethod = new HttpPost(mServerUrl);
postMethod.setEntity(new UrlEncodedFormEntity( [...some nameValuePairs] ));
try {
ResponseHandler<String> httpResponceHandler = new BasicResponseHandler();
responce = mClient.execute(postMethod, httpResponceHandler);
}
catch (Throwable t) {
//...
}
Run Code Online (Sandbox Code Playgroud)
(如果我使用本地apache服务器,那么一切正常,但在phpnet.us上我得到例外.)
我该怎么做才能使Java代码工作?
我试图研究我所遇到的简单问题但却做不到.我试图从Web获取XML格式的数据并使用perl解析它.现在,我知道如何循环重复元素.但是,当它不重复时我会被困住(我知道这可能是愚蠢的).如果元素重复,我把它放在数组中并获取数据.但是,当只有一个元素抛出时,错误说"不是数组引用".我希望我的代码可以在两个时间解析(对于单个和多个元素).我使用的代码如下:
use LWP::Simple;
use XML::Simple;
use Data::Dumper;
open (FH, ">:utf8","xmlparsed1.txt");
my $db1 = "pubmed";
my $query = "13054692";
my $q = 16354118; #for multiple MeSH terms
my $xml = new XML::Simple;
$urlxml = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=$db1&id=$query&retmode=xml&rettype=abstract";
$dataxml = get($urlxml);
$data = $xml->XMLin("$dataxml");
#print FH Dumper($data);
foreach $e(@{$data->{PubmedArticle}->{MedlineCitation}->{MeshHeadingList}->{MeshHeading}})
{
print FH $e->{DescriptorName}{content}, ' $$ ';
}
Run Code Online (Sandbox Code Playgroud)
另外,我可以做一些事情,以便在最后一个元素之后不会打印分隔符$$吗?我也尝试了以下代码:
$mesh = $data->{PubmedArticle}->{MedlineCitation}->{MeshHeadingList}->{MeshHeading};
while (my ($key, $value) = each(%$mesh)){
print FH "$value";
}
Run Code Online (Sandbox Code Playgroud)
但是,这会打印所有的子节点,我只想要内容节点.
我有一个关于SQL Server优化的一般问题:如何减少存储过程中的读取次数?
我对以下良好实践感兴趣: - 在物理表和临时表中创建索引 - 使用临时表而不是在程序中使用相同的表几次 - 在DML之前使用DDL - 在存储过程开始时设置NOCOUNT ON - ...
我们遇到的问题是由于存储过程引起的大量读取而使用的磁盘空间,我需要对其进行优化.
"最昂贵"的存储过程的一部分是:
create table #stavke
(
Id_Br int identity(1, 1), IDStavke int,
HeaderID int, Currency varchar(3), GLAcct varchar(20), id varchar(20), Trnuid varchar(60),
ReferenceID varchar(20), DocumentID varchar(20),
DtAvail varchar(10), DtBooking varchar(10), DatePosted varchar(10),
Amount money, AmountLcl money,
Description varchar(250), Type varchar(10), DP int )
insert into #stavke
(
IDStavke, HeaderID, GLAcct, Currency, id , Trnuid ,
ReferenceID, DocumentID ,
DtAvail , DtBooking , DatePosted,
Amount , AmountLcl …Run Code Online (Sandbox Code Playgroud) 对于java来说,我是新手.我想从java中启动的进程中读取stdout.我在谷歌搜索时得到以下代码:
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(args);
BufferedReader br = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
while(br.ready()){
System.out.println(br.readLine());
}
Run Code Online (Sandbox Code Playgroud)
但是,此代码不会打印进程(例如,ls)应该生成的输出(顺便说一下,我在Linux上,openJDK 1.6)
但是,如果我将while循环更改为:
String line;
while((line = br.readLine())!=null){
System.out.println(line);
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作.
以前的代码有什么问题?根据java api doc所说的,我认为它们是相似的.