Exemple #1
0
        /// <summary>
        /// Changes the textures
        /// </summary>
        void iconControl1_SelectionChanged()
        {
            string filename = iconControl1.SelectedName;

            if (filename == string.Empty)
            {
                return;
            }

            // seeking the transarent color
            Bitmap bmp            = new Bitmap(filename);
            Color  clrTransparent = Color.White;

            for (int i = 0; i < bmp.Width; i++)
            {
                int j;
                for (j = 0; j < bmp.Height; j++)
                {
                    Color clr = bmp.GetPixel(i, j);
                    if (clr.A == 0)
                    {
                        clrTransparent = clr;
                        break;
                    }
                }
                if (j != bmp.Width)
                {
                    break;
                }
            }

            MapWinGIS.Image img = new MapWinGIS.Image();
            if (img.Open(filename, ImageType.USE_FILE_EXTENSION, true, null))
            {
                img.LoadBuffer(50);

                img.TransparencyColor    = Colors.ColorToUInteger(clrTransparent);
                img.TransparencyColor2   = Colors.ColorToUInteger(clrTransparent);
                img.UseTransparencyColor = true;

                _options.Picture = img;

                DrawPreview();
            }
            else
            {
                string errString = string.Empty;
                if (img.LastErrorCode != 0)
                {
                    errString = ": " + img.get_ErrorMsg(img.LastErrorCode);
                }
                Globals.MessageBoxError("Failed to open image: " + errString);
            }
        }