我用过这段代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
namespace WindowsApplication1 {
public partial class Form1 : Form {
// Class to report progress
private class UIProgress {
public UIProgress(string name_, long bytes_, long maxbytes_) {
name = name_; bytes = bytes_; maxbytes = maxbytes_;
}
public string name;
public long bytes;
public long maxbytes;
}
// Class to report exception {
private class UIError {
public UIError(Exception ex, string path_) {
msg = ex.Message; path = path_; …Run Code Online (Sandbox Code Playgroud) 我有这个WPF应用程序从REST Web服务获取数据并返回JSON数据.然后这个数据将转换为xml.稍后将此xml文件转换回JSON,以与来自调用相同功能的REST Web服务的新JSON数据进行比较.我该怎么做呢?
以下是我所做的一个示例:
HTTPGet req = new HTTPGet();
req.Request("http://restservice//function");
string str= req.ResponseBody;
StringBuilder xmlTemplate = new StringBuilder("{\"?xml\":{\"@version\": \"1.0\",\"@standalone\": \"no\"},\"root\":REPLACE }");
StringBuilder json = xmlTemplate.Replace(Constants.Constants.XMLREPLACEVAL, str); //this so that it will be same with the JObject from XML file
JObject jObject1 = JObject.Parse(json.ToString());
XmlDocument doc = new XmlDocument();
string xml = File.ReadAllText("json.xml");
doc.LoadXml(xml);
string jsonText = JsonConvert.SerializeXmlNode(doc);
JObject jObject2 = JObject.Parse(jsonText);
if(jObject1.Equals(jObject2))
//DO SOMETHING
Run Code Online (Sandbox Code Playgroud) 我使用Visual Studio 2010 C#编写了一个类库来读取计算机的硬件信息(例如HDD/SSD).我将使用此dll创建一个使用InnoSetup的安装程序来读取目标计算机的硬件信息.现在我的问题是.NET dll不能直接使用,除非它已经注册.我试图在InnoSetup的InitializeSetup中找到一种注册dll的方法,这样我就可以使用dll中的函数了.这是我为安装程序编写的脚本.
function InitializeSetup(): Boolean;
var
obj: Variant;
diskPartitions: Integer;
va: String;
ErrorCode: Integer;
b: Boolean;
begin
ExtractTemporaryFile('SSHardwareChecker.dll');
RegisterServer(False, ExpandConstant('{tmp}\SSHardwareChecker.dll'), False);
obj := CreateOleObject('SSHardwareChecker.SSClass');
va := obj.GetDiskDriveInformation;
MsgBox(va, mbInformation, mb_Ok);
b:=UnregisterServer(False, ExpandConstant('{tmp}\SSHardwareChecker.dll'), False);
end;
Run Code Online (Sandbox Code Playgroud)
该功能RegisterServer似乎不起作用RegSvr32 failed with exit code 0x4.它会抛出一个错误.我在网上读了很多文章说.net dll应该用regasm注册.我真的不知道如何做到这一点,尤其是在Inno Setup中.
请帮帮我们
我有一个文本块,其尺寸为宽度= 511,高度= 159.字号= 28.如果文本超出文本块的尺寸,我想更改字体大小,以便显示所有文本.有办法做到这一点吗?一个公式可能?
我不是很擅长VC++但是有没有人有一个示例代码来获取计算机中磁盘的旋转速度.我一直致力于检测SSD驱动器,一天研究的一个解决方案是获得转速,而且由于SSD的转速为0 rpm,这可能是检测SSD驱动器的唯一方法.
有没有办法在WPF数据网格中的水平网格线上有一条虚线?我到处搜索,似乎无法找到具体的方法.可以解决此问题的一个解决方案是设置Datagrid.RowStyle.我试过这个,它会导致错误.我已将datagrid绑定到数据表.2列只是文本,第3列是图像列.对于这个列,我使用了DataGridTemplateColumn.文本块和图像.我希望你能帮助我们......如果你想要我的代码样本,那就是.
<StackPanel>
<dg:DataGrid Name="questionList"
HeadersVisibility="None"
AutoGenerateColumns="False"
Background="White"
Margin="42,32,43,0"
BorderThickness="0"
GridLinesVisibility="Horizontal"
CanUserAddRows="False"
HorizontalGridLinesBrush="#FFCCCCCC"
MaxHeight="549"
Cursor="Hand"
PreviewMouseLeftButtonUp="questionnaireList_PreviewMouseLeftButtonUp">
<dg:DataGrid.CellStyle>
<Style TargetType="{x:Type dg:DataGridCell}">
<Setter Property="BorderThickness" Value="0"/>
</Style>
</dg:DataGrid.CellStyle>
<dg:DataGrid.RowStyle>
<Style TargetType="{x:Type dg:DataGridRow}">
<Setter Property="Background" Value="{Binding MyImage, Converter={x:Static my:StatusColorConverter.instance}}" />
</Style>
</dg:DataGrid.RowStyle>
<dg:DataGrid.Columns>
<dg:DataGridTemplateColumn Width="69*">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="12,16,0,17"
FontSize="18"
Foreground="#0891F1"
Text="{Binding Path=Number}"
TextWrapping="Wrap"/>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn Width="601*">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock FontSize="16" Foreground="#666666"
Text="{Binding Path=Desc}"
TextWrapping="Wrap"
TextAlignment="Justify"
Margin="0,16,0,17" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn Width="117*">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=Imgs}"
Stretch="None"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Margin="0,16,18,17" /> …Run Code Online (Sandbox Code Playgroud) c# ×4
.net ×2
inno-setup ×2
wpf ×2
c ×1
c++ ×1
datagrid ×1
file-copying ×1
file-io ×1
json.net ×1
progress-bar ×1
visual-c++ ×1
xaml ×1