Exemplo n.º 1
0
        public DrawingPopupWindow(DrawingToolkit toolkit, int x, int y, int width, int height,
                                  IToolkitEventSink sink) : base(toolkit)
        {
            //Console.WriteLine("DrawingPopupWindow");
            this.sink  = sink;
            dimensions = new Rectangle(x, y, width, height);

            // At the moment we create a unique class name for EVERY window. SWF does it for each unique window class
            className = "DrawingPopupWindow" + createCount++;

            // Register the windows class
            windowsClass             = new Win32.Api.WNDCLASS();
            windowsClass.style       = Win32.Api.WindowClassStyle.CS_DBLCLKS;
            windowsClass.lpfnWndProc = new Win32.Api.WNDPROC(toolkit.WindowsLoop);
            // We will draw
            windowsClass.hbrBackground = IntPtr.Zero;
            windowsClass.lpszClassName = className;
            if (Win32.Api.RegisterClassA(ref windowsClass) == 0)
            {
                throw new Exception("Failed to register Windows class " + className);
            }

            // Set default window characteristics
            style         = Win32.Api.WindowStyle.WS_POPUP;
            menu          = false;
            extendedStyle = Win32.Api.WindowsExtendedStyle.WS_EX_TOOLWINDOW;
            // We capture the mouse, and we want the client windows to be notified
            topOfhierarchy = this;
        }
Exemplo n.º 2
0
        // Select this brush into a graphics object.
        public override void Select(IToolkitGraphics _graphics)
        {
            DrawingGraphics graphics = (_graphics as DrawingGraphics);

            if (graphics != null)
            {
                Xsharp.Graphics g = graphics.graphics;
                Xsharp.Bitmap   bitmap;
                lock (typeof(DrawingHatchBrush))
                {
                    bitmap = GetBitmap(style);
                }
                g.Function      = GCFunction.GXcopy;
                g.SubwindowMode = SubwindowMode.ClipByChildren;
                if (bitmap != null)
                {
                    // Use an opaque stipple to fill the region.
                    g.Foreground =
                        DrawingToolkit.DrawingToXColor(foreColor);
                    g.Background =
                        DrawingToolkit.DrawingToXColor(backColor);
                    g.SetFillOpaqueStippled(bitmap, 0, 0);
                }
                else
                {
                    // We don't recognize this hatch style, so use a
                    // solid brush with the foreground color.
                    g.Foreground =
                        DrawingToolkit.DrawingToXColor(foreColor);
                    g.SetFillSolid();
                }
                graphics.Brush = this;
            }
        }
Exemplo n.º 3
0
        // Set the clipping region to a list of rectangles.
        public override void SetClipRects(System.Drawing.Rectangle[] rects)
        {
            IntPtr region = DrawingToolkit.RectanglesToRegion(rects);

            Win32.Api.SelectClipRgn(hdc, region);
            Win32.Api.DeleteObject(region);
        }
Exemplo n.º 4
0
        public DrawingTopLevelWindow(DrawingToolkit toolkit, String name,
                                     int width, int height, IToolkitEventSink sink) : base(toolkit)
        {
            this.sink = sink;
            //Console.WriteLine("DrawingTopLevelWindow");
            dimensions = new Rectangle(0, 0, width, height);

            // At the moment we create a unique class name for EVERY window. SWF does it for each unique window class
            className = "DrawingTopLevelWindow" + createCount++;

            // Register the windows class
            windowsClass             = new Win32.Api.WNDCLASS();
            windowsClass.style       = Win32.Api.WindowClassStyle.CS_DBLCLKS;
            windowsClass.lpfnWndProc = new Win32.Api.WNDPROC(toolkit.WindowsLoop);
            // We will draw
            windowsClass.hbrBackground = IntPtr.Zero;
            windowsClass.lpszClassName = className;
            if (Win32.Api.RegisterClassA(ref windowsClass) == 0)
            {
                throw new Exception("Failed to register Windows class " + className);
            }

            // Set default window characteristics
            flags = ToolkitWindowFlags.Menu | ToolkitWindowFlags.Close | ToolkitWindowFlags.Minimize | ToolkitWindowFlags.Maximize | ToolkitWindowFlags.Caption | ToolkitWindowFlags.ResizeHandles;
            toolkit.GetWin32StylesFromFlags(flags, out style, out extendedStyle);
            menu           = false;
            extendedStyle  = 0;
            topOfhierarchy = this;
        }
	public DrawingTopLevelWindow(DrawingToolkit toolkit, String name,
		int width, int height, IToolkitEventSink sink) : base ( toolkit )
	{
		this.sink = sink;
		//Console.WriteLine("DrawingTopLevelWindow");
		dimensions = new Rectangle(0, 0, width, height);

		// At the moment we create a unique class name for EVERY window. SWF does it for each unique window class
		className = "DrawingTopLevelWindow" + createCount++;

		// Register the windows class
		windowsClass = new Win32.Api.WNDCLASS();
		windowsClass.style = Win32.Api.WindowClassStyle.CS_DBLCLKS;
		windowsClass.lpfnWndProc = new Win32.Api.WNDPROC(toolkit.WindowsLoop);
		// We will draw
		windowsClass.hbrBackground = IntPtr.Zero;
		windowsClass.lpszClassName = className ;
		if (Win32.Api.RegisterClassA( ref windowsClass)==0) 
		{
			throw new Exception("Failed to register Windows class " + className);
		}
			
		// Set default window characteristics
		flags = ToolkitWindowFlags.Menu | ToolkitWindowFlags.Close | ToolkitWindowFlags.Minimize | ToolkitWindowFlags.Maximize | ToolkitWindowFlags.Caption | ToolkitWindowFlags.ResizeHandles;
		toolkit.GetWin32StylesFromFlags( flags, out style, out extendedStyle);
		menu = false;
		extendedStyle = 0;
		topOfhierarchy = this;
	}
Exemplo n.º 6
0
 // Move or resize this window.
 void IToolkitWindow.MoveResize(int x, int y, int width, int height)
 {
     DrawingToolkit.ValidateWindowPosition(ref x, ref y);
     DrawingToolkit.ValidateWindowSize(ref width, ref height);
     Move(x, y);
     Resize(width, height);
 }
	public DrawingPopupWindow(DrawingToolkit toolkit, int x, int y, int width, int height,
		IToolkitEventSink sink) : base ( toolkit )
	{
		//Console.WriteLine("DrawingPopupWindow");
		this.sink = sink;
		dimensions = new Rectangle(x, y, width, height);

		// At the moment we create a unique class name for EVERY window. SWF does it for each unique window class
		className = "DrawingPopupWindow" + createCount++;

		// Register the windows class
		windowsClass = new Win32.Api.WNDCLASS();
		windowsClass.style = Win32.Api.WindowClassStyle.CS_DBLCLKS;
		windowsClass.lpfnWndProc = new Win32.Api.WNDPROC(toolkit.WindowsLoop);
		// We will draw
		windowsClass.hbrBackground = IntPtr.Zero;
		windowsClass.lpszClassName = className ;
		if (Win32.Api.RegisterClassA( ref windowsClass)==0) 
		{
			throw new Exception("Failed to register Windows class " + className);
		}
			
		// Set default window characteristics
		style = Win32.Api.WindowStyle.WS_POPUP;
		menu = false;
		extendedStyle = Win32.Api.WindowsExtendedStyle.WS_EX_TOOLWINDOW;
		// We capture the mouse, and we want the client windows to be notified
		topOfhierarchy = this;
	}
	protected DrawingWindow( DrawingToolkit toolkit )
	{
		this.toolkit = toolkit;
		if( registeredBeginInvokeMessage == 0 )
			registeredBeginInvokeMessage =
				Win32.Api.RegisterWindowMessageA("DOTNET_BEGIN_INVOKE_MESSAGE");
	}
Exemplo n.º 9
0
 protected DrawingWindow(DrawingToolkit toolkit)
 {
     this.toolkit = toolkit;
     if (registeredBeginInvokeMessage == 0)
     {
         registeredBeginInvokeMessage =
             Win32.Api.RegisterWindowMessageA("DOTNET_BEGIN_INVOKE_MESSAGE");
     }
 }
Exemplo n.º 10
0
 // Set the background of the window to a solid color.
 void IToolkitWindow.SetBackground(System.Drawing.Color color)
 {
     if (color.A < 128)
     {
         BackgroundPixmap = null;
     }
     else
     {
         Background = DrawingToolkit.DrawingToXColor(color);
     }
 }
Exemplo n.º 11
0
        // Select this brush into a graphics object.
        public override void Select(IToolkitGraphics _graphics)
        {
            DrawingGraphics graphics = (_graphics as DrawingGraphics);

            if (graphics != null)
            {
                Xsharp.Graphics g = graphics.graphics;
                g.Function      = GCFunction.GXcopy;
                g.SubwindowMode = SubwindowMode.ClipByChildren;
                g.SetFillSolid();
                g.Foreground   = DrawingToolkit.DrawingToXColor(Color);
                graphics.Brush = this;
            }
        }
Exemplo n.º 12
0
 // Draw a bitmap-based glyph to a "Graphics" object.  "bits" must be
 // in the form of an xbm bitmap.
 public override void DrawGlyph(int x, int y,
                                byte[] bits, int bitsWidth, int bitsHeight,
                                System.Drawing.Color color)
 {
     Xsharp.Bitmap bitmap;
     bitmap = new Xsharp.Bitmap(bitsWidth, bitsHeight, bits);
     try
     {
         graphics.Foreground = DrawingToolkit.DrawingToXColor(color);
         graphics.SetFillStippled(bitmap, x, y);
         graphics.FillRectangle(x, y, bitsWidth, bitsHeight);
         graphics.SetFillSolid();
     }
     finally
     {
         bitmap.Destroy();
     }
 }
Exemplo n.º 13
0
        public DrawingHiddenWindow(DrawingToolkit toolkit, String name,
                                   int width, int height, IToolkitEventSink sink) : base(toolkit)
        {
            className = "DrawingHiddenWindow";
            // Register the windows class
            windowsClass             = new Win32.Api.WNDCLASS();
            windowsClass.style       = Win32.Api.WindowClassStyle.CS_DBLCLKS;
            windowsClass.lpfnWndProc = new Win32.Api.WNDPROC(toolkit.WindowsLoop);
            // We will draw
            windowsClass.hbrBackground = IntPtr.Zero;
            windowsClass.lpszClassName = className;
            if (Win32.Api.RegisterClassA(ref windowsClass) == 0)
            {
                throw new Exception("Failed to register Windows class " + className);
            }

            // Set default window characteristics
            style          = Win32.Api.WindowStyle.WS_OVERLAPPEDWINDOW;
            extendedStyle  = 0;
            topOfhierarchy = this;
        }
	public DrawingHiddenWindow(DrawingToolkit toolkit, String name,
		int width, int height, IToolkitEventSink sink) : base ( toolkit )
	{
		className = "DrawingHiddenWindow";
		// Register the windows class
		windowsClass = new Win32.Api.WNDCLASS();
		windowsClass.style = Win32.Api.WindowClassStyle.CS_DBLCLKS;
		windowsClass.lpfnWndProc = new Win32.Api.WNDPROC(toolkit.WindowsLoop);
		// We will draw
		windowsClass.hbrBackground = IntPtr.Zero;
		windowsClass.lpszClassName = className ;
		if (Win32.Api.RegisterClassA( ref windowsClass)==0) 
		{
			throw new Exception("Failed to register Windows class " + className);
		}
			
		// Set default window characteristics
		style = Win32.Api.WindowStyle.WS_OVERLAPPEDWINDOW;
		extendedStyle = 0;
		topOfhierarchy = this;
	}
Exemplo n.º 15
0
 public DrawingControlWindow(DrawingToolkit toolkit, string name, DrawingWindow parent, int x, int y, int width, int height, IToolkitEventSink sink) : base(toolkit)
 {
     this.sink = sink;
     //Console.WriteLine("DrawingControlWindow");
     this.parent = parent;
     dimensions  = new Rectangle(x, y, width, height);
     //At the moment we create a unique class name for EVERY window. SWF does it for each window type
     className = "DrawingControlWindow" + createCount++;
     //Register the windows class
     windowsClass               = new Win32.Api.WNDCLASS();
     windowsClass.style         = Win32.Api.WindowClassStyle.CS_DBLCLKS;
     windowsClass.lpfnWndProc   = new Win32.Api.WNDPROC(toolkit.WindowsLoop);
     windowsClass.hbrBackground = IntPtr.Zero;     //(IntPtr)(Win32.Api.COLOR_WINDOW + 1);
     windowsClass.lpszClassName = className;
     if (Win32.Api.RegisterClassA(ref windowsClass) == 0)
     {
         throw new Exception("Failed to register Windows class " + className);
     }
     //Set default windows settings
     style         = Win32.Api.WindowStyle.WS_CHILD | Win32.Api.WindowStyle.WS_TABSTOP | Win32.Api.WindowStyle.WS_CLIPSIBLINGS;
     extendedStyle = 0;
 }
	public DrawingControlWindow(DrawingToolkit toolkit, string name, DrawingWindow parent, int x, int y, int width, int height, IToolkitEventSink sink) : base (toolkit)
	{
		this.sink = sink;
		//Console.WriteLine("DrawingControlWindow");
		this.parent = parent;
		dimensions = new Rectangle( x, y, width, height );
		//At the moment we create a unique class name for EVERY window. SWF does it for each window type
		className = "DrawingControlWindow" + createCount++;
		//Register the windows class
		windowsClass = new Win32.Api.WNDCLASS();
		windowsClass.style = Win32.Api.WindowClassStyle.CS_DBLCLKS;
		windowsClass.lpfnWndProc = new Win32.Api.WNDPROC(toolkit.WindowsLoop);
		windowsClass.hbrBackground = IntPtr.Zero; //(IntPtr)(Win32.Api.COLOR_WINDOW + 1);
		windowsClass.lpszClassName = className ;
		if (Win32.Api.RegisterClassA( ref windowsClass)==0) 
		{
			throw new Exception("Failed to register Windows class " + className);
		}
		//Set default windows settings
		style = Win32.Api.WindowStyle.WS_CHILD | Win32.Api.WindowStyle.WS_TABSTOP | Win32.Api.WindowStyle.WS_CLIPSIBLINGS;
		extendedStyle = 0;
	}
Exemplo n.º 17
0
 // Invalidate a rectangle within this window.
 void IToolkitWindow.Invalidate(int x, int y, int width, int height)
 {
     DrawingToolkit.ValidateWindowPositionPaint(ref x, ref y);
     DrawingToolkit.ValidateWindowSize(ref width, ref height);
     Repaint(x, y, width, height);
 }
	public DrawingRootTopLevelWindow(DrawingToolkit toolkit, String name,
		int width, int height, IToolkitEventSink sink) : base (toolkit, name, width, height, sink) {}
Exemplo n.º 19
0
 public DrawingRootTopLevelWindow(DrawingToolkit toolkit, String name,
                                  int width, int height, IToolkitEventSink sink) : base(toolkit, name, width, height, sink)
 {
 }
Exemplo n.º 20
0
 // Set the foreground of the window to a solid color.
 void IToolkitWindow.SetForeground(System.Drawing.Color color)
 {
     Foreground = DrawingToolkit.DrawingToXColor(color);
 }
Exemplo n.º 21
0
        // Select this pen into a graphics object.
        public override void Select(IToolkitGraphics _graphics)
        {
            if (_graphics == null)
            {
                return;
            }

            if (_graphics is DrawingGraphics)
            {
                DrawingGraphics graphics = _graphics as DrawingGraphics;
                Xsharp.Graphics g        = graphics.graphics;
                int             width    = (int)(properties.Width);
                LineStyle       style    = MapLineStyle(properties.DashStyle);
                if (style == LineStyle.LineOnOffDash)
                {
                    if (width == 1)
                    {
                        width = 0;
                    }
                    switch (properties.DashStyle)
                    {
                    case DashStyle.Dash:
                    {
                        g.DashPattern = dash;
                    }
                    break;

                    case DashStyle.Dot:
                    {
                        g.DashPattern = dot;
                    }
                    break;

                    case DashStyle.DashDot:
                    {
                        g.DashPattern = dashdot;
                    }
                    break;

                    case DashStyle.DashDotDot:
                    {
                        g.DashPattern = dashdotdot;
                    }
                    break;

                    case DashStyle.Custom:
                    {
                        float [] src    = properties.DashPattern;
                        int      iLen   = src.Length;
                        byte []  ayCopy = new byte[iLen];
                        float    fWidth = properties.Width;
                        float    tmp;
                        for (int i = 0; i < iLen; i++)
                        {
                            tmp = src[i] * fWidth;
                            if (tmp < 0)
                            {
                                tmp = 0;
                            }
                            else if (tmp > 0xFF)
                            {
                                tmp = 0xFF;
                            }
                            ayCopy[i] = (byte)(tmp);
                            if (ayCopy[i] == 0)
                            {
                                ayCopy[i] = 1;                                                              // must not be zero
                            }
                        }
                        g.DashPattern = ayCopy;
                    }
                    break;
                    }
                }
                g.Function      = GCFunction.GXcopy;
                g.SubwindowMode = SubwindowMode.ClipByChildren;
                g.LineWidth     = width;
                g.LineStyle     = style;
                g.CapStyle      = MapCapStyle(properties.EndCap);
                g.JoinStyle     = MapJoinStyle(properties.LineJoin);
                g.Foreground    = DrawingToolkit.DrawingToXColor
                                      (properties.Color);
                g.SetFillSolid();
                graphics.Pen = this;
            }
            else if (_graphics is DrawingGraphicsImage)
            {
                DrawingGraphicsImage graphics = _graphics as DrawingGraphicsImage;
                graphics.Pen = this;
            }
        }