Пример #1
0
        //BOOL OnEraseBkgnd(CDC* pDC)
        //{
        //    return TRUE;
        //}

        private void DialogStatistics_Paint(object sender, PaintEventArgs e)
        {
            CDC dc = new CDC();

            dc.SetGraphics(e.Graphics);

            //获取位置
            CRect rcClient = new CRect();

            GetClientRect(ref rcClient);

            //创建缓冲
            CDC     DCBuffer    = new CDC();
            CBitmap ImageBuffer = new CBitmap();

            ImageBuffer.CreateCompatibleBitmap(dc, rcClient.Width(), rcClient.Height());
            DCBuffer.CreateCompatibleDC(ImageBuffer);

            //设置 DC
            //DCBuffer.SetBkMode(TRANSPARENT);
            //CBitmap* oldBitmap = DCBuffer.SelectObject(&ImageBuffer);
            DCBuffer.SelectObject(m_InfoFont);
            DCBuffer.SetTextAlign(CDC.TA_TOP | CDC.TA_LEFT);
            DCBuffer.SetTextColor(Color.FromArgb(250, 250, 255));

            //背景
            m_ImageBackdrop.BitBlt(DCBuffer.GetSafeHdc(), 0, 0);

            //线
            CPoint point = new CPoint();

            point.SetPoint(51, 284);
            for (int i = 0; i < HorseDefine.HORSES_ALL; ++i)
            {
                for (int j = 0; j < m_nWinCount[i]; ++j)
                {
                    m_ImageLine.BitBlt(DCBuffer.GetSafeHdc(), point.x, point.y);
                    point.y -= 1;
                }

                string szInfo = string.Empty;
                CRect  rect   = new CRect();
                rect.SetRect(point.x - 2, point.y - 15, point.x + 17, point.y);
                szInfo = m_nWinCount[i].ToString();
                DCBuffer.DrawText(szInfo, rect, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_CENTER);

                point.x += 21;
                point.y  = 284;
            }

            //绘画界面
            dc.BitBlt(0, 0, rcClient.Width(), rcClient.Height(), ImageBuffer, 0, 0, 0);

            //清理资源
            //DCBuffer.SetTextColor(oldColor);
            //DCBuffer.SetTextAlign(nTextAlign);
            //DCBuffer.SelectObject(oldBitmap);
            //DCBuffer.SelectObject(oldFont);
            //DCBuffer.DeleteDC();
            //ImageBuffer.DeleteObject();
        }
Пример #2
0
 public AyaPhoto RequestAyaPhoto(CRect rect, CameraType[]?cameras = null)
 {
     return(new AyaPhoto(RequestPhotoTex(rect, cameras), rect));
 }
Пример #3
0
        /// <summary>Open a raw mouse device and wrap it into an adapter that will call the provided object when input happens.</summary>
        public static iInputEventTimeSource openRawMouse(this Dispatcher dispatcher, iMouseHandler handler, CRect clipRect, RawDevice device = null)
        {
            // Find the mouse
            if (null == device)
            {
                device = RawDevice.list().FirstOrDefault(isMouse);
                if (null == device)
                {
                    throw new ApplicationException("No mice are detected");
                }
            }

            // Create the adapter to translate raw events into mouse events
            RawMouse mouse = clipRect.isEmpty ? new RawMouse(device, handler) : new RawMouseClipped(device, clipRect, handler);

            // Open the device
            using (iLinuxDispatcher linuxDispatcher = ComLightCast.cast <iLinuxDispatcher>(dispatcher.nativeDispatcher))
                linuxDispatcher.openInputDevice(device.eventInterface, mouse);

            return(mouse);
        }
Пример #4
0
 public sMeshDataSize renderBlock(Span <sVertexWithId> span, uint id, ReadOnlySpan <char> str, ref CRect rect, eTextRendering how)
 {
     if (str.IsEmpty)
     {
         return(new sMeshDataSize());
     }
     ref var resourses = ref getResources(how);
Пример #5
0
        private unsafe void BtnRender_Click(object sender, EventArgs e)
        {
            int fontSize = (int)NudFontSize.Value;

            CFont.Init(MakePath());
            Bitmap image = new Bitmap(Picture.Width, Picture.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            Picture.Image = image;
            Graphics g = Graphics.FromImage(image);

            g.Clear(Color.White);
            g.Dispose();
            var text = string.Intern(Txt.Text);//弄成常量
            //var text = Charset.Content;
            CFontInfo fontInfo;

            CG.GetValidFontSize((int)NudFontSize.Value, out fontInfo);
            CBitmap bitmap;

            CGraphicInits.InitBitmap(out bitmap, CPixelFormat.Format8bppIndexed, image.Width, image.Height);
            CTextInfo textInfo = new CTextInfo()
            {
                Start  = 0,
                End    = text.Length,
                Length = text.Length
            };

            textInfo.Text = Utils.ToCharPointer(text);
            var modifyRect = new CRect();
            var rect       = new CRect()
            {
                MinX = 0, MinY = 0, MaxX = 400, MaxY = 300
            };

            CG.DrawText(ref bitmap, textInfo, fontInfo, rect, new CPoint()
            {
                X = 0, Y = 0
            }, out modifyRect);
            EInkRender.DrawToBitmap(ref image, bitmap, rect);

            ////注意:设置负数的缩进,会有文本绘制不全的问题
            //FontMargin margin = new FontMargin();
            //margin.PageMarginLeft = 12;
            //margin.PageMarginRight = margin.PageMarginLeft;
            //margin.PageMarginTop = margin.PageMarginLeft;
            //margin.PageMarginRight = margin.PageMarginLeft;
            //margin.LineMarginTop = 4;
            //margin.LineMarginBottom = 2;
            //margin.MarginLeft = -2;
            //margin.MarginRight = -1;
            //margin.MarginTop = 0;
            //margin.MarginBottom = 0;
            //margin.ParagraphFirstLineMarginLeft = (short)((info.Width + margin.MarginLeft + margin.MarginRight) * 2);//空2个字符

            //int startX = margin.PageMarginLeft + margin.MarginLeft;
            //int x = startX + margin.ParagraphFirstLineMarginLeft;
            //int y = margin.PageMarginTop + margin.MarginTop;
            //FontBitmap matrix;
            //int maxX = bitmap.Width - margin.PageMarginRight - margin.MarginRight - 1;
            //int maxY = bitmap.Height - margin.PageMarginBottom - margin.LineMarginBottom - margin.MarginBottom - 1;
            //int lineHeight = info.Height + margin.LineMarginTop + margin.LineMarginBottom + margin.MarginTop + margin.MarginBottom;
            ////注意
            //for (int i = 0; i < text.Length; i++)
            //{
            //    var character = text[i];
            //    //强制换行
            //    if (character == '\n' || (character == '\r' && i < text.Length - 1) && character == '\n')
            //    {
            //        x = startX + margin.ParagraphFirstLineMarginLeft;
            //        y += lineHeight;
            //        //跳过\n
            //        if (character == '\r')
            //        {
            //            i++;
            //        }
            //        continue;
            //    }

            //    if (Fonts.ePageGetFontMatrix(character, fontSize, out matrix))
            //    {
            //        int width = info.Width;
            //        //新起一行
            //        if (x + width > maxX)
            //        {
            //            x = startX;
            //            y += lineHeight;
            //        }
            //        if (y > maxY)
            //        {
            //            break;
            //        }
            //        Fonts.ePageDrawFontMatrix(bitmap, x, y, matrix, info);

            //        x += width + margin.MarginLeft + margin.MarginRight;
            //    }
            //}
        }
Пример #6
0
 void iWindowSetup.adjustInitialPosition(ref CRect displayRectangle, ref sWindowInitialPosition swp)
 {
     // swp.show = eShowWindow.Minimized;
     // swp.show = eShowWindow.Maximized;
     // swp.show = eShowWindow.Fullscreen;
 }
Пример #7
0
 /// <summary>Create uncropped</summary>
 public sDecodedVideoSize(CSize size)
 {
     this.size    = size;
     cropRect     = new CRect(default, size);
Пример #8
0
        private void PatMaxTool_Changed(object sender, Cognex.VisionPro.CogChangedEventArgs e)
        {
            //If FunctionalArea And cogFA_Tool_Results Then
            if ((Cognex.VisionPro.Implementation.CogToolBase.SfCreateLastRunRecord |
                 Cognex.VisionPro.Implementation.CogToolBase.SfRunStatus) > 0)
            {
                //Note, Results will be nothing if Run failed.
                if (PatMaxTool.Results == null)
                {
                    //txtPatMaxScoreValue.Text = "N/A";
                }
                else if (PatMaxTool.Results.Count > 0)
                {
                    int nRetrieved = PatMaxTool.Results.Count;

                    for (int nItem = 0; nItem < nRetrieved; nItem++)
                    {
                        if (nItem >= PARAM_NUM_TO_FIND)
                        {
                            break;
                        }

                        int nIndexer = nItem;//listSorted.ElementAt(nItem);

                        try
                        {
                            CogPMAlignResult result = PatMaxTool.Results[nIndexer];

                            if (result.Score <= PARAM_ACCEPT_RATIO / 100.0)
                            {
                                continue;
                            }

                            //Passing result does not imply Pattern is found, must check count.
                            CogCompositeShape resultGraphics = default(CogCompositeShape);
                            resultGraphics = PatMaxTool.Results[nIndexer].CreateResultGraphics(CogPMAlignResultGraphicConstants.MatchRegion);

                            CogRectangle rect     = resultGraphics.EnclosingRectangle(CogCopyShapeConstants.All);
                            RectangleF   rcResult = new RectangleF((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height);

                            // Get matced Template Center
                            PointF ptTemplateCenter = CRect.GetCenter(rcResult);

                            // Set Relative Distance
                            PointF ptDistance = CPoint.GetDistancePoint(PARAM_PT_RELATIVE_ORIGIN, ptTemplateCenter);

                            CogTransform2DLinear ll = result.GetPose();

                            ptrnResult.AddData(rcResult, ptTemplateCenter, ptDistance, result.Score, 0);
                        }
                        catch
                        {
                        }
                    }
                }
                else
                {
                    //txtPatMaxScoreValue.Text = "N/A";
                }
            }
        }
Пример #9
0
        /// <summary>Overwrite a box of 2D texture with supplied data in system RAM</summary>
        public static void updateTexture <T>(this IDeviceContext context, ITexture texture, ReadOnlySpan <T> source, ref CRect destBox) where T : unmanaged
        {
            CSize boxSize = destBox.size;

            Debug.Assert(boxSize.cx * boxSize.cy == source.Length);
            TextureSubResData tsrd = new TextureSubResData(false);

            tsrd.Stride = Marshal.SizeOf <T>() * boxSize.cx;
            Box box = createBox(ref destBox);

            unsafe
            {
                fixed(T *pointer = source)
                {
                    tsrd.pData = (IntPtr)pointer;
                    context.UpdateTexture(texture, 0, 0, ref box, ref tsrd);
                }
            }
        }
Пример #10
0
 internal sDecodedVideoSize(CSize size, CRect cropRect, eChromaFormat chromaFormat)
 {
     this.size         = size;
     this.cropRect     = cropRect;
     this.chromaFormat = chromaFormat;
 }
Пример #11
0
        /// <summary>Switch window state without moving the window</summary>
        public static void moveWindow(this iDiligentWindow wnd, eShowWindow newState)
        {
            CRect rect = CRect.empty;

            wnd.moveWindow(newState, ref rect);
        }
Пример #12
0
 /// <summary>
 /// Return true if the object is in the given rectangle.
 /// </summary>
 /// <param name="rect">Rectangle in world-space</param>
 /// <returns></returns>
 public static ExPred Rect(CRect rect)
 {
     return(bpi => CollisionMath.pointInRect.Of(
                bpi.loc, ExC(rect)
                ));
 }
Пример #13
0
        //BOOL OnEraseBkgnd(CDC* pDC)
        //{
        //    return true;
        //}

        private void DialogRecord_Paint(object sender, PaintEventArgs e)
        {
            CDC dc = new CDC();

            dc.SetGraphics(e.Graphics);

            //获取位置
            CRect rcClient = new CRect();

            GetClientRect(ref rcClient);

            //创建缓冲
            CDC     DCBuffer    = new CDC();
            CBitmap ImageBuffer = new CBitmap();

            ImageBuffer.CreateCompatibleBitmap(dc, rcClient.Width(), rcClient.Height());
            DCBuffer.CreateCompatibleDC(ImageBuffer);

            //设置 DC
            //DCBuffer.SetBkMode(TRANSPARENT);
            //CBitmap* oldBitmap = DCBuffer.SelectObject(&ImageBuffer);
            DCBuffer.SelectObject(m_InfoFont);
            DCBuffer.SetTextAlign(CDC.TA_TOP | CDC.TA_LEFT);
            DCBuffer.SetTextColor(Color.FromArgb(250, 250, 255));

            //背景
            m_ImageBackdropHand.BitBlt(DCBuffer.GetSafeHdc(), 0, 0);

            int nBcakY = m_ImageBackdropHand.GetHeight();

            for (int i = 0; i < HorseDefine.MAX_SCORE_HISTORY; ++i)
            {
                m_ImageBackdrop.BitBlt(DCBuffer.GetSafeHdc(), 0, nBcakY);
                nBcakY += m_ImageBackdrop.GetHeight();
            }
            m_ImageBackdropTail.BitBlt(DCBuffer.GetSafeHdc(), 0, nBcakY);

            //写记录
            int    nRecordsY = m_ImageBackdropHand.GetHeight();
            string szInfo    = string.Empty;
            CRect  rect      = new CRect();

            for (int i = 0; i < m_GameRecords.Count; ++i)
            {
                rect.SetRect(0, nRecordsY, 28, nRecordsY + 15);
                szInfo = m_GameRecords[i].nStreak.ToString();
                DCBuffer.DrawText(szInfo, rect, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_CENTER);

                rect.SetRect(28, nRecordsY, 57, nRecordsY + 15);
                szInfo = IdentifyAreas(m_GameRecords[i].nRanking);
                DCBuffer.DrawText(szInfo, rect, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_CENTER);

                rect.SetRect(57, nRecordsY, 86, nRecordsY + 15);
                szInfo = m_GameRecords[i].nRiskCompensate.ToString();
                DCBuffer.DrawText(szInfo, rect, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_CENTER);

                rect.SetRect(86, nRecordsY, 151, nRecordsY + 15);
                szInfo = string.Format("{0}{1}:{2}{3}:{4}{5}",
                                       m_GameRecords[i].nHours >= 10 ? TEXT("") : TEXT("0"), m_GameRecords[i].nHours,
                                       m_GameRecords[i].nMinutes >= 10 ? TEXT("") : TEXT("0"), m_GameRecords[i].nMinutes,
                                       m_GameRecords[i].nSeconds >= 10 ? TEXT("") : TEXT("0"), m_GameRecords[i].nSeconds);
                DCBuffer.DrawText(szInfo, rect, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_CENTER);
                nRecordsY += 15;
            }

            nRecordsY = m_szTotalSize.cy - 85;
            rect.SetRect(5, nRecordsY, 146, nRecordsY + 15);
            szInfo = string.Format("本局总投注:{0}", m_lAllBet);
            DCBuffer.DrawText(szInfo, rect, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_LEFT);

            nRecordsY += 15;
            rect.SetRect(5, nRecordsY, 146, nRecordsY + 15);
            szInfo = string.Format("本局投注人数:{0}", m_lBetMumber);
            DCBuffer.DrawText(szInfo, rect, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_LEFT);

            nRecordsY += 20;
            rect.SetRect(5, nRecordsY, 146, nRecordsY + 15);
            szInfo = string.Format("您的余额为:{0}", m_lPlayerScore);
            DCBuffer.DrawText(szInfo, rect, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_LEFT);

            //绘画界面
            dc.BitBlt(0, 0, rcClient.Width(), rcClient.Height(), ImageBuffer, 0, 0, 0);

            //清理资源
            //DCBuffer.SetTextColor(oldColor);
            //DCBuffer.SetTextAlign(nTextAlign);
            //DCBuffer.SelectObject(oldBitmap);
            //DCBuffer.SelectObject(oldFont);
            //DCBuffer.DeleteDC();
            //ImageBuffer.DeleteObject();
        }
Пример #14
0
 internal RawMouseClipped(RawDevice device, CRect clipRect, iMouseHandler handler) :
     base(device, handler)
 {
     this.clipRect = clipRect;
     position      = prevPosition = clipRect.center;
 }
Пример #15
0
        internal SequenceParameterSet(ref BitReader reader)
        {
            // Ported from C++ in Chromium, \chromium-master\media\video\h264_parser.cc

            profile = (eAvcProfile)reader.readInt(8);
            reader.skipBits(8);                                       // constraint_set0_flag x6 + 2 reserved bits
            levelIndex     = (byte)reader.readInt(8);
            parameterSetId = checked ((byte)reader.unsignedGolomb()); // seq_parameter_set_id
            if (parameterSetId >= 32)
            {
                throw new ArgumentException();
            }

            if (extraBs.Contains((byte)profile))
            {
                uint chromaFormatIndex = reader.unsignedGolomb();                   // uint chroma_format_idc
                if (chromaFormatIndex >= 4)
                {
                    throw new ArgumentException();
                }
                chromaFormat = (eChromaFormat)chromaFormatIndex;
                if (3 == chromaFormatIndex)
                {
                    separateColourPlaneFlag = reader.readBit();
                }
                else
                {
                    separateColourPlaneFlag = false;
                }

                uint bit_depth_luma_minus8 = reader.unsignedGolomb();
                if (bit_depth_luma_minus8 >= 7)
                {
                    throw new ArgumentException();
                }
                bitDepthLuma = (byte)(bit_depth_luma_minus8 + 8);

                uint bit_depth_chroma_minus8 = reader.unsignedGolomb();
                if (bit_depth_chroma_minus8 >= 7)
                {
                    throw new ArgumentException();
                }
                bitDepthChroma = (byte)(bit_depth_chroma_minus8 + 8);

                bool qpprime_y_zero_transform_bypass_flag = reader.readBit();
                bool seq_scaling_matrix_present_flag      = reader.readBit();
                if (seq_scaling_matrix_present_flag)
                {
                    throw new NotImplementedException();
                }
            }
            else
            {
                chromaFormat            = eChromaFormat.c420;
                separateColourPlaneFlag = false;
                bitDepthLuma            = bitDepthChroma = 8;
            }

            uint log2_max_frame_num_minus4 = reader.unsignedGolomb();

            frameIndexBits = checked ((byte)(log2_max_frame_num_minus4 + 4));

            uint pic_order_cnt_type = reader.unsignedGolomb();

            switch (pic_order_cnt_type)
            {
            case 0:
                reader.skipGolomb();                            // log2_max_pic_order_cnt_lsb_minus4
                break;

            case 1:
                reader.skipBits(1);                           // delta_pic_order_always_zero_flag
                reader.skipGolomb();                          // int offset_for_non_ref_pic
                reader.skipGolomb();                          // int offset_for_top_to_bottom_field
                uint num_ref_frames_in_pic_order_cnt_cycle = reader.unsignedGolomb();
                if (num_ref_frames_in_pic_order_cnt_cycle >= 0xFF)
                {
                    throw new ArgumentException();
                }
                for (int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++)
                {
                    reader.skipGolomb();                                // int offset_for_ref_frame
                }
                break;
            }
            reader.skipGolomb();            // uint max_num_ref_frames
            reader.skipBits(1);             // bool gaps_in_frame_num_value_allowed_flag

            // Decoded size
            int  pic_width_in_mbs_minus1        = (int)reader.unsignedGolomb();
            int  pic_height_in_map_units_minus1 = (int)reader.unsignedGolomb();
            bool frame_mbs_only_flag            = reader.readBit();

            decodedSize    = default;
            decodedSize.cx = (pic_width_in_mbs_minus1 + 1) * 16;
            if (false == frame_mbs_only_flag)
            {
                reader.skipBits(1);                     // bool mb_adaptive_frame_field_flag
            }
            int map_unit = frame_mbs_only_flag ? 16 : 32;

            decodedSize.cy = map_unit * (pic_height_in_map_units_minus1 + 1);

            reader.skipBits(1);               // direct_8x8_inference_flag

            // Frame cropping
            bool frame_cropping_flag = reader.readBit();

            if (frame_cropping_flag)
            {
                int frame_crop_left_offset   = (int)reader.unsignedGolomb();
                int frame_crop_right_offset  = (int)reader.unsignedGolomb();
                int frame_crop_top_offset    = (int)reader.unsignedGolomb();
                int frame_crop_bottom_offset = (int)reader.unsignedGolomb();

                CSize cropUnit;
                switch (chromaFormat)
                {
                case eChromaFormat.c420:
                    cropUnit = new CSize(2, 2);
                    break;

                case eChromaFormat.c422:
                    cropUnit = new CSize(2, 1);
                    break;

                case eChromaFormat.c444:
                    cropUnit = new CSize(1, 1);
                    break;

                default:
                    throw new ArgumentException();
                }

                cropRectangle        = default;
                cropRectangle.left   = frame_crop_left_offset * cropUnit.cx;
                cropRectangle.top    = frame_crop_top_offset * cropUnit.cy;
                cropRectangle.right  = decodedSize.cx - frame_crop_right_offset * cropUnit.cx;
                cropRectangle.bottom = decodedSize.cy - frame_crop_bottom_offset * cropUnit.cy;
            }
            else
            {
                cropRectangle = new CRect(default, decodedSize);