C# Equivalent to this code

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

I have used this

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

but not working for me. Any idea ??

I made a class

 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;

its not working either i have to pass it as an argument to the Colorsamples.Add();

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

I had a quick look at the interop and the Add method takes an object. As @icbytes implies, it takes an array so you could probably get away with an array of boxed objects. The interop uses double (not float) all over so double is probably the type you want to use.

For you own curiosity you should loop through the ColorSamplers collection and see what underlying types there are contained inside it. The collection stores objects that implement ColorSampler (which contains a SolidColorClass property) so if you know what objects implement this you can create those types to pass into the Add method.

Set the preference to pixels first to assume all values you provide are pixel-based.

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 } );

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

C# Equivalent to this code

From Dev

Equivalent C# of this PHP code

From Dev

Equivalent C# of this PHP code

From Dev

Equivalent PHP code in C#

From Dev

C# equivalent code for Powershell

From Dev

Writing equivalent code in Pascal to code C#

From Dev

Writing equivalent code in Pascal to code C#

From Dev

C++ to C code conversion, is it equivalent?

From Dev

What is the equivalent of this snippet of Java code in C#?

From Dev

Equivalent C# code for the VB counterpart

From Dev

Equivalent PyQt code for C++ Qt Snippet

From Dev

What is this Java code equivalent in C# ? (setRequestEntity)

From Dev

equivalent in vb.net of c# code

From Dev

C# equivalent of Visual Basic Code with CType

From Dev

C++ equivalent to python code: 'function(*list)'

From Dev

Cant find VBA equivalent to this c# code

From Dev

Equivalent of Constructor code in visual C# Complex

From Dev

equivalent in vb.net of c# code

From Dev

Equivalent to Interfaces in Embedded C / Code organization

From Dev

C++ equivalent to python code: 'function(*list)'

From Dev

What is this Java code equivalent in C# ? (setRequestEntity)

From Dev

Assembly strings and equivalent code in C++

From Dev

Equivalent of swift code in firebase to objective c

From Dev

What is the C++ equivalent to this MATLAB code?

From Dev

Is it possible to write this Rust code into semantically equivalent C++ code?

From Dev

I want to convert C code block to equivalent PHP code

From Dev

Equivalent PHP language code for C language code using pointers

From Dev

Equivalent java code statement for C code statement used in recursion

From Dev

what is equivalent Swift code of this Objective-c code?

Related Related

HotTag

Archive