History - how to remove (missing) items  SOLVED

PDF-XChange Editor SDK for Developers

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

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
zarkogajic
User
Posts: 668
Joined: Thu Sep 05, 2019 12:35 pm

History - how to remove (missing) items

Post by zarkogajic » Mon Feb 10, 2020 12:29 pm

Hi support,

I'd like to remove the item from the history list - if the file in the history is missing, that is if "the system cannot find the file specified" would appear as the error in the preview.

Is there an event to catch (and I've tried e.history.itemAdded but no luck) when the open history is populated from the history settings file to catch and do the above ?


-žarko

User avatar
Sasha - Tracker Dev Team
User
Posts: 4931
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team » Mon Feb 10, 2020 1:18 pm

Hello žarko,

Sadly there is no method or event to catch to tweak the item insertion. There is an End-User solution to this one, though it requires the dialog to popup. History View/Options/Clear.../Remove/All Broken

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 668
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic » Mon Feb 10, 2020 2:21 pm

Hi Alex,

Let's say I do not mind popup to get visible briefly ... can this be done from code:

image.png

?


User avatar
Sasha - Tracker Dev Team
User
Posts: 4931
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team » Tue Feb 11, 2020 10:31 am

Hello žarko,

There is an easier way - execute an cmd.historyList.clear command and that dialog will show. Before that, you can set the Operations.ClearHistory.Filter setting to 1 (Broken) and the checkbox will select the needed item. Then you should catch the e_ShowModal event in the OnEventMonitor method:

Code: Select all

public void OnEventMonitor(PDFXEdit.IUIX_Obj pTarget, PDFXEdit.IUIX_Event pEvent)
			{
				if (pEvent.Code == (uint)PDFXEdit.UIX_EventCodes.e_ShowModal)
				{
					IntPtr outPtr;
					pTarget.QueryImpl(typeof(PDFXEdit.IUIX_Dialog).GUID, null, out outPtr);
					PDFXEdit.IUIX_Dialog dlg = (PDFXEdit.IUIX_Dialog)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
					if (dlg == null)
						return;
					//Here check the dialog ID - should be DlgClearHistory
					
					//
					PDFXEdit.IUIX_Obj btnObj = dlg.GetItem("btn.ok");
					btnObj.QueryImpl(typeof(PDFXEdit.IUIX_Button).GUID, null, out outPtr);
					PDFXEdit.IUIX_Button btn = (PDFXEdit.IUIX_Button)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
					objectTarget = new ObjectEventTarget(btn.Obj);
					btn.AutoClick(0);
				}
			}

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 668
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic » Wed Feb 12, 2020 9:10 am

Hi Alex,
execute an cmd.historyList.clear command and that dialog will show.
I've tried this (so only execute that command), but nothing happens :( Should I do something before?

p.s.
I can execute "cmd.manageHistory", but from there I would then need to auto click the "Clear..." button and that will dispaly the "Clear History" dialog...

-žarko

User avatar
Sasha - Tracker Dev Team
User
Posts: 4931
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team » Wed Feb 12, 2020 9:55 am

Hello zarko,

You will have to specify the owner of the command - and that is the HistoryView:

Code: Select all

int nID = pdfCtl.Inst.Str2ID("historyView");
PDFXEdit.IPXV_View view = pdfCtl.Frame.View.Panes.Active[nID];
pdfCtl.Inst.ExecUICmd("cmd.historyList.clear", view.Obj);
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 668
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic » Wed Feb 12, 2020 10:18 am

Hi Alex,

Thanks. This helped and the dialog is displayed.

I have the btn but nothing happens after AutoClick(0) - the dialog does not get closed nor are the broken items removed from the history.

Also, what is this for:

"objectTarget = new ObjectEventTarget(btn.Obj);"


User avatar
Sasha - Tracker Dev Team
User
Posts: 4931
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team » Thu Feb 13, 2020 10:33 am

Hello žarko,

Code: Select all

objectTarget = new ObjectEventTarget(btn.Obj);
This is the leftovers of the code piece that can help you listen to the clicked event for example (made a sample for someone some time ago).

As for the autoclick - it seems that you will need to specify at least 1 second as a timeout (1 as a parameter - then it will work). Though the dialog will hang for a second.

I have a solution to this one that I have made earlier for my own purposes - I've emulated a physical user click on that button. Here's the code that should help:

Code: Select all

					PDFXEdit.UIX_NotifyInfo ni = new PDFXEdit.UIX_NotifyInfo();
						ni.nCode = (int)PDFXEdit.UIX_NotifyCodes.UIX_Notify_Clicked;
						ni.pFrom = dlg.GetItem("btn.ok");
						IntPtr ptr;
						ni.pFrom.QueryImpl(typeof(PDFXEdit.IUIX_ObjImpl).GUID, null, out ptr);
						PDFXEdit.IUIX_ObjImpl uiObjImpl = (PDFXEdit.IUIX_ObjImpl)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(ptr);
						ni.pFromImpl = uiObjImpl;
						ni.nFromID = ni.pFrom.ID;
						ni.pData = 0;

						evt.nCode = (int)PDFXEdit.UIX_EventCodes.e_Notify;
						IntPtr resPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ni));
						System.Runtime.InteropServices.Marshal.StructureToPtr(ni, resPtr, false);
						evt.nParam1 = (uint)resPtr;
						SV.Obj.SendRawEvent(ref evt);

						Marshal.FreeHGlobal(resPtr);
						resPtr = IntPtr.Zero;
						System.Runtime.InteropServices.Marshal.Release(ptr);
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 668
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic » Thu Feb 13, 2020 10:03 pm

Hi Alex,

Thanks, will try the "emulated click" ..

Btw, what is "SV" in "SV.Obj.SendRawEvent(ref evt);" ?


User avatar
Sasha - Tracker Dev Team
User
Posts: 4931
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team » Fri Feb 14, 2020 7:47 am

Hello žarko,

Call this for your dialog's object.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 668
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic » Tue Feb 18, 2020 12:30 pm

Alex,

After a successful mimic-click, now we have this dialog :)

image.png
image.png (95.69 KiB) Viewed 1187 times

Can I somehow pre-set "yes, and don't ask again" ?


User avatar
Sasha - Tracker Dev Team
User
Posts: 4931
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: History - how to remove (missing) items  SOLVED

Post by Sasha - Tracker Dev Team » Tue Feb 18, 2020 12:37 pm

Hello žarko,

You can set the Prompts.AskForDeleteHistory setting to false - that dialog window won't be shown afterwards.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 668
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic » Tue Feb 18, 2020 12:50 pm

Hi Alex,

Thanks, that does it :)


User avatar
Will - Tracker Supp
Site Admin
Posts: 6905
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: History - how to remove (missing) items

Post by Will - Tracker Supp » Tue Feb 18, 2020 2:26 pm

:D
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com

Post Reply