CodeCarvings Piczard V1.2 Help
UserState & PictureTrimmer Value
See Also Send Feedback
Piczard Fundamentals - Web > PictureTrimmer > UserState & PictureTrimmer Value

Glossary Item Box

CONTENTS

  1. PictureTrimmerValue
  2. PictureTrimmerUserState
  3. Load and save the value/state of the control
  4. Accessing value/state of the control on the client side
  5. Additional information about the PictureTrimmerValue and the PictureTrimmerUserState classes

 

After an image has ben loaded into a PictureTrimmer instance, you can access the current state / value of the control by using the UserState and/or the Value properties.

Please see the Example A.304 - "Web - PictureTrimmer / UserState & PictureTrimmer Value"

 

 

1. PictureTrimmerValue

The Value property of a PictureTrimmer instance provides access to the current value of the control.
The PictureTrimmerValue class encapsulates all the data necessary to process the source image according to the user selection:

  1. Crop coordinates (please see the figure 1 - point 1)
  2. ResizeFactor (please see the figure 1 - point 2)
  3. RotationAngle (please see the figure 1 - point 3)
  4. Horizontal Flip (please see the figure 1 - point 4)
  5. Vertical Flip (please see the figure 1 - point 5)
  6. Brightness (please see the figure 1 - point 6)
  7. Contrast (please see the figure 1 - point 7)
  8. Hue (please see the figure 1 - point 8)
  9. Saturation (please see the figure 1 - point 9)

Figure 1: PictureTrimmer Value

 

PictureTrimmerValue is a Piczard image filter (it inherits from the ImageProcessingFilter class).
Please see: How Piczard Works

 

 

2. PictureTrimmerUserState

Differently from the Value property, the UserState property of a PictureTrimmer instance provides access to the whole current state of the control.
This includes the current Value - AND - also the current UI parameters.
The PictureTrimmerUIParams class provides access to:

  1. ZoomFactor (please see the figure 2 - point 1)
  2. Horizontal scroll of the Picture (please see the figure 2 - point 2)
  3. Vertical scroll of the Picture (please see the figure 2 - point 3)
  4. Vertical scroll of the Command Panel (please see the figure 2 - point 4)

Figure 2: PictureTrimmer UI parameters

 

The parameters contained in the PictureTrimmerUIParams are:

 

 

3. Load and save the value/state of the control

The PictureTrimmerValue and the PictureTrimmerUserState classes can be easily serialized/deserialized as string by using the JSONSerializer class (Please see: JSON Serialization)
In this way you can save/load the value (or the whole state) of the control.

The following example shows how to save the Value of a PictureTrimmer control into a DB:

Copy Code
string valueString = CodeCarvings.Piczard.Serialization.JSONSerializer.SerializeToString(PictureTrimmer1.Value);
mySqlSaveCommand.Parameters.AddWithValue(
"@Picture1_value", valueString);

Where:

 

The following examples shows how to load the value of a PictureTrimmer control stored into a DB:

Copy Code
string valueString = (string)mySqlDataReader["Picture1_value"];
PictureTrimmer1.Value = PictureTrimmerValue.FromJSON(valueString);

Where:

 

Before setting the Value or the UserState properties of the PictureTrimmer control you have to load an image into it (for example by invoking the LoadImageFromFileSystem method first).

Please see also:

 

 

4. Accessing value/state of the control on the client side 

The state of PictureTrimmer control (and therefore also its value) can be get and set both on the server-side and on the client-side.

The following examples show how to get or set the state of a PictureTrimmer control on the client-side:

 

 

5. Additional information about the PictureTrimmerValue and the PictureTrimmerUserState classes

You can access the current PictureTrimmer value in two different ways:

  1. By using the Value property of the PictureTrimmer instance
  2. By using the Value property of a PictureTrimmerUserState instance (which in turn it can be obtained by using the UserState property of the PictureTrimmer instance)

There is a small difference in the two methods.
In facts, by using the method #1 - before returning the PictureTrimmerValue - the data are automatically adjusted.
For example:

If you want to get the original (not adjusted) PictureTrimmerValue, then you have to use the UserState property (method #2).

See Also

Other Features
JSON Serialization

©2013 Sergio Turolla. All Rights Reserved.