Ejemplo n.º 1
0
        static public int ConvertToPDF(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            IIXC_Inst  ixcInst = Parent.m_pxcInst.GetExtension("IXC");
            IAUX_Inst  auxInst = Parent.m_pxcInst.GetExtension("AUX");
            IPXC_Pages pages   = Parent.m_CurDoc.Pages;
            IPXC_Page  Page    = pages[0];
            double     nHeight = 0.0;
            double     nWidth  = 0.0;

            Page.GetDimension(out nWidth, out nHeight);
            IIXC_Image img = ixcInst.CreateEmptyImage();

            img.Load(System.Environment.CurrentDirectory + "\\Images\\Editor_welcome.png");
            IIXC_Page           ixcPage = img.GetPage(0);
            IPXC_Image          pxcImg  = Parent.m_CurDoc.AddImageFromIXCPage(ixcPage);
            IPXC_ContentCreator CC      = Parent.m_CurDoc.CreateContentCreator();
            PXC_Rect            rcImg   = new PXC_Rect();

            CC.SaveState();
            {
                //Proportional resize rectangle calculation
                {
                    double k1 = nWidth / nHeight;
                    double k2 = (double)pxcImg.Width / pxcImg.Height;
                    if (k1 >= k2)
                    {
                        rcImg.top   = nHeight;
                        rcImg.right = nWidth / 2.0 + rcImg.top * k2 / 2.0;
                        rcImg.left  = nWidth / 2.0 - rcImg.top * k2 / 2.0;
                    }
                    else
                    {
                        rcImg.right  = nWidth;
                        rcImg.top    = nHeight / 2.0 + rcImg.right / k2 / 2.0;
                        rcImg.bottom = nHeight / 2.0 - rcImg.right / k2 / 2.0;
                    }
                }
                //Moving the image rectangle to the center

                PXC_Rect rcImage = new PXC_Rect();
                rcImage.right = 1;
                rcImage.top   = 1;
                PXC_Matrix matrix = Page.GetMatrix(PXC_BoxType.PBox_PageBox);
                matrix = auxInst.MathHelper.Matrix_RectToRect(ref rcImage, ref rcImg);
                CC.ConcatCS(ref matrix);
                CC.PlaceImage(pxcImg);
            }
            CC.RestoreState();
            Page.PlaceContent(CC.Detach());

            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_All);
        }
Ejemplo n.º 2
0
        static public void AddStandardStampByID(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }
            IPXC_Pages         pages        = Parent.m_CurDoc.Pages;
            IPXC_Page          firstPage    = pages[0];
            PXC_Rect           rcPB         = firstPage.get_Box(PXC_BoxType.PBox_PageBox);
            IPXC_StampsManager stampManager = Parent.m_pxcInst.StampsManager;
            IPXC_StampInfo     si           = stampManager.FindStamp("Draft");
            //Creating stamp annotation
            IPXS_Inst pSInt   = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS");
            uint      nStamp  = pSInt.StrToAtom("Stamp");
            double    nHeight = 0;
            double    nWidth  = 0;

            si.GetSize(out nWidth, out nHeight);
            PXC_Rect rc;

            rc.left   = rcPB.left - nWidth / 2.0 + nHeight / 2.0;
            rc.right  = rcPB.left + nWidth / 2.0 + nHeight / 2.0;
            rc.top    = rcPB.top;
            rc.bottom = rc.top - nWidth;
            IPXC_Annotation      annot     = firstPage.InsertNewAnnot(nStamp, ref rc, 0);
            IPXC_AnnotData_Stamp stampData = (IPXC_AnnotData_Stamp)annot.Data;

            stampData.Rotation = 90;
            stampData.SetStampName(si.ID);
            annot.Data = stampData;
            Marshal.ReleaseComObject(firstPage);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 3
0
        static public int RemoveAttachment(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                return(0);
            }

            if (Parent.AttachmentView.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select attachment from the Attachments list.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(0);
            }

            Form1.ListItemAttachment currentAnnot = Parent.AttachmentView.SelectedItems[0] as Form1.ListItemAttachment;
            if (currentAnnot.SubItems[currentAnnot.SubItems.Count - 1].Text == "Embedded File Item")
            {
                IPXC_NameTree attachments = Parent.m_CurDoc.GetNameTree("EmbeddedFiles");
                attachments.Remove(currentAnnot.SubItems[0].Text);
                return((int)Form1.eFormUpdateFlags.efuf_Attachments | (int)Form1.eFormUpdateFlags.efuf_Annotations);
            }
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  page  = pages[(uint)(currentAnnot.m_nPageNumber)];

            page.RemoveAnnots((uint)currentAnnot.m_nIndexOnPage, 1);

            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);


            return((int)Form1.eFormUpdateFlags.efuf_Attachments | (int)Form1.eFormUpdateFlags.efuf_Annotations);
        }
Ejemplo n.º 4
0
        static public void AddCheckBoxFormFields(Form1 Parent)
        {
            int index = 1;
            //delegate string CheckNamesFields(IPXC_Document Doc, string fieldName, ref int x);
            CheckNamesFields checkNamesFields = (IPXC_Document Doc, string fName, ref int inx) =>
            {
                string sFieldName = "";
                uint   i          = 0;
                do
                {
                    sFieldName = fName + inx;
                    IPXC_FormField ff = Doc.AcroForm.GetFieldByName(sFieldName);
                    if (ff == null)
                    {
                        break;
                    }
                    inx++;
                    i++;
                }while (i <= Doc.AcroForm.FieldsCount);
                inx++;
                return(sFieldName);
            };

            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            PXC_Rect rc = new PXC_Rect();

            rc.top   = 800;
            rc.right = 600;

            //Adding uncheked checkbox
            IPXC_UndoRedoData urD   = null;
            IPXC_Pages        pages = Parent.m_CurDoc.Pages;
            IPXC_Page         Page  = pages.InsertPage(0, rc, out urD);
            PXC_Rect          rcPB  = new PXC_Rect();

            rcPB.left   = 3.2 * 72.0;
            rcPB.right  = rcPB.left + 0.5 * 72.0;
            rcPB.top    = rc.top - 0.2 * 72.0;
            rcPB.bottom = rcPB.top - 0.5 * 72.0;             //top is greater then bottom (PDF Coordinate System)
            IPXC_FormField checkBoxUnch = Parent.m_CurDoc.AcroForm.CreateField(checkNamesFields(Parent.m_CurDoc, "CheckBox", ref index), PXC_FormFieldType.FFT_CheckBox, 0, ref rcPB);

            Marshal.ReleaseComObject(checkBoxUnch);

            //Adding cheked checkbox
            rcPB.right = rc.right - 3.2 * 72.0;
            rcPB.left  = rcPB.right - 0.5 * 72.0;
            IPXC_FormField        checkBoxCh = Parent.m_CurDoc.AcroForm.CreateField(checkNamesFields(Parent.m_CurDoc, "CheckBox", ref index), PXC_FormFieldType.FFT_CheckBox, 0, ref rcPB);
            IPXC_Annotation       annot      = checkBoxCh.Widget[0];
            IPXC_AnnotData_Widget widget     = (IPXC_AnnotData_Widget)annot.Data;

            checkBoxCh.CheckWidget((uint)checkBoxCh.GetWidgetIndex(annot), true);
            Marshal.ReleaseComObject(checkBoxCh);
            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 5
0
        static public void AddDateFormFields(Form1 Parent)
        {
            int index = 1;
            //delegate string CheckNamesFields(IPXC_Document Doc, string fieldName, ref int x);
            CheckNamesFields checkNamesFields = (IPXC_Document Doc, string fName, ref int inx) =>
            {
                string sFieldName = "";
                uint   i          = 0;
                do
                {
                    sFieldName = fName + inx;
                    IPXC_FormField ff = Doc.AcroForm.GetFieldByName(sFieldName);
                    if (ff == null)
                    {
                        break;
                    }
                    inx++;
                    i++;
                }while (i <= Doc.AcroForm.FieldsCount);
                inx++;
                return(sFieldName);
            };

            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            PXC_Rect rc = new PXC_Rect();

            rc.top   = 800;
            rc.right = 600;

            //Adding Date
            IPXC_UndoRedoData urD   = null;
            IPXC_Pages        pages = Parent.m_CurDoc.Pages;
            IPXC_Page         Page  = pages.InsertPage(0, rc, out urD);
            PXC_Rect          rcPB  = new PXC_Rect();

            rcPB.left   = 2.5 * 72.0;
            rcPB.right  = rc.right - 2.5 * 72.0;
            rcPB.top    = rc.top - 1.5 * 72.0;
            rcPB.bottom = rcPB.top - 0.5 * 72.0;             //top is greater then bottom (PDF Coordinate System)

            IPXC_FormField        Date        = Parent.m_CurDoc.AcroForm.CreateField(checkNamesFields(Parent.m_CurDoc, "Date", ref index), PXC_FormFieldType.FFT_Text, 0, ref rcPB);
            IPXC_Annotation       annot       = Date.Widget[0];
            IPXC_AnnotData_Widget widget      = (IPXC_AnnotData_Widget)annot.Data;
            IPXC_ActionsList      actionsList = Parent.m_CurDoc.CreateActionsList();

            //Set script to ActionList
            actionsList.AddJavaScript("var now = new Date()\n" +
                                      "this.getField(\"Date1\").value = (now.getMonth() + 1) + \"/\" + now.getDate() + \"/\" + now.getFullYear(); ");
            Date.Actions[PXC_TriggerType.Trigger_Format] = actionsList;
            Marshal.ReleaseComObject(Date);
            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 6
0
        static public void AddComboBoxFormFields(Form1 Parent)
        {
            int index = 1;
            //delegate string CheckNamesFields(IPXC_Document Doc, string fieldName, ref int x);
            CheckNamesFields checkNamesFields = (IPXC_Document Doc, string fName, ref int inx) =>
            {
                string sFieldName = "";
                uint   i          = 0;
                do
                {
                    sFieldName = fName + inx;
                    IPXC_FormField ff = Doc.AcroForm.GetFieldByName(sFieldName);
                    if (ff == null)
                    {
                        break;
                    }
                    inx++;
                    i++;
                }while (i <= Doc.AcroForm.FieldsCount);
                inx++;
                return(sFieldName);
            };

            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            PXC_Rect rc = new PXC_Rect();

            rc.top   = 800;
            rc.right = 600;

            //Adding ComboBox with items
            IPXC_UndoRedoData urD   = null;
            IPXC_Pages        pages = Parent.m_CurDoc.Pages;
            IPXC_Page         Page  = pages.InsertPage(0, rc, out urD);
            PXC_Rect          rcPB  = new PXC_Rect();

            rcPB.left   = 1.5 * 72.0;
            rcPB.right  = rc.right - 1.5 * 72.0;
            rcPB.top    = rc.top - 1.5 * 72.0;
            rcPB.bottom = rcPB.top - 0.5 * 72.0;             //top is greater then bottom (PDF Coordinate System)

            IPXC_FormField comboBox = Parent.m_CurDoc.AcroForm.CreateField(checkNamesFields(Parent.m_CurDoc, "ComboBox", ref index), PXC_FormFieldType.FFT_ComboBox, 0, ref rcPB);

            comboBox.InsertOptRecord("lable1", "First Item");
            comboBox.InsertOptRecord("lable2", "Second Item");
            comboBox.InsertOptRecord("lable3", "Third Item");
            comboBox.InsertOptRecord("lable4", "Forth Item");
            comboBox.SelectItem(1, true);
            Marshal.ReleaseComObject(comboBox);
            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
        }
        static public int AddTextAnnotation(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            IPXC_UndoRedoData urData    = null;
            IPXC_Pages        pages     = Parent.m_CurDoc.Pages;
            IPXC_Page         firstPage = pages[0];
            PXC_Rect          rcPage    = firstPage.get_Box(PXC_BoxType.PBox_PageBox);

            Marshal.ReleaseComObject(firstPage);
            IPXC_Page page    = pages.InsertPage(0, ref rcPage, out urData);
            IPXS_Inst pxsInst = Parent.m_pxcInst.GetExtension("PXS");
            IAUX_Inst auxInst = Parent.m_pxcInst.GetExtension("AUX");
            //Getting Text annotation atom for the InsertNewAnnot method
            uint nText = pxsInst.StrToAtom("Text");

            double   nCX   = (rcPage.right - rcPage.left) / 2.0;
            double   nCY   = (rcPage.top - rcPage.bottom) / 2.0;
            PXC_Rect rcOut = new PXC_Rect();

            rcOut.left   = nCX - 200;
            rcOut.bottom = nCY + 250;
            rcOut.right  = nCX - 150;
            rcOut.top    = nCY + 300;
            IPXC_Annotation     annot = unchecked (page.InsertNewAnnot(nText, ref rcOut));
            IPXC_AnnotData_Text aData = annot.Data as IPXC_AnnotData_Text;

            aData.Contents = "Text Annotation 1.";
            aData.Title    = "Text Annotation 1";
            var color = auxInst.CreateColor(ColorType.ColorType_RGB);

            color.SetRGB(0.0f, 0.8f, 0.8f);
            aData.Color   = color;
            aData.Opacity = 0.5f;
            annot.Data    = aData;

            rcOut.bottom  -= 100;
            rcOut.top     -= 100;
            annot          = unchecked (page.InsertNewAnnot(nText, ref rcOut));
            aData          = annot.Data as IPXC_AnnotData_Text;
            aData.Contents = "Text Annotation 2.";
            aData.Title    = "Text Annotation 2";
            color          = auxInst.CreateColor(ColorType.ColorType_RGB);
            color.SetRGB(0.5f, 0.4f, 0.48f);
            aData.Color = color;
            annot.Data  = aData;
            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Annotations);
        }
Ejemplo n.º 8
0
        static public void ExportAllFieldsOnPage(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.OpenDocumentFromStream(Parent);
                Parent.UpdateControlsFromDocument(0);
                Parent.UpdatePreviewFromCurrentDocument();
            }
            //Getting current page
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  Page  = pages[Parent.CurrentPage];

            //Locking CosDocument for reading
            Parent.m_CurDoc.CosDocument.LockDocument();
            //Creating new array that will store the variants of the needed form fields
            IPXS_Inst       pxsInst = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS");
            IPXS_PDFVariant arrVar  = pxsInst.NewVar_Array(0, Parent.m_CurDoc.CosDocument);
            //Get AcroForm from Document
            IPXC_AcroForm acroForm = Parent.m_CurDoc.AcroForm;

            for (uint i = 0; i < acroForm.FieldsCount; i++)
            {
                IPXC_FormField field = acroForm.Field[i];
                if (field == null)
                {
                    continue;
                }
                arrVar.Arr_Insert(field.PDFObject);
                Marshal.ReleaseComObject(field);
            }
            Parent.m_CurDoc.CosDocument.UnlockDocument();

            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
            if (arrVar.Count == 0)
            {
                return;
            }
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = "FDF Documents (*.fdf)|*.fdf|XFDF Documents (*.xfdf)|*.xfdf|HTML Documents (*.html)|*.hrml|XML Documents (*.xml)|*.xml";
            sfd.FilterIndex     = 4;
            sfd.CheckPathExists = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                IAFS_Inst afsInst = (IAFS_Inst)Parent.m_pxcInst.GetExtension("AFS");
                IAFS_Name name    = afsInst.DefaultFileSys.StringToName(sfd.FileName);
                string    sExt    = Path.GetExtension(sfd.FileName).ToLower();
                sExt = sExt.TrimStart('.');
                acroForm.Export(name, sExt, arrVar, true, (uint)PXC_ExportFormFlags.FormExport_Default);
                Process.Start("explorer.exe", "/select, \"" + sfd.FileName + "\"");
            }
        }
Ejemplo n.º 9
0
        static public int AddPopupAnnotation(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            IPXC_UndoRedoData urData    = null;
            IPXC_Pages        pages     = Parent.m_CurDoc.Pages;
            IPXC_Page         firstPage = pages[0];
            PXC_Rect          rcPage    = firstPage.get_Box(PXC_BoxType.PBox_PageBox);

            Marshal.ReleaseComObject(firstPage);
            IPXC_Page page    = pages.InsertPage(0, ref rcPage, out urData);
            IPXS_Inst pxsInst = Parent.m_pxcInst.GetExtension("PXS");
            IAUX_Inst auxInst = Parent.m_pxcInst.GetExtension("AUX");
            //Getting Popup annotation atom for the InsertNewAnnot method
            uint nSquare = pxsInst.StrToAtom("Square");

            double   nCX   = (rcPage.right - rcPage.left) / 2.0;
            double   nCY   = (rcPage.top - rcPage.bottom) / 2.0;
            PXC_Rect rcOut = new PXC_Rect();

            rcOut.left   = nCX - 200;
            rcOut.bottom = nCY + 200;
            rcOut.right  = nCX + 200;
            rcOut.top    = nCY + 300;
            IPXC_Annotation             sqAnnot = page.InsertNewAnnot(nSquare, ref rcOut);
            IPXC_AnnotData_SquareCircle aSData  = sqAnnot.Data as IPXC_AnnotData_SquareCircle;
            var color = auxInst.CreateColor(ColorType.ColorType_RGB);

            color.SetRGB(0.0f, 0.8f, 0.8f);
            aSData.Color    = color;
            aSData.Title    = "Square annotation 1.";
            aSData.Contents = "Popup Annotation 1.";
            sqAnnot.Data    = aSData;

            //Getting Text annotation atom for the InsertNewAnnot method
            uint                 nText = pxsInst.StrToAtom("Popup");
            IPXC_Annotation      annot = page.InsertNewAnnot(nText, ref rcOut);
            IPXC_AnnotData_Popup aData = annot.Data as IPXC_AnnotData_Popup;

            aData.Opened = true;
            annot.Data   = aData;
            sqAnnot.SetPopup(annot);

            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Annotations);
        }
Ejemplo n.º 10
0
        static public void AddBarcodeFormFields(Form1 Parent)
        {
            int index = 1;
            //delegate string CheckNamesFields(IPXC_Document Doc, string fieldName, ref int x);
            CheckNamesFields checkNamesFields = (IPXC_Document Doc, string fName, ref int inx) =>
            {
                string sFieldName = "";
                uint   i          = 0;
                do
                {
                    sFieldName = fName + inx;
                    IPXC_FormField ff = Doc.AcroForm.GetFieldByName(sFieldName);
                    if (ff == null)
                    {
                        break;
                    }
                    inx++;
                    i++;
                }while (i <= Doc.AcroForm.FieldsCount);
                inx++;
                return(sFieldName);
            };

            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            PXC_Rect rc = new PXC_Rect();

            rc.top   = 800;
            rc.right = 600;

            //Adding Barcode
            IPXC_UndoRedoData urD   = null;
            IPXC_Pages        pages = Parent.m_CurDoc.Pages;
            IPXC_Page         Page  = pages.InsertPage(0, rc, out urD);
            PXC_Rect          rcPB  = new PXC_Rect();

            rcPB.left   = 2.5 * 72.0;
            rcPB.right  = rc.right - 2.5 * 72.0;
            rcPB.top    = rc.top - 1.5 * 72.0;
            rcPB.bottom = rcPB.top - 1.5 * 72.0;             //top is greater then bottom (PDF Coordinate System)

            IPXC_FormField Barcode = Parent.m_CurDoc.AcroForm.CreateField(checkNamesFields(Parent.m_CurDoc, "Barcode", ref index), PXC_FormFieldType.FFT_Barcode, 0, ref rcPB);

            Marshal.ReleaseComObject(Barcode);
            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
        }
        static public int RemoveAnnotations(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  page  = pages[Parent.CurrentPage];

            page.RemoveAnnots(0, page.GetAnnotsCount());
            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Annotations);
        }
Ejemplo n.º 12
0
        static public void AddRadioButtonsFormFields(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            PXC_Rect rc = new PXC_Rect();

            rc.top   = 800;
            rc.right = 600;

            //Adding group with RadioButtons
            IPXS_Inst         pxsInst = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS");
            IPXC_UndoRedoData urD     = null;
            IPXC_Pages        pages   = Parent.m_CurDoc.Pages;
            IPXC_Page         Page    = pages.InsertPage(0, rc, out urD);
            PXC_Rect          rcPB    = new PXC_Rect();

            rcPB.top    = rc.top - 0.35 * 72.0;
            rcPB.bottom = rcPB.top - 0.5 * 72.0;             //top is greater then bottom (PDF Coordinate System)
            rcPB.left   = 1.7 * 72.0;
            rcPB.right  = rcPB.left + 0.5 * 72.0;
            IPXC_FormField firstGroup = Parent.m_CurDoc.AcroForm.CreateField("RadioButton", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB);

            rcPB.left  = 2.3 * 72.0;
            rcPB.right = rcPB.left + 0.5 * 72.0;
            Parent.m_CurDoc.AcroForm.CreateField("RadioButton", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB);
            rcPB.left  = 2.9 * 72.0;
            rcPB.right = rcPB.left + 0.5 * 72.0;
            Parent.m_CurDoc.AcroForm.CreateField("RadioButton", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB);

            rcPB.right = rc.right - 1.5 * 72.0;
            rcPB.left  = rcPB.right - 0.5 * 72.0;
            IPXC_FormField secondGroup = Parent.m_CurDoc.AcroForm.CreateField("RadioButton1", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB);

            rcPB.top    = rcPB.top - 0.6 * 72.0;
            rcPB.bottom = rcPB.top - 0.5 * 72.0;
            Parent.m_CurDoc.AcroForm.CreateField("RadioButton1", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB);
            firstGroup.CheckWidget(1, true);
            secondGroup.CheckWidget(1, true);

            Marshal.ReleaseComObject(firstGroup);
            Marshal.ReleaseComObject(secondGroup);
            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 13
0
        static public void ResizeDocumentPagesToTheContent(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.OpenDocFromStringPath(Parent);
            }
            IPXC_Pages pages = Parent.m_CurDoc.Pages;

            for (uint i = 0; i < pages.Count; i++)
            {
                IPXC_Page page        = pages[i];
                PXC_Rect  contentRect = page.get_Box(PXC_BoxType.PBox_BBox);
                page.set_Box(PXC_BoxType.PBox_MediaBox, ref contentRect);
                Marshal.ReleaseComObject(page);
            }
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 14
0
        static public int InsertEmptyPagesIntoDoc(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.OpenDocFromStringPath(Parent);
            }
            IPXC_Pages        pages     = Parent.m_CurDoc.Pages;
            IPXC_Page         firstPage = pages[0];
            PXC_Rect          rcMedia   = firstPage.get_Box(PXC_BoxType.PBox_MediaBox);
            IPXC_UndoRedoData urd       = null;

            //Adding page with the size of the first page of the current document
            pages.AddEmptyPages(0, 1, ref rcMedia, null, out urd);
            Marshal.ReleaseComObject(firstPage);
            Marshal.ReleaseComObject(pages);
            return((int)Form1.eFormUpdateFlags.efuf_All);
        }
Ejemplo n.º 15
0
        static public int DrawSquareAnnotation(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }
            IPXC_Pages pages   = Parent.m_CurDoc.Pages;
            IPXC_Page  page    = pages[0];
            PXC_Rect   rcPage  = page.get_Box(PXC_BoxType.PBox_PageBox);
            IPXS_Inst  pxsInst = Parent.m_pxcInst.GetExtension("PXS");
            IAUX_Inst  auxInst = Parent.m_pxcInst.GetExtension("AUX");
            //Getting Square annotation atom for the InsertNewAnnot method
            uint nSquare = pxsInst.StrToAtom("Square");
            //Placing it in the center of page
            double   nCX   = (rcPage.right - rcPage.left) / 2.0;
            double   nCY   = (rcPage.top - rcPage.bottom) / 2.0;
            PXC_Rect rcOut = new PXC_Rect();

            rcOut.left   = nCX - 200;
            rcOut.bottom = nCY - 100;
            rcOut.right  = nCX + 200;
            rcOut.top    = nCY + 100;
            IPXC_Annotation             annot = page.InsertNewAnnot(nSquare, ref rcOut);
            IPXC_AnnotData_SquareCircle aData = annot.Data as IPXC_AnnotData_SquareCircle;

            aData.Opacity = 0.7;
            var color = auxInst.CreateColor(ColorType.ColorType_RGB);

            color.SetRGB(0.0f, 1.0f, 1.0f);
            aData.Color = color;
            //Setting dashed border pattern
            var border = new PXC_AnnotBorder();

            border.nStyle       = PXC_AnnotBorderStyle.ABS_Dashed;
            border.nWidth       = 4.0f;
            border.DashArray    = new float[10];
            border.DashArray[0] = border.DashArray[1] = 16.0f; //Width of dashes
            border.nDashCount   = 2;                           //Number of dashes
            aData.set_Border(border);
            annot.Data = aData;
            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Annotations);
        }
Ejemplo n.º 16
0
        static public int AddAttachmentAsAnnotation(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            IPXC_UndoRedoData urData    = null;
            IPXC_Pages        pages     = Parent.m_CurDoc.Pages;
            IPXC_Page         firstPage = pages[0];
            PXC_Rect          rcPage    = firstPage.get_Box(PXC_BoxType.PBox_PageBox);

            Marshal.ReleaseComObject(firstPage);
            IPXC_Page page    = pages.InsertPage(0, ref rcPage, out urData);
            IPXS_Inst pxsInst = Parent.m_pxcInst.GetExtension("PXS");
            IAUX_Inst auxInst = Parent.m_pxcInst.GetExtension("AUX");
            //Getting File attachment annotation atom for the InsertNewAnnot method
            uint nText = pxsInst.StrToAtom("FileAttachment");

            double   nCX   = (rcPage.right - rcPage.left) / 2.0;
            double   nCY   = (rcPage.top - rcPage.bottom) / 2.0;
            PXC_Rect rcOut = new PXC_Rect();

            rcOut.left   = nCX - 200;
            rcOut.bottom = nCY + 250;
            rcOut.right  = nCX - 150;
            rcOut.top    = nCY + 300;
            IPXC_Annotation annot = page.InsertNewAnnot(nText, ref rcOut);
            IPXC_AnnotData_FileAttachment aData = annot.Data as IPXC_AnnotData_FileAttachment;

            aData.Contents = "FileAttachment Annotation 1.";
            string                  sFilePath = System.Environment.CurrentDirectory + "\\Documents\\Hobbit.txt";
            IPXC_FileSpec           fileSpec  = Parent.m_CurDoc.CreateEmbeddFile(sFilePath);
            IPXC_EmbeddedFileStream EFS       = fileSpec.EmbeddedFile;

            EFS.UpdateFromFile2(sFilePath);
            aData.FileAttachment = fileSpec;
            annot.Data           = aData;

            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Annotations | (int)Form1.eFormUpdateFlags.efuf_Attachments);
        }
Ejemplo n.º 17
0
        static public void LoadStampFromTheImageFile(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            //Loading image file
            IAFS_Inst afsInst       = (IAFS_Inst)Parent.m_pxcInst.GetExtension("AFS");
            string    sPath         = System.Environment.CurrentDirectory + "\\Images\\run_24.png";
            IAFS_Name name          = afsInst.DefaultFileSys.StringToName(sPath);
            int       openFileFlags = (int)(AFS_OpenFileFlags.AFS_OpenFile_Read | AFS_OpenFileFlags.AFS_OpenFile_ShareRead);
            IAFS_File destFile      = afsInst.DefaultFileSys.OpenFile(name, openFileFlags);
            //Creating new collection
            IPXC_StampsCollection sc = Parent.m_pxcInst.StampsManager.CreateEmptyCollection("My Stamps");

            IPXC_StampInfo si        = sc.AddStamp(destFile, "My Stamp");
            IPXC_Pages     pages     = Parent.m_CurDoc.Pages;
            IPXC_Page      firstPage = pages[0];
            PXC_Rect       rcPB      = firstPage.get_Box(PXC_BoxType.PBox_PageBox);
            //Creating stamp annotation
            IPXS_Inst pSInt   = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS");
            uint      nStamp  = pSInt.StrToAtom("Stamp");
            double    nHeight = 0;
            double    nWidth  = 0;

            si.GetSize(out nWidth, out nHeight);
            //Increasing width and height by 20
            PXC_Rect rc;             //Annotation rectangle

            rc.left   = 0;
            rc.right  = nWidth * 20;
            rc.top    = rcPB.top;
            rc.bottom = rc.top - nHeight * 20;
            IPXC_Annotation      annot     = firstPage.InsertNewAnnot(nStamp, ref rc, 0);
            IPXC_AnnotData_Stamp stampData = (IPXC_AnnotData_Stamp)annot.Data;

            stampData.set_BBox(rc);             //Stamp rectangle boundaries
            stampData.SetStampName(si.ID);
            annot.Data = stampData;
            Marshal.ReleaseComObject(firstPage);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 18
0
        static public void AddStandardStampByIndexInCollection(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }
            IPXC_Pages         pages        = Parent.m_CurDoc.Pages;
            IPXC_Page          firstPage    = pages[0];
            PXC_Rect           rcPB         = firstPage.get_Box(PXC_BoxType.PBox_PageBox);
            IPXC_StampsManager stampManager = Parent.m_pxcInst.StampsManager;
            uint nColIndex           = (uint)stampManager.FindCollection("Standard");
            IPXC_StampsCollection sc = stampManager[nColIndex];
            IPXC_StampInfo        si = null;

            for (uint i = 0; i < sc.Count; i++)
            {
                if (sc[i].ID == "Expired")
                {
                    si = sc[i];
                    break;
                }
            }
            //Creating stamp annotation
            IPXS_Inst pSInt   = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS");
            uint      nStamp  = pSInt.StrToAtom("Stamp");
            double    nHeight = 0;
            double    nWidth  = 0;

            si.GetSize(out nWidth, out nHeight);
            PXC_Rect rc;

            rc.left   = 0;
            rc.right  = nWidth;
            rc.top    = rcPB.top;
            rc.bottom = rc.top - nHeight;
            IPXC_Annotation      annot     = firstPage.InsertNewAnnot(nStamp, ref rc, 0);
            IPXC_AnnotData_Stamp stampData = (IPXC_AnnotData_Stamp)annot.Data;

            stampData.SetStampName(si.ID);
            annot.Data = stampData;
            Marshal.ReleaseComObject(firstPage);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 19
0
        static public void FlattenAllFieldsOnPage(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.OpenDocumentFromStream(Parent);
                Parent.UpdateControlsFromDocument(0);
                Parent.UpdatePreviewFromCurrentDocument();
            }
            //Getting current page
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  Page  = pages[Parent.CurrentPage];
            //Get AcroForm from Document
            IPXC_AcroForm acroForm = Parent.m_CurDoc.AcroForm;

            acroForm.FlattenAllFields();

            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 20
0
        static public void LoadStampsCollectionFromFile(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            //Loading stamp collection from stamp file
            IAFS_Inst             afsInst       = (IAFS_Inst)Parent.m_pxcInst.GetExtension("AFS");
            string                sPath         = System.Environment.CurrentDirectory + "\\Documents\\MyStamps.pdf";
            IAFS_Name             name          = afsInst.DefaultFileSys.StringToName(sPath);
            int                   openFileFlags = (int)(AFS_OpenFileFlags.AFS_OpenFile_Read | AFS_OpenFileFlags.AFS_OpenFile_ShareRead);
            IAFS_File             destFile      = afsInst.DefaultFileSys.OpenFile(name, openFileFlags);
            IPXC_StampsCollection sc            = Parent.m_pxcInst.StampsManager.LoadCollection(destFile);

            //Placing stamp from the loaded collection
            IPXC_Pages     pages     = Parent.m_CurDoc.Pages;
            IPXC_Page      firstPage = pages[0];
            PXC_Rect       rcPB      = firstPage.get_Box(PXC_BoxType.PBox_PageBox);
            IPXC_StampInfo si        = sc[0];      //getting stamp by index - they are sorted by name
            //Creating stamp annotation
            IPXS_Inst pSInt   = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS");
            uint      nStamp  = pSInt.StrToAtom("Stamp");
            double    nHeight = 0;
            double    nWidth  = 0;

            si.GetSize(out nWidth, out nHeight);
            PXC_Rect rc;            //Annotation rectangle

            rc.left   = 0;
            rc.right  = nWidth;
            rc.top    = rcPB.top;
            rc.bottom = rc.top - nHeight;
            IPXC_Annotation      annot     = firstPage.InsertNewAnnot(nStamp, ref rc, 0);
            IPXC_AnnotData_Stamp stampData = (IPXC_AnnotData_Stamp)annot.Data;

            stampData.set_BBox(rc);             //Stamp rectangle boundaries
            stampData.SetStampName(si.ID);
            annot.Data = stampData;
            Marshal.ReleaseComObject(firstPage);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 21
0
        static public void AddTextToThePageCenter(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }
            IPXC_Pages          pages  = Parent.m_CurDoc.Pages;
            IPXC_Page           page   = pages[0];
            PXC_Rect            rcPage = page.get_Box(PXC_BoxType.PBox_PageBox);
            IPXC_ContentCreator CC     = Parent.m_CurDoc.CreateContentCreator();
            IPXC_Font           font   = Parent.m_CurDoc.CreateNewFont("Tahoma", 0, 400);

            CC.SaveState();
            CC.SetFont(font);
            CC.SetStrokeColorRGB(0x000000);
            CC.SetFontSize(36);
            string   str   = "Centered Text";
            PXC_Rect rcOut = new PXC_Rect();

            //Calculating the text rectangle
            CC.ShowTextBlock(str, ref rcPage, ref rcPage, (uint)PXC_DrawTextFlags.DTF_CalcSizeOnly, -1, null, null, null, out rcOut);
            //Placing it in the center of page
            double nCX = (rcPage.right - rcPage.left) / 2.0;
            double nCY = (rcPage.top - rcPage.bottom) / 2.0;
            double nW  = rcOut.right - rcOut.left;
            double nH  = rcOut.top - rcOut.bottom;

            rcOut.left   = nCX - nW / 2.0;
            rcOut.bottom = nCY - nH / 2.0;
            rcOut.right  = rcOut.left + nW;
            rcOut.top    = rcOut.bottom + nH;
            //Outputting the text
            PXC_Rect rc = new PXC_Rect();

            CC.ShowTextBlock(str, ref rcOut, ref rcOut, 0, -1, null, null, null, out rc);
            CC.RestoreState();
            page.PlaceContent(CC.Detach());
            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);
        }
Ejemplo n.º 22
0
        static public int ConvertFromTXT(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }
            IPXC_Pages pages     = Parent.m_CurDoc.Pages;
            IPXC_Page  firstPage = pages[0];
            PXC_Rect   rc        = firstPage.get_Box(PXC_BoxType.PBox_PageBox);

            Marshal.ReleaseComObject(firstPage);
            IPXC_UndoRedoData   urData;
            IPXC_ContentCreator CC   = Parent.m_CurDoc.CreateContentCreator();
            IPXC_Page           page = pages.InsertPage(0, ref rc, out urData);
            DrawTextCallbacks   drawTextCallbacks = new DrawTextCallbacks();

            drawTextCallbacks.m_currPage = page;

            drawTextCallbacks.m_Text = File.ReadAllText(Environment.CurrentDirectory + "\\Documents\\Hobbit.txt");

            IPXC_Font font = Parent.m_CurDoc.CreateNewFont("Times New Roman", 0, 400);

            CC.SetColorRGB(0x00000000);
            CC.SetFont(font);
            CC.SetFontSize(15);

            PXC_Rect rect = new PXC_Rect();

            rect.top    = rc.top - 40;
            rect.right  = rc.right - 40;
            rect.bottom = rc.bottom + 40;
            rect.left   = rc.left + 40;

            CC.ShowTextBlock(drawTextCallbacks.m_Text, rect, rect, (uint)PXC_DrawTextFlags.DTF_Center, -1, null, null, drawTextCallbacks, out rect);
            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_All);
        }
        static public int AddChildBookmark(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                return(0);
            }

            IPXC_Bookmark bookmark = null;

            if (Parent.SelectedBookmarkNode == null)
            {
                bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true);
            }
            else
            {
                bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewChild((Parent.SelectedBookmarkNode.m_Bookmark.ChildrenCount > 0));
            }
            IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList();

            bookmark.Title = (Parent.CurrentPage + 1) + " page";
            bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal;
            PXC_Destination dest = new PXC_Destination();

            dest.nPageNum   = Parent.CurrentPage;
            dest.nNullFlags = 0;
            dest.nType      = PXC_DestType.Dest_FitR;
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  page  = pages[Parent.CurrentPage];
            PXC_Rect   rc    = page.get_Box(PXC_BoxType.PBox_BBox);

            double[] rect = { rc.left, rc.bottom, rc.right, rc.top };
            dest.dValues = rect;
            aList.AddGoto(dest);
            bookmark.Actions = aList;
            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Bookmarks);
        }
        static public int FlattenAnnotations(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  page  = pages[Parent.CurrentPage];
            //Filling the list of the annotations that need to be flattened
            IPXC_AnnotsList al = Parent.m_pxcInst.CreateAnnotsList();

            for (uint i = 0; i < page.GetAnnotsCount(); i++)
            {
                IPXC_Annotation annot = page.GetAnnot(i);
                al.Insert(annot, uint.MaxValue);
            }
            Parent.m_CurDoc.FlattenAnnotations(Parent.CurrentPage, al);
            Marshal.ReleaseComObject(al);
            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Annotations);
        }
Ejemplo n.º 25
0
            public void OnGetNewRect(IPXC_ContentCreator pCC, out PXC_Rect pRect, ref uint pFlags, out PXC_Rect pClip)
            {
                m_currPage.PlaceContent(pCC.Detach(), (uint)PXC_PlaceContentFlags.PlaceContent_Replace);
                PXC_Rect          rc = m_currPage.get_Box(PXC_BoxType.PBox_PageBox);
                IPXC_UndoRedoData urData;

                m_currPage.Document.CreateContentCreator();
                IPXC_Pages pages = m_currPage.Document.Pages;
                IPXC_Page  page  = pages.InsertPage(m_currPage.Number + 1, ref rc, out urData);

                Marshal.ReleaseComObject(m_currPage);
                m_currPage = page;

                PXC_Rect rect = new PXC_Rect();

                rect.top    = rc.top - 40;
                rect.right  = rc.right - 40;
                rect.bottom = rc.bottom + 40;
                rect.left   = rc.left + 40;

                pRect = rect;
                pClip = rect;
                Marshal.ReleaseComObject(pages);
            }
        static public int RotateAnnotations(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  page  = pages[Parent.CurrentPage];

            for (uint i = 0; i < page.GetAnnotsCount(); i++)
            {
                IPXC_Annotation annot = page.GetAnnot(i);
                PXC_Point       rcRotPnt;
                //We are taking the center point of the annotation as the rotation point
                rcRotPnt.x = annot.get_Rect().left + (annot.get_Rect().right - annot.get_Rect().left) / 2.0f;
                rcRotPnt.y = annot.get_Rect().top - (annot.get_Rect().top - annot.get_Rect().bottom) / 2.0f;
                //We will be adding 45 degrees to the annotation rotation each time
                annot.Handler.RotateAnnot(annot, 45.0f, false, rcRotPnt);
            }
            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Annotations);
        }
Ejemplo n.º 27
0
        private static void Draw_Keys(ref IPXC_ContentCreator CC, ref IPXC_Page page)
        {
            page_Width = 800;
            page_Height = 1200;
            Rect_size = (page_Width) / (workspace_ob.field_ex.size_rect - 8);
            height = workspace_ob.field_ex.heigth;
            width = workspace_ob.field_ex.width;
            keys_count = workspace_ob.keys.Count;

            

            CC.SetLineWidth(0.5);
            for (int i = 1, key_counter = 0; i <= keys_count && key_counter < keys_count; i++, key_counter++)
            {
                int key_rect_top = page_Height - (i * Rect_size);
                int key_rect_bottom = page_Height - (i * Rect_size) - Rect_size;
                int key_rect_right = page_Width - Rect_size;
                int key_rect_left = Rect_size;
                Color current_key_color = workspace_ob.keys[key_counter].clr;

                string current_key_text = workspace_ob.keys[key_counter].str;
                rc.top = key_rect_top;
                rc.bottom = key_rect_bottom;
                rc.left = Rect_size;
                rc.right = key_rect_right / 4;

                CC.Rect(rc.left, rc.bottom, rc.right, rc.top);
                CC.SetFillColorRGB(Get_UINT_Color(Color.White));
                CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd);

                CC.SetFillColorRGB(Get_UINT_Color(Color.Black));
                CC.ShowTextBlock(current_key_text, ref rc, ref rc, (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                CC.Rect(key_rect_right / 4, key_rect_bottom, key_rect_right / 2 - 2, key_rect_top);
                CC.SetFillColorRGB(Get_UINT_Color(current_key_color));
                CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd);

                page.PlaceContent(CC.Detach());
                try
                {
                    current_key_color = workspace_ob.keys[++key_counter].clr;

                    CC.Rect(key_rect_right / 2 + 2, key_rect_bottom, key_rect_right - (key_rect_right / 4), key_rect_top);
                    CC.SetFillColorRGB(Get_UINT_Color(Color.White));
                    CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd);

                    current_key_text = workspace_ob.keys[key_counter].str;
                    rc.top = key_rect_top;
                    rc.bottom = key_rect_bottom;
                    rc.left = key_rect_right / 2;
                    rc.right = key_rect_right - (key_rect_right / 4);

                    CC.SetFillColorRGB(Get_UINT_Color(Color.Black));
                    CC.ShowTextBlock(current_key_text, ref rc, ref rc, (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                    CC.Rect(key_rect_right - (key_rect_right / 4), key_rect_bottom, key_rect_right, key_rect_top);
                    CC.SetFillColorRGB(Get_UINT_Color(current_key_color));
                    CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd);
                }
                catch { break; }
                page.PlaceContent(CC.Detach());
            }
        }
        static public int AddRedactAnnotation(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            IPXC_UndoRedoData urData    = null;
            IPXC_Pages        pages     = Parent.m_CurDoc.Pages;
            IPXC_Page         firstPage = pages[0];
            PXC_Rect          rcPage    = firstPage.get_Box(PXC_BoxType.PBox_PageBox);

            Marshal.ReleaseComObject(firstPage);
            IPXC_Page           page    = pages.InsertPage(0, ref rcPage, out urData);
            IPXS_Inst           pxsInst = Parent.m_pxcInst.GetExtension("PXS");
            IAUX_Inst           auxInst = Parent.m_pxcInst.GetExtension("AUX");
            IPXC_ContentCreator CC      = Parent.m_CurDoc.CreateContentCreator();
            double nCX = (rcPage.right - rcPage.left) / 2.0;
            double nCY = (rcPage.top - rcPage.bottom) / 4.0 * 3.0;

            IPXC_Font font = Parent.m_CurDoc.CreateNewFont("Arial", (uint)PXC_CreateFontFlags.CreateFont_Monospaced, 700);

            CC.SetFontSize(30);
            CC.SetFont(font);
            CC.SetColorRGB(0x00000000);
            for (int i = 0; i < 4; i++)
            {
                CC.ShowTextLine(nCX - 190, nCY - (40 * i), "This is a story of long ago.", -1, (uint)PXC_ShowTextLineFlags.STLF_Default | (uint)PXC_ShowTextLineFlags.STLF_AllowSubstitution);
            }
            page.PlaceContent(CC.Detach(), (uint)PXC_PlaceContentFlags.PlaceContent_Replace);
            IPXC_PageText Text = page.GetText(null, false);

            PXC_Rect rcOut = new PXC_Rect();

            rcOut.left   = nCX - 150;
            rcOut.bottom = nCY - 100;
            rcOut.right  = nCX + 150;
            rcOut.top    = nCY + 100;
            //Getting Redact annotation atom for the InsertNewAnnot method
            uint                     nText = pxsInst.StrToAtom("Redact");
            IPXC_Annotation          annot = unchecked (page.InsertNewAnnot(nText, ref rcOut));
            IPXC_AnnotData_Redaction aData = annot.Data as IPXC_AnnotData_Redaction;

            aData.Title = "Redact annotation 1.";

            IPXC_QuadsF quadsF = Parent.m_pxcInst.CreateQuads();
            uint        afafaf = quadsF.Count;
            PXC_RectF   rectF  = new PXC_RectF();

            Text.GetTextQuads3(8, 75, quadsF, out rectF);
            aData.Quads = quadsF;
            var color = auxInst.CreateColor(ColorType.ColorType_RGB);

            color.SetRGB(0.0f, 0.0f, 0.0f);
            aData.FColor = color;
            aData.SColor = color;
            annot.Data   = aData;

            Marshal.ReleaseComObject(page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_Annotations);
        }
Ejemplo n.º 29
0
        //Method for drawing Keys in verrtical mode
        private static void Draw_Keys_Vartical(ref IPXC_ContentCreator CC, ref IPXC_Page page)
        {
            // Create new PXC_Rect instances
            PXC_Rect rc = new PXC_Rect();
            PXC_Rect rc_out = new PXC_Rect();

            int Rect_size_for_20 = page_Width / 22;
            height = workspace_ob.field_ex.heigth;
            width = workspace_ob.field_ex.width;
            keys_count = workspace_ob.keys.Count;
            Colomn_number key_colomn_number = Colomn_number.FIRST;

            CC.SetLineWidth(0.5);//Set line  width

            string str_keys = "Keys:\n";

            // Define the coordinates for rect
            rc.top = y_field_bottom - Rect_size_for_20 + Rect_size_for_20;
            rc.bottom = y_field_bottom - Rect_size_for_20 * 6;
            rc.left = Rect_size_for_20;
            rc.right = Rect_size_for_20 * 3;

            //Create IPXC_CharFormat to modify font size 
            IPXC_CharFormat char_format = inst_pxc.CreateCharFormat();
            char_format.FontSize = 20;
            char_format.ModifyMask((uint)PXC_CharFormatMask.CFM_FontSize, 0);

            //Creation text block for keys text
            CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

            //Draw text block with current text in rc coordinates
            CC.ShowTextBlock(str_keys, ref rc, ref rc,
                (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter | (uint)PXC_DrawTextFlags.DTF_Justify,
                (int)-1, char_format, null, null, out rc_out);


            // Define the coordinates for Template text block
            rc.top = page_Height - Rect_size_for_20 * 2 + 50;
            rc.bottom = page_Height - Rect_size_for_20 - 30;
            rc.left = Rect_size_for_20;
            rc.right = page_Width - Rect_size_for_20;

            //Showing text block with Template name            
            string template_info = Get_Template_String();
            CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

            //Draw text block with current text in rc coordinates
            CC.ShowTextBlock(template_info, ref rc, ref rc,
                (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter
                | (uint)PXC_DrawTextFlags.DTF_Justify, (int)-1, char_format, null, null, out rc_out);

            for (int i = 1, key_counter = 0; i <= keys_count && key_counter < keys_count; i++, key_counter++)
            {
                int key_rect_top = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20 + Rect_size_for_20);
                int key_rect_bottom = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20);
                int key_rect_right = page_Width - Rect_size_for_20;
                int key_rect_left = Rect_size_for_20;
                Color current_key_color = workspace_ob.keys[key_counter].clr;
                string string_in_key_field = workspace_ob.clr_name[key_counter];

                string current_key_text = workspace_ob.keys[key_counter].str;

                // Define the coordinates for rect
                rc.top = key_rect_top;
                rc.bottom = key_rect_bottom;
                rc.left = key_rect_left;
                rc.right = key_rect_right / 4;

                if (key_colomn_number == Colomn_number.FIRST && rc.top >= Rect_size)
                {
                    DrawColoringRect(ref CC, ref rc, Color.White);

                    // Define the coordinates for rect
                    rc.top = key_rect_top + 30;
                    rc.bottom = key_rect_bottom - 30;

                    CC.SetFillColorRGB(Get_UINT_Color(Color.Black)); //Set color of filling

                    //Draw text block with current text in rc coordinates
                    CC.ShowTextBlock(current_key_text, ref rc, ref rc,
                        (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                    rc.top = key_rect_top;
                    rc.bottom = key_rect_bottom;
                    rc.left = key_rect_right / 4;
                    rc.right = key_rect_right / 2 - 2;

                    CC.Rect(rc.left, rc.bottom, rc.right, rc.top);//Draw rectangle by current coordinates
                    CC.SetFillColorRGB(Get_UINT_Color(current_key_color));//Set color of filling
                    CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd);//Filling current element

                    rc.top = key_rect_top + 50;
                    rc.bottom = key_rect_bottom - 50;
                    rc.left = key_rect_right / 4;
                    rc.right = key_rect_right / 2 - 2;

                    if (!isDarkColor(string_in_key_field))
                        CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling 
                    else
                        CC.SetFillColorRGB(Get_UINT_Color(Color.White));//Set color of filling 

                    CC.ShowTextBlock(string_in_key_field, ref rc, ref rc,
                        (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);
                }

                else
                {
                    if (key_colomn_number == Colomn_number.FIRST)
                    {
                        key_colomn_number = Colomn_number.SECOND;
                        i = 1;
                    }

                    key_rect_top = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20 + Rect_size_for_20);
                    key_rect_bottom = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20);
                    key_rect_right = page_Width - Rect_size_for_20 - 6;
                    key_rect_left = key_rect_right / 2;

                    // Define the coordinates for rect
                    rc.top = key_rect_top;
                    rc.bottom = key_rect_bottom;
                    rc.left = key_rect_left + 10;
                    rc.right = key_rect_left + (key_rect_right - key_rect_left) / 2;

                    CC.Rect(rc.left, rc.bottom, rc.right, rc.top);//Draw rectangle by current coordinates
                    CC.SetFillColorRGB(Get_UINT_Color(Color.White));//Set color of filling
                    CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd);//Filling current element

                    // Define the coordinates for rect
                    rc.top = key_rect_top + 30;
                    rc.bottom = key_rect_bottom - 30;

                    CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

                    //Draw text block with current text in rc coordinates
                    CC.ShowTextBlock(current_key_text, ref rc, ref rc,
                        (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                    rc.top = key_rect_top;
                    rc.bottom = key_rect_bottom;
                    rc.left = rc.right;
                    rc.right = key_rect_left + (key_rect_right - key_rect_left);

                    CC.Rect(rc.left, rc.bottom, rc.right, rc.top);//Draw rectangle by current coordinates
                    CC.SetFillColorRGB(Get_UINT_Color(current_key_color));//Set color of filling
                    CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd);//Filling current element

                    rc.top = key_rect_top + 30;
                    rc.bottom = key_rect_bottom - 30;

                    rc.right = key_rect_right;

                    if (!isDarkColor(string_in_key_field))
                        CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling 
                    else
                        CC.SetFillColorRGB(Get_UINT_Color(Color.White));//Set color of filling 

                    CC.ShowTextBlock(string_in_key_field, ref rc, ref rc,
                        (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);
                }
                page.PlaceContent(CC.Detach());//Appends drawn content to current page
                CC.SetLineWidth(0.5);//Set line  width
                CC.StrokePath(true);//Set end of drawing current element
            }

        }
Ejemplo n.º 30
0
        private static void Draw_Keys_Horisontal(ref IPXC_ContentCreator CC, ref IPXC_Page page)
        {
            int Rect_size_for_20 = (page_Width) / (20 + 2);
            height = workspace_ob.field_ex.heigth;
            width = workspace_ob.field_ex.width;
            keys_count = workspace_ob.keys.Count;
            PXC_Rect rc = new PXC_Rect();
            PXC_Rect rc_out = new PXC_Rect();
            CC.SetLineWidth(0.5);//Set line  width

            string str_keys = "Keys:\n";

            // Define the coordinates for rect
            rc.top = page_Height - (2 * Rect_size) - Rect_size_for_20 + 60;
            rc.bottom = page_Height - (2 * Rect_size) - 60;
            rc.left = x_field_bottom + Rect_size_for_20;
            rc.right = x_field_bottom + Rect_size_for_20 * 6;

            IPXC_CharFormat char_format = inst_pxc.CreateCharFormat();
            char_format.FontSize = 20;
            char_format.ModifyMask((uint)PXC_CharFormatMask.CFM_FontSize, 0);

            CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

            //Draw text block with current text in rc coordinates
            CC.ShowTextBlock(str_keys, ref rc, ref rc,
                (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter | (uint)PXC_DrawTextFlags.DTF_Justify,
                (int)-1, char_format, null, null, out rc_out);

            // Define the coordinates for rect
            rc.top = page_Height - Rect_size_for_20 * 2 + 90;
            rc.bottom = page_Height - Rect_size_for_20;
            rc.left = Rect_size_for_20;
            rc.right = page_Width - Rect_size_for_20;

            string template_info = Get_Template_String();
            CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

            //Draw text block with current text in rc coordinates
            CC.ShowTextBlock(template_info, ref rc, ref rc,
                (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter
                | (uint)PXC_DrawTextFlags.DTF_Justify, (int)-1, char_format, null, null, out rc_out);

            for (int i = 1, key_counter = 0; i <= keys_count && key_counter < keys_count; i++, key_counter++)
            {
                int key_rect_top = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20 + Rect_size_for_20);
                int key_rect_bottom = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20);
                int key_rect_right = page_Width - Rect_size_for_20;
                int key_rect_left = Rect_size_for_20;
                Color current_key_color = workspace_ob.keys[key_counter].clr;
                string string_in_key_field = workspace_ob.clr_name[key_counter];
                string current_key_text = workspace_ob.keys[key_counter].str;

                // Define the coordinates for rect
                rc.top = page_Height - (3 * Rect_size) - ((Rect_size_for_20 / 2) * (i + 1)) + Rect_size_for_20 / 2;
                rc.bottom = page_Height - (3 * Rect_size) - ((Rect_size_for_20 / 2) * i) + Rect_size_for_20 / 2;
                rc.left = x_field_bottom + Rect_size_for_20;
                rc.right = x_field_bottom + Rect_size_for_20 * 4;

                DrawColoringRect(ref CC, ref rc, Color.White);

                // Define the coordinates for rect
                rc.top = rc.top + 30;
                rc.bottom = rc.bottom - 30;

                CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

                //Draw text block with current text in rc coordinates
                CC.ShowTextBlock(current_key_text, ref rc, ref rc,
                    (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                double old_left = rc.left;

                // Define the coordinates for rect
                rc.top = page_Height - (3 * Rect_size) - ((Rect_size_for_20 / 2) * (i + 1)) + Rect_size_for_20 / 2;
                rc.bottom = page_Height - (3 * Rect_size) - ((Rect_size_for_20 / 2) * i) + Rect_size_for_20 / 2;
                rc.left = rc.right + 10;
                rc.right = rc.right + (rc.right - old_left) + 10;

                DrawColoringRect(ref CC, ref rc, current_key_color);

                rc.top = rc.top + 30;
                rc.bottom = rc.bottom - 30;

                if (!isDarkColor(string_in_key_field))
                    CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling 
                else
                    CC.SetFillColorRGB(Get_UINT_Color(Color.White));//Set color of filling 

                CC.ShowTextBlock(string_in_key_field, ref rc, ref rc,
                    (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                page.PlaceContent(CC.Detach());//Appends drawn content to current page
                CC.SetLineWidth(0.5);//Set line  width
                CC.StrokePath(true);//Set end of drawing current element
            }
        }
        static public int SortBookmarksByPage(Form1 Parent)
        {
            //delegate double[] GetXYFromDestination(IPXC_Bookmark bookmark, PXC_Destination dest);
            GetXYFromDestination getXYFromDestination = (IPXC_Document doc, PXC_Destination destination) => {
                PXC_DestType Type          = destination.nType;
                PXC_Point    retValue      = new PXC_Point();
                IPXC_Pages   pages         = doc.Pages;
                IPXC_Page    page          = pages[destination.nPageNum];
                PXC_Rect     contentBBox   = page.get_Box(PXC_BoxType.PBox_BBox);
                PXC_Rect     pageBBox      = page.get_Box(PXC_BoxType.PBox_PageBox);
                bool         IsContentType = (Type == PXC_DestType.Dest_FitB) || (Type == PXC_DestType.Dest_FitBH) || (Type == PXC_DestType.Dest_FitBV);
                retValue.x = IsContentType ? contentBBox.left : pageBBox.left;
                retValue.y = IsContentType ? contentBBox.top : pageBBox.top;
                switch (Type)
                {
                case PXC_DestType.Dest_XYZ:
                {
                    if ((destination.nNullFlags & 1) == 0)
                    {
                        retValue.x = destination.dValues[0];
                    }
                    if ((destination.nNullFlags & 2) == 0)
                    {
                        retValue.y = destination.dValues[1];
                    }
                    break;
                }

                case PXC_DestType.Dest_FitH:
                {
                    if ((destination.nNullFlags & 2) == 0)
                    {
                        retValue.y = destination.dValues[1];
                    }
                    break;
                }

                case PXC_DestType.Dest_FitV:
                {
                    if ((destination.nNullFlags & 1) == 0)
                    {
                        retValue.x = destination.dValues[0];
                    }
                    break;
                }

                case PXC_DestType.Dest_FitR:
                {
                    if ((destination.nNullFlags & 1) == 0)
                    {
                        retValue.x = destination.dValues[0];
                    }
                    if ((destination.nNullFlags & 8) == 0)
                    {
                        retValue.y = destination.dValues[3];
                    }
                    break;
                }

                case PXC_DestType.Dest_FitBH:
                {
                    if ((destination.nNullFlags & 2) == 0)
                    {
                        retValue.y = destination.dValues[1];
                    }
                    break;
                }

                case PXC_DestType.Dest_FitBV:
                {
                    if ((destination.nNullFlags & 1) == 0)
                    {
                        retValue.x = destination.dValues[0];
                    }
                    break;
                }

                default:
                    break;
                }
                Marshal.ReleaseComObject(page);
                Marshal.ReleaseComObject(pages);
                return(retValue);
            };
            //delegate void SortByAnything(SortByAnything sort, IPXC_Bookmark root);
            SortByAnything sortByAnything = (sort, root, actionType) => {
                List <Tuple <IPXC_Bookmark, PXC_Destination> > bookmarks = new List <Tuple <IPXC_Bookmark, PXC_Destination> >();
                int             MAX_VALUE   = int.MaxValue;
                PXC_Destination invalidDest = new PXC_Destination();
                invalidDest.nPageNum = (uint)MAX_VALUE;

                while (root.ChildrenCount > 0)
                {
                    Tuple <IPXC_Bookmark, PXC_Destination> currentBookmark = Tuple.Create(root.FirstChild, invalidDest);
                    if (root.FirstChild.Actions != null)
                    {
                        for (int i = (int)root.FirstChild.Actions.Count - 1; i >= 0; i--)
                        {
                            if (root.FirstChild.Actions[(uint)i].Type == actionType)
                            {
                                IPXC_Action_Goto actionGoTo = root.FirstChild.Actions[(uint)i] as IPXC_Action_Goto;
                                PXC_Destination  currDest   = actionGoTo.IsNamedDest
                                                                        ? Parent.m_CurDoc.GetNamedDestination(actionGoTo.DestName)
                                                                        : actionGoTo.get_Dest();
                                currentBookmark = Tuple.Create(root.FirstChild, currDest);
                                break;
                            }
                        }
                    }
                    root.FirstChild.Unlink();

                    if ((bookmarks.Count == 0) || (currentBookmark.Item2.nPageNum > bookmarks[bookmarks.Count - 1].Item2.nPageNum))
                    {
                        bookmarks.Add(currentBookmark);
                        continue;
                    }
                    else if (currentBookmark.Item2.nPageNum < bookmarks[0].Item2.nPageNum)
                    {
                        bookmarks.Insert(0, currentBookmark);
                        continue;
                    }

                    int first = 0;
                    int last  = bookmarks.Count;

                    while (first < last)
                    {
                        int mid = first + (last - first) / 2;
                        if (currentBookmark.Item2.nPageNum == bookmarks[mid].Item2.nPageNum)
                        {
                            if ((MAX_VALUE == currentBookmark.Item2.nPageNum) && (MAX_VALUE == bookmarks[mid].Item2.nPageNum))
                            {
                                if (Form1.NativeMethods.StrCmpLogicalW(currentBookmark.Item1.Title, bookmarks[mid].Item1.Title) == 1)
                                {
                                    first = mid + 1;
                                }
                                else
                                {
                                    last = mid;
                                }
                            }
                            else
                            {
                                PXC_Point currentBookmarkXY   = getXYFromDestination(Parent.m_CurDoc, currentBookmark.Item2);
                                PXC_Point bookmarkXY_FromList = getXYFromDestination(Parent.m_CurDoc, bookmarks[mid].Item2);
                                if (currentBookmarkXY.y < bookmarkXY_FromList.y)
                                {
                                    first = mid + 1;
                                }
                                else if (currentBookmarkXY.y > bookmarkXY_FromList.y)
                                {
                                    last = mid;
                                }
                                else
                                {
                                    if (currentBookmarkXY.x < bookmarkXY_FromList.x)
                                    {
                                        last = mid;
                                    }
                                    else
                                    {
                                        first = mid + 1;
                                    }
                                }
                            }
                        }
                        else if (currentBookmark.Item2.nPageNum < bookmarks[mid].Item2.nPageNum)
                        {
                            last = mid;
                        }
                        else
                        {
                            first = mid + 1;
                        }
                    }
                    bookmarks.Insert(last, currentBookmark);
                }

                foreach (Tuple <IPXC_Bookmark, PXC_Destination> bookmark in bookmarks)
                {
                    root.AddChild(bookmark.Item1, true);
                    if (bookmark.Item1.ChildrenCount > 0)
                    {
                        sort(sort, bookmark.Item1, actionType);
                    }
                }
            };

            if (Parent.m_CurDoc == null)
            {
                return(0);
            }

            IPXS_Inst pxsInst = Parent.m_pxcInst.GetExtension("PXS") as IPXS_Inst;
            uint      nGoTo   = pxsInst.StrToAtom("GoTo");

            sortByAnything(sortByAnything, Parent.m_CurDoc.BookmarkRoot, nGoTo);
            return((int)Form1.eFormUpdateFlags.efuf_Bookmarks);
        }
Ejemplo n.º 32
0
        //Method for drawing Keys in verrtical mode
        private static void Draw_Keys_Vartical(ref IPXC_ContentCreator CC, ref IPXC_Page page)
        {
            // Create new PXC_Rect instances
            PXC_Rect rc     = new PXC_Rect();
            PXC_Rect rc_out = new PXC_Rect();

            int Rect_size_for_20 = page_Width / 22;

            height     = workspace_ob.field_ex.heigth;
            width      = workspace_ob.field_ex.width;
            keys_count = workspace_ob.keys.Count;
            Colomn_number key_colomn_number = Colomn_number.FIRST;

            CC.SetLineWidth(0.5);//Set line  width

            string str_keys = "Keys:\n";

            // Define the coordinates for rect
            rc.top    = y_field_bottom - Rect_size_for_20 + Rect_size_for_20;
            rc.bottom = y_field_bottom - Rect_size_for_20 * 6;
            rc.left   = Rect_size_for_20;
            rc.right  = Rect_size_for_20 * 3;

            //Create IPXC_CharFormat to modify font size
            IPXC_CharFormat char_format = inst_pxc.CreateCharFormat();

            char_format.FontSize = 20;
            char_format.ModifyMask((uint)PXC_CharFormatMask.CFM_FontSize, 0);

            //Creation text block for keys text
            CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

            //Draw text block with current text in rc coordinates
            CC.ShowTextBlock(str_keys, ref rc, ref rc,
                             (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter | (uint)PXC_DrawTextFlags.DTF_Justify,
                             (int)-1, char_format, null, null, out rc_out);


            // Define the coordinates for Template text block
            rc.top    = page_Height - Rect_size_for_20 * 2 + 50;
            rc.bottom = page_Height - Rect_size_for_20 - 30;
            rc.left   = Rect_size_for_20;
            rc.right  = page_Width - Rect_size_for_20;

            //Showing text block with Template name
            string template_info = Get_Template_String();

            CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

            //Draw text block with current text in rc coordinates
            CC.ShowTextBlock(template_info, ref rc, ref rc,
                             (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter
                             | (uint)PXC_DrawTextFlags.DTF_Justify, (int)-1, char_format, null, null, out rc_out);

            for (int i = 1, key_counter = 0; i <= keys_count && key_counter < keys_count; i++, key_counter++)
            {
                int    key_rect_top        = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20 + Rect_size_for_20);
                int    key_rect_bottom     = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20);
                int    key_rect_right      = page_Width - Rect_size_for_20;
                int    key_rect_left       = Rect_size_for_20;
                Color  current_key_color   = workspace_ob.keys[key_counter].clr;
                string string_in_key_field = workspace_ob.clr_name[key_counter];

                string current_key_text = workspace_ob.keys[key_counter].str;

                // Define the coordinates for rect
                rc.top    = key_rect_top;
                rc.bottom = key_rect_bottom;
                rc.left   = key_rect_left;
                rc.right  = key_rect_right / 4;

                if (key_colomn_number == Colomn_number.FIRST && rc.top >= Rect_size)
                {
                    DrawColoringRect(ref CC, ref rc, Color.White);

                    // Define the coordinates for rect
                    rc.top    = key_rect_top + 30;
                    rc.bottom = key_rect_bottom - 30;

                    CC.SetFillColorRGB(Get_UINT_Color(Color.Black)); //Set color of filling

                    //Draw text block with current text in rc coordinates
                    CC.ShowTextBlock(current_key_text, ref rc, ref rc,
                                     (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                    rc.top    = key_rect_top;
                    rc.bottom = key_rect_bottom;
                    rc.left   = key_rect_right / 4;
                    rc.right  = key_rect_right / 2 - 2;

                    CC.Rect(rc.left, rc.bottom, rc.right, rc.top);          //Draw rectangle by current coordinates
                    CC.SetFillColorRGB(Get_UINT_Color(current_key_color));  //Set color of filling
                    CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd); //Filling current element

                    rc.top    = key_rect_top + 50;
                    rc.bottom = key_rect_bottom - 50;
                    rc.left   = key_rect_right / 4;
                    rc.right  = key_rect_right / 2 - 2;

                    if (!isDarkColor(string_in_key_field))
                    {
                        CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling
                    }
                    else
                    {
                        CC.SetFillColorRGB(Get_UINT_Color(Color.White));//Set color of filling
                    }
                    CC.ShowTextBlock(string_in_key_field, ref rc, ref rc,
                                     (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);
                }

                else
                {
                    if (key_colomn_number == Colomn_number.FIRST)
                    {
                        key_colomn_number = Colomn_number.SECOND;
                        i = 1;
                    }

                    key_rect_top    = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20 + Rect_size_for_20);
                    key_rect_bottom = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20);
                    key_rect_right  = page_Width - Rect_size_for_20 - 6;
                    key_rect_left   = key_rect_right / 2;

                    // Define the coordinates for rect
                    rc.top    = key_rect_top;
                    rc.bottom = key_rect_bottom;
                    rc.left   = key_rect_left + 10;
                    rc.right  = key_rect_left + (key_rect_right - key_rect_left) / 2;

                    CC.Rect(rc.left, rc.bottom, rc.right, rc.top);          //Draw rectangle by current coordinates
                    CC.SetFillColorRGB(Get_UINT_Color(Color.White));        //Set color of filling
                    CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd); //Filling current element

                    // Define the coordinates for rect
                    rc.top    = key_rect_top + 30;
                    rc.bottom = key_rect_bottom - 30;

                    CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

                    //Draw text block with current text in rc coordinates
                    CC.ShowTextBlock(current_key_text, ref rc, ref rc,
                                     (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                    rc.top    = key_rect_top;
                    rc.bottom = key_rect_bottom;
                    rc.left   = rc.right;
                    rc.right  = key_rect_left + (key_rect_right - key_rect_left);

                    CC.Rect(rc.left, rc.bottom, rc.right, rc.top);          //Draw rectangle by current coordinates
                    CC.SetFillColorRGB(Get_UINT_Color(current_key_color));  //Set color of filling
                    CC.FillPath(true, true, PXC_FillRule.FillRule_EvenOdd); //Filling current element

                    rc.top    = key_rect_top + 30;
                    rc.bottom = key_rect_bottom - 30;

                    rc.right = key_rect_right;

                    if (!isDarkColor(string_in_key_field))
                    {
                        CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling
                    }
                    else
                    {
                        CC.SetFillColorRGB(Get_UINT_Color(Color.White));//Set color of filling
                    }
                    CC.ShowTextBlock(string_in_key_field, ref rc, ref rc,
                                     (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);
                }
                page.PlaceContent(CC.Detach()); //Appends drawn content to current page
                CC.SetLineWidth(0.5);           //Set line  width
                CC.StrokePath(true);            //Set end of drawing current element
            }
        }
Ejemplo n.º 33
0
        private static void Draw_Keys_Horisontal(ref IPXC_ContentCreator CC, ref IPXC_Page page)
        {
            int Rect_size_for_20 = (page_Width) / (20 + 2);

            height     = workspace_ob.field_ex.heigth;
            width      = workspace_ob.field_ex.width;
            keys_count = workspace_ob.keys.Count;
            PXC_Rect rc     = new PXC_Rect();
            PXC_Rect rc_out = new PXC_Rect();

            CC.SetLineWidth(0.5);//Set line  width

            string str_keys = "Keys:\n";

            // Define the coordinates for rect
            rc.top    = page_Height - (2 * Rect_size) - Rect_size_for_20 + 60;
            rc.bottom = page_Height - (2 * Rect_size) - 60;
            rc.left   = x_field_bottom + Rect_size_for_20;
            rc.right  = x_field_bottom + Rect_size_for_20 * 6;

            IPXC_CharFormat char_format = inst_pxc.CreateCharFormat();

            char_format.FontSize = 20;
            char_format.ModifyMask((uint)PXC_CharFormatMask.CFM_FontSize, 0);

            CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

            //Draw text block with current text in rc coordinates
            CC.ShowTextBlock(str_keys, ref rc, ref rc,
                             (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter | (uint)PXC_DrawTextFlags.DTF_Justify,
                             (int)-1, char_format, null, null, out rc_out);

            // Define the coordinates for rect
            rc.top    = page_Height - Rect_size_for_20 * 2 + 90;
            rc.bottom = page_Height - Rect_size_for_20;
            rc.left   = Rect_size_for_20;
            rc.right  = page_Width - Rect_size_for_20;

            string template_info = Get_Template_String();

            CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

            //Draw text block with current text in rc coordinates
            CC.ShowTextBlock(template_info, ref rc, ref rc,
                             (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter
                             | (uint)PXC_DrawTextFlags.DTF_Justify, (int)-1, char_format, null, null, out rc_out);

            for (int i = 1, key_counter = 0; i <= keys_count && key_counter < keys_count; i++, key_counter++)
            {
                int    key_rect_top        = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20 + Rect_size_for_20);
                int    key_rect_bottom     = y_field_bottom - 2 * Rect_size_for_20 - (i * Rect_size_for_20);
                int    key_rect_right      = page_Width - Rect_size_for_20;
                int    key_rect_left       = Rect_size_for_20;
                Color  current_key_color   = workspace_ob.keys[key_counter].clr;
                string string_in_key_field = workspace_ob.clr_name[key_counter];
                string current_key_text    = workspace_ob.keys[key_counter].str;

                // Define the coordinates for rect
                rc.top    = page_Height - (3 * Rect_size) - ((Rect_size_for_20 / 2) * (i + 1)) + Rect_size_for_20 / 2;
                rc.bottom = page_Height - (3 * Rect_size) - ((Rect_size_for_20 / 2) * i) + Rect_size_for_20 / 2;
                rc.left   = x_field_bottom + Rect_size_for_20;
                rc.right  = x_field_bottom + Rect_size_for_20 * 4;

                DrawColoringRect(ref CC, ref rc, Color.White);

                // Define the coordinates for rect
                rc.top    = rc.top + 30;
                rc.bottom = rc.bottom - 30;

                CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling

                //Draw text block with current text in rc coordinates
                CC.ShowTextBlock(current_key_text, ref rc, ref rc,
                                 (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                double old_left = rc.left;

                // Define the coordinates for rect
                rc.top    = page_Height - (3 * Rect_size) - ((Rect_size_for_20 / 2) * (i + 1)) + Rect_size_for_20 / 2;
                rc.bottom = page_Height - (3 * Rect_size) - ((Rect_size_for_20 / 2) * i) + Rect_size_for_20 / 2;
                rc.left   = rc.right + 10;
                rc.right  = rc.right + (rc.right - old_left) + 10;

                DrawColoringRect(ref CC, ref rc, current_key_color);

                rc.top    = rc.top + 30;
                rc.bottom = rc.bottom - 30;

                if (!isDarkColor(string_in_key_field))
                {
                    CC.SetFillColorRGB(Get_UINT_Color(Color.Black));//Set color of filling
                }
                else
                {
                    CC.SetFillColorRGB(Get_UINT_Color(Color.White));//Set color of filling
                }
                CC.ShowTextBlock(string_in_key_field, ref rc, ref rc,
                                 (uint)PXC_DrawTextFlags.DTF_Center | (uint)PXC_DrawTextFlags.DTF_VCenter, (int)-1, null, null, null, out rc_out);

                page.PlaceContent(CC.Detach()); //Appends drawn content to current page
                CC.SetLineWidth(0.5);           //Set line  width
                CC.StrokePath(true);            //Set end of drawing current element
            }
        }