小编Edw*_*uay的帖子

如何将.eps文件转换为高质量的1024x1024 .jpg?

我有一个.eps文件,我可以在Photoshop中看到它,它具有非常高的分辨率,锐利的边缘等,甚至大于1024x1024.

使用ImageMagick我想将此.eps转换为1024x1024 .jpg,分辨率非常高.

但是,使用以下命令,图像非常模糊:

convert -resize "1024x1024" -colorspace RGB -flatten test.eps test.jpg 
Run Code Online (Sandbox Code Playgroud)

我必须使用哪些ImageMagick参数,以便生成的.jpg为1024x1024并且是高质量,清晰的图像?

这里是我们发现的一些XMP数据,也许是导致它不能调整大小的原因-size:

在此输入图像描述

imagemagick

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

VARCHAR像90年代一样吗?

  1. VARCHAR不存储Unicode字符.
  2. NVARCHAR存储Unicode字符.
  3. 今天的应用程序应始终与Unicode兼容.
  4. NVARCHAR需要两倍的空间来存储它.
  5. 第4点无关紧要,因为存储空间非常便宜.

Ergo:今天设计SQL Server数据库时,应始终使用NVARCHAR.

这听起来有道理吗?有没有人不同意任何前提?今天有没有理由在NVARCHAR上选择VARCHAR?

sql-server nvarchar

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

如何通过ObjectDataProvider将ComboBox绑定到通用字典

我想用代码中的键/值数据填充ComboBox,我有这个:

XAML:

<Window x:Class="TestCombo234.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TestCombo234"
    Title="Window1" Height="300" Width="300">
    <Window.Resources>
        <ObjectDataProvider x:Key="Choices" ObjectType="{x:Type local:CollectionData}" MethodName="GetChoices"/>
    </Window.Resources>
    <StackPanel HorizontalAlignment="Left">
        <ComboBox ItemsSource="{Binding Source={StaticResource Choices}}"/>
    </StackPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)

代码背后:

using System.Windows;
using System.Collections.Generic;

namespace TestCombo234
{
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
    }

    public static class CollectionData
    {
        public static Dictionary<int, string> GetChoices()
        {
            Dictionary<int, string> choices = new Dictionary<int, string>();
            choices.Add(1, "monthly");
            choices.Add(2, "quarterly");
            choices.Add(3, "biannually");
            choices.Add(4, "yearly");
            return choices;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但这给了我这个:

alt text …

c# data-binding wpf xaml combobox

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

Properties.Settings.Default的数据保存在哪里?

在我的WPF应用程序中,单击解决方案资源管理器中的Settings.settings并输入具有User范围的StringCollection变量:

替代文字http://i45.tinypic.com/24xdmir.png

在我的app.config中,我看到它们被保存在那里:

<userSettings>
    <TestSettings.Properties.Settings>
        <setting name="Paths" serializeAs="Xml">
            <value>
                <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                    <string>one</string>
                    <string>two</string>
                    <string>three</string>
                    <string>four</string>
                    <string>five</string>
                    <string>six</string>
                    <string>seven</string>
                </ArrayOfString>
            </value>
        </setting>
    </TestSettings.Properties.Settings>
</userSettings>
Run Code Online (Sandbox Code Playgroud)

然后我运行我的应用程序并使用此代码:

StringCollection paths = Properties.Settings.Default.Paths;

Properties.Settings.Default.Paths.Add("added in code");
Properties.Settings.Default.Save();

foreach (var path in paths)
{
    System.Console.WriteLine(path);
}
Run Code Online (Sandbox Code Playgroud)

这给了我这个输出:

one
two
three
four
five
six
seven
added in code
Run Code Online (Sandbox Code Playgroud)

再次运行应用程序,它给了我这个输出:

one
two
three
four
five
six
seven
added in code
added in code
Run Code Online (Sandbox Code Playgroud)

但是我再次查看我的app.config …

c# wpf settings

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

如何让DataTemplate.DataTrigger检查大于或小于?

以下DataTemplate.DataTrigger使年龄显示为红色,如果它等于 30.

如果年龄显示大于 30,如何使年龄显示为红色?

<DataTemplate DataType="{x:Type local:Customer}">
    <Grid x:Name="MainGrid" Style="{StaticResource customerGridMainStyle}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="150"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <TextBlock Grid.Column="0" Grid.Row="0" Text="First Name" Margin="5"/>
        <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding FirstName}" Margin="5"/>
        <TextBlock Grid.Column="0" Grid.Row="1" Text="Last Name" Margin="5"/>
        <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding LastName}" Margin="5"/>
        <TextBlock Grid.Column="0" Grid.Row="2" Text="Age" Margin="5"/>
        <TextBlock x:Name="Age" Grid.Column="1" Grid.Row="2" Text="{Binding Age}" Margin="5"/>
    </Grid>

    <DataTemplate.Triggers>
        <DataTrigger Binding="{Binding Path=Age}">
            <DataTrigger.Value>30</DataTrigger.Value>
            <Setter TargetName="Age" Property="Foreground" Value="Red"/> 
        </DataTrigger>
    </DataTemplate.Triggers>

</DataTemplate>
Run Code Online (Sandbox Code Playgroud)

wpf xaml datatrigger datatemplate

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

如何仅在XAML中设置上边距?

我可以在代码中单独设置边距,但是如何在XAML中设置边距,例如我该怎么做:

伪代码:

<StackPanel Margin.Top="{Binding TopMargin}">
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml margins

44
推荐指数
4
解决办法
6万
查看次数

在使用MVVM时,如何将TextBox设置为"密码框"并显示星标?

我怎样才能在XAML中执行此操作:

伪代码:

<TextBox Text="{Binding Password}" Type="Password"/>
Run Code Online (Sandbox Code Playgroud)

这样当用户输入密码时,用户就会看到星星或圆点.

我已经尝试了各种示例,建议使用PasswordCharPasswordBox,但无法使这些工作.

例如,我可以做到这一点,如图在这里:

<PasswordBox Grid.Column="1" Grid.Row="1"
    PasswordChar="*"/>
Run Code Online (Sandbox Code Playgroud)

但我当然希望将Text属性绑定到我的ViewModel,这样我可以在单击按钮时发送绑定TextBox的值(不使用后面的代码),我想这样做:

<TextBox Grid.Column="1" Grid.Row="0" 
    Text="{Binding Login}" 
    Style="{StaticResource FormTextBox}"/>
<PasswordBox Grid.Column="1" Grid.Row="1"
    Text="{Binding Password}" 
    PasswordChar="*"
    Style="{StaticResource FormTextBox}"/>
Run Code Online (Sandbox Code Playgroud)

但是PasswordBox没有Text属性.

c# wpf xaml textbox mvvm

42
推荐指数
6
解决办法
10万
查看次数

衡量代码执行时间的最佳方法是什么?

我正在尝试确定删除字符串的方法是最快的.

我只是得到开始结束时间并显示差异.

但结果是如此多变,例如如下所示,相同的方法可以从60毫秒到231毫秒.

获得更准确结果的更好方法是什么?

替代文字http://www.deviantsart.com/upload/1q4t3rl.png

using System;
using System.Collections;
using System.Collections.Generic;

namespace TestRemoveFast
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int j = 0; j < 10; j++)
            {
                string newone = "";
                List<string> tests = new List<string>();
                for (int i = 0; i < 100000; i++)
                {
                    tests.Add("{http://company.com/Services/Types}ModifiedAt");
                }

                DateTime start = DateTime.Now;
                foreach (var test in tests)
                {
                    //newone = ((System.Xml.Linq.XName)"{http://company.com/Services/Types}ModifiedAt").LocalName;
                    newone = Clean(test);
                }

                Console.WriteLine(newone);
                DateTime …
Run Code Online (Sandbox Code Playgroud)

c# performance

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

如何找出使用PHPExcel从Excel文件中读取的行数和列数?

使用以下代码,我可以使用PHPExcel从Excel文件中读取单元格.

我目前手动定义要读取的行数和列数.

有没有一种方法PHPExcel可以告诉我有多少行和列我必须读取以从工作表中获取所有数据,例如,即使某些行和列留空?

$file_name = htmlentities($_POST['file_name']);
$sheet_name = htmlentities($_POST['sheet_name']);
$number_of_columns = htmlentities($_POST['number_of_columns']);
$number_of_rows = htmlentities($_POST['number_of_rows']);

$objReader = PHPExcel_IOFactory::createReaderForFile("data/" . $file_name);
$objReader->setLoadSheetsOnly(array($sheet_name));
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("data/" . $file_name);

echo '<table border="1">';
for ($row = 1; $row < $number_of_rows; $row++) {
    echo '<tr>';
    for ($column = 0; $column < $number_of_columns; $column++) {
        $value = $objPHPExcel->setActiveSheetIndex(0)->getCellByColumnAndRow($column, $row)->getValue();
        echo '<td>';
        echo $value . '&nbsp;';
        echo '</td>';
    }
    echo '</tr>';
}
echo '</table>';
Run Code Online (Sandbox Code Playgroud)

解:

谢谢,Mark,这是这些功能的完整解决方案:

$file_name = htmlentities($_POST['file_name']);
$sheet_name = htmlentities($_POST['sheet_name']);
$number_of_columns = …
Run Code Online (Sandbox Code Playgroud)

php phpexcel

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

你是如何在MVVM中成功实现MessageBox.Show()功能的?

我有一个WPF应用程序,它在ViewModel中调用MessageBox.Show()方式(以检查用户是否真的要删除).这实际上是有效的,但是违背了MVVM,因为ViewModel不应该明确地确定View上发生了什么.

所以现在我在想如何在我的MVVM应用程序中最好地实现MessageBox.Show()功能,选项:

  1. 我可以收到一条短信,上面写着"你确定......?" 以及我的XAML中的边框中的两个按钮是和否全部,并在模板上创建一个触发器,使其基于名为AreYourSureDialogueBoxIsVisible的ViewModelProperty折叠/可见,然后当我需要此对话框时,将AreYourSureDialogueBoxIsVisible指定为"true" "还可以通过我的ViewModel中的DelegateCommand处理这两个按钮.

  2. 我也可以尝试用XAML中的触发器来处理这个问题,这样删除按钮实际上只会使一些Border元素出现,其中包含消息和按钮,而Yes按钮实际上是删除了.

对于曾经使用MessageBox.Show()的几行代码而言,这两种解决方案似乎都过于复杂.

您在哪些方面成功实现了MVVM应用程序中的Dialogue Box?

wpf triggers messagebox mvvm

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