Ejemplo n.º 1
0
        static public bool HasPane(ICabNode root, string paneID)
        {
            ICabNode kids = root["Kids"];

            for (uint i = 0; i < kids.Count; i++)
            {
                ICabNode kid = kids[i];
                if ((kid == null) || (!kid.Valid))
                {
                    continue;
                }
                if (kid["ID"].String == paneID)
                {
                    return(true);
                }
                if (HasPane(kid, paneID))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
 public void OptimizeDocument(OperationParameters operation)
 {
     try
     {
         var      nId     = MInst.Str2ID(@"op.document.optimize", false);
         var      op      = MInst.CreateOp(nId);
         var      input   = op.Params.Root["Input"];
         var      impPath = FsInst.DefaultFileSys.StringToName(operation.FilePath);
         ICabNode options = op.Params.Root["Options"];
         ICabNode images  = options["Images"];
         images["Enabled"].v     = true;
         images["ReducedOnly"].v = false;
         ICabNode comp = images["Comp"];
         //set all methods to retain existing
         comp["Color.Method"].v     = 0;
         comp["Grayscale.Method"].v = 0;
         comp["Indexed.Method"].v   = 0;
         comp["Mono.Method"].v      = 0;
         //set my params
         var opParam = operation.CompMode + "." + "Method";
         comp[opParam].v = operation.Method;
         if (((operation.CompMode == "Color") || (operation.CompMode == "Grayscale")) &&
             ((operation.Method == 1) || (operation.Method == 2)))
         {
             comp[operation.CompMode + "." + "JPEGQuality"].v = operation.Quality;
         }
         var resDoc    = MPxcInst.OpenDocumentFrom(impPath, null);
         input.Add().v = resDoc;
         op.Do();
         resDoc.WriteToFile(operation.OutputFilePath);
         resDoc.Close();
         operation.ErrCodes = string.Empty;
     }
     catch (Exception e)
     {
         operation.ErrCodes = e.Message;
         Console.WriteLine(e.Message);
     }
 }
Ejemplo n.º 3
0
        public bool HasPane(ICabNode root)
        {
            //Getting children of the current root to see whether they have the ID equal to m_sCustomPaneID
            ICabNode kids = root["Kids"];

            for (uint i = 0; i < kids.Count; i++)
            {
                ICabNode kid = kids[i];
                if ((kid == null) || (!kid.Valid))
                {
                    continue;
                }
                if (kid["ID"].String == m_sCustomPaneID)
                {
                    return(true);
                }
                if (HasPane(kid))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        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;
                }
            }
        }