gpt4 book ai didi

C#相当于这段代码

转载 作者:行者123 更新时间:2023-11-29 22:08:54 24 4
gpt4 key购买 nike

var xPos = new UnitValue( 0.5,'px') ;
var yPos = new UnitValue( 0.5,'px');
var pixPos = [ xPos, yPos ];

我用过这个

Tuple<PsUnits, PsUnits> tuple = new Tuple<PsUnits,PsUnits>(xpos,ypos);

但不适合我。有什么想法吗??

我上了一个类

 public class pixpos
{
float XPOS;
float YPOS;
public float xpos
{
get
{
return this.XPOS;
}
set
{
this.XPOS = value;
}
}
public float ypos
{
get { return this.YPOS; }
set { this.YPOS = value; }
}
}
pixpos obj = new pixpos();
obj.xpos = xPos;
obj.ypos = yPos;

它也不起作用我必须将它作为参数传递给 Colorsamples.Add();

 Photoshop.Application appRef = default(Photoshop.Application);
var mySampler = appRef.ActiveDocument.ColorSamplers.Add(ps);

最佳答案

我快速查看了互操作,Add 方法接受了一个对象。正如@icbytes 所暗示的那样,它需要一个数组,因此您可能可以摆脱一组装箱对象。互操作全部使用 double(而不是 float),因此 double 可能是您要使用的类型。

出于好奇,您应该遍历 ColorSamplers 集合并查看其中包含哪些基础类型。该集合存储实现 ColorSampler 的对象(其中包含一个 SolidColorClass 属性),因此如果您知道哪些对象实现了它,您可以创建这些类型以传递到 Add 方法。

首先将首选项设置为像素,以假设您提供的所有值都是基于像素的。

Photoshop.Application appRef = default(Photoshop.Application);
appRef.Preferences.RulerUnits = PsUnits.psPixels;

foreach (ColorSampler sampler in appRef.ActiveDocument.ColorSamplers)
{
// Check to see what underlying type a sampler is so you can try
// and make instances of this to pass into the Add method.
Console.WriteLine(sampler.GetType().FullName);
}

// Try add an object array of double values, based on the error message implied units could work.
// 'D' with convert the number literal to a 'double'.
appRef.ActiveDocument.ColorSamplers.Add(new object[] { 0.5D, 0.5D } );

关于C#相当于这段代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19177693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com