Наследование: GDIInfoContext
Пример #1
0
        public static GDIContext CreateForDisplay(string displayName)
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = GDI32.CreateDC("DISPLAY", displayName, null, IntPtr.Zero);
            GDIContext newContext = new GDIContext(hdc, true);

            return newContext;
        }
Пример #2
0
        public static GDIContext CreateForDevice(string device, string name)
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = GDI32.CreateDC(device, name, null, IntPtr.Zero);
            GDIContext newContext = new GDIContext(hdc, true);

            return newContext;
        }
Пример #3
0
        public Projector()
            : base("Snap N Projector", 20, 20, 640, 480)
        {
            HostForm groupForm = new HostForm();
            groupForm.ShowDialog();

            // Get the address and port from the form
            string groupIP = groupForm.groupAddressField.Text;
            int groupPort = int.Parse(groupForm.groupPortField.Text);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(groupIP), groupPort);

            
            fDrawingContext = GDIContext.CreateForDesktopBackground();
            fDestinationRect = new Rectangle(0, 0, fDrawingContext.SizeInPixels.Width, fDrawingContext.SizeInPixels.Height);

            // Create the session
            fSession = new MultiSession(Guid.NewGuid().ToString(), ipep);

            fViewer = new SketchViewer(fSession, 1600, 1200);
            fViewer.DataChangedEvent += ReceiveImage;
        }
Пример #4
0
 internal GDIContext(GDIContext aDC)
     : this(GDI32.CreateCompatibleDC(aDC), true)
 {
 }
Пример #5
0
        public static GDIContext CreateForWindowClientArea(IntPtr hWnd)
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = User32.GetDC(hWnd);
            //hdc = User32.GetDCEx(hWnd, IntPtr.Zero, DeviceContextValues.Window);
            GDIContext newContext = new GDIContext(hdc, false);

            return newContext;
        }
Пример #6
0
        public static GDIContext CreateForWholeWindow(IntPtr hWnd)
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = User32.GetWindowDC(hWnd);
            GDIContext newContext = new GDIContext(hdc, false);

            return newContext;
        }
Пример #7
0
 public GDIRenderer(GDIContext devContext)
 {
     fObjectDictionary = new Dictionary<Guid, GDIObject>();
     fDeviceContext = devContext;
     fDeviceContext.SetGraphicsMode(GDI32.GM_ADVANCED);  // Use advanced graphics mode so we can use world transforms
 }
Пример #8
0
 public ScreenSnapper(GDIContext aContext)
 {
     fContext = aContext;
 }
Пример #9
0
        /// <summary>
        /// Create a GDIContext so that drawing to the desktop can occur.
        /// On Vista, the drawing will be behind all windows, but will draw on top
        /// of any icons on the actual desktop.
        /// For Windows XP, the drawing will be behind those icons as well.
        /// </summary>
        /// <returns>The Device Context for drawing to the desktop background.</returns>
        public static GDIContext CreateForDesktopBackground()
        {
            IntPtr hDC = IntPtr.Zero;

            // First get a handle on the Program Manager window using FindWindow
            IntPtr hProgMan = User32.FindWindow("ProgMan", null);

            if (IntPtr.Zero != hProgMan)
            {
                // The only child of this window is the Shell Window
                // So get that handle.
                IntPtr hShellView = User32.GetWindow(hProgMan, User32.GW_CHILD);

                // Now that we have the shell window, get the ListView, which is the 
                // child displaying everything.
                IntPtr hListView = User32.GetWindow(hShellView, User32.GW_CHILD);

                // Finally, get the DeviceContext handle for this list view
                hDC = User32.GetDC(hListView);
            }
            else
            {
                // If null was returned, then we're probably on Vista, and need to ask for
                // The "Program Manager" window.
                if (IntPtr.Zero == hProgMan)
                {
                    hProgMan = User32.FindWindow("Program Manager", null);
                    hDC = User32.GetDC(hProgMan);
                }
            }


            // And create a GDIContext for it
            GDIContext aContext = new GDIContext(hDC, false);

            return aContext;

        }
Пример #10
0
        public virtual bool StretchBlt(GDIContext srcDC, Rectangle srcRect, Rectangle dstRect, TernaryRasterOps dwRop)
        {
            bool result = GDI32.StretchBlt(this, dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height,
                srcDC, srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, (int)dwRop);

            return result;
        }
Пример #11
0
        public virtual bool PlgBlt(GDIContext srcDC, Rectangle srcRect,
            POINT[] dstParallelogramPoints,
            IntPtr hbmMask, int xMask, int yMask)
        {
            bool result = GDI32.PlgBlt(this, dstParallelogramPoints,
                srcDC, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
                hbmMask, xMask, yMask);

            return result;
        }
Пример #12
0
        public virtual bool BitBlt(GDIContext srcDC, Point srcPoint, Rectangle dstRect, TernaryRasterOps dwRop)
        {
            bool success = GDI32.BitBlt(this, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height,
                                 srcDC, srcPoint.X, srcPoint.Y, (int)dwRop);

            return success;
        }
Пример #13
0
        public virtual bool AlphaBlend(GDIContext srcDC, Rectangle srcRect, Rectangle dstRect, byte opacity)
        {
            blender.SourceConstantAlpha = opacity;

            bool success = GDI32.AlphaBlend(this, dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height,
                srcDC, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, blender);

            return success;
        }
Пример #14
0
 public virtual void StretchBlt(int x, int y, int width, int height,
             GDIContext srcDC, int srcX, int srcY, int srcWidth, int srcHeight,
             TernaryRasterOps dwRop)
 {
     bool success = DeviceContext.StretchBlt(srcDC, new Rectangle(srcX, srcY, srcWidth, srcHeight),
         new Rectangle(x, y, width, height), dwRop);
 }
Пример #15
0
        //public virtual void BitBlt(int x, int y, GDIDIBitmap bitmap)
        //{
        //    int scansDrawn = DeviceContext.StretchDIBits(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height),
        //        new Rectangle(x, y, bitmap.Width, bitmap.Height), TernaryRasterOps.SRCCOPY);
        //}

        public virtual bool BitBlt(int x, int y, int nWidth, int nHeight,
            GDIContext hSrcDC, int xSrc, int ySrc, TernaryRasterOps dwRop)
        {
            bool success = DeviceContext.BitBlt(hSrcDC, new Point(xSrc, ySrc), new Rectangle(x, y, nWidth, nHeight), dwRop);

            return success;
        }
Пример #16
0
        public static GDIContext CreateForDefaultDisplay()
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = User32.GetWindowDC(User32.GetDesktopWindow());
            GDIContext newContext = new GDIContext(hdc, false);

            return newContext;
        }
Пример #17
0
 public ScreenSnapper()
 {
     fContext = GDIContext.CreateForDefaultDisplay();
 }
Пример #18
0
        public static GDIContext CreateForAllAttachedMonitors()
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = GDI32.CreateDC("DISPLAY", null, null, IntPtr.Zero);
            GDIContext newContext = new GDIContext(hdc, true);

            // public static IntPtr CreateDC(string lpszDriver, string lpszDevice, IntPtr lpInitData);

            return newContext;
        }
Пример #19
0
        public static GDIContext CreateForMemory()
        {
            IntPtr hdc;

            hdc = GDI32.CreateCompatibleDC(GDIContext.CreateForDefaultDisplay());
            GDIContext newConText = new GDIContext(hdc, true);

            return newConText;
        }
Пример #20
0
        // get the combined world to device coordinate space mapping
        public bool GetDPtoLP(GDIContext hDC)
        {
            if (!GDI32.GetWorldTransform(hDC, out fMatrix))
                return false;

            POINT origin = new POINT();
            GDI32.GetWindowOrgEx(hDC, out origin);
            Translate(-(float)origin.X, -(float)origin.Y);

            SIZE sizew = new SIZE();
            SIZE sizev = new SIZE();
            GDI32.GetWindowExtEx(hDC, out sizew);
            GDI32.GetViewportExtEx(hDC, out sizev);

            Scale((float)sizew.Width / sizev.Height, (float)sizew.Height / sizev.Height);

            GDI32.GetViewportOrgEx(hDC, out origin);
            Translate((float)origin.X, (float)origin.Y);

            return true;
        }