public SkinProgressBar()
 {
     this._context.MaximumBuffer = new System.Drawing.Size(base.Width + 1, base.Height + 1);
     this._bufferedGraphics = this._context.Allocate(base.CreateGraphics(), new Rectangle(System.Drawing.Point.Empty, base.Size));
     this.ForeColor = Color.Red;
     base.ResizeRedraw = true;
 }
Ejemplo n.º 2
0
        public DrawerWnd(CDrawer dr)
        {
            InitializeComponent();

            // use the log as built from parent
            _log = dr._log;

            // save window size
            m_ciWidth = dr.m_ciWidth;
            m_ciHeight = dr.m_ciHeight;

            // cap delegates, this will be set by owner
            m_delRender = null;
            m_delMouseMove = null;
            m_delMouseLeftClick = null;
            m_delMouseRightClick = null;

            // cap/set references
            m_bgc = new BufferedGraphicsContext();
            m_bg = null;

            // create the bitmap for the underlay and clear it to whatever colour
            m_bmUnderlay = new Bitmap(dr.m_ciWidth, dr.m_ciHeight);    // docs say will use Format32bppArgb

            // fill the bitmap with the default drawer bb colour
            FillBB(Color.Black);

            // show that drawer is up and running
            _log.WriteLine("Drawer Started...");
        }
Ejemplo n.º 3
0
 public frmCogMain()
 {
     InitializeComponent();
       // Create a new Environment
       Graphics g = Graphics.FromHwnd(pnlSimulation.Handle);
       context = BufferedGraphicsManager.Current;
       context.MaximumBuffer = new Size((int)g.VisibleClipBounds.Width + 1, (int)g.VisibleClipBounds.Height + 1);
       grafx = context.Allocate(g, new Rectangle(0, 0, (int)g.VisibleClipBounds.Width, (int)g.VisibleClipBounds.Height));
       this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
       env = new Clockwork.Environment(grafx, imgDrawList, COG_Model.Properties.Settings.Default.NumberOfAgents,
                               (int)COG_Model.Properties.Settings.Default.NumberIterations, (int)COG_Model.Properties.Settings.Default.TimeIteration);
       // Register the events
       env.NewAgent += new Clockwork.Environment.NewAgentCallBack(env_NewAgent);
       env.DeleteAgent += new Clockwork.Environment.DeleteAgentCallBack(env_DeleteAgent);
       env.StatUpdate += new Clockwork.Environment.StatUpdateCallBack(env_StatUpdate);
       env.TimerChange += new Clockwork.Environment.TimerCallBack(env_TimerChange);
       env.Complete += new Clockwork.Environment.CompleteCallBack(env_Complete);
       env.New();
       // Disable the run controls
       btnStop.Enabled = false;
       // Add the Execution plan tree to the display
       executionTree = new ucExecutionTree(ref env);
       executionTree.Dock = DockStyle.Fill;
       spltInfo.Panel2.Controls.Add(executionTree);
 }
Ejemplo n.º 4
0
        private void frmPathFinderDemo_Load(object sender, EventArgs e)
        {
            m_blnIsLoading = true;
            m_blnMouseDown = false;

            mGraphContext = BufferedGraphicsManager.Current;

            mBuffer1 = mGraphContext.Allocate(pnlViewPort.CreateGraphics(), pnlViewPort.DisplayRectangle);
            mBuffer1.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            mBuffer1.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            m_Pathfinder = new PathFinder();
            m_Pathfinder.InitialiseGraph(CELLS_UP, CELLS_DOWN, pnlViewPort.Width, pnlViewPort.Height);
            m_Pathfinder.InitialiseSourceTargetIndexes();

            m_Pathfinder.ShowGraph = MenuGraph.Checked;
            m_Pathfinder.ShowTiles = MenuTiles.Checked;

            m_intMouseGridIndex = -1;
            ResetButtonAlgos();

            m_Pathfinder.CurrentTerrainBrush = GetButtonTerrainBrush();

            ReDraw();

            m_blnIsLoading = false;
        }
Ejemplo n.º 5
0
        public Form1()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

            this.Width = 640;
            this.Height = 480;
            pnlRenderArea.Top = 0;
            pnlRenderArea.Left = 0;
            pnlRenderArea.Width = ClientRectangle.Width;
            pnlRenderArea.Height = ClientRectangle.Height;

            // Retrieves the BufferedGraphicsContext for the
            // current application domain.
            context = BufferedGraphicsManager.Current;

            // Sets the maximum size for the primary graphics buffer
            // of the buffered graphics context for the application
            // domain.  Any allocation requests for a buffer larger
            // than this will create a temporary buffered graphics
            // context to host the graphics buffer.
            context.MaximumBuffer = new Size(this.Width + 1, this.Height + 1);

            // Allocates a graphics buffer the size of this form
            // using the pixel format of the Graphics created by
            // the Form.CreateGraphics() method, which returns a
            // Graphics object that matches the pixel format of the form.
            grafx = GetGraphics(pnlRenderArea);
        }
 private BufferedGraphics AllocBuffer(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
 {
     if (Interlocked.CompareExchange(ref this.busy, 1, 0) != 0)
     {
         return this.AllocBufferInTempManager(targetGraphics, targetDC, targetRectangle);
     }
     this.targetLoc = new Point(targetRectangle.X, targetRectangle.Y);
     try
     {
         Graphics graphics;
         if (targetGraphics != null)
         {
             IntPtr hdc = targetGraphics.GetHdc();
             try
             {
                 graphics = this.CreateBuffer(hdc, -this.targetLoc.X, -this.targetLoc.Y, targetRectangle.Width, targetRectangle.Height);
             }
             finally
             {
                 targetGraphics.ReleaseHdcInternal(hdc);
             }
         }
         else
         {
             graphics = this.CreateBuffer(targetDC, -this.targetLoc.X, -this.targetLoc.Y, targetRectangle.Width, targetRectangle.Height);
         }
         this.buffer = new BufferedGraphics(graphics, this, targetGraphics, targetDC, this.targetLoc, this.virtualSize);
     }
     catch
     {
         this.busy = 0;
         throw;
     }
     return this.buffer;
 }
Ejemplo n.º 7
0
 private void InitializeGraphics()
 {
     this.DoubleBuffered = true;
     graphics = mainPictureBox.CreateGraphics();
     bufferedGraphicsContext = new BufferedGraphicsContext();
     bufferedGraphics = bufferedGraphicsContext.Allocate(graphics, new Rectangle(0, 0, mainPictureBox.Width, mainPictureBox.Height));
 }
Ejemplo n.º 8
0
        public MainForm()
        {
            InitializeComponent();

            _VideoWindow = new VideoWindow();
            _Brush = null;

            shemes = new Shemes();
            tscbShemes.Items.Clear();
            tscbShemes.Items.Add(shemes.GetCurrentShemeName());
            tscbShemes.SelectedIndex = 0;

            LoadLastShemeName();

            if (Program.PauseInsteadOfStop)
                tsmiPauseInsteadStop.Image = Properties.Resources.ok;
            else
                tsmiPauseInsteadStop.Image = null;

            brush = new SolidBrush(BackColor);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.Resize += new System.EventHandler(this.OnResize);
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.OnPaint);

            UpdateRect();
            context = BufferedGraphicsManager.Current;
            context.MaximumBuffer = rect.Size;
            grafx = context.Allocate(this.CreateGraphics(), rect);
            DrawToBuffer(grafx.Graphics);

            _Runner = new Thread(Runner);
            _Runner.Start();

            _Loader = new Thread(new ParameterizedThreadStart(LoadTile));
        }
Ejemplo n.º 9
0
        private double t; // used for the level timer

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor that sets up graphics buffer and gameworld
        /// </summary>
        /// <param name="dc">Graphics object from the form</param>
        /// <param name="displayRectangle">Rectangle that is the size of the graphics object</param>
        public GameWorld(Graphics dc, Rectangle displayRectangle)
        {
            buffer = BufferedGraphicsManager.Current.Allocate(dc, displayRectangle);
            this.dc = buffer.Graphics;
            m = new Menu(this.dc);
            SetupGameWorld();
        }
Ejemplo n.º 10
0
 public void rendercontext()
 {
     gfx = null;
     Rectangle rc = new Rectangle(0, 0, canvasptc.Width, canvasptc.Height);
     gfx = context.Allocate(canvasptc.CreateGraphics(),rc);
     renderdata(gfx.Graphics);
 }
Ejemplo n.º 11
0
        public void draw(MazeGenerator maze, BufferedGraphics buffer, int[,] mazeArray)
        {

            for (int i = 0; i < maze.height; i++)
            {
                for (int j = 0; j < maze.width; j++)
                {
                    if (mazeArray[i, j] == 2)
                    {
                        if (j < 24 && mazeArray[i, j + 1] == 0)
                        {
                            buffer.Graphics.DrawImage(Image3, new Rectangle(20 * i, 20 * j, 20, 20));
                        }
                        else
                        {
                            buffer.Graphics.DrawImage(Image1, new Rectangle(20 * i, 20 * j, 20, 20));
                        }
                    }
                    else
                    {
                        buffer.Graphics.DrawImage(Image2, new Rectangle(20 * i, 20 * j, 20, 20));

                    }
                }

            }
        }
Ejemplo n.º 12
0
        public void update(BufferedGraphics buffer) 
        {
          //  PlayerSpaw();

            //=====balas========
            if (crea1==true)
            {
                balas[indicador].mover();

                if (limit()==true)
                    crea1 = false;
                
            }
            //=====power up ========
            if (cont == 10)
            {
                pu_Spawn(1);
                posiciona_PU();
                pu_draw(buffer);
                if (find_powerup() == true)
                {
                    cont = 0;
                }
            }
            
        }
Ejemplo n.º 13
0
        public MainForm()
        {
            InitializeComponent();

            this.currentFileData = new GameData(32, 32);
            this.currentFileName = null;

            this.toolImages = new TextureBrush[7];

            for (int i = 0; i < this.toolImages.Length; i++)
            {
                this.toolImages[i] = new TextureBrush(Image.FromFile("images/" + i + ".png"));
            }

            this.backgroundImage = new TextureBrush(Image.FromFile("images/checkerboard.png"));

            this.selectedTool = 1;

            this.graphicsContext = BufferedGraphicsManager.Current;
            this.graphics = graphicsContext.Allocate(this.StageEditBoard.CreateGraphics(),
                new Rectangle(0, 0, 32 * (int)EDIT_BOARD_SCALING, 32 * (int)EDIT_BOARD_SCALING));

            for(int i = 0; i < MainForm.DIRECTIONS.Length; i++)
                this.StartDirection.Items.Add(DIRECTIONS[i]);

            this.LoadTextureFiles();

            this.FileNew(null, null);
        }
Ejemplo n.º 14
0
 public Environment(BufferedGraphics g, ImageList newEntities, int size, int newIterations, int newDuration)
 {
     rnd = new Random(System.Environment.TickCount);
       stats = new Dictionary<STATISTIC, double>();
       results = new List<string>();
       messageQueue = new MessageQueue();
       Environment a = this;
       executionTree = new ExecutionTree(ref a);
       entities = newEntities;
       device = g;
       WorkerSupportsCancellation = true;
       speed = 5;
       // Determine the percent chance that a new agent will be introduced into the environment.
       // The higher the chance the more likely the size of the population will be larger.
       if (size == 0)
     populationSize = 0.10;
       else if (size == 1)
     populationSize = 0.25;
       else if (size == 2)
     populationSize = 0.50;
       // Set the run parameters
       iterations = newIterations;
       duration = newDuration * 60;
       timer = new TimeSpan();
 }
        protected override void Draw(BufferedGraphics g)
        {
            if (!GInformation.Gameinfo.IsIngame)
                return;

            var iValidPlayerCount = GInformation.Gameinfo.ValidPlayerCount;

            if (iValidPlayerCount == 0)
                return;

            if (GInformation.Player.Count <= 0)
                return;

            var iSingleHeight = Height;
            var fNewFontSize = (float) ((29.0/100)*iSingleHeight);

            var dtTimeStamp = DateTime.Now;

            var strTime = dtTimeStamp.ToLongTimeString();
            g.Graphics.DrawString(
                "Time: " + strTime,
                new Font("Century Gothic", fNewFontSize, FontStyle.Regular),
                Brushes.White,
                Brushes.Black, (float) ((13.67/100)*Width),
                (float) ((24.0/100)*iSingleHeight),
                1f, 1f, true);
        }
 /// <summary>
 /// Konstruktor
 /// </summary>
 public MotorVisualization()
 {
     InitializeComponent();
     wheel = Properties.Resources.kolecko;
     buffer = context.Allocate(pnlMotor.CreateGraphics(), pnlMotor.ClientRectangle);
     buffer.Graphics.DrawImageUnscaledAndClipped(wheel, pnlMotor.ClientRectangle);
 }
Ejemplo n.º 17
0
 public override void Draw(System.Drawing.BufferedGraphics g)
 {
     try
     {
         g.Graphics.DrawImage(Image.FromFile(ImageFileName), new Point((int)X, (int)Y));
     }
     catch { }
 }
Ejemplo n.º 18
0
        public void rendercontext()
        {
            gfx = null;
            Rectangle rc = new Rectangle(0, 0, canvasptc.Width, canvasptc.Height);

            gfx = context.Allocate(canvasptc.CreateGraphics(), rc);
            renderdata(gfx.Graphics);
        }
Ejemplo n.º 19
0
        protected BufferedGraphicsContext graphicContext = null; // методы сознания графичечких буферов

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        /// <param name="g">Повехность на которой необходимо выполнять рисование</param>
        /// <param name="FrameToDraw">Область и положение, занимаемое графиком калибровки на форме</param>
        public GraphicDrawter(Graphics g, Rectangle FrameToDraw)
        {
            graphicContext = BufferedGraphicsManager.Current;
            graphicBuffer = graphicContext.Allocate(g, FrameToDraw);

            graphicBuffer.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            //graphicBuffer.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
        }
Ejemplo n.º 20
0
        public SmoothPanel2()
        {
            GraphicManager = BufferedGraphicsManager.Current;
            GraphicManager.MaximumBuffer = new Size(this.Width + 1, this.Height + 1);
            ManagedBackBuffer = GraphicManager.Allocate(this.CreateGraphics(), ClientRectangle);

            //SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
        }
Ejemplo n.º 21
0
 //Constructor. This also creates the thread, which is running the gameloop.
 public GameWorld(Graphics dc, Rectangle displayRectangle)
 {
     WindowRectangle = displayRectangle;
     this.backBuffer = BufferedGraphicsManager.Current.Allocate(dc, displayRectangle);
     this.dc = backBuffer.Graphics;
     SetupWorld();
     Thread t = new Thread(GameLoop);
     t.Start();
 }
Ejemplo n.º 22
0
    	private void Form1_Load(object sender, EventArgs e)
        {
        	pbBox.AllowDrop = true;
            BGC = BufferedGraphicsManager.Current;
			view.Window = new Rectangle(0, 0, pbBox.Width - 1, pbBox.Height - 1);
            grOffside = BGC.Allocate(pbBox.CreateGraphics(), view.Window);
            grOffside.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            grOffside.Graphics.SmoothingMode = SmoothingMode.HighQuality;    		
            timer.Enabled = true;            
        }
Ejemplo n.º 23
0
 public GraphicForm()
 {
     InitializeComponent();
     pictureBox.BackColor = Color.Gray;
     currentContext = BufferedGraphicsManager.Current;
     myBuffer = currentContext.Allocate(pictureBox.CreateGraphics(), pictureBox.DisplayRectangle);
     this.graphic = myBuffer.Graphics;
     pen = new Pen(Color.Gold);
     figureList = new List<Figure>();
 }
Ejemplo n.º 24
0
 public DrawingSystem(Form form, EntityManager manager)
     : base(manager)
 {
     _form = form;
     _form.Invoke(new Action(() =>
     {
         _context = BufferedGraphicsManager.Current;
         _buffer = _context.Allocate(_form.CreateGraphics(), _form.DisplayRectangle);
     }));
 }
Ejemplo n.º 25
0
 public ProgressBarEx()
     : base()
 {
     _context = BufferedGraphicsManager.Current;
     _context.MaximumBuffer = new Size(Width+1, Height+1);
     _bufferedGraphics = _context.Allocate(
         CreateGraphics(),
         new Rectangle(Point.Empty, Size));
     SetRegion();
 }
Ejemplo n.º 26
0
        protected override void OnResize(EventArgs eventargs)
        {
            if (ManagedBackBuffer != NO_MANAGED_BACK_BUFFER) ManagedBackBuffer.Dispose();

            GraphicManager.MaximumBuffer = new Size(this.Width + 1, this.Height + 1);

            ManagedBackBuffer = GraphicManager.Allocate(this.CreateGraphics(), ClientRectangle);

            this.Refresh();
        }
Ejemplo n.º 27
0
        public VideoScreen()
        {
            bufferContext = BufferedGraphicsManager.Current;
            width = Width;
            height = Height;
            bg = bufferContext.Allocate(CreateGraphics(), new Rectangle(0, 0, Width, Height));
            g = bg.Graphics;

            InitializeComponent();
        }
Ejemplo n.º 28
0
        public void draw(BufferedGraphics buffer)
        {
            maze.draw(renderer, buffer);
            personaje.draw(renderer, buffer);
            if (crea1 == true)
            {
                bulletdraw(buffer);
            }

        }
Ejemplo n.º 29
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dc"></param>
 /// <param name="displayRectangle"></param>
 public GameWorld(Graphics dc, Rectangle displayRectangle)
 {
     WindowRectangle = displayRectangle;
     this.backBuffer = BufferedGraphicsManager.Current.Allocate(dc, displayRectangle);
     this.dc = backBuffer.Graphics;
     objects = new List<GameObject>();
     removeList = new List<GameObject>();
     SetupDifferentWorlds();
     SetupWorld();
 }
Ejemplo n.º 30
0
        private void doubleBufferControl_Resize(object sender, EventArgs e)
        {
            graphicManager.MaximumBuffer = new Size(this.Width + 1, this.Height + 1);

            if (managedBackBuffer != null)
                managedBackBuffer.Dispose();

            managedBackBuffer = graphicManager.Allocate(this.CreateGraphics(), ClientRectangle);

            this.Refresh();
        }
Ejemplo n.º 31
0
        void OnResize(object sender, EventArgs e)
        {
            if (ManagedBackBuffer != NO_MANAGED_BACK_BUFFER)
                ManagedBackBuffer.Dispose();

            GraphicManager.MaximumBuffer = new Size(this.Width + 1, this.Height + 1);

            ManagedBackBuffer = GraphicManager.Allocate(this.CreateGraphics(), ClientRectangle);

            this.Invalidate();
        }
Ejemplo n.º 32
0
 public UCNoteGraph()
 {
     InitializeComponent();
     PitchStart = 0;
     PitchRange = 20;
     NoteWidth = 5;
     lastNoteLocation = new Point(0, Height);
     bufferedGraphicsContext = BufferedGraphicsManager.Current;
     bufferedGraphics = bufferedGraphicsContext.Allocate(CreateGraphics(), ClientRectangle);
     SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
 }
Ejemplo n.º 33
0
        private void LMSAPIForm_Load(object sender, EventArgs e)
        {
            this.cbRangoAngular.SelectedIndex   = 0;
            this.cbRangoDistancia.SelectedIndex = 0;
            this.cbResAngular.SelectedIndex     = 0;
            this.cbPuerto.SelectedIndex         = 0;

            //crear herramientas graficas
            context = BufferedGraphicsManager.Current;
            gfx     = null;
            resize_canvas();
        }
Ejemplo n.º 34
0
        private void stopWatch_Load(object sender, EventArgs e)
        {
            CurrentContext = BufferedGraphicsManager.Current;
            System.Drawing.BufferedGraphics bg = CurrentContext.Allocate(CreateGraphics(), ClientRectangle);
            bg.Graphics.Clear(SystemColors.Window);


            DrawLines(bg.Graphics);
            DrawNumbers(bg.Graphics);
            DrawHands(bg.Graphics);
            bg.Render();
        }
Ejemplo n.º 35
0
        private void stopWatch_Paint(object sender, PaintEventArgs e)
        {
            CurrentContext = BufferedGraphicsManager.Current;
            System.Drawing.BufferedGraphics bg = CurrentContext.Allocate(CreateGraphics(), ClientRectangle);
            bg.Graphics.Clear(Color.White);

            // DateTime now = DateTime.Now
            DrawLines(bg.Graphics);
            DrawNumbers(bg.Graphics);
            DrawHands(bg.Graphics);
            drawCircle(bg.Graphics);
            bg.Render();
        }
Ejemplo n.º 36
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            CurrentContext = BufferedGraphicsManager.Current;
            System.Drawing.BufferedGraphics bg = CurrentContext.Allocate(CreateGraphics(), ClientRectangle);
            bg.Graphics.Clear(Color.White);

            currentTimePassed = DateTime.Now - startTime + pauseTime;

            DrawLines(bg.Graphics);
            DrawNumbers(bg.Graphics);
            DrawHands(bg.Graphics);
            drawCircle(bg.Graphics);
            bg.Render();
        }
Ejemplo n.º 37
0
        //Constructor
        public DXGDI_Interface(Form form)
        {
            // local copy of game form
            this.form = form;

            //Create drawing surface from game form
            formGraphics = form.CreateGraphics();

            //Initialize back-buffer graphics
            currenContext = BufferedGraphicsManager.Current;
            backBuffer    = currenContext.Allocate(formGraphics, form.ClientRectangle);

            //Initialize drawing brush
            blackBrush = new SolidBrush(Color.White);
        }
Ejemplo n.º 38
0
        public void Reset()
        {
            if (!running)
            {
                pauseTime         = TimeSpan.Zero;
                currentTimePassed = TimeSpan.Zero;

                CurrentContext = BufferedGraphicsManager.Current;
                System.Drawing.BufferedGraphics bg = CurrentContext.Allocate(CreateGraphics(), ClientRectangle);
                bg.Graphics.Clear(SystemColors.Window);


                DrawLines(bg.Graphics);
                DrawNumbers(bg.Graphics);
                DrawHands(bg.Graphics);
                bg.Render();
            }
        }
Ejemplo n.º 39
0
 public override void Draw(System.Drawing.BufferedGraphics g)
 {
     try
     {
         if (Octave == MIDI_Library.Octave.First)
         {
             g.Graphics.DrawImage(Image.FromFile(ImageFileName), new Point((int)X, (int)Y - 15));
         }
         else if (Octave == MIDI_Library.Octave.Second)
         {
             g.Graphics.DrawImage(Image.FromFile(ImageFileName), new Point((int)X, (int)Y + 2));
         }
         else if (Octave == MIDI_Library.Octave.Third)
         {
             g.Graphics.DrawImage(Image.FromFile(ImageFileName), new Point((int)X, (int)Y + 2));
         }
     }
     catch { }
 }
Ejemplo n.º 40
0
        public override void Draw(System.Drawing.BufferedGraphics g)
        {
            try
            {
                switch (Octave)
                {
                case MIDI_Library.Octave.First:
                    g.Graphics.DrawImage(Image.FromFile(ImageFileName), new Point((int)X, (int)Y - 15));
                    break;

                case MIDI_Library.Octave.Second:
                    g.Graphics.DrawImage(Image.FromFile(ImageFileName), new Point((int)X, (int)Y + 1));
                    break;

                case MIDI_Library.Octave.Third:
                    g.Graphics.DrawImage(Image.FromFile(ImageFileName), new Point((int)X, (int)Y + 1));
                    break;
                }
            }
            catch { }
        }
        private BufferedGraphics AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
        {
            BufferedGraphicsContext tempContext = null;
            BufferedGraphics        tempBuffer  = null;

            try {
                tempContext = new BufferedGraphicsContext();
                if (tempContext != null)
                {
                    tempBuffer = tempContext.AllocBuffer(targetGraphics, targetDC, targetRectangle);
                    tempBuffer.DisposeContext = true;
                }
            }
            finally {
                if (tempContext != null && (tempBuffer == null || (tempBuffer != null && !tempBuffer.DisposeContext)))
                {
                    tempContext.Dispose();
                }
            }

            return(tempBuffer);
        }
        private BufferedGraphics AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
        {
            BufferedGraphicsContext context  = null;
            BufferedGraphics        graphics = null;

            try
            {
                context = new BufferedGraphicsContext();
                if (context != null)
                {
                    graphics = context.AllocBuffer(targetGraphics, targetDC, targetRectangle);
                    graphics.DisposeContext = true;
                }
            }
            finally
            {
                if ((context != null) && ((graphics == null) || ((graphics != null) && !graphics.DisposeContext)))
                {
                    context.Dispose();
                }
            }
            return(graphics);
        }
Ejemplo n.º 43
0
        private void stopWatch_Resize(object sender, EventArgs e)
        {
            if (Width < Height)
            {
                radius = Width / 2;
            }
            else
            {
                radius = Height / 2;
            }
            center  = new Point(Width / 2, Height / 2);
            center2 = new Point(Width / 2, Height / 3);


            CurrentContext = BufferedGraphicsManager.Current;
            System.Drawing.BufferedGraphics bg = CurrentContext.Allocate(CreateGraphics(), ClientRectangle);
            bg.Graphics.Clear(Color.White);

            DrawLines(bg.Graphics);
            DrawNumbers(bg.Graphics);
            DrawHands(bg.Graphics);
            drawCircle(bg.Graphics);
            bg.Render();
        }
 public BufferedGraphicsManagerWrapper(Panel panel, Action renderAction)
     : base(renderAction)
 {
     _bufferedGraphics = BufferedGraphicsManager.Current.Allocate(panel.CreateGraphics(), panel.DisplayRectangle);
     _wrapper          = new BufferedGraphicsWrapper(_bufferedGraphics);
 }
 public BufferedGraphicsWrapper(System.Drawing.BufferedGraphics bufferedGraphics)
 {
     _bufferedGraphics = bufferedGraphics;
 }
Ejemplo n.º 46
0
 public void SetImageBuffer()
 {
     _imageBuffer = _currentBufferContext.Allocate(_pictureBox.CreateGraphics(), _pictureBox.DisplayRectangle);
 }
Ejemplo n.º 47
0
        public BufferedGraphics Allocate(Graphics targetGraphics, Rectangle targetRectangle)
        {
            BufferedGraphics graphics = new BufferedGraphics(targetGraphics, targetRectangle);

            return(graphics);
        }
#pragma warning disable CA1822
        private BufferedGraphics AllocBuffer(Graphics?targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
        {
            BufferedGraphics graphics = new BufferedGraphics(targetGraphics, targetDC, targetRectangle);

            return(graphics);
        }