Esempio n. 1
0
        //构造函数
        public ShootBoard(ref GroupBox GrpBx)
        {
            GrpBxRef = GrpBx;

            //创建图像并保存其引用
            GrphcBuf = (new BufferedGraphicsContext()).Allocate(GrpBx.CreateGraphics(), GrpBx.ClientRectangle);

            //加载校准值
            LoadCorrectData();

            //加载屏幕信息
            LoadScreenData();

            //清屏
            GrphcBuf.Graphics.Clear(Gray);

            //计算击中符号圈直径
            CenterSize = (int)(PointLength / 1.5);

            //初始化像素和毫米之间的映射比例
            GetScreenData(ScreenInch, ScreenLengthWidthRatio);

            //创建一个数据源
            ShootPoints = new List <ShootPoint>();
        }
        public void Sus(GroupBox nesne)
        {
            Graphics   grafik = nesne.CreateGraphics();
            SolidBrush firca  = new SolidBrush(Color.FromArgb(229, 213, 121));

            float r              = nesne.ClientSize.Width / 2;
            float alinacakDeger  = 0;
            float alinacakDegerX = 0;
            float alinacakDegerY = 0;

            if (nesne.ClientSize.Height < nesne.ClientSize.Width)
            {
                alinacakDeger  = 10;
                alinacakDegerY = (nesne.ClientSize.Height / 2) - 5;
                alinacakDegerX = (nesne.ClientSize.Width / 2) - 5;
            }
            else
            {
                alinacakDeger  = 10;
                alinacakDegerX = (nesne.ClientSize.Width / 2) - 5;
                alinacakDegerY = (nesne.ClientSize.Height / 2);
            }

            grafik.FillEllipse(firca, alinacakDegerX, alinacakDegerY, alinacakDeger, alinacakDeger);
        }
Esempio n. 3
0
        internal static void AlterarBordaComponente(this GroupBox elementoPai, DateTimePicker componente, Color cor)
        {
            float    Espessura = (float)4.0;
            Graphics g         = elementoPai.CreateGraphics();

            g.DrawRectangle(new Pen(cor, Espessura), componente.Location.X, componente.Location.Y, componente.Width, componente.Height);
        }
Esempio n. 4
0
        /// <summary>
        /// Alterar borda de componente Devido a erros
        /// </summary>
        /// <param name="elementoPai">Elemento pai do componente </param>
        /// <param name="componente">Componente para alterar a borda</param>
        /// <param name="cor">Cor de alteração</param>
        internal static void AlterarBordaComponente(this GroupBox elementoPai, TextBox componente, Color cor)
        {
            //componente.BorderStyle = BorderStyle.None;

            float    Espessura = (float)4.0;
            Graphics g         = elementoPai.CreateGraphics();

            g.BeginContainer();
            g.DrawRectangle(new Pen(cor, Espessura), componente.Location.X, componente.Location.Y, componente.Width, componente.Height);
        }
Esempio n. 5
0
File: Main.cs Progetto: sjk7/DX90SDK
    private void DlgMainForm_Load(object sender, System.EventArgs e)
    {
        string sdkpath = DXUtil.SdkMediaPath;

        // Get the graphics object for the static groupbox control.
        applicationGraphics = gbStatic.CreateGraphics();
        mappings            = new ActionFormat[1];
        mappings[0]         = new ActionFormat();

        ConstructActionMap();
        // Get the devices on the system that can be mapped to the action map, and are attached.
        applicationDevices = Manager.GetDevices(mappings[0], EnumDevicesBySemanticsFlags.AttachedOnly);

        // Make sure there are sound devices available.
        if (0 == applicationDevices.Count)
        {
            MessageBox.Show("No available input devices. Sample will close.");
            Close();
            return;
        }

        try
        {
            // Create a sound device, and sound buffer array.
            applicationSoundDevice = new SoundDevice();
            applicationSoundDevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
            applicationSoundBuffers = new SecondaryBuffer[8];
        }
        catch (SoundException)
        {
            MessageBox.Show("No available sound device. Sample will close.");
            Close();
            return;
        }

        foreach (SemanticsInstance instance in applicationDevices)
        {
            // Build and set the action map against each device.
            instance.Device.BuildActionMap(mappings[0], ActionMapControl.Default);
            instance.Device.SetActionMap(mappings[0], ApplyActionMap.Default);
        }

        // Load default wav files.
        LoadSoundFile(sdkpath + "drumpad-bass_drum.wav", 0);
        LoadSoundFile(sdkpath + "drumpad-snare_drum.wav", 1);
        LoadSoundFile(sdkpath + "drumpad-hhat_up.wav", 2);
        LoadSoundFile(sdkpath + "drumpad-hhat_down.wav", 3);
        LoadSoundFile(sdkpath + "drumpad-crash.wav", 4);
        LoadSoundFile(sdkpath + "drumpad-voc_female_ec.wav", 5);
        LoadSoundFile(sdkpath + "drumpad-speech.wav", 6);

        // Turn on the timer.
        timer1.Enabled = true;
    }
Esempio n. 6
0
        private void Doc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            GroupBox grd = Grbox_TTVePhim;
            Bitmap   bmp = new Bitmap(grd.Width, grd.Height, grd.CreateGraphics());

            grd.DrawToBitmap(bmp, new Rectangle(0, 0, grd.Width, grd.Height));
            RectangleF bounds = e.PageSettings.PrintableArea;
            float      factor = ((float)bmp.Height / (float)bmp.Width);

            e.Graphics.DrawImage(bmp, bounds.Left, bounds.Top, bounds.Width, factor * bounds.Width);
        }
Esempio n. 7
0
        public void DrawMaze(GroupBox canvas)
        {
            Pen        myPen     = new System.Drawing.Pen(Color.Red);
            SolidBrush mBrush    = new SolidBrush(Color.LawnGreen);
            Graphics   fGraphics = canvas.CreateGraphics();

            fGraphics.Clear(Color.Gray);

            Random rand = new Random();

            startPosition    = new Point(rand.Next(0, width), rand.Next(0, height));
            finalDestination = new Point(rand.Next(0, width), rand.Next(0, height));

            int size = 20;

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    MazeCell currCell = maze[i][j];

                    if (currCell.North == null)
                    {
                        fGraphics.DrawLine(myPen, i * size, j * size, (i + 1) * size, j * size);
                    }

                    if (currCell.South == null)
                    {
                        fGraphics.DrawLine(myPen, i * size, (j + 1) * size, (i + 1) * size, (j + 1) * size);
                    }

                    if (currCell.East == null)
                    {
                        fGraphics.DrawLine(myPen, (i + 1) * size, j * size, (i + 1) * size, (j + 1) * size);
                    }

                    if (currCell.West == null)
                    {
                        fGraphics.DrawLine(myPen, i * size, j * size, i * size, (j + 1) * size);
                    }
                }
            }

            //drawing startin and ending point
            fGraphics.FillRectangle(mBrush, startPosition.X * size + size / 2, startPosition.Y * size + size / 2, size / 2, size / 2);
            mBrush.Color = Color.SteelBlue;
            fGraphics.FillRectangle(mBrush, finalDestination.X * size + size / 2, finalDestination.Y * size + size / 2, size / 2, size / 2);

            myPen.Dispose();
            fGraphics.Dispose();
            mBrush.Dispose();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="area"></param>
        /// <param name="color"></param>
        private void gDraw(GroupBox area, Color color)
        {
            Graphics g = area.CreateGraphics();

            g.Clear(this.BackColor);
            Rectangle PicRect = area.ClientRectangle;
            Pen       p       = new Pen(color, 30);//定义了一个蓝色,宽度为的画笔

            g.DrawEllipse(p, PicRect.Width / 7, PicRect.Height / 7, PicRect.Height / 4 * 3, PicRect.Width / 4 * 3);

            System.Drawing.Font font  = new System.Drawing.Font("Agency FB", 25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            SolidBrush          brush = new SolidBrush(Color.Blue);

            g.DrawString("99.99%", font, brush, 180F, 200F);
        }
        public void Saat(int saat, GroupBox nesne)
        {
            Graphics grafik = nesne.CreateGraphics();
            Pen      kalem  = new Pen(Color.Black, 6);

            float r = nesne.ClientSize.Width / 2;

            if (nesne.ClientSize.Width > nesne.ClientSize.Height)
            {
                float formunRYuksekligi = nesne.ClientSize.Height / 2;
                r = formunRYuksekligi;
            }
            float xOrta = nesne.ClientSize.Width / 2;
            float yOrta = nesne.ClientSize.Height / 2;
            float aci   = -saat * 30 + 90;

            r -= (float)(r * 0.40);//kenarlardan birakilacak bosluk

            float noktaX = (float)(xOrta + r * Math.Cos(aci * Math.PI / 180));
            float noktaY = (float)(yOrta - r * Math.Sin(aci * Math.PI / 180));

            grafik.DrawLine(kalem, xOrta, yOrta, noktaX, noktaY);
        }
        public void Cerceve(GroupBox nesne)
        {
            Graphics grafik          = nesne.CreateGraphics();
            int      kalemDefaultBoy = 4;
            Pen      kalem           = new Pen(Color.Black, kalemDefaultBoy);

            float r              = nesne.ClientSize.Width / 2;
            float alinacakDeger  = 0;
            float alinacakDegerX = 0;
            float alinacakDegerY = 0;

            if (nesne.ClientSize.Height < nesne.ClientSize.Width)
            {
                alinacakDeger  = nesne.ClientSize.Height;
                alinacakDegerY = 0;
                alinacakDegerX = (nesne.ClientSize.Width - nesne.ClientSize.Height) / 2;
            }
            else
            {
                alinacakDeger  = nesne.ClientSize.Width;
                alinacakDegerX = 0;
                alinacakDegerY = (nesne.ClientSize.Height - nesne.ClientSize.Width) / 2;
            }

            grafik.DrawEllipse(kalem, alinacakDegerX, alinacakDegerY, alinacakDeger, alinacakDeger);

            float kx1, kx2, ky1, ky2;
            float xOrta = nesne.ClientSize.Width / 2, yOrta = nesne.ClientSize.Height / 2;

            if (nesne.ClientSize.Width > nesne.ClientSize.Height)
            {
                float formunRYuksekligi = nesne.ClientSize.Height / 2;
                r = formunRYuksekligi;
            }

            r -= birakilacakBosluk;

            for (int aci = 0; aci <= 360; aci += 6)
            {
                kx1 = (float)(xOrta + (r + 10) * Math.Cos(aci * Math.PI / 180));//10 çizgi uzunluğunu temsil ediyor.
                kx2 = (float)(xOrta + r * Math.Cos(aci * Math.PI / 180));

                ky1 = (float)(yOrta - (r + 10) * Math.Sin(aci * Math.PI / 180));//10 çizginin eğimini temsil ediyor.
                ky2 = (float)(yOrta - r * Math.Sin(aci * Math.PI / 180));

                if (aci % 90 == 0)//çeyrek, yarım veya tam'a eşit ise
                {
                    kalem.Width = kalemDefaultBoy + 4;
                    grafik.DrawLine(kalem, kx1, ky1, kx2, ky2);
                }
                else if (aci % 30 == 0)//her saat başı
                {
                    kalem.Width = kalemDefaultBoy;
                    grafik.DrawLine(kalem, kx1, ky1, kx2, ky2);
                }
                else//her dakika
                {
                    kalem.Width = kalemDefaultBoy - 2;
                    grafik.DrawLine(kalem, kx1, ky1, kx2, ky2);
                }
            }
        }