Description
Reset crop data.
Syntax
Page.ResetCropData() |
Example
Public Function AssetToEditorialCrop(ByVal wireImageId As Integer, ByVal quiet As Boolean, ByVal autoCloseMode As GNClient.AutoCloseMode) As Boolean
Dim dummyId As Integer
Dim dummyWidth As Integer
Dim dummyHeight As Integer
Dim parameters As String
Dim replacePlaceholder As Boolean = False
dummyId = Page.GetSelectedImgId
If dummyId = 0 Then
MsgBox(My.Resources.IDS_SelPlaceholder, vbExclamation, ApplicationBase.Current.ApplicationName) ' "A placeholder or a dummy image must be selected on page for this to work!"
Return False 'no picture selected
ElseIf dummyId < 0 Then
If Page.GetSelectedKind() = POK.oBitmap Then
replacePlaceholder = True 'it is a placeholder
Else
Return False 'no picture selected
End If
ElseIf dummyId > 0 Then
If Not Page.GetSelectedImgDummy And Not quiet Then
If Not EdConfig.glbReplaceNonDummyImg Then 'added by BS on 19/Dec/2011 - possibility to override prompt by setting EdConfig.glbReplaceNonDummyImg to true (default=false)
If MsgBox(My.Resources.IDS_CropNonDummy, vbQuestion + MsgBoxStyle.YesNo, My.Resources.IDS_CropTitle) <> vbYes Then
Return True 'no confirm
End If
End If
End If
End If
dummyWidth = Page.GetSelectionWidth()
dummyHeight = Page.GetSelectionHeight()
parameters = "wf=Crop&Ids=" & wireImageId & "&autoCloseMode=" & autoCloseMode & "&Pars=width:" & dummyWidth & ";height:" & dummyHeight & ";"
If dummyId > 0 Then
parameters &= "dummyId:" & dummyId & ";"
End If
Dim workflowName As String = Nothing
Dim result As GNClient.WFResult = Nothing
Fred.ExecuteWorkflow(parameters, workflowName, result)
' check if user pressed Cancel - if so, 'result' will be nothing, then return false
If result Is Nothing Then Return False
If replacePlaceholder Then
'replace the placeholder with the picture
If Not result Is Nothing AndAlso Not result.ImportResults Is Nothing Then
For Each changedImage As GNClient.XmlImportResult In result.ImportResults
If changedImage.ObjectId <> wireImageId Then
'tested changedImage.ObjectId: note that changedImage.IsNew can be false if the name of the picture already exists
If changedImage.ObjectId > 0 Then
Dim curObjReplace = Fred.AppGetObjReplace
Fred.AppSetObjReplace(IFredApp.objReplace.objReplaceYes)
Dim iImgProc = Fred.AppGetImgProcessing
Fred.AppSetImgProcessing(IFredApp.eLoadCrop.lcFit)
Page.ImgInsertId(changedImage.ObjectId, photoname)
Fred.AppSetObjReplace(curObjReplace)
Fred.AppSetImgProcessing(iImgProc)
Exit For
End If
End If
Next
End If
End If
Fred.ImgRefresh(True) 'reload the image, so the system knows that it is not a dummy anymore
Page.ResetCropData()
Page.ViewRedraw()
Return True 'replaced/created dummy picture
End Function
Context
Page designer