Page 1 of 1

History - how to remove (missing) items

Posted: Mon Feb 10, 2020 12:29 pm
by zarkogajic
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

Re: History - how to remove (missing) items

Posted: Mon Feb 10, 2020 1:18 pm
by Sasha - Tracker Dev Team
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

Re: History - how to remove (missing) items

Posted: Mon Feb 10, 2020 2:21 pm
by zarkogajic
Hi Alex,

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

image.png

?


Re: History - how to remove (missing) items

Posted: Tue Feb 11, 2020 10:31 am
by Sasha - Tracker Dev Team
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

Re: History - how to remove (missing) items

Posted: Wed Feb 12, 2020 9:10 am
by zarkogajic
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

Re: History - how to remove (missing) items

Posted: Wed Feb 12, 2020 9:55 am
by Sasha - Tracker Dev Team
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

Re: History - how to remove (missing) items

Posted: Wed Feb 12, 2020 10:18 am
by zarkogajic
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);"


Re: History - how to remove (missing) items

Posted: Thu Feb 13, 2020 10:33 am
by Sasha - Tracker Dev Team
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

Re: History - how to remove (missing) items

Posted: Thu Feb 13, 2020 10:03 pm
by zarkogajic
Hi Alex,

Thanks, will try the "emulated click" ..

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


Re: History - how to remove (missing) items

Posted: Fri Feb 14, 2020 7:47 am
by Sasha - Tracker Dev Team
Hello žarko,

Call this for your dialog's object.

Cheers,
Alex

Re: History - how to remove (missing) items

Posted: Tue Feb 18, 2020 12:30 pm
by zarkogajic
Alex,

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

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

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


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

Posted: Tue Feb 18, 2020 12:37 pm
by Sasha - Tracker Dev Team
Hello žarko,

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

Cheers,
Alex

Re: History - how to remove (missing) items

Posted: Tue Feb 18, 2020 12:50 pm
by zarkogajic
Hi Alex,

Thanks, that does it :)


Re: History - how to remove (missing) items

Posted: Tue Feb 18, 2020 2:26 pm
by Will - Tracker Supp
:D