コード例 #1
0
ファイル: X11BrushInfo.cs プロジェクト: kobbst/X11_Xlib
        /// <summary>Initialize a new instance of the System.BrushInfo structure that has specific tile pixmap and color.</summary>
        /// <param name="uriSource">The image source uri.<see cref="System.String"/></param>
        /// <param name="image">The tile image to apply.<see cref="X11Graphic"/></param>
        /// <param name="color">The color value.<see cref="X11.TColor"/></param>
        /// <returns>The requested brush info.<see cref="BrushInfo"/></returns>
        /// <remarks>The TileBrush supports bitmap offset.</remarks>
        /// <exception cref="ArgumentNullException">If 'uriSource' is null or empty string.</exception>
        public static X11BrushInfo ImageBrush(string uriSource, X11.X11Graphic image, X11.TColor color)
        {
            if (string.IsNullOrEmpty(uriSource))
            {
                throw new ArgumentNullException();
            }

            X11BrushInfo bi = new X11BrushInfo(BrushType.Image, image, color);

            bi._imageUri = uriSource;
            return(bi);
        }
コード例 #2
0
ファイル: X11BrushInfo.cs プロジェクト: kobbst/X11_Xlib
        /// <summary>Internal (inheritable) dispose by parent.</summary>
        /// <param name="disposing">Determine whether Dispose() has been called by the user (true) or the runtime from inside the finalizer (false).</param>
        /// <remarks>If disposing equals false, no references to other objects shold be called.</remarks>
        protected void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // Free OWN managed objects.
                }
                // Free OWN unmanaged objects.
                // Set large fields to null.
                if (_hatchBitmap != IntPtr.Zero)
                {
                    X11.X11lib.XFreePixmap(_hatchDisplay, _hatchBitmap);
                    _hatchDisplay = IntPtr.Zero;
                    _hatchBitmap  = IntPtr.Zero;
                }
                if (_tileGraphic != null)
                {
                    _tileGraphic.Dispose();
                    _tileGraphic = null;
                }
                if (_tileStockPixmaps.Count > 0 || _currentTilePixmap != IntPtr.Zero)
                {
                    for (int index = _tileStockPixmaps.Count - 1; index >= 0; index--)
                    {
                        if (_tileStockPixmaps[index].Pixmap != IntPtr.Zero)
                        {
                            if (_currentTilePixmap == _tileStockPixmaps[index].Pixmap)
                            {
                                _currentTilePixmap = IntPtr.Zero;
                            }
                            X11.X11lib.XFreePixmap(_tilePixmapDisplay, _tileStockPixmaps[index].Pixmap);
                        }
                        _tileStockPixmaps.RemoveAt(index);
                    }
                    _tileStockPixmaps.Clear();

                    if (_currentTilePixmap != IntPtr.Zero)
                    {
                        X11.X11lib.XFreePixmap(_tilePixmapDisplay, _currentTilePixmap);
                    }
                    _currentTilePixmap = IntPtr.Zero;

                    _tilePixmapDisplay = IntPtr.Zero;
                }

                _disposed = true;
            }
        }
コード例 #3
0
ファイル: X11BrushInfo.cs プロジェクト: kobbst/X11_Xlib
        /// <summary>Init the tile pixmap of an image brush info.</summary>
        /// <param name="x11display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param>
        /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param>
        /// <param name="individualColormap"> The X11 application individual colormap, if any. <see cref="IntPtr"/> </param>
        /// <param name="graphicDepth"> The depth (number of planes) of the graphic - that holds color pixel information. <see cref="TInt"/> </para>
        /// <returns>True on success, or fals otherwise.<see cref="System.Boolean"/></returns>
        public bool InitTilePixmap(IntPtr x11display, int screenNumber, IntPtr individualColormap, int graphicDepth)
        {
            if (string.IsNullOrEmpty(_imageUri))
            {
                return(false);
            }

            System.Uri uri = new System.Uri(_imageUri);

            _tileGraphic = new X11.X11Graphic(x11display, screenNumber, individualColormap, (X11.TInt)graphicDepth, uri.AbsolutePath);
            if (_tileGraphic != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
ファイル: X11BrushInfo.cs プロジェクト: kobbst/X11_Xlib
 /// <summary>Initialize a new instance of the System.BrushInfo structure that has specific color.</summary>
 /// <param name="type">The type value.<see cref="System.X11BrushInfo.BrushType"/></param>
 /// <param name="image">The graphic to cteate the tile pixmap for tile fill from.<see cref="X11.X11Graphic"/></param>
 /// <param name="color">The color value.<see cref="X11.TColor"/></param>
 private X11BrushInfo(BrushType type, X11.X11Graphic image, X11.TColor color)
 {
     _brushType   = type;
     _tileGraphic = image;
     _color       = color;
 }