小编pmi*_*hna的帖子

如何在我的"Metro Style"应用程序中拖放WPF?

我正在尝试创建一些Windows Metro风格应用程序的原始模仿.到目前为止我所做的是在窗口中添加新的瓷砖ObservableCollection,我可以改变它们的颜色并使用它们将它们移除ContextMenu.现在我想通过实际预览拖动来实现拖放(使用半透明平铺).我试图自己使用很多教程来描述WPF中的DragDrop类,但我不得不承认我无法理解它并且需要帮助.我试着遵循:本教程.这是我的应用程序的屏幕截图:截图 我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace Metro_Pawel_Michna
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private ObservableCollection<myButton> _tiles = new ObservableCollection<myButton>();
        Random r = new Random();
        private int index = -1;
        private List<Color> myColors = new List<Color>(); …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf xaml drag-and-drop

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

如何将参数传递给线程并获取返回值?

public class CalculationThread implements Runnable {

    int input;
    int output;

    public CalculationThread(int input)
    {
        this.input = input;
    }

    public void run() {
        output = input + 1;
    }

    public int getResult() {
        return output;
    }
}
Run Code Online (Sandbox Code Playgroud)

别的地方:

Thread thread = new Thread(new CalculationThread(1));
thread.start();
int result = thread.getResult();
Run Code Online (Sandbox Code Playgroud)

当然,thread.getResult()不起作用(它试图从Thread类中调用此方法).

你得到了我想要的东西.我怎样才能在Java中实现这一目标?

java multithreading

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

如何从我的应用程序中检查比特币地址余额?

我如何检查比特币地址(任何,不一定是我的)的余额,比如说在 Java 应用程序(或任何其他语言)中?

我需要一个像上一个功能blockchain.infobiteasy.com但我不希望使用自己的API。比特币是开源的,所以我想也许自己获取数据不会那么困难?

bitcoin

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

Ebean和多对多的关系 - 怎么样?

我在MySQL Workbench中创建了一个模式: 我的架构 如何将此映射到Play Framework中的Ebean中的实体?在教程中,他们使用方法编写模型类,对其进行注释@Entity并让Play生成SQL脚本,但不关心数据类型(例如,如何设置VARCHAR限制).

那么多对多关系怎么样?在我的情况下 - 我应该创建一个实体类,UsersScenarios还是应该创建一个Scenario模型,其中包含一些包含Users对象集合的字段和一个User包含Scenario对象集合的模型?或者也许我应该在MySQL Workbench中生成模式并以某种方式将其映射到我的应用程序中?

请帮助我,因为我没有任何ORM经验.

编辑:我用两个模型做了一点测试:

EntityA.java:

package models;

import java.util.*;

import play.db.ebean.*;
import play.data.validation.Constraints.*;

import javax.persistence.*;

@Entity
public class EntityA extends Model {

        @Id
        public Long id;

        @Required
        public String label;

        @ManyToMany
        public List<EntityB> entitiesB = new ArrayList<EntityB>();

        public static Finder<Long,EntityA> find = new Finder(
                        Long.class, EntityA.class
        );
}
Run Code Online (Sandbox Code Playgroud)

EntityB.java

package models;

import java.util.*;

import play.db.ebean.*;
import play.data.validation.Constraints.*;

import javax.persistence.*;

@Entity
public class …
Run Code Online (Sandbox Code Playgroud)

mysql orm playframework ebean playframework-2.2

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

如何在VS2010的紧凑型数据库中添加外键?

如果我通过VS2010创建一个SQL Express数据库,我可以创建图表,这样就可以设置外键关系.紧凑型数据库中的情况如何?服务器资源管理器中没有此类DB的选项.

visual-studio-2010 sql-server-ce

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

如何在Flot图表中居中心?

我正在使用Flot库和angular-flot.我有一个固定大小的图表,当有1或2个条形时看起来不太好看.您可以看到以下2个条形的示例:

2个酒吧

这些条试图遍布x轴的整个长度.我希望它居中 - 它们应该从中间"开始"并水平扩散.这在Flot中可能吗?

我对酒吧的选择:

options: {
    series: {
        bars: {
            show: true,
            barWidth: 0.4,
            lineWidth: 1,
            align: 'center',
            fillColor: {
                colors: [{
                    opacity: 0.5
                }, {
                    opacity: 0.1
                }]
            }
        }
    },
    xaxis: {
       mode: 'categories',
       axisLabel: 'Machines',
       axisLabelUseCanvas: true,
       axisLabelFontSizePixels: 14,
       axisLabelFontFamily: 'RobotoLight, Helvetica Neue, Helvetica',
       axisLabelPadding: 10
    },
    yaxis: {
       axisLabel: metricName,
       axisLabelUseCanvas: true,
       axisLabelFontSizePixels: 14,
       axisLabelFontFamily: 'RobotoLight, Helvetica Neue, Helvetica',
       axisLabelPadding: 10
    },
    grid: {
       hoverable: true,
       clickable: false,
       borderWidth: 1
    } …
Run Code Online (Sandbox Code Playgroud)

javascript flot angularjs

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

Postgres和jsonb-在任何键处搜索值

是否可以在Postgres的JSONB列中的任何键处寻找给定值?在文档中,我看不到任何示例。

JSONB列中的示例值:

{
  a: 1,
  b: 2,
  c: 3
}
Run Code Online (Sandbox Code Playgroud)

我想在1任何地方查找所有具有值的记录。注意:a, b, c此刻可能还有其他按键(未知)。

postgresql jsonb

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

如何将实体从Entity Framework绑定到DataGrid?

我的XAML:

<Window x:Class="Newsletter.UI.MessagesWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MessagesWindow" Name="messagesWindow" Height="576" Width="1024" WindowStartupLocation="CenterScreen" Closed="MessagesWindowClosed">
    <Window.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="Width" Value="149"/>
            <Setter Property="Margin" Value="10"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="75"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0"  Orientation="Horizontal" HorizontalAlignment="Center">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Button Name="saveButton" Grid.Row="0" Content="Save"  Margin="10,10,10,5"/>
                <TextBox Name="searchTextBox" Grid.Row="1"  Margin="10,5,10,10"/>
            </Grid>
            <Button Name="recipientsButton" Content="RECIPIENTS" Click="RecipientsButtonClick" />
            <Button Name="createButton" Content="CREATE" Click="CreateButtonClick" />
            <Button Name="removeButton" Content="REMOVE" />
            <Button Name="editButton" Content="EDIT" />
            <Button Name="resendButton" Content="RESEND"/>
        </StackPanel>
        <DataGrid Name="gridMessages" Grid.Row="1"/>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

我的.cs代码:

private …
Run Code Online (Sandbox Code Playgroud)

data-binding wpf ado.net entity-framework

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

DdlGenerator构造函数不需要参数?

我想单元测试我的数据库操作,我发现了这段代码.但是,我收到了以下错误:

[CityGame] $ test
[info] Compiling 2 Java sources to /Users/pmichna/Documents/code/citygame/target/scala-2.10/test-classes...
[error] /Users/pmichna/Documents/code/citygame/test/models/BaseModelTest.java:31: error: constructor DdlGenerator in class DdlGenerator cannot be applied to given types;
[error]         ddl = new DdlGenerator((SpiEbeanServer) server, new MySqlPlatform(), config);
[error]               ^
[error]   required: no arguments
[error]   found: SpiEbeanServer,MySqlPlatform,ServerConfig
[error]   reason: actual and formal argument lists differ in length
[error] 1 error
[error] (test:compile) javac returned nonzero exit code
[error] Total time: 2 s, completed 2013-12-17 00:21:23
Run Code Online (Sandbox Code Playgroud)

有没有DdlGenerator改变?

database playframework ebean playframework-2.2

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

Expect{ subject }.to change(...).by(1) 不起作用

该测试通过:

it 'test' do
  old = parenthood.student.balance
  Payment.money_transfer_to_child current_user: parenthood.user,
                                  student_id: parenthood.student.id,
                                  amount: '1',
                                  comment: 'some comment'
  expect(parenthood.student.reload.balance).to eq(old+1)
end
Run Code Online (Sandbox Code Playgroud)

将其更改为以下形式使其无法通过(“被 0 更改”):

subject { Payment.money_transfer_to_child current_user: parenthood.user,
                                              student_id: parenthood.student.id,
                                              amount: '1',
                                              comment: 'some comment' }
it { expect{ subject }.to change(parenthood.student.reload, :balance).by(1) }
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

rspec ruby-on-rails

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