IPX Control Commands Sample Without Menu

PDF-XChange Editor SDK for Developers

Moderators: Tracker Support, TrackerSupp-Daniel, Sean - Tracker, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
Lambchop
User
Posts: 10
Joined: Mon May 02, 2022 5:58 pm

IPX Control Commands Sample Without Menu

Post by Lambchop »

Hey Folks –
Is there a sample project that provides all of the major IPX functionality using code only? For example, I want to add an acroform field programmatically using the UI with mouse up/down events without using the IPX menu. Step 1: put the mouse into draw mode, Step 2: capture a region based on mouse down/up, Step 3: draw the corresponding selected acroform field. I have found numerous examples of Step #3, but I am not finding the example code for #1 and #2.

I would really like to see the same sample code for all of the basic menu item functionality like adding notes, draw objects, etc. that is used from the menu. Essentially, I really want to recreate the current IPX menu with my own code as I currently have my own menu controls that I want to use but I cannot find the standalone sample code to recreate the coding. I completely understand that showing all the code might be a headache but I am struggling to find the individual code snippets of Steps #1-#2-#3 for most all of the menu functions.

Again, I am only referencing simple stuff like: overlay management, select text, select regions, select comments, snapshot, add text, add image, highlight, line, pencil, distance, add sticky notes, copy, paste, ... you know ... simple stuff but all programmatically starting with the mouse down/up events to the method/event itself with the return object (if any). I have been reading the online help and it is hit or miss on finding code snippets.

So… all of this is probably me missing an obvious, but I would rather accept your internal mocking than me keep hitting my head on the wall for missing the obvious… :D :D :D my head is starting to hurt …
I have all of the GitHub sample code … but … what am I missing?
-Eric
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2190
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: IPX Control Commands Sample Without Menu

Post by Vasyl-Tracker Dev Team »

Step 1: put the mouse into draw mode, Step 2: capture a region based on mouse down/up, Step 3: draw the corresponding selected acroform field. I have found numerous examples of Step #3, but I am not finding the example code for #1 and #2.
Seems to be easy... You just need:
1. Open any document (as a user or via code). The document must have permission to add/edit form fields.
2. Activate a special tool for adding the corresponding type of form-filed via running the corresponding command:

pdfCtl.Inst.ExecUICmd("cmd.tool.editFields.mode.text");
- after this user will be able to use mouse/finger to create new text fields on the pages. Other commands for form-field creation tool(s) are:

cmd.tool.editFields.mode.text
cmd.tool.editFields.mode.check
cmd.tool.editFields.mode.radio
cmd.tool.editFields.mode.list
cmd.tool.editFields.mode.combo
cmd.tool.editFields.mode.button
cmd.tool.editFields.mode.signature
cmd.tool.editFields.mode.barcode
cmd.tool.editFields.mode.date
cmd.tool.editFields.mode.image

However, if you already handle mouse_down->mouse_move... mouse_up sequence of events and want to add via code the certain form field on mouse_up, then:

form = pdfCtl.Doc.CoreDoc.AcroForm;

IPXC_FormField field = form.CreateField("Text1", PXC_FormFieldType.FFT_Text, pageIndex, rectOnPage);
field.SetValueText("Sample Text");

// redraw corresponding page's region after adding new form field there:
pdfCtl.Doc.InvalidatePageRects(pageIndex, rectOnPage, 1);
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Lambchop
User
Posts: 10
Joined: Mon May 02, 2022 5:58 pm

Re: IPX Control Commands Sample Without Menu

Post by Lambchop »

Thank you Vasyl! I am getting stuck on simply creating the rectangle draw on the viewer. Super simple stuff like how to put the control into a select or draw mode (like what happens after I choose "edit text" or "insert text"). I want to recreate what your menu commands do from scratch (i.e. I want to put the viewer into edit/insert mode programmatically). The Tracker menu is freaking awesome, but there are several menu commands that I need granular control to display my own interfaces. That means I have to learn how to recreate all of your menu commands using my own code... which is why I want to see your code ... because I "don't" have that mouse down/up code that you guys are using :wink:
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2190
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: IPX Control Commands Sample Without Menu

Post by Vasyl-Tracker Dev Team »

In the sample, we provided you - you may see the one important string:

doc.ActivateTool(MarkupTool.ID);

- this code enables your custom tool to listen all UI-events from the PagesView window. And to disable it for your tool(==listener) you need to click any other tool on the Editor' toolbar, for example - 'Hand' tool. Or run it:

doc.ActivateTool(pdfCtl.Inst.Str2ID("tool.hand"));

===

To add your own item to existing Editor's toolbar (C#):

Code: Select all

public partial class MyCmdHandler : PDFXEdit.IUIX_CmdHandler
{
	MainFrm frm = null;
	public MyCmdHandler(MainFrm f) { frm = f; }
	public void OnCreateNewCtl(PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdBar pParent, out PDFXEdit.IUIX_Obj pCtl)
	{
		pCtl = null;
	}
	public void OnGetCtlSizes(PDFXEdit.IUIX_CmdItem pItem, ref PDFXEdit.tagSIZE nSize, ref PDFXEdit.tagSIZE nMinSize, ref PDFXEdit.tagSIZE nMaxSize)
	{ }
	public void OnGetItemSubMenu(PDFXEdit.IUIX_CmdItem pItem, out PDFXEdit.IUIX_CmdMenu pSubMenu)
	{
		pSubMenu = null;
	}
	public void OnDrawItemIcon(PDFXEdit.IUIX_RenderContext pRC, PDFXEdit.IUIX_CmdItem pItem, ref PDFXEdit.tagRECT stIconRect, ref PDFXEdit.tagRECT stClip)
	{ }
	public void OnGetItemState(PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdItem pItem, PDFXEdit.IUIX_Obj pOwner, out int nState)
	{
		PDFXEdit.IPXV_Document doc = frm.pdfCtl.Doc;
		if (doc == null)
		{
			nState = (int)PDFXEdit.UIX_CmdItemState.UIX_CmdItemState_Disabled;
			return;
		}
		nState = doc.ActiveTool == frm.MarkupTool ? (int)PDFXEdit.UIX_CmdItemState.UIX_CmdItemState_Checked : (int)PDFXEdit.UIX_CmdItemState.UIX_CmdItemState_Normal;
	}
	public void OnNotify(int nCode, PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdItem pItem, PDFXEdit.IUIX_Obj pOwner, uint nNotifyData)
	{
		if (nCode == (int)PDFXEdit.UIX_CmdNotifyCodes.UIX_CmdNotify_Exec)
		{
			PDFXEdit.IPXV_Document doc = frm.pdfCtl.Doc;
			if (doc != null)
			{
				// toggle
				if (doc.ActiveTool != frm.MarkupTool)
					doc.ActivateTool(frm.MarkupTool.ID);
				else
					doc.ActivateTool(frm.pdfCtl.Inst.Str2ID("tool.hand"));
			}
		}
	}
}
....

PDFXEdit.IUIX_Cmd cmd = uiInst.CmdManager.Cmds.AddNew("myUniqueCmdID", "", new MyCmdHandler(this));

cmd.Icon = uiInst.GetIcon("cmd.annot.redact.toRect");
cmd.Title = "My Custom Tool";
cmd.Tip = "My Custom Tool Tip";

PDFXEdit.IUIX_CmdBar bar = uiInst.CmdManager.GetFirstCmdBar(pdfCtl.Inst.Str2ID("cmdbar.file"));
bar.InsertItem(cmd, -1, 0, 0, -1);
And result of it:
image.png
HTH
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1214
Joined: Thu Sep 05, 2019 12:35 pm

Re: IPX Control Commands Sample Without Menu

Post by zarkogajic »

Hi Vasyl,
In the sample, we provided you...
I'm also interested in the "custom tool" sample ...

-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2190
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: IPX Control Commands Sample Without Menu

Post by Vasyl-Tracker Dev Team »

Here it is:

FullDemo.CustomTool.zip
(130.63 KiB) Downloaded 9 times
image.png
And Note for Lambchop: this attached sample project has fixed one bug with redrawing custom regions. Also we slightly improved the corresponding UI. So for you is better to use this new one...
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1214
Joined: Thu Sep 05, 2019 12:35 pm

Re: IPX Control Commands Sample Without Menu

Post by zarkogajic »

Thanks Vasyl.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 15291
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

IPX Control Commands Sample Without Menu

Post by Tracker Supp-Stefan »

:)
Lambchop
User
Posts: 10
Joined: Mon May 02, 2022 5:58 pm

Re: IPX Control Commands Sample Without Menu

Post by Lambchop »

I can only get my code to work using the Tracker menu, I cannot get a custom menu to work correctly. So just confirming ... there is no way for me to create my own menu? I am forced to you use the Tracker menu for everything?
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2190
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: IPX Control Commands Sample Without Menu

Post by Vasyl-Tracker Dev Team »

Well, you may hide all tracker's toolbars and add your own toolbar instead, via:

Code: Select all

// hide all standard toolbars above the pages view
{
	PDFXEdit.IUIX_Obj cmdPaneObj = pdfCtl.Inst.ActiveMainView.CmdPaneTop.Obj;
	PDFXEdit.IUIX_CmdManager cmdMan = uiInst.CmdManager;
	uint cmdBarsCnt = cmdMan.CmdBarsCount;
	for (uint i = 0; i < cmdBarsCnt; i++)  {
		PDFXEdit.IUIX_CmdBar cbar = cmdMan.CmdBar[(int)i];
		if (cbar.Obj.IsChildOf(cmdPaneObj))
			cbar.Hide();
	}
}

// add own toobar instead of them
{
	PDFXEdit.tagRECT rc;
	rc.left = rc.right = rc.top = rc.bottom = 0;
	PDFXEdit.IUIX_CmdBar bar = uiInst.CreateCmdBar(pdfCtl.Inst.ActiveMainView.Obj, rc, "myCmdBar", "My Toolbar");
	pdfCtl.Inst.ActiveMainView.CmdPaneTop.InsertBar(bar, -1, -1, true);
	// add own commands to this custom toolbar. Also here you may add any standard cmd too...
}

// to show all cmdPanes (hidden by default)
pdfCtl.VisibleCmdPanes = (uint)PDFXEdit.PXV_VisibleCmdPanes.PXV_VisibleCmdPanes_All;

HTH
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Post Reply