Disable properties on annotaion placement or selection

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, 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
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Disable properties on annotaion placement or selection

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable properties on annotaion placement or selection

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Disable properties on annotaion placement or selection

Post 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;
            //        }
            //    }
            //}
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable properties on annotaion placement or selection

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Disable properties on annotaion placement or selection

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable properties on annotaion placement or selection

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Disable properties on annotaion placement or selection

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable properties on annotaion placement or selection

Post by Sasha - Tracker Dev Team »

Hello Simon,

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

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Disable properties on annotaion placement or selection

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable properties on annotaion placement or selection

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Disable properties on annotaion placement or selection

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable properties on annotaion placement or selection

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Disable properties on annotaion placement or selection

Post by lidds »

Alex,

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

Thanks

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

Re: Disable properties on annotaion placement or selection

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Disable properties on annotaion placement or selection

Post by lidds »

Alex,

Any news back from the developer on this?

Thanks

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

Re: Disable properties on annotaion placement or selection

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply