public Form1()
        {
            InitializeComponent();

            PDFXEdit.PXV_Inst Inst = pdfCtl.Inst;

            nMY_PANE_ID          = Inst.Str2ID(MY_PANE_ID, true);
            nMY_DOC_PANE_ID      = Inst.Str2ID(MY_DOC_PANE_ID, true);
            e_documentView_ready = Inst.Str2ID("e.documentView.ready", true);

            pdfCtl.EnableEventListening2(e_documentView_ready, true);             // to call pdfCtl_OnEvent

            // Register a callback to create custom panes during load of panes layout (from the settings)
            myPanesCreator = new CustomPanesCreator(Inst, this);
            Inst.RegisterViewCreator(myPanesCreator);

            settingsLocation = Inst.CreateString("HKCU\\Software\\{PDFXEdit.CustomPane.tmp}");
            try
            {
                Inst.LoadUserSettings(settingsLocation);                 // try to load all previously saved settings (including the custom layout of panes)
            }
            catch { };

            /////////////////////////////////////////////////////////////////////////////////////////
            // Check if our custom pane is already present in the mainView's layout, if not - add it
            /////////////////////////////////////////////////////////////////////////////////////////

            /**/
            // Method 1: use the Inst.ActiveMainView.Layout object
            PDFXEdit.IUIX_Layout layout = Inst.ActiveMainView.Panes.Layout;
            if (!HasPane(layout, nMY_PANE_ID))             // check if pane is present already in the layout
            {
                PDFXEdit.IPXV_View paneContainer;
                PDFXEdit.tagRECT   rc;
                rc.left = rc.top = rc.right = rc.bottom = 0;
                myPanesCreator.CreateNewView(Inst.ActiveMainView, layout.Obj, nMY_PANE_ID, "", ref rc, out paneContainer);
                if (paneContainer != null)
                {
                    PDFXEdit.tagSIZE sz;
                    sz.cx = sz.cy = defPaneSize;
                    layout.Insert(paneContainer.Obj,
                                  "My Custom Pane",
                                  layout.Root, ref sz,
                                  (int)UIX_LayoutItemStyleFlags.UIX_LayoutItemStyle_FixedSize);                                       // make pane fixed size (not proportional)
                }
            }

            /*/
             * // Method 2: check and manipulate the panes layout settings
             * bool paneAdded = false;
             * do
             * {
             *      // First we check whether the pane is already inside of the settings CAB
             *      PDFXEdit.ICabNode layout = Inst.Settings["MainView.Layout"]; // This is the layout CAB - here all of the Panes' settings are stored
             *                                                                                                                               // Then we have docked panes and floating panes
             *                                                                                                                               // Docked panes are stored in Root and floating panes are stored in FloatingRoots
             *                                                                                                                               // We'll need to run recursively through the children to see whether our custom pane is inside
             *
             *      // Lookup in docked panes
             *      if (HasPane(layout["Root"], MY_PANE_ID))
             *              break;
             *      // Lookup in floating panes
             *      if (HasPane(layout["FloatingRoots"], MY_PANE_ID))
             *              break;
             *      // If we don't yet have the pane added then in this sample we will have to add it as a docked pane
             *      ICabNode root = layout["Root"];
             *      // First level children of the Root node are place holders for panes
             *      // The root itself has a UIX_LayoutItemStyle_Splitted | UIX_LayoutItemStyle_VertSplitters | UIX_LayoutItemStyle_NoTabBar style
             *      // In this sample we will add panes to the rightmost splitter (where the search view and properties pane are)
             *      ICabNode placeHolders = root["Kids"];
             *      // Taking the last child for the rightmost placeholder and if it does not exist for some reason, we will add it
             *      // Alternatively the placeholders can be added to divide the Main View even more
             *      // For example, if you want your Custom view to be added before the Properties View and Search View then insert the placeholder before the placeholder that holds these views
             *      ICabNode placeHolder = null;
             *      if (placeHolders.Count == 0)
             *              placeHolder = placeHolders.Add();
             *      else
             *              placeHolder = placeHolders[placeHolders.Count - 1];
             *      // Now we have our new placeholder and we will have to add our Custom View to it
             *      ICabNode kid = placeHolder["Kids"].Add();
             *      // Now we will have to fill the newly added CAB node with needed data
             *      kid["ID"].v = MY_PANE_ID;
             *      kid["S"].v = (int)UIX_LayoutItemStyleFlags.UIX_LayoutItemStyle_FixedSize; // make pane fixed size (not proportional)
             *      kid["FW"].v = defPaneSize;  // fixed-width (UIX_LayoutItemStyle_FixedSize is required)
             *      kid["FH"].v = defPaneSize;  // fixed-height (UIX_LayoutItemStyle_FixedSize is required)
             *      kid["Title"].v = "My Custom Main Pane"; // Title for display
             *      paneAdded = true;
             * } while (false);
             *
             * if (paneAdded)
             *      Inst.ActiveMainView.LoadPanesLayout(); // reload the mofified layout of panes
             * /*/
            /**/
        }
        public Form1()
        {
            //Custom Instance initialization
            PDFXEdit.PXV_Inst Inst = new PDFXEdit.PXV_Inst();
            Inst.Init(null, "", "", "", "", (int)PDFXEdit.PXV_AppTypeFlags.PXV_AppType_SDK);

            InitializeComponent();

            //Creating Custom Pane's ID
            int nViewID = Inst.Str2ID(m_sCustomPaneID, true);

            //This part is necessary for correct pane loading from settings CAB - without this it won't show
            do
            {
                //First we check whether the pane is already inside of the settings CAB
                PDFXEdit.ICabNode layout = Inst.Settings["MainView.Layout"];                 //This is the layout CAB - here all of the Panes' settings are stored
                //Then we have docked panes and floating panes
                //Docked panes are stored in Root and floating panes are stored in FloatingRoots
                //We'll need to run recursively through the children to see whether our custom pane is inside
                bool bHasPane = HasPane(layout["Root"]);
                if (bHasPane)
                {
                    break;
                }
                bHasPane = HasPane(layout["FloatingRoots"]);
                if (bHasPane)
                {
                    break;
                }
                //If we don't yet have the pane added then in this sample we will have to add it as a docked pane
                ICabNode root = layout["Root"];
                //First level children of the Root node are place holders for panes
                //The root itself has a UIX_LayoutItemStyle_Splitted | UIX_LayoutItemStyle_VertSplitters | UIX_LayoutItemStyle_NoTabBar style
                //In this sample we will add panes to the rightmost splitter (where the search view and properties pane are)
                ICabNode placeHolders = root["Kids"];
                //Taking the last child for the rightmost placeholder and if it does not exist for some reason, we will add it
                //Alternatively the placeholders can be added to divide the Main View even more
                //For example, if you want your Custom view to be added before the Properties View and Search View then insert the placeholder before the placeholder that holds these views
                ICabNode placeHolder = null;
                if (placeHolders.Count == 0)
                {
                    placeHolder = placeHolders.Add();
                }
                else
                {
                    placeHolder = placeHolders[placeHolders.Count - 1];
                }
                //Now we have our new placeholder and we will have to add our Custom View to it
                ICabNode kid = placeHolder["Kids"].Add();
                //Now we will have to fill the newly added CAB node with needed data
                kid["ID"].v = m_sCustomPaneID;
                kid["S"].v  = 0;                //UIX_LayoutItemStyleFlags
                kid["FW"].v = 200;              //width
                //Flags
                //UIX_LayoutItemFlag_Hidden = 0x1,
                //UIX_LayoutItemFlag_Client = 0x4,
                //UIX_LayoutItemFlag_Minimized = 0x8,
                kid["F"].v = 0;
                //This will be displayed in the pane's title
                kid["Title"].v = "My Custom View";
            } while (false);

            //Creating a view creator so that the control will know how to initialize our Custom pane
            CustomViewCreator myViewCreator = new CustomViewCreator(Inst, m_sCustomPaneID, this);

            Inst.RegisterViewCreator(myViewCreator);
            //Loading panes layout
            Inst.ActiveMainView.LoadPanesLayout();

            //Showing our pane when the Control is initialized
            for (uint i = 0; i < Inst.ActiveMainView.Panes.Count; i++)
            {
                IPXV_View view = Inst.ActiveMainView.Panes[i];
                if (view?.ID == nViewID)
                {
                    Inst.ActiveMainView.Panes.Show(view);
                    break;
                }
            }
        }