Ejemplo n.º 1
0
        //BOOL OnEraseBkgnd(CDC* pDC)
        //{
        //    return TRUE;
        //}
        private void DialogMessage_Paint(object sender, PaintEventArgs e)
        {
            CDC dc = new CDC();

            dc.SetGraphics(e.Graphics); // device context for painting

            //获取位置
            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);
            //DCBuffer.SelectObject(&ImageBuffer);
            DCBuffer.SelectObject(m_InfoFont);
            DCBuffer.SetTextAlign(CDC.TA_TOP | CDC.TA_LEFT);
            DCBuffer.SetTextColor(Color.FromArgb(250, 250, 0));

            m_ImageBackdrop.BitBlt(DCBuffer.GetSafeHdc(), 0, 0);

            string szInfo = string.Empty;

            DCBuffer.DrawText(m_szMessage, rcClient, CDC.DT_SINGLELINE | CDC.DT_END_ELLIPSIS | CDC.DT_VCENTER | CDC.DT_CENTER);

            //绘画界面
            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();
        }
Ejemplo n.º 2
0
        static public CBitmap BuildCBitmap(Control parent)
        {
            while (model.allControls.Exists(l => l.cd.Name == "CBitmap" + CBitmap.count))
            {
                CBitmap.count++;
            }
            CBitmap c = new CBitmap();

            parent.Controls.Add(c);

            SetCommonHandlers(c);
            SetChangesHandler(c);

            Model.getInstance().allControls.Add(c);
            c.SetControlDescription();
            (c as PictureBox).SizeMode = PictureBoxSizeMode.StretchImage;
            (c as PictureBox).Image    = System.Drawing.SystemIcons.Error.ToBitmap();

            model.logCreator.Append("+ Added " + c.cd.Name);
            return(c);
        }
Ejemplo n.º 3
0
        //BOOL OnEraseBkgnd(CDC* pDC)
        //{
        //    return true;
        //}

        private void DialogBetRecord_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);
            //DCBuffer.SelectObject(&ImageBuffer);
            DCBuffer.SelectObject(m_InfoFont);
            DCBuffer.SetTextAlign(CDC.TA_TOP | CDC.TA_LEFT);
            DCBuffer.SetTextColor(Color.FromArgb(250, 250, 0));

            m_ImageBackdrop.BitBlt(DCBuffer.GetSafeHdc(), 0, 0);

            //绘画界面
            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();
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        private void CreatePreviewControls(Section s, XElement i)
        {
            if (s == null)
            {
                return;
            }
            if (i == null)
            {
                return;
            }

            switch (i.Attribute("type").Value)
            {
            case "CLabel":
                CLabel lbl = ControlFactory.BuildCLabel(s.Tab);
                lbl.cd.Name = i.Element("Name").Value;
                break;

            case "CComboBox":
                CComboBox cb = ControlFactory.BuildCComboBox(s.Tab);
                cb.cd.Name = i.Element("Name").Value;
                break;

            case "CButton":
                CButton b = ControlFactory.BuildCButton(s.Tab);
                b.cd.Name = i.Element("Name").Value;
                break;

            case "CGroupBox":
                CGroupBox gb = ControlFactory.BuildCGroupBox(s.Tab);
                gb.cd.Name = i.Element("Name").Value;
                break;

            case "CPanel":
                CPanel pl = ControlFactory.BuildCPanel(s.Tab);
                pl.cd.Name = i.Element("Name").Value;
                break;

            case "CBitmap":
                CBitmap bm = ControlFactory.BuildCBitmap(s.Tab);
                bm.cd.Name = i.Element("Name").Value;
                break;

            case "CTextBox":
                CTextBox tb = ControlFactory.BuildCTextBox(s.Tab);
                tb.cd.Name = i.Element("Name").Value;
                break;

            case "CCheckBox":
                CCheckBox ccb = ControlFactory.BuildCCheckBox(s.Tab);
                ccb.cd.Name = i.Element("Name").Value;
                break;

            case "CTabControl":
                CTabControl ctc = ControlFactory.BuildCTabControl(s.Tab);
                ctc.cd.Name = i.Element("Name").Value;
                break;

            case "CTabPage":
                //Tab pages require its parent TabControl to be created first.
                break;
            }
        }
Ejemplo n.º 6
0
        private void SetControlSpecificProperties(ICustomControl c, XElement i)
        {
            if (c is CComboBox)
            {
                // Fill out the lists of items inside combo box
                ComboBox cb = c as ComboBox;
                foreach (XElement e in i.Element("Items").Descendants("Item"))
                {
                    String value = e.Value.ToString();
                    c.cd.comboBoxRealItems.Add(value);
                    value = TokenTextTranslator.TranslateFromTextFile(value);
                    value = TokenControlTranslator.TranslateFromControl(value);
                    c.cd.comboBoxItems.Add(value);
                }

                foreach (XElement e in i.Element("ConfigItems").Descendants("Item"))
                {
                    c.cd.comboBoxConfigItems.Add(e.Value.ToString());
                }

                // Fill out the comboBox
                foreach (String s in c.cd.comboBoxItems)
                {
                    cb.Items.Add(s);
                }

                try
                {
                    if (!i.Element("Items").Element("Selected").IsEmpty)
                    {
                        String value = TokenTextTranslator.TranslateFromTextFile(i.Element("Items").Element("Selected").Value);
                        value           = TokenControlTranslator.TranslateFromControl(value);
                        cb.SelectedItem = value;
                    }
                }
                catch (NullReferenceException)
                {
                    System.Diagnostics.Debug.WriteLine("*** INFO *** Problem reading " + c.cd.Name + " Attributes. No items defined?");
                }
            }
            else if (c is CCheckBox)
            {
                CheckBox cb = c as CheckBox;
                try
                {
                    c.cd.checkBoxCheckedValue   = i.Element("Settings").Element("CheckedValue").Value;
                    c.cd.checkBoxUncheckedValue = i.Element("Settings").Element("UncheckedValue").Value;
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine("*** INFO *** Problem reading CheckBox Attributes");
                }
            }
            else if (c is CButton)
            {
                try
                {
                    CButton b = c as CButton;
                    b.cd.RealPath   = i.Element("Settings").Element("ExePath").Value;
                    b.cd.Parameters = i.Element("Settings").Element("CallParameters").Value;
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine("*** INFO *** Problem reading Exe Path for Button");
                }
            }
            else if (c is CBitmap)
            {
                try
                {
                    CBitmap m = c as CBitmap;
                    m.cd.RealPath = i.Element("Settings").Element("Path").Value;
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine("*** INFO *** Problem reading Exe Path for Button");
                }
            }
        }
Ejemplo n.º 7
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();
        }