Page 1 of 1

Disable properties on annotaion placement or selection

Posted: Thu Jul 20, 2017 9:46 am
by lidds
I want to hide the "General" properties of all annotation element from the properties pane. I have got the code that works, as shown below, however what I want is for this code to be run automatically when a new annotation element is placed, selected etc. Obviously I would need to put this in an event to fire my code, however I am unsure of the event to use??

Code: Select all

    Public Sub disableProperties()
        Dim nID As Integer = Me.docPreview.Inst.Str2ID("propertiesView")
        Dim view As PDFXEdit.IPXV_View = Me.docPreview.Frame.View.Panes.Active(nID)
        If view IsNot Nothing Then
            Dim outPtr As IntPtr
            view.Obj.QueryImpl(GetType(PDFXEdit.IUIX_PropList).GUID, Nothing, outPtr)
            Dim propList As PDFXEdit.IUIX_PropList = DirectCast(System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr), PDFXEdit.IUIX_PropList)
            If propList IsNot Nothing Then
                Dim listPtr As IntPtr
                propList.Obj.QueryImpl(GetType(PDFXEdit.IUIX_List).GUID, Nothing, listPtr)
                Dim list As PDFXEdit.IUIX_List = DirectCast(System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(listPtr), PDFXEdit.IUIX_List)
                If list IsNot Nothing Then
                    'Removes general properties
                    list.RemoveGroups(0, 1)
                End If
            End If
        End If
    End Sub
Current event code within my application that maybe I could use?

Code: Select all

        Public Sub OnEvent(pSender As PDFXEdit.IUIX_Obj, pEvent As PDFXEdit.IUIX_Event) Implements PDFXEdit.IUIX_ObjImpl.OnEvent
            If pEvent.Code = CInt(&H204) Then

                Dim pt As PDFXEdit.tagPOINT
                pt.x = pEvent.Pos.x
                pt.y = pEvent.Pos.y
                Dim screenPt As PDFXEdit.tagPOINT
                Dim nHitTestCode As Integer = 0
                Dim annot As PDFXEdit.IPXC_Annotation = Parent.docPreview.Doc.ActiveView.PagesView.GetAnnotFromPt(pt, nHitTestCode)

                If annot IsNot Nothing Then
                    Dim linkAnnotType As UInteger = Parent.pxsInst.StrToAtom("Link")
                    If annot.Type = linkAnnotType Then
                        pEvent.Handled = True
                    End If
                Else
                    pSender.ClientPtToScreen(pt, screenPt)
                    Parent.RadialMenu1.ShowPopup(New Point(screenPt.x, screenPt.y))
                End If
            ElseIf pEvent.Code = CInt(PDFXEdit.UIX_EventCodes.e_BeforeDestroy) Then
                Dispose()
            ElseIf pEvent.Code = CInt(PDFXEdit.UIX_EventCodes.e_Last) Then
                Dispose()
            End If
        End Sub
Thanks in advance

Simon

Re: Disable properties on annotaion placement or selection

Posted: Thu Jul 20, 2017 9:50 am
by Sasha - Tracker Dev Team
Hello Simon,

The correct event to use in this case is https://sdkhelp.pdf-xchange.com/vie ... s_inserted
Please look at the FullDemo application on how to use the Control's events. And also, do not forget to register/unregister them.

Cheers,
Alex

Re: Disable properties on annotaion placement or selection

Posted: Thu Jul 20, 2017 10:28 am
by lidds
I've looked in the FullDemo and have found the following section that refers to IPXV_AnnotsEvent however if I uncomment the code in the FullDemo is errors??

Code: Select all

private void pdfCtl_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
		{
			Debug.WriteLine("pdfCtl.OnEvent: e.nEventID=={0}", e.nEventID);

            //PDFXEdit.IPXV_AnnotsEvent annotsEvent = (PDFXEdit.IPXV_AnnotsEvent)e.pEvent;
            //if (annotsEvent != null)
            //{
            //    uint squareAnnotType = pxsInst.StrToAtom("Square");
            //    // Other types:
            //    //	Link,
            //    //	Popup,
            //    //	Movie,
            //    //	Widget,
            //    //	Screen,
            //    //	PrinterMark,
            //    //	TrapNet,
            //    //	Watermark,
            //    //	3D,
            //    //	RichMedia,
            //    //	Text,
            //    //	FreeText,
            //    //	Line,
            //    //	Square,
            //    //	Circle,
            //    //	Polygon,
            //    //	PolyLine,
            //    //	Highlight,
            //    //	Underline,
            //    //	Squiggly,
            //    //	StrikeOut,
            //    //	Stamp,
            //    //	Caret,
            //    //	Ink,
            //    //	FileAttachment,
            //    //	Sound,
            //    //	Redact,
            //    //	Projection,

            //    uint annotsCnt = annotsEvent.Items.Count;
            //    for (uint i = 0; i < annotsCnt; i++)
            //    {
            //        PDFXEdit.IPXC_Annotation annot = annotsEvent.Items[i];
            //        if (squareAnnotType == annot.Type)
            //        {
            //            uint pageIndex = annot.Page.Number;
            //        }
            //    }
            //}

Re: Disable properties on annotaion placement or selection

Posted: Thu Jul 20, 2017 11:14 am
by Sasha - Tracker Dev Team
You don't need to uncomment that code - just write down your event in the IDS enum and then use it as the other ones available in sample.

Cheers,
Alex

Re: Disable properties on annotaion placement or selection

Posted: Thu Aug 31, 2017 11:29 am
by lidds
Alex,

I still cannot get this to work I have added my code to fire when the op.annots.addNew event is triggered however it still does not hide the properties. Is is as if another event is firing that I need to capture, maybe properties pane update event or something?

Code: Select all

        ElseIf e.nEventID = nIDS(CInt(IDS.e_operExecuted)) Then
            Try
                Dim oper As PDFXEdit.IOperation = DirectCast(e.pFrom, PDFXEdit.IOperation)
                Dim input As PDFXEdit.ICabNode = oper.Params.Root("Input")
                Dim commands As String = Me.docPreview.Inst.ID2Str(oper.ID)

                Console.WriteLine("eExecuted: " & commands)

                If oper.ID = Me.docPreview.Inst.Str2ID("op.annots.addNew", False) Then
                    disableProperties()
                End If
Thanks in advance

Simon

Re: Disable properties on annotaion placement or selection

Posted: Thu Aug 31, 2017 12:11 pm
by Sasha - Tracker Dev Team
Hello Simon,

I've read the problem again and I think that the correct event would be the https://sdkhelp.pdf-xchange.com/vie ... on_changed event. If you catch it - get the ActiveSel from the document and see whether it's an IPXV_AnnotSelection. If so, call your code.

Cheers,
Alex

Re: Disable properties on annotaion placement or selection

Posted: Thu Aug 31, 2017 1:38 pm
by lidds
Alex,

I have done the following but it still does not hide the properties??

Code: Select all

        ElseIf e.nEventID = nIDS(CInt(IDS.e_docSelection_changed)) Then
            Try
                Dim annotsSelected As PDFXEdit.IPXV_AnnotSelection = DirectCast(Me.docPreview.Doc.ActiveSel, PDFXEdit.IPXV_AnnotSelection)
                If annotsSelected IsNot Nothing Then
                    disableProperties()
                End If
            Catch ex As Exception
                e.pEvent.Result = 1
                e.pEvent.Handled = True
            End Try
Thanks

Simon

Re: Disable properties on annotaion placement or selection

Posted: Thu Aug 31, 2017 1:43 pm
by Sasha - Tracker Dev Team
Hello Simon,

Are you catching the breakpoint there and also does your disabling code work at all?

Cheers,
Alex

Re: Disable properties on annotaion placement or selection

Posted: Thu Aug 31, 2017 1:50 pm
by lidds
Alex,

Yes I am catching the break point there and the disableProperties code does work as I have just added a button to fire the method and it works. It must be firing some kind of update properties pane event after the e.docSelection.changed event.

Simon

Re: Disable properties on annotaion placement or selection

Posted: Fri Sep 01, 2017 2:20 pm
by Sasha - Tracker Dev Team
Hello Simon,

I don's see any event that is being fired after the properties update (and they do update after the selection change event). So basically that means that you won't be able to do this with the events alone.

Cheers,
Alex

Re: Disable properties on annotaion placement or selection

Posted: Sun Sep 03, 2017 7:53 am
by lidds
Alex,

Instead of hiding them, is it possible to make the Subject, Author, Name and Locked properties readonly so the user cannot change them?

Thanks

Simon

Re: Disable properties on annotaion placement or selection

Posted: Tue Sep 05, 2017 9:32 am
by Sasha - Tracker Dev Team
Hello Simon,

I've asked a developer who is responsible for this feature - waiting for him to reply.

Cheers,
Alex

Re: Disable properties on annotaion placement or selection

Posted: Mon Sep 11, 2017 12:10 am
by lidds
Alex,

I was wondering if your developer has got back to you on this?

Thanks

Simon

Re: Disable properties on annotaion placement or selection

Posted: Mon Sep 11, 2017 7:40 am
by Sasha - Tracker Dev Team
Hello Simon,

Just had a chat with him - he said that he'll discuss this and will hopefully reply tomorrow.

Cheers,
Alex

Re: Disable properties on annotaion placement or selection

Posted: Fri Sep 15, 2017 11:20 am
by lidds
Alex,

Any news back from the developer on this?

Thanks

Simon

Re: Disable properties on annotaion placement or selection

Posted: Fri Sep 15, 2017 11:54 am
by Sasha - Tracker Dev Team
Hello Simon,

The appropriate User Story was assigned to that developer - he will implement it when he has time.

Cheers,
Alex