Пример #1
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
            }
        }
Пример #2
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
            }
        }