/*
Copyright 2008 Stefano Chizzolini. http://clown.stefanochizzolini.it
Contributors:
* Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it)
This file should be part of the source code distribution of "PDF Clown library"
(the Program): see the accompanying README files for more info.
This Program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later version.
This Program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY, either expressed or implied; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
You should have received a copy of the GNU General Public License along with this
Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
Redistribution and use, with or without modification, are permitted provided that such
redistributions retain the above copyright notice, license and disclaimer, along with
this list of conditions.
*/
using it.stefanochizzolini.clown.documents.interaction.actions;
using it.stefanochizzolini.clown.files;
using it.stefanochizzolini.clown.objects;
using System;
using System.Collections.Generic;
namespace it.stefanochizzolini.clown.documents.interaction.annotations{
/**
<summary>Annotation actions [PDF:1.6:8.5.2].</summary>
*/
public class AnnotationActions
: PdfObjectWrapper<PdfDictionary>
{
#region dynamic
#region fields
private Annotation parent;
#endregion
#region constructors
public AnnotationActions(
Annotation parent
) : base(
parent.File,
new PdfDictionary()
)
{this.parent = parent;}
internal AnnotationActions(
Annotation parent,
PdfDirectObject baseObject,
PdfIndirectObject container
) : base(baseObject,container)
{this.parent = parent;}
#endregion
#region interface
#region public
public override object Clone(
Document context
)
{throw new NotImplementedException();}
/**
<summary>Gets/Sets the action to be performed when the annotation is activated.</summary>
*/
public Action OnActivate
{
get
{
/*
NOTE: 'A' entry may be undefined.
*/
PdfDirectObject onActivateObject = parent.BaseDataObject[PdfName.A];
if(onActivateObject == null)
return null;
return Action.Wrap(onActivateObject,Container);
}
set
{
parent.BaseDataObject[PdfName.A] = value.BaseObject;
parent.Update(); // Ensures that the annotation's object modification is preserved.
}
}
/**
<summary>Gets/Sets the action to be performed when the cursor enters the annotation's active area.</summary>
*/
public Action OnEnter
{
get
{
/*
NOTE: 'E' entry may be undefined.
*/
PdfDirectObject onEnterObject = BaseDataObject[PdfName.E];
if(onEnterObject == null)
return null;
return Action.Wrap(onEnterObject,Container);
}
set
{BaseDataObject[PdfName.E] = value.BaseObject;}
}
/**
<summary>Gets/Sets the action to be performed when the cursor exits the annotation's active area.</summary>
*/
public Action OnExit
{
get
{
/*
NOTE: 'X' entry may be undefined.
*/
PdfDirectObject onExitObject = BaseDataObject[PdfName.X];
if(onExitObject == null)
return null;
return Action.Wrap(onExitObject,Container);
}
set
{BaseDataObject[PdfName.X] = value.BaseObject;}
}
/**
<summary>Gets/Sets the action to be performed when the mouse button is pressed
inside the annotation's active area.</summary>
*/
public Action OnMouseDown
{
get
{
/*
NOTE: 'D' entry may be undefined.
*/
PdfDirectObject onMouseDownObject = BaseDataObject[PdfName.D];
if(onMouseDownObject == null)
return null;
return Action.Wrap(onMouseDownObject,Container);
}
set
{BaseDataObject[PdfName.D] = value.BaseObject;}
}
/**
<summary>Gets/Sets the action to be performed when the mouse button is released
inside the annotation's active area.</summary>
*/
public Action OnMouseUp
{
get
{
/*
NOTE: 'U' entry may be undefined.
*/
PdfDirectObject onMouseUpObject = BaseDataObject[PdfName.U];
if(onMouseUpObject == null)
return null;
return Action.Wrap(onMouseUpObject,Container);
}
set
{BaseDataObject[PdfName.U] = value.BaseObject;}
}
/**
<summary>Gets/Sets the action to be performed when the page containing the annotation is closed.</summary>
*/
public Action OnPageClose
{
get
{
/*
NOTE: 'PC' entry may be undefined.
*/
PdfDirectObject onPageCloseObject = BaseDataObject[PdfName.PC];
if(onPageCloseObject == null)
return null;
return Action.Wrap(onPageCloseObject,Container);
}
set
{BaseDataObject[PdfName.PC] = value.BaseObject;}
}
/**
<summary>Gets/Sets the action to be performed when the page containing the annotation
is no longer visible in the viewer application's user interface.</summary>
*/
public Action OnPageInvisible
{
get
{
/*
NOTE: 'PI' entry may be undefined.
*/
PdfDirectObject onPageInvisibleObject = BaseDataObject[PdfName.PI];
if(onPageInvisibleObject == null)
return null;
return Action.Wrap(onPageInvisibleObject,Container);
}
set
{BaseDataObject[PdfName.PI] = value.BaseObject;}
}
/**
<summary>Gets/Sets the action to be performed when the page containing the annotation is opened.</summary>
*/
public Action OnPageOpen
{
get
{
/*
NOTE: 'PO' entry may be undefined.
*/
PdfDirectObject onPageOpenObject = BaseDataObject[PdfName.PO];
if(onPageOpenObject == null)
return null;
return Action.Wrap(onPageOpenObject,Container);
}
set
{BaseDataObject[PdfName.PO] = value.BaseObject;}
}
/**
<summary>Gets/Sets the action to be performed when the page containing the annotation
becomes visible in the viewer application's user interface.</summary>
*/
public Action OnPageVisible
{
get
{
/*
NOTE: 'PV' entry may be undefined.
*/
PdfDirectObject onPageVisibleObject = BaseDataObject[PdfName.PV];
if(onPageVisibleObject == null)
return null;
return Action.Wrap(onPageVisibleObject,Container);
}
set
{BaseDataObject[PdfName.PV] = value.BaseObject;}
}
#endregion
#endregion
#endregion
}
}
|