Esempio n. 1
0
 protected override void OnPaint(PaintEventArgs e)
 {
     //System.Diagnostics.Debug.WriteLine( string.Format( "Painting: W{0} CR{1}", this.ClientRectangle, e.ClipRectangle ) );
     Section.GraphicsSettings gs = new Section.GraphicsSettings(e.Graphics);
     _canvas.PaintBackground(gs, e.ClipRectangle);
     _canvas.Paint(gs, e.ClipRectangle);
 }
Esempio n. 2
0
        private static ImageWindow CreateDragImageWindow(Section[] sections, bool applyDether)
        {
            int width = 0;

            foreach (Section s in sections)
            {
                if (s.Rectangle.Width > width)
                {
                    width = s.Rectangle.Width;
                }
            }
            int height = sections[sections.Length - 1].Rectangle.Bottom - sections[0].Rectangle.Top;

            using (Bitmap bmpOfSections = new Bitmap(width, height))
            {
                using (Bitmap finalBmp = new Bitmap(bmpOfSections.Width, bmpOfSections.Height))
                {
                    using (Graphics grfxFinalBmp = Graphics.FromImage(finalBmp))
                    {
                        int paintYPos = 0;
                        foreach (Section s in sections)
                        {
                            using (Graphics grfxBmpOfSections = Graphics.FromImage(bmpOfSections))
                            {
                                Rectangle rcSection = s.HostBasedRectangle;
                                //
                                // Draw section into its bmp
                                grfxBmpOfSections.TranslateTransform(-rcSection.X, -rcSection.Y + paintYPos);
                                paintYPos += s.Rectangle.Height;

                                grfxBmpOfSections.TextRenderingHint = TextRenderingHint.AntiAlias;

                                Section.GraphicsSettings gs = new Section.GraphicsSettings(grfxBmpOfSections);
                                s.PaintBackground(gs, rcSection);
                                s.Paint(gs, rcSection);
                            }
                        }

                        // to do, add dithering support

                        //
                        // Now draw a transparent verison of it onto the final bmp
                        grfxFinalBmp.DrawImage(bmpOfSections,
                                               new Rectangle(0, 0, bmpOfSections.Width, bmpOfSections.Height),
                                               0,
                                               0,
                                               finalBmp.Width,
                                               finalBmp.Height,
                                               GraphicsUnit.Pixel);

                        //
                        // Make the cursor from our final bmp
                        return(new ImageWindow(Icon.FromHandle(finalBmp.GetHicon())));
                    }
                }
            }
        }
Esempio n. 3
0
 void ISectionHost.ProcessLayoutsNow()
 {
     if (_lazyLayouts.Count == 1 && _lazyLayouts.ToArray()[0] == _canvas)
     {
         LayoutControl();
         _lazyLayouts.Clear();
     }
     else
     {
         using (Graphics grfx = CreateGraphics())
         {
             Section.GraphicsSettings grfxSettings = new Section.GraphicsSettings(grfx);
             Section[] sectionsToLayout            = _lazyLayouts.ToArray();
             _lazyLayouts.Clear();
             foreach (Section s in sectionsToLayout)
             {
                 s.Layout(grfxSettings, s.Size);
                 s.Invalidate();
             }
         }
     }
 }
        private static ImageWindow CreateDragImageWindow( Section[] sections, bool applyDether )
        {
            int width = 0;
            foreach( Section s in sections )
            {
                if( s.Rectangle.Width > width )
                {
                    width = s.Rectangle.Width;
                }
            }
            int height = sections[sections.Length - 1].Rectangle.Bottom - sections[0].Rectangle.Top;

            using( Bitmap bmpOfSections = new Bitmap( width, height ) )
            {
                using( Bitmap finalBmp = new Bitmap( bmpOfSections.Width, bmpOfSections.Height ) )
                {
                    using( Graphics grfxFinalBmp = Graphics.FromImage( finalBmp ) )
                    {
                        int paintYPos = 0;
                        foreach( Section s in sections )
                        {
                            using( Graphics grfxBmpOfSections = Graphics.FromImage( bmpOfSections ) )
                            {
                                Rectangle rcSection = s.HostBasedRectangle;
                                //
                                // Draw section into its bmp
                                grfxBmpOfSections.TranslateTransform( -rcSection.X, -rcSection.Y + paintYPos );
                                paintYPos += s.Rectangle.Height;

                                grfxBmpOfSections.TextRenderingHint = TextRenderingHint.AntiAlias;

                                Section.GraphicsSettings gs = new Section.GraphicsSettings( grfxBmpOfSections );
                                s.PaintBackground( gs, rcSection );
                                s.Paint( gs, rcSection );
                            }
                        }

                        // to do, add dithering support

                        //
                        // Now draw a transparent verison of it onto the final bmp
                        grfxFinalBmp.DrawImage( bmpOfSections,
                                                                     new Rectangle( 0, 0, bmpOfSections.Width, bmpOfSections.Height ),
                                                                     0,
                                                                     0,
                                                                     finalBmp.Width,
                                                                     finalBmp.Height,
                                                                     GraphicsUnit.Pixel );

                        //
                        // Make the cursor from our final bmp
                        return new ImageWindow( Icon.FromHandle( finalBmp.GetHicon() ) );
                    }
                }
            }
        }
 protected override void OnPaint( PaintEventArgs e )
 {
     //System.Diagnostics.Debug.WriteLine( string.Format( "Painting: W{0} CR{1}", this.ClientRectangle, e.ClipRectangle ) );
     Section.GraphicsSettings gs = new Section.GraphicsSettings( e.Graphics );
     _canvas.PaintBackground( gs, e.ClipRectangle );
     _canvas.Paint( gs, e.ClipRectangle );
 }
 void ISectionHost.ProcessLayoutsNow()
 {
     if( _lazyLayouts.Count == 1 && _lazyLayouts.ToArray()[0] == _canvas )
     {
         LayoutControl();
         _lazyLayouts.Clear();
     }
     else
     {
         using( Graphics grfx = CreateGraphics() )
         {
             Section.GraphicsSettings grfxSettings = new Section.GraphicsSettings( grfx );
             Section[] sectionsToLayout = _lazyLayouts.ToArray();
             _lazyLayouts.Clear();
             foreach( Section s in sectionsToLayout )
             {
                 s.Layout( grfxSettings, s.Size );
                 s.Invalidate();
             }
         }
     }
 }