<< Click to Display Table of Contents >> Navigation: Create a PDF Editor > .NET (C#) Example > Update GUI |
This method can be used to update the checked and enabled state of the buttons.
private void UpdateGUI()
{
for (int i = 0; i < toolStrip1.Items.Count; i++)
if ( toolStrip1.Items[i] is ToolStripButton )
{
ToolStripButton btn = toolStrip1.Items[i] as ToolStripButton;
int ac = (int)btn.Tag;
if (ac > 0 )
{
int state = pdfViewer1.Command(commands.COMPDF_ACTION_READSTATE, ac);
// 1=Checked, 2=Disabled
btn.Enabled = (state & 2)==0 ;
btn.CheckState = ((state & 1) == 1) ? CheckState.Checked : CheckState.Unchecked;
}
}
}
WPViewPDF triggers an event OnViewerMessage which can be used to call the method UpdateGUI.
private void pdfViewer1_OnViewerMessage(object Sender, ref int ID, int param)
{
switch (ID)
{
case commands.MSGPDF_NEEDPASSWORD:
{
break;
}
case commands.MSGPDF_CHANGESELPAGE: // Moved to different page (=wparam)
{
break;
}
case commands.MSGPDF_CHANGEVIEWPAGE: // Moved to different page (=wparam)
// MSGPDF_CHANGEVIEWPAGE is also triggered if the action mode was changed.
// This makes MSGPDF_CHANGEVIEWPAGE
// to update GUI elements, such a buttons
{
UpdateGUI();
break;
}
case commands.MSGPDF_CHANGEANNOT: // WPViewPDF 4 and 5 only: The annot have been moved, created or deleted.
{
break;
}
case commands.MSGPDF_CHANGESELOBJECT: // A Draw object has been selected or deselected
{
break;
}
}
}
This is the method which updates the state of the buttons