Beispiel #1
0
        public void StockIconsTest(StockIcon stockIcon)
        {
            var icon = Icons.GetStockIcon(stockIcon);

            Assert.IsTrue(!OSUtils.IsWindows || icon != null);
            SaveIcon(stockIcon.ToString(), icon);
        }
        // ###############################################################################
        // ### C O N S T R U C T I O N   A N D   I N I T I A L I Z A T I O N
        // ###############################################################################

        #region Construction

        /// <summary> Initializing constructor. </summary>
        /// <param name="display">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="icon"> The left bitmap to display. <see cref="XrwBitmap.Icon"/> </param>
        public X11Graphic(IntPtr display, TInt screenNumber, StockIcon icon)
        {
            // Check arguments.
            if (display == IntPtr.Zero)
            {
                throw new ArgumentNullException("display");
            }
            if (icon == X11Graphic.StockIcon.None)
            {
                throw new ArgumentNullException("icon");
            }

            _display      = display;
            _screenNumber = screenNumber;

            // Load bitmap.
            Bitmap bmp = null;

            try
            {
                System.IO.Stream bmpStream = null;

                if (icon == X11Graphic.StockIcon.Attention16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_ATTENTION_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Attention32TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_ATTENTION_32_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Attention48TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_ATTENTION_48_TRUECOLOR, false);
                }

                else if (icon == X11Graphic.StockIcon.Cancel16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_CANCEL_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Cancel32TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_CANCEL_32_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Cancel48TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_CANCEL_48_TRUECOLOR, false);
                }

                else if (icon == X11Graphic.StockIcon.Error16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_ERROR_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Error32TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_ERROR_32_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Error48TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_ERROR_48_TRUECOLOR, false);
                }

                else if (icon == X11Graphic.StockIcon.Information16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_INFO_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Information32TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_INFO_32_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Information48TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_INFO_48_TRUECOLOR, false);
                }

                else if (icon == X11Graphic.StockIcon.Ok16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_OK_16_TRUECOLOR, false);
                }

                else if (icon == X11Graphic.StockIcon.Question16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_QUESTION_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Question32TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_QUESTION_32_TRUECOLOR, false);
                }

                else if (icon == X11Graphic.StockIcon.Warning16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_WARNING_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.Warning32TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_WARNING_32_TRUECOLOR, false);
                }

                else if (icon == X11Graphic.StockIcon.ToggleOff16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_TOGGLEOFF_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.ToggleOn16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_TOGGLEON_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.RadioOff16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_RADIOOFF_16_TRUECOLOR, false);
                }
                else if (icon == X11Graphic.StockIcon.RadioOn16TrueColor)
                {
                    bmpStream = new System.IO.MemoryStream(X11Resources.IMAGE_RADIOON_16_TRUECOLOR, false);
                }

                bmp = new Bitmap(bmpStream);
                bmpStream.Close();
            }
            catch (Exception e)
            {
                throw e;
            }
            if (bmp == null)
            {
                throw new OperationCanceledException("Failed to create bitmap from '" + icon.ToString() + "'.");
            }

            InitializeGraphicRessources(bmp);
        }