Пример #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);
            }
        }
Пример #2
0
        /// <summary>
        ///当选择了icon,更新预览
        /// </summary>
        private void IconControl1SelectionChanged()
        {
            string filename = iconControl1.SelectedName;

            if (string.IsNullOrWhiteSpace(filename))
            {
                return;
            }

            var   bmp            = new Bitmap(filename);
            Color clrTransparent = Color.White;

            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.PointType = tkPointSymbolType.ptSymbolPicture;
                _options.Picture   = img;

                UpdatePrictureScale();

                DrawPreview();
            }
            else
            {
                string errString = string.Empty;
                if (img.LastErrorCode != 0)
                {
                    errString = ": " + img.ErrorMsg[img.LastErrorCode];
                }
                MessageBox.Show("Failed to open image: " + errString);
            }

            if (!_noEvents)
            {
                btnApply.Enabled = true;
            }
        }