小编Pri*_*kar的帖子

嵌入字体适用于设计人员,但不适用于应用程

我正在构建一个wpf应用程序,我想在我的应用程序中使用Open Sans Regular字体.

将此链接称为嵌入字体.我将OpenSans Regular.ttf文件添加到项目属性下的资源中.

然后我在我的申请中提到了他们,如下所述:

<Window x:Class="FontEmbeddingDemo.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" FontFamily="Resources/#Open Sans">
<Window.Resources>

</Window.Resources>
<Grid>
    <TextBlock Height="100" Text="This is test text." FontSize="14" FontFamily="Resources/#Open Sans"/>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

在Visual Studio的设计器中,我可以看到字体已更改为打开sans但是当我运行应用程序时,它采用系统默认字体(我的系统中的Arial).

如果您需要任何其他信息,请告诉我.

wpf fonts

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

用龙目岛创建枚举

我在我的应用程序中使用了lombok项目。我正在创建一个枚举。如果我用

@AllArgsConstructor

带有我的枚举的批注,它无法识别构造函数,枚举抛出并且无法接受字符串参数的错误。

如何解决呢?

import lombok.Getter;
import lombok.AllArgsConstructor

@AllArgsConstructor
public enum Direction {
    NORTH("NORTH"), // all these enums give error, for no constructor
    SOUTH("SOUTH"),
    EAST("EAST"),
    WEST("WEST");

    @Getter private String value;
}
Run Code Online (Sandbox Code Playgroud)

PS:我正在使用具有lombok插件安装的intellij-idea。我的龙目岛依赖版本是:1.16.20

java enums lombok

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

在C#列表中查找重复项的计数

我在C#中使用List.代码如下所述:

TestCase.cs

 public class TestCase
{
    private string scenarioID;
    private string error;

    public string ScenarioID
    {
        get
        {
            return this.scenarioID;
        }
        set
        {
            this.scenarioID = value;
        }
    }

    public string Error
    {
        get
        {
            return this.error;
        }
        set
        {
            this.error = value;
        }
    }

    public TestCase(string arg_scenarioName, string arg_error)
    {
        this.ScenarioID = arg_scenarioName;
        this.Error = arg_error;
    }
}
Run Code Online (Sandbox Code Playgroud)

我创建的列表是:

private List<TestCase> GetTestCases()
    {
        List<TestCase> scenarios = new List<TestCase>();
        TestCase scenario1 = new TestCase("Scenario1", string.Empty);
        TestCase scenario2 = new TestCase("Scenario2", string.Empty); …
Run Code Online (Sandbox Code Playgroud)

c# list

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

angularjs:将json数据从服务返回到控制器

我正在使用带有spring mvc的angular js开发一个Web应用程序.

它正在点击spring mvc rest服务并将数据带到angular js服务,但我无法在服务中看到相同的数据.

controllers.js

app.controller('CustomersController', function($scope, customersService){

init();
function init(){
    var data =customersService.getCustomers();
    $scope.customers = data;
}

$scope.insertCustomer = function(){
    var firstName = $scope.newCustomer.firstName;
    var lastName = $scope.newCustomer.lastName;
    var city = $scope.newCustomer.city;
    customersService.insertCustomer(firstName, lastName, city);
    $scope.newCustomer.firstName = '';
    $scope.newCustomer.lastName = '';
    $scope.newCustomer.city = '';
};

$scope.deleteCustomer = function(id){
    customersService.deleteCustomer(id);
};
});

app.controller('NavbarController', function ($scope, $location) {
    $scope.getClass = function (path) {
        if ($location.path().substr(0, path.length) == path) {
            return true;
        } else {
            return false;
        }
    }; …
Run Code Online (Sandbox Code Playgroud)

xmlhttprequest angularjs

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

内容和背景之间传递的Chrome扩展程序消息无效

我正在开发一个chrome扩展,这里是主要文件:

background.js

getPageDimension = function (){
    chrome.tabs.getSelected(null, function(tab) {
        chrome.tabs.sendMessage(tab.id, { message: "DIMENSION" }, function(response){
            if (response != null) {
                console.log(response.x);
                console.log(response.y);
                console.log(response.w);
                console.log(response.h);
            }else{
                console.log('Response is null');
            }
        });
    }); 
};
Run Code Online (Sandbox Code Playgroud)

content.js

chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {        
    if (msg.message && (msg.message == "DIMENSION")) {                          
        var dimension = getPageDiemension(document.documentElement);        
        console.log(dimension.x);
        console.log(dimension.y);
        console.log(dimension.w);
        console.log(dimension.h);
        sendResponse({x: dimension.x, y: dimension.y,w: dimension.w,h: dimension.h});       
    }
});

getPageDiemension = function(currentDom){
    var dimension = new Object();
    dimension.x = 0;
    dimension.y = 0;
    dimension.w = currentDom.scrollWidth;
    dimension.h = currentDom.scrollHeight; …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome google-chrome-extension

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

reactstrap工具提示动态ID

我正在开发一个react应用程序并使用reactstrap。

我正在使用reactstrap的工具提示组件,它需要一个目标属性,即目标元素ID的值。这个id是动态生成的,似乎reactstrap工具提示不喜欢它。

组件看起来像:

MovieCard.jsx

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Col, Card, CardImg, CardBody, CardTitle, CardSubtitle, CardText, Button, Tooltip } from 'reactstrap';
import { LimitedTextTitle } from '../custom-styled/CustomStyledComponents';

class MovieCard extends Component {  

  constructor (props) {
    super(props);
    this.state = {
      open: false
    };
    this.toggle = this.toggle.bind(this);
  }

  toggle () {
    this.setState({
      open: !this.state.open
    })
  }

  render () {
    const { imdbID, Title, Year, Rated, Plot, Country, Poster } = this.props.movie;

    return (
  <Col …
Run Code Online (Sandbox Code Playgroud)

reactjs bootstrap-4 reactstrap

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

使用Oledb读取Excel文件 - 将excel文件的内容视为仅文本

我正在使用C#和OleDb从excel 2007文件中读取数据.

我正在使用的连接字符串是:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";
Run Code Online (Sandbox Code Playgroud)

以下是读取excel的代码:

private OleDbConnection con = null;
private OleDbCommand cmd = null;
private OleDbDataReader dr = null;
private OleDbDataAdapter adap = null;
private DataTable dt = null;
private DataSet ds = null;
private string query;
private string conStr;

public MainWindow()
{
    this.InitializeComponent();
    this.query = "SELECT * FROM [Sheet1$]";
    this.conStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\301591\\Desktop\\Fame.xlsx;Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text\"";
}

private void btnImport_Click(object sender, RoutedEventArgs e)
{
    this.ImportingDataSetWay();
}

private void ImportingDataSetWay()
{
    con = new OleDbConnection(conStr); …
Run Code Online (Sandbox Code Playgroud)

c# oledb wpf excel-2007

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

HQL右外连接

我试图在HQL中执行正确的外连接.查询创建如下所述:

Query query = this.sessionFactory
            .getCurrentSession()
            .createQuery(
"select 
       O.customer.id as id, 
       O.customer.firstName as firstName, 
       O.customer.lastName as lastName, 
       O.customer.address as address, 
       O.customer.city as city, 
       count(O.id) as totalOrders 
 from 
       Order O 
       right outer join O.customer 
 group by 
       O.customer.id");
Run Code Online (Sandbox Code Playgroud)

mysql上的SQL查询工作正常,但HQL查询返回内连接的结果.

SQL查询是:

select c.id,
    c.firstname,
    c.lastname,
    c.city,
    count(o.id) as total_order
  from orders o right outer join customers c
  on c.id = o.customer_id group by id
Run Code Online (Sandbox Code Playgroud)

hibernate join hql

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

Selenium屏幕捕获 - 图像不可用

我正在尝试使用firefox的selenium 捕获屏幕上的http://www.flipkart.com网址.

public class App {

    private static final String APP_URL = "http://www.flipkart.com";

    public static void main(String[] args) {
        WebDriver webDriver = null;
        try {
            webDriver = new FirefoxDriver();
            webDriver.get(APP_URL);
            webDriver.manage().window().maximize();

            if (webDriver instanceof TakesScreenshot) {
                TakesScreenshot screenshot = (TakesScreenshot) webDriver;
                File imageFile = screenshot.getScreenshotAs(OutputType.FILE);
                FileUtils.copyFile(imageFile, new File(
                        "C:\\Captures\\captured.png"));
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (webDriver != null) {
                webDriver.quit();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

它需要整页的屏幕截图,但内部页面显示图像不可用于许多其他图像.我无法纠正它.帮我.

用硒拍摄的屏幕截图

java selenium selenium-webdriver

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

Java SimpleDateFormat:无法解析的日期异常

代码如下:

public static void main(String[] args){
    Date date = new Date();
    DateFormat dateFormat= new SimpleDateFormat("dd-MMM-yyy");

    try{
        Date formattedDate = dateFormat.parse(date.toString());
        System.out.println(formattedDate.toString());
    }catch(ParseException parseEx){
        parseEx.printStackTrace();
    }
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,dateFormat.parse(date.toString())抛出无法解析的日期异常:Unparseable date: "Mon Jan 28 18:53:24 IST 2013

我无法弄清楚原因。

java simpledateformat

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

XState TypeScript - useInterprete 服务

我正在构建一个带有 UI 并TypeScript与UIxState相结合的登录机器React

我的机器是:

import { LoginResponse } from 'async/authentication/responseModel';
import Data from 'data';
import { AUTH_TOKEN } from 'Machines/authentication/constants';
import services from 'services';
import { assign, DoneInvokeEvent, Interpreter, Machine, MachineConfig, State } from 'xstate';

export type AutomataContext = {
  authentication: {
    oldToken: {
      exists: boolean;
      token: string;
    };
    token: string;
  };
  login: {
    email: string;
    password: string;
  };
};

export interface AutomataStatesSchema {
  states: {
    SEARCHING_EXISTING_AUTH_TOKEN: {};
    VERIFYING_EXISTING_TOKEN: {};
    LOGIN_VIEW: {};
    AUTHENTICATING: {}; …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs xstate xstate-react

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