當前位置: 首頁>>代碼示例>>C#>>正文


C# BufferedGraphics.Render方法代碼示例

本文整理匯總了C#中System.Drawing.BufferedGraphics.Render方法的典型用法代碼示例。如果您正苦於以下問題:C# BufferedGraphics.Render方法的具體用法?C# BufferedGraphics.Render怎麽用?C# BufferedGraphics.Render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.BufferedGraphics的用法示例。


在下文中一共展示了BufferedGraphics.Render方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnPaint

		protected override void OnPaint(PaintEventArgs e)
		{
			BufferedGraphicsContext currentContext;
			currentContext = BufferedGraphicsManager.Current;
			myBuffer = currentContext.Allocate(this.CreateGraphics(), this.DisplayRectangle);

			PaintEventArgs args = new PaintEventArgs(myBuffer.Graphics, e.ClipRectangle);

			base.OnPaint(args);

			myBuffer.Render(e.Graphics);
			myBuffer.Dispose();
		}
開發者ID:gspatace,項目名稱:logexpert,代碼行數:13,代碼來源:LogTabControl.cs

示例2: clock_Tick

        private void clock_Tick(object sender, EventArgs e)
        {
            // Make the draw buffer and set background color
            myBuffer = currentContext.Allocate(canvas.CreateGraphics(), canvas.DisplayRectangle);
            myBuffer.Graphics.FillRectangle(Brushes.WhiteSmoke, canvas.DisplayRectangle);

            // Move Update Draw Simulation Objects
            foreach (SimulationObject so in objects)
            {
                so.UpdateState();
                so.PerformAction();
                so.Draw(myBuffer.Graphics);
            }

            // Main draw
            myBuffer.Render();
            myBuffer.Dispose();
        }
開發者ID:rNdm74,項目名稱:C-,代碼行數:18,代碼來源:Form1.cs

示例3: timer1_Tick

        private void timer1_Tick(object sender, EventArgs e)
        {
            
            using (currentContext = BufferedGraphicsManager.Current)
            using (myBuffer = currentContext.Allocate(this.CreateGraphics(), this.DisplayRectangle))
            {
                game.draw(myBuffer);
                game.update(myBuffer);
                myBuffer.Render(this.CreateGraphics());
            }
            cont++;

            if(cont == 50) 
            {
                cont = 0;
                game.reset(myBuffer);
            }
        }
開發者ID:Ripazhakgggdkp,項目名稱:ProyectoAlgoritmos,代碼行數:18,代碼來源:Form1.cs

示例4: accel_AccelerationChange

        void accel_AccelerationChange(object sender, AccelerationChangeEventArgs e)
        {
            formGraphicsContext = new BufferedGraphicsContext();

            formGraphicsBuffer = formGraphicsContext.Allocate(Graphics.FromImage(formDrawingSurface), rectBounds);

            formGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            formGraphicsBuffer.Graphics.Clear(SystemColors.Control);

            int i = 0;
            //low pass filtering
            switch (e.Index)
            {
                case 0:
                    xOut = 0;
                    xFilt[6] = e.Acceleration;
                    for (i = 0; i < 6; i++)
                    {
                        xFilt[i] = xFilt[i + 1];
                        xOut = xOut + xFilt[i];
                    }
                    xOut = xOut / 6;
                    label6.Text = e.Acceleration.ToString();
                    break;
                case 1:
                    yOut = 0;
                    yFilt[6] = e.Acceleration;
                    for (i = 0; i < 6; i++)
                    {
                        yFilt[i] = yFilt[i + 1];
                        yOut = yOut + yFilt[i];
                    }
                    yOut = yOut / 6;
                    label7.Text = e.Acceleration.ToString();
                    break;
                case 2:
                    zOut = 0;
                    zFilt[6] = e.Acceleration;
                    for (i = 0; i < 6; i++)
                    {
                        zFilt[i] = zFilt[i + 1];
                        zOut = zOut + zFilt[i];
                    }
                    zOut = zOut / 6;
                    label8.Text = e.Acceleration.ToString();
                    break;
            }

            x1Old = xCenter - (float)xOut * circleRadius;
            y1Old = yCenter + (float)yOut * circleRadius;

            formGraphicsBuffer.Graphics.DrawLine(xyAxisPen, xCenter, yCenter, x1Old, y1Old);
            formGraphicsBuffer.Graphics.DrawEllipse(circlePen, circleRectangle);

            if (accel.axes.Count == 3)
            {
                if (zOut > 0)
                {
                    formGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Red, 2),
                        new Rectangle((int)xCenter - (int)(circleRadius * zOut), (int)yCenter - (int)(circleRadius * zOut),
                        (int)(circleDiameter * zOut), (int)(circleDiameter * zOut)));
                }
                else
                {
                    formGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Green, 2),
                        new Rectangle((int)xCenter - (int)(circleRadius * -zOut), (int)yCenter - (int)(circleRadius * -zOut),
                        (int)(circleDiameter * -zOut), (int)(circleDiameter * -zOut)));
                }
            }

            formGraphicsBuffer.Render(panel1.CreateGraphics());

            formGraphicsBuffer.Dispose();

            formGraphicsContext.Dispose();
        }
開發者ID:niccokunzmann,項目名稱:PhidgetsWithCSharp,代碼行數:77,代碼來源:Form1.cs

示例5: BufferedDrawImg

        /// <summary>
        /// 雙緩衝畫圖,用於畫map底圖
        /// </summary>
        /// <param name="g">目標設備的Graphics</param>
        /// <param name="PicImg">底圖的Image實例</param>
        /// <param name="left">底圖左邊線X坐標</param>
        /// <param name="top">底圖上邊線Y坐標</param>
        /// <param name="width">底圖寬</param>
        /// <param name="height">底圖的高</param>
        private void BufferedDrawImg(Graphics g, Image PicImg, int left, int top, float width, float height)
        {
            if (PicImg != null)
            {
                context = BufferedGraphicsManager.Current;
                context.MaximumBuffer = new Size(this.Width + 1, this.Height + 1);
                bgraph = context.Allocate(g, new Rectangle(0, 0, this.Width + 1, this.Height + 1));
                bgraph.Graphics.Clear(this.BackColor);
                bgraph.Graphics.DrawImage(PicImg, left, top, width, height);
                bgraph.Graphics.DrawRectangle(Pens.Black, rect);
                PaintStation(bgraph.Graphics);
                PaintMover(bgraph.Graphics);
                PaintRoute(bgraph.Graphics);
                if (IsPaintRoute)
                {
                    PaintStation(bgraph.Graphics);
                    PaintMover(bgraph.Graphics);
                }
                PaintMoverRoute(bgraph.Graphics);

                //bgraph.Graphics.DrawImage(myimage, 200, 200, 50, 50);
                bgraph.Render();
                bgraph.Dispose();
            }
        }
開發者ID:ZoeCheck,項目名稱:128_5.6_2010,代碼行數:34,代碼來源:ZzhaMapGis.cs

示例6: Draw

 private void Draw(BufferedGraphics buffer, float delta)
 {
     UpdateFPS();
     this.world.Draw(buffer.Graphics, this.view, delta);
     this.ui.Draw(buffer.Graphics, this.world);
     buffer.Render();
 }
開發者ID:Quaade,項目名稱:SurvivalGame,代碼行數:7,代碼來源:Game.cs

示例7: accel_AccelerationChange

        //acceleration change event handler
        void accel_AccelerationChange(object sender, AccelerationChangeEventArgs e)
        {
            //get our graphics buffer going so we can draw to our panel
            accelGraphicsContext = new BufferedGraphicsContext();
            accelGraphicsBuffer = accelGraphicsContext.Allocate(Graphics.FromImage(accelDrawingSurface), boundsRectangle);
            accelGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            accelGraphicsBuffer.Graphics.Clear(SystemColors.Control);

            Accelerometer attached = (Accelerometer)sender;

            //in this switch statement we will do a bit of simple low pass filtering to smooth out the motion of the graphical representation of the
            //acceleration data.  We will also write the raw data to the textbox for the appropriate axis.
            int i = 0;
            try
            {
                switch (e.Index)
                {
                    case 0:
                        xOut = 0;
                        xFilt[6] = e.Acceleration;
                        for (i = 0; i < 6; i++)
                        {
                            xFilt[i] = xFilt[i + 1];
                            xOut = xOut + xFilt[i];
                        }
                        xOut = xOut / 6;
                        axis1AccelTxt.Text = e.Acceleration.ToString();
                        break;
                    case 1:
                        yOut = 0;
                        yFilt[6] = e.Acceleration;
                        for (i = 0; i < 6; i++)
                        {
                            yFilt[i] = yFilt[i + 1];
                            yOut = yOut + yFilt[i];
                        }
                        yOut = yOut / 6;
                        axis2AccelTxt.Text = e.Acceleration.ToString();
                        break;
                    case 2:
                        zOut = 0;
                        zFilt[6] = e.Acceleration;
                        for (i = 0; i < 6; i++)
                        {
                            zFilt[i] = zFilt[i + 1];
                            zOut = zOut + zFilt[i];
                        }
                        zOut = zOut / 6;
                        axis3AccelTxt.Text = e.Acceleration.ToString();
                        break;
                }
            }
            catch (PhidgetException ex)
            {
                MessageBox.Show(ex.Description);
            }

            xOld = xCenter - (float)xOut * circleRadius;
            yOld = yCenter + (float)yOut * circleRadius;

            accelGraphicsBuffer.Graphics.DrawLine(xyAxisPen, xCenter, yCenter, xOld, yOld);
            accelGraphicsBuffer.Graphics.DrawEllipse(circlePen, circleRectangle);

            if (attached.axes.Count == 3)
            {
                if (zOut > 0)
                {
                    accelGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Red, 2),
                        new Rectangle((int)xCenter - (int)(circleRadius * zOut), (int)yCenter - (int)(circleRadius * zOut),
                        (int)(circleDiameter * zOut), (int)(circleDiameter * zOut)));
                }
                else
                {
                    accelGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Green, 2),
                        new Rectangle((int)xCenter - (int)(circleRadius * -zOut), (int)yCenter - (int)(circleRadius * -zOut),
                        (int)(circleDiameter * -zOut), (int)(circleDiameter * -zOut)));
                }
            }

            accelGraphicsBuffer.Render(panel1.CreateGraphics());

            accelGraphicsBuffer.Dispose();

            accelGraphicsContext.Dispose();
        }
開發者ID:niccokunzmann,項目名稱:PhidgetsWithCSharp,代碼行數:86,代碼來源:Form1.cs

示例8: MainForm_Load

        private void MainForm_Load(object sender, EventArgs e)
        {
            myContext = new BufferedGraphicsContext();
            myBuffer = myContext.Allocate(this.CreateGraphics(), this.DisplayRectangle);
            myBuffer.Graphics.Clear(SystemColors.Control);

            myBuffer.Graphics.DrawLine(Pens.Black, 820, 120, 820, 169);
            myBuffer.Graphics.DrawLine(Pens.Black, 821, 120, 821, 169);
            lblYScale.Text = YScaleText[yScaleIndex];
            lblXScale.Text = XScaleText[xScaleIndex];
            myBuffer.Render();

            int firmwareID1 = 0;
            int firmwareID2 = 0;
            int firmwareID3 = 0;

            //char[] buff = new char[1];
            //buff[0] = 's';
            //serialPort1.Write(buff, 0, 1);
            //serialPort1.WriteLine("s");

            try
            {
                // Try to open Intan RHA2000-EVAL board on USB port
                myUSBSource.Open(ref firmwareID1, ref firmwareID2, ref firmwareID3);
            }
            catch
            {
                // If no board is found (or drivers are not installed), run application with synthetic neural data for demonstration purposes

                if (MessageBox.Show("Intan Technologies USB device not found.  Click OK to run application with synthesized neural data for demonstration purposes.\n\nTo use the RHA2000-EVAL board click Cancel, load correct drivers and/or connect device to USB port, then restart application.\n\nVisit http://www.intantech.com for drivers and more information.",
                    "Intan USB Device Not Found", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel)
                    this.Close();

                this.Text = "Intan Technologies Amplifier Demo (SIMULATED DATA: Connect board and restart program to record live data)";
                myUSBSource.SynthDataMode = true;
                tmrSynthData.Enabled = true;
                yScaleIndex = 5;
                lblYScale.Text = YScaleText[yScaleIndex];

                // Disable hardware options if no board is connected
                chkSettle.Enabled = false;
                btnZCheck.Enabled = false;

            }

            if (myUSBSource.SynthDataMode)
                lblStatus.Text = "No USB board connected.  Ready to run with synthesized neural data.";

            else
            {
                lblStatus.Text = String.Concat("Connected to Intan Interface Board with firmware type ",
                    firmwareID1.ToString(), ", version ",
                    firmwareID2.ToString(), ".",
                    firmwareID3.ToString());
            }
        }
開發者ID:cineguerrilha,項目名稱:ICe-e,代碼行數:57,代碼來源:MainForm.cs

示例9: Draw

        public void Draw(Graphics g, ref int x, ref int y, Rectangle target, bool final)
        {
            if (!this.Visible)
                return;
            this.BackColor = Block.BackColor;
            try
            {
                bgc = BGC.Allocate(g, target);
                bgc.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
                bgc.Graphics.FillRegion(new SolidBrush(this.Block.BackColor), new System.Drawing.Region(new Rectangle(0, 0, this.Width, this.Height)));
                foreach (Element elm in Children)
                {

                    x += elm.X;
                    y += elm.Y;
                    if(elm.Visible &&
                        elm.X  - this.SpiderView.HorizontalScroll.Value < this.Width + 3 && elm.Y + elm.Height > this.SpiderView.VerticalScroll.Value &&
                    elm.Y  - this.SpiderView.VerticalScroll.Value < this.Height + 3 && elm.X + elm.Width > this.SpiderView.HorizontalScroll.Value)
                        elm.Draw(bgc.Graphics, ref x, ref y, final);
                    elm.AbsoluteTop = y;
                    elm.AbsoluteLeft = x;
                    if (elm.GetType() == typeof(columnheader))
                    {
                        overflows.Add(new DrawBuffer() { x = x, y = y, elm = elm });
                    }
                    x -= elm.X;
                    y -= elm.Y;

                }
                foreach (DrawBuffer db in overflows)
                {
                    db.elm.Draw(bgc.Graphics, ref db.x, ref db.y, final);
                }
                overflows.Clear();

                bgc.Render();
            }
            catch (System.ComponentModel.Win32Exception e)
            {

            }
        }
開發者ID:krikelin,項目名稱:SpiderView,代碼行數:42,代碼來源:Board.cs

示例10: OnPaint


//.........這裏部分代碼省略.........
                    {
                        if (skipMS > 3600000)
                            myBuffer.Graphics.DrawString(String.Format("{0:0}h", t / 3600000.0f), timingFont, blackBrush, new PointF(x, 0));
                        else
                            if (skipMS > 60000)
                                myBuffer.Graphics.DrawString(String.Format("{0:0}m", t / 60000.0f), timingFont, blackBrush, new PointF(x, 0));
                            else
                                if (skipMS > 100)
                                    myBuffer.Graphics.DrawString(String.Format("{0:0}s", t / 1000.0f), timingFont, blackBrush, new PointF(x, 0));
                                else
                                    myBuffer.Graphics.DrawString(String.Format("{0:0}", t), timingFont, blackBrush, new PointF(x, 0));
                    }
                    else
                    {
                        if (skipMS > 3600000)
                            myBuffer.Graphics.DrawString(String.Format("{0:n}h", t / 3600000.0f), timingFont, blackBrush, new PointF(x, 0));
                        else
                            if (skipMS > 60000)
                                myBuffer.Graphics.DrawString(String.Format("{0:n}m", t / 60000.0f), timingFont, blackBrush, new PointF(x, 0));
                            else
                                if (skipMS > 100)
                                    myBuffer.Graphics.DrawString(String.Format("{0:n}s", t / 1000.0f), timingFont, blackBrush, new PointF(x, 0));
                                else
                                    myBuffer.Graphics.DrawString(String.Format("{0:n}", t), timingFont, blackBrush, new PointF(x, 0));
                    }

                    myBuffer.Graphics.DrawLine(tickPen, x, 0, x, height - 1);
                }

                byte[] waveData = memoryStream.GetBuffer();
                int bytesToProcess = samplesPerPixel * bytesPerSample;

                if (minValues.Length < (e.ClipRectangle.Width + e.ClipRectangle.X))
                {
                    minValues = new float[e.ClipRectangle.Width + e.ClipRectangle.X];
                    maxValues = new float[e.ClipRectangle.Width + e.ClipRectangle.X];
                }

                bool skipTaken = false;

                for (x = 0; (x < e.ClipRectangle.Right) && (position < waveData.Length); x++)
                {
                    if ((x >= skipAudioX)&&(!skipTaken))
                    {
                        x += skipAudioAmount;
                        skipTaken = true;
                    }
                    short low = BitConverter.ToInt16(waveData, (int)position);
                    short high = low;
                    long n;
                    for (n = position + bytesPerSample; (n < (position + bytesToProcess)) && (n < waveData.Length); n += bytesPerSample)
                    {
                        short sample = BitConverter.ToInt16(waveData, (int)n);
                        if (sample < low) low = sample;
                        if (sample > high) high = sample;
                    }

                    position = n;
                    float lowPercent = ((((float)low) - short.MinValue) / ushort.MaxValue);
                    float highPercent = ((((float)high) - short.MinValue) / ushort.MaxValue);

                    minValues[x] = height * lowPercent;
                    maxValues[x] = height * highPercent;

                    int l = (int)minValues[x];
                    int h = (int)maxValues[x] + 1;
                    myBuffer.Graphics.DrawLine(linePen, x, l, x, h);
                }

                for (i = 0; i < editPoints.Count; i++)
                {
                    if ((editPoints[i].position > beginPosition) && (editPoints[i].position < endPosition))
                    {
                        if (i == editPointSelected)
                            DrawSelectedEditPoint(myBuffer.Graphics, i, editSelectedBrush, editSelectedPen, (int)height);
                        else
                            DrawEditPoint(editPoints[i], myBuffer.Graphics, (int)height);

                    }
                }

                if (!mouseDrag)
                {
                    int hover = editPointHover;
                    if (hover >= 0)
                    {
                        x = (int)((long)editPoints[hover].position - startPosition) / (samplesPerPixel * bytesPerSample);
                        if ((x>0)&&(x<e.ClipRectangle.Right))
                            ControlPaint.DrawReversibleFrame(RectangleToScreen(new Rectangle((int)x - 8, 0, 16, Height - scrollHeight)), Color.Black, FrameStyle.Dashed);
                    }
                }

                myBuffer.Render(e.Graphics);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            //base.OnPaint(e);
        }
開發者ID:runtime1point0,項目名稱:Fritz-robot-only,代碼行數:101,代碼來源:Recorder.cs

示例11: Meshis

        public void Meshis(Graphics Graphic,int manhue,int sat, int bright)
        {
            if (Bg!=null)
            {
                F = new Bitmap(Bg, Bg.Width, Bg.Height);
                BE = X.Allocate(Graphic, new Rectangle(0, 0, this.Width, this.Height));

                for (int i = 0; i < F.Width; i++)
                {
                    for (int j = 0; j < F.Height; j++)
                    {
                        Color s = F.GetPixel(i, j);
                        float f = (s.R + s.G + s.B) / 3;

                        float x = (f / 255) * 100;
             //           double rr = Math.Sin(127+manhue/(Math.PI/(255*2))) * f;
                        int sp = bright >= 100 ? sp = bright - 100 : sp = 100;
                       // Color y = XColors.HSBToRGB((manhue) - (int)((int)f), sat, (int)bright);
                        Color y = XColors.Transgen( firstColor, lastColor, manhue + (int)((float)f*2.5f), saturation, brightness);

                        /*
                        if ( f>=127)
                        {
                            int sr = sat ;

                            float frr = XColors.Diff(y.R, 255) ;
                            float frg = XColors.Diff(y.G, 255) ;
                            float frb = XColors.Diff(y.B, 255) ;
                            float ar=frr*(sat/100);
                            float ag = frg * (sat / 100);
                            float ab = frb * (sat / 100);
                            Color r = Color.FromArgb(y.R + (int)ar, y.G + (int)ag, y.B + (int)ab);
                            y = r;
                        }
                         */
                        F.SetPixel(i, j, y);
                    }
                }
                int r = this.Width / Bg.Width;
                for (int i = 0; i < this.Width; i++)
                {
                    BE.Graphics.DrawImage(F, new Point(i*Bg.Width, 0));
                }
                BE.Render();
            }
        }
開發者ID:krikelin,項目名稱:MediaChrome,代碼行數:46,代碼來源:clsColorPage.cs

示例12: displayImage

 private void displayImage()
 {
     Graphics g = CreateGraphics();
     using (frame = bufferContext.Allocate(g, tabControl.ClientRectangle))
     {
         //frame = bufferContext.Allocate(g, tabControl.ClientRectangle);
         System.Drawing.Rectangle destRect = this.panningPanel.ClientRectangle;
         destRect.Location = this.panningPanel.Location;
         System.Drawing.Rectangle srcRect = new System.Drawing.Rectangle(offsetWidth, offsetHeight, 1000, 1000);
         frame.Graphics.DrawImage(Properties.Resources.GameOfThrones, destRect, srcRect, g.PageUnit);
         frame.Render();
     }
 }
開發者ID:nmackay132,項目名稱:COP4226_HW3,代碼行數:13,代碼來源:MainForm.cs

示例13: RedrawFieldPanel

        /// <summary>
        /// This function should be used whenever the underlying krystal data or the field panel has changed.
        /// If the krystal data has changed, the panel obviously needs to be updated.
        /// If the field panel has been resized, the diagram is re-centred.
        /// </summary>
        private void RedrawFieldPanel()
        {
            if (_fieldPanelGraphicsBuffer != null)
                _fieldPanelGraphicsBuffer.Dispose();
            _fieldPanelGraphicsBuffer = _bufferedGraphicsContext.Allocate(FieldPanel.CreateGraphics(), FieldPanel.DisplayRectangle);

            float scalePercent = float.Parse(this.ZoomComboBox.Text);
            try
            {
                _painter.Draw(_fieldPanelGraphicsBuffer.Graphics, _outputKrystal, scalePercent);
                _fieldPanelGraphicsBuffer.Render();
            }
            catch (ApplicationException ae)
            {
                MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
開發者ID:suvjunmd,項目名稱:Moritz,代碼行數:22,代碼來源:ExpansionEditor.cs

示例14: drawMagFieldGraph

        private void drawMagFieldGraph()
        {
            magFieldGraphicsContext = new BufferedGraphicsContext();
            magFieldGraphicsBuffer = magFieldGraphicsContext.Allocate(Graphics.FromImage(magFieldDrawingSurface), magFieldBoundsRectangle);
            magFieldGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            magFieldGraphicsBuffer.Graphics.Clear(SystemColors.Control);

            float xCenter = (float)(magFieldBoundsRectangle.Width / 2.0);
            float yCenter = (float)(magFieldBoundsRectangle.Height / 2.0);

            float xOld = xCenter + (float)(spatial.compassAxes[0].MagneticField) * magFieldCircleRadius * (float)(1 / ambientMagneticField);
            float yOld = yCenter + (float)(spatial.compassAxes[1].MagneticField) * magFieldCircleRadius * (float)(1 / ambientMagneticField);

            magFieldGraphicsBuffer.Graphics.DrawLine(magFieldXYAxisPen, xCenter, yCenter, xOld, yOld);
            magFieldGraphicsBuffer.Graphics.DrawEllipse(magFieldCirclePen, magFieldCircleRectangle);

            if (spatial.compassAxes.Count == 3)
            {
                double zOut = (spatial.compassAxes[2].MagneticField) * (float)(1 / ambientMagneticField);
                if (zOut > 0)
                {
                    magFieldGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Red, 2),
                        new Rectangle((int)xCenter - (int)(magFieldCircleRadius * zOut), (int)yCenter - (int)(magFieldCircleRadius * zOut),
                        (int)(magFieldCircleDiameter * zOut), (int)(magFieldCircleDiameter * zOut)));
                }
                else
                {
                    magFieldGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Green, 2),
                        new Rectangle((int)xCenter - (int)(magFieldCircleRadius * -zOut), (int)yCenter - (int)(magFieldCircleRadius * -zOut),
                        (int)(magFieldCircleDiameter * -zOut), (int)(magFieldCircleDiameter * -zOut)));
                }
            }

            magFieldGraphicsBuffer.Render(magFieldView.CreateGraphics());

            magFieldGraphicsBuffer.Dispose();

            magFieldGraphicsContext.Dispose();
        }
開發者ID:DutchSoldier,項目名稱:FHSICT,代碼行數:39,代碼來源:Form1.cs

示例15: drawGyroGraph

        private void drawGyroGraph()
        {
            //get our graphics buffer going so we can draw to our panel
            gyroGraphicsContext = new BufferedGraphicsContext();
            gyroGraphicsBuffer = gyroGraphicsContext.Allocate(Graphics.FromImage(gyroDrawingSurface), gyroboundsRectangle);
            gyroGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            gyroGraphicsBuffer.Graphics.Clear(SystemColors.Control);

            float xCenter = (float)(gyroboundsRectangle.Width / 2.0);
            float yCenter = (float)(gyroboundsRectangle.Height / 2.0);

            //heading circles
            for (int i = 0; i < spatial.gyroAxes.Count; i++)
            {
                gyroGraphicsBuffer.Graphics.DrawEllipse(gyrocirclePen, gyrocircleRectangle[i]);
                gyroGraphicsBuffer.Graphics.DrawEllipse(
                    gyroxyAxisPen[i],
                    (float)(gyrocircleRadius[i] * Math.Cos(gyroHeading[i] * (Math.PI / 180.0)) + xCenter) - 2,
                    (float)(-gyrocircleRadius[i] * Math.Sin(gyroHeading[i] * (Math.PI / 180.0)) + yCenter) - 2,
                    4,
                    4
                );
            }

            gyroGraphicsBuffer.Render(gyroView.CreateGraphics());

            gyroGraphicsBuffer.Dispose();

            gyroGraphicsContext.Dispose();
        }
開發者ID:DutchSoldier,項目名稱:FHSICT,代碼行數:30,代碼來源:Form1.cs


注:本文中的System.Drawing.BufferedGraphics.Render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。