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); }
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 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); }
//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 } }
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 } }
//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 } }
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 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); }
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()); } }