Example #1
0
        protected static void DrawIcon(Graphics graphics, Image imgPanelIcon, int x, int y)
        {
            if (graphics == null)
            {
                throw new ArgumentException(
                          string.Format(
                              System.Globalization.CultureInfo.CurrentUICulture,
                              StaticResource.IDS_ArgumentException,
                              typeof(Graphics).Name));
            }
            if (imgPanelIcon == null)
            {
                throw new ArgumentException(
                          string.Format(
                              System.Globalization.CultureInfo.CurrentUICulture,
                              StaticResource.IDS_ArgumentException,
                              typeof(Image).Name));
            }

            int       iconWidth     = imgPanelIcon.Width;
            int       iconHeight    = imgPanelIcon.Height;
            Rectangle rectangleIcon = new Rectangle(x, y, iconWidth, iconHeight);

            using (System.Drawing.Imaging.ImageAttributes imageAttribute = new System.Drawing.Imaging.ImageAttributes())
            {
                imageAttribute.SetColorKey(Color.Magenta, Color.Magenta); //颜色改为透明
                System.Drawing.Imaging.ColorMap colorMap = new System.Drawing.Imaging.ColorMap();
                colorMap.OldColor = Color.FromArgb(0, 60, 166);           //改颜色
                colorMap.NewColor = Color.Black;
                imageAttribute.SetRemapTable(new System.Drawing.Imaging.ColorMap[] { colorMap });

                graphics.DrawImage(imgPanelIcon, rectangleIcon, 0, 0, iconWidth, iconHeight, GraphicsUnit.Pixel, imageAttribute);
            }
        }
Example #2
0
        private void drawImageCentered(Image i, Graphics g)
        {
            int cx, cy;

            if (i == null)
            {
                return;
            }

            cx = (this.Size.Width - i.Width) / 2;
            cy = (this.Size.Height - i.Height) / 2;

            if (_activePicture)
            {
                // give the pressed image an offset
                cx++;
                cy++;
            }

            // set transparency key
            System.Drawing.Imaging.ImageAttributes imageAttr = new System.Drawing.Imaging.ImageAttributes();
            imageAttr.SetColorKey(backgroundImageColor(i), backgroundImageColor(i));

            Rectangle imgRect = new Rectangle(cx, cy, i.Width, i.Height);

            g.DrawImage(i, imgRect, 0, 0, i.Width, i.Height, GraphicsUnit.Pixel, imageAttr);
        }
Example #3
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            for (int y = 0; y < mapData.Length; y++)
            {
                for (int x = 0; x < mapData[0].Length; x++)
                {
                    TilePiece mapPiece = mapData[y][x];

                    if (gridPoint.X == x && gridPoint.Y == y)
                    {
                        mapPiece = _selectedPiece;
                    }

                    Image drawPiece = tileImages[mapPiece];

                    System.Drawing.Imaging.ImageAttributes a = new System.Drawing.Imaging.ImageAttributes();
                    a.SetColorKey(Color.FromArgb(254, 254, 254), Color.White, System.Drawing.Imaging.ColorAdjustType.Bitmap);

                    e.Graphics.DrawImage(drawPiece, new Rectangle(x * 80, y * 80, 80, 80), 0, 0, drawPiece.Width, drawPiece.Height, GraphicsUnit.Pixel, a);

                    if (mapPiece == TilePiece.Start)
                    {
                        e.Graphics.DrawImage(car, new Rectangle(x * 80 + 40 - car.Width / 2, y * 80 + 40 - car.Height / 2, car.Width, car.Height));
                    }
                }
            }
        }
Example #4
0
 internal void DrawPlusMinus(Graphics g)
 {
     if (!IsInATreeListView)
     {
         return;
     }
     if (TreeListView._updating)
     {
         return;
     }
     Debug.Assert(!TreeListView.InvokeRequired);
     if (Items.Count == 0 || TreeListView.Columns.Count == 0)
     {
         return;
     }
     System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
     attr.SetColorKey(Color.Transparent, Color.Transparent);
     if (TreeListView.Columns[0].Width > (Level + 1) * SystemInformation.SmallIconSize.Width)
     {
         g.DrawImage(
             TreeListView.plusMinusImageList.Images[IsExpanded ? 1 : 0],
             GetBounds(TreeListViewItemBoundsPortion.PlusMinus),
             0, 0, SystemInformation.SmallIconSize.Width, SystemInformation.SmallIconSize.Height,
             GraphicsUnit.Pixel, attr);
     }
     attr.Dispose();
 }
Example #5
0
        static public void DrawAlphaImage(Graphics g, Image image, int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, Color tranColor)
        {
            Rectangle dstRect = new Rectangle(dstX, dstY, width, height);
            Rectangle srcRect = new Rectangle(srcX, srcY, srcWidth, srcHeight);

            System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
            attr.SetColorKey(tranColor, tranColor);

            g.DrawImage(image, dstRect, srcX, srcY, width, height, GraphicsUnit.Pixel, attr);
        }
Example #6
0
        public static Bitmap MakeColourTransparent(Bitmap bm, Color makeTransparent)
        {
            Bitmap newImage = new Bitmap(bm.Width, bm.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using (Graphics g = Graphics.FromImage(newImage))
            {
                System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes();
                ia.SetColorKey(makeTransparent, makeTransparent);
                g.DrawImage(bm, new Rectangle(Point.Empty, newImage.Size), 0, 0, newImage.Width, newImage.Height, GraphicsUnit.Pixel, ia);
            }
            return(newImage);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (null != _alphaControl && null != _alphaControl._alphaImage)
            {
                Rectangle destRect = this.ClientRectangle;
                Rectangle srcRect  = this.RectangleToScreen(this.ClientRectangle);

                e.Graphics.DrawImage(_alphaControl._alphaImage, destRect, srcRect, GraphicsUnit.Pixel);
            }
            System.Drawing.Imaging.ImageAttributes a = new System.Drawing.Imaging.ImageAttributes();
            a.SetColorKey(this.TransparentColor, this.TransparentColor);
            e.Graphics.DrawImage(this.Image, new Rectangle(0, 0, this.Width, this.Height), 0, 0, this.Image.Width, this.Image.Height, GraphicsUnit.Pixel, a);
        }
Example #8
0
        /// <summary>
        /// Draws the Chevron Image at the specified location.
        /// </summary>
        /// <param name="graphics">The Graphics to draw on.</param>
        /// <param name="imgChevron">Chevron Image to draw.</param>
        /// <param name="chevronBackColor"></param>
        /// <param name="iPositionX">The left position of the Chevron Image</param>
        protected static void DrawChevron(Graphics graphics, Image imgChevron, Rectangle imageRectangle, Color chevronBackColor)
        {
            if (graphics == null)
            {
                throw new ArgumentException(
                          string.Format(
                              System.Globalization.CultureInfo.CurrentUICulture,
                              Resources.IDS_ArgumentException,
                              typeof(Graphics).Name));
            }
            if (imgChevron == null)
            {
                throw new ArgumentException(
                          string.Format(
                              System.Globalization.CultureInfo.CurrentUICulture,
                              Resources.IDS_ArgumentException,
                              typeof(Image).Name));
            }

            int chevronPositionX = imageRectangle.Left;
            int chevronPositionY = ImagePaddingTop;

            Rectangle rectangleChevron = new Rectangle(
                chevronPositionX + (imageRectangle.Width / 3) - 2,
                chevronPositionY + 3,
                9,
                9);

            using (System.Drawing.Imaging.ImageAttributes imageAttribute = new System.Drawing.Imaging.ImageAttributes())
            {
                imageAttribute.SetColorKey(Color.White, Color.White);
                System.Drawing.Imaging.ColorMap colorMap = new System.Drawing.Imaging.ColorMap();
                colorMap.OldColor = Color.FromArgb(0, 60, 166);
                colorMap.NewColor = chevronBackColor;
                imageAttribute.SetRemapTable(new System.Drawing.Imaging.ColorMap[] { colorMap });

                using (LinearGradientBrush brushInnerCircle = new LinearGradientBrush(
                           new Rectangle(chevronPositionX, chevronPositionY, 16, 16),
                           Color.FromArgb(128, Color.White),
                           Color.FromArgb(0, Color.White),
                           LinearGradientMode.Vertical))
                {
                    graphics.FillPath(brushInnerCircle, GetPath(new Rectangle(chevronPositionX, chevronPositionY, 15, 15), 5));
                }
                graphics.DrawImage(imgChevron, rectangleChevron, 0, 0, 9, 9, GraphicsUnit.Pixel, imageAttribute);
            }
        }
Example #9
0
 public Form1()
 {
     InitializeComponent();
     for (int i = 0; i < 10; i++)
     {
         Image    image1 = Bitmap.FromFile(string.Format("{0}\\{1}.png", directory, i + 1));
         Image    image2 = Bitmap.FromFile(string.Format("{0}\\{1}.png", directory, i + 2));
         Bitmap   image3 = new Bitmap(image1.Width, image1.Height);
         Graphics g      = Graphics.FromImage(image3);
         System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes();
         attributes.SetColorKey(image3.GetPixel(100, 100), image3.GetPixel(10, 10));
         g.DrawImage(image2, new Rectangle(0, 0, image3.Width, image3.Height / 2), 0, 0, image2.Width, image2.Height / 2, GraphicsUnit.Pixel, attributes);
         g.DrawImage(image1, new Rectangle(0, image3.Height / 2, image3.Width, image3.Height / 2), 0, image1.Height / 2, image1.Width, image1.Height / 2, GraphicsUnit.Pixel);
         g.DrawString((i + 1).ToString(), DefaultFont, new SolidBrush(Color.Black), 0, 0);
         g.Dispose();
         image3.Save(string.Format("{0}\\{1}.png", directory, i + 201));
     }
 }
Example #10
0
        //============
        // 背景画像とキャラクター画像の合成
        // 第1引数: 合成する背景画像
        // 第2引数: 合成するキャラクター画像
        // 第3引数: キャラクターの位置座標
        // 戻り値: 合成後の画像
        public Image ComposeBackgroundImgAndCharacterImg(
            Image Background_Img,
            Image Character_Img,
            Point Chara_Position)
        {
            // 合成を行なうためのイメージ画像を作成
            // (背景画像を新規作成のイメージ画像にコピー)
            Image ImageWork = (Image)Background_Img.Clone();
            // グラフィック用オブジェクトを生成
            Graphics gr = Graphics.FromImage(ImageWork);

            // 透明色指定(白を指定)
            System.Drawing.Imaging.ImageAttributes ImgAttr = new System.Drawing.Imaging.ImageAttributes();
            ImgAttr.SetColorKey(Color.FromArgb(230, 230, 230), Color.FromArgb(255, 255, 255));  // 真白から白(少し黒よりの白)までの範囲を指定
            // キャラクター画像の描画
            gr.DrawImage(CharacterImg, new Rectangle(CharaPosition, CharacterImg.Size), 0, 0, CharacterImg.Width, CharacterImg.Height, GraphicsUnit.Pixel, ImgAttr);
            // 合成後のイメージ画像を返却
            return(ImageWork);
        }
Example #11
0
 static GMapMarker()
 {
     attr.SetColorKey(Color.White, Color.White);
 }
Example #12
0
        /// <summary>
        /// Draws the Chevron Image at the specified location.
        /// </summary>
        /// <param name="graphics">The Graphics to draw on.</param>
        /// <param name="imgChevron">Chevron image to draw.</param>
        /// <param name="imageRectangle">A Rectangle structure that specifies the bounds of the linear gradient.</param>
        /// <param name="foreColorImage">the foreground color of this image</param>
        /// <param name="bDrawBackground">Gets or sets a value indicating whether the background of the close and expand images is drawn</param>
        protected static void DrawChevron(Graphics graphics, Image imgChevron, Rectangle imageRectangle, Color foreColorImage, bool bDrawBackground, int chevronPositionY)
        {
            if (graphics == null)
            {
                throw new ArgumentException(
                    string.Format(
                    System.Globalization.CultureInfo.CurrentUICulture,
                    Resources.IDS_ArgumentException,
                    typeof(Graphics).Name));
            }
            if (imgChevron == null)
            {
                throw new ArgumentException(
                    string.Format(
                    System.Globalization.CultureInfo.CurrentUICulture,
                    Resources.IDS_ArgumentException,
                    typeof(Image).Name));
            }

            int chevronPositionX = imageRectangle.Left;

            Rectangle rectangleChevron = new Rectangle(
                chevronPositionX + (imageRectangle.Width / 3) - 2,
                chevronPositionY + 3,
                9,
                9);

            using (System.Drawing.Imaging.ImageAttributes imageAttribute = new System.Drawing.Imaging.ImageAttributes())
            {
                imageAttribute.SetColorKey(Color.Magenta, Color.Magenta);
                System.Drawing.Imaging.ColorMap colorMap = new System.Drawing.Imaging.ColorMap();
                colorMap.OldColor = Color.FromArgb(0, 60, 166);
                colorMap.NewColor = foreColorImage;
                imageAttribute.SetRemapTable(new System.Drawing.Imaging.ColorMap[] { colorMap });

                if (bDrawBackground == true)
                {
                    using (LinearGradientBrush brushInnerCircle = new LinearGradientBrush(
                        new Rectangle(chevronPositionX, chevronPositionY, 16, 16),
                        Color.FromArgb(128, Color.White),
                        Color.FromArgb(0, Color.White),
                        LinearGradientMode.Vertical))
                    {
                        graphics.FillPath(brushInnerCircle, GetPath(new Rectangle(chevronPositionX, chevronPositionY, 15, 15), 5));
                    }
                }
                graphics.DrawImage(imgChevron, rectangleChevron, 0, 0, 9, 9, GraphicsUnit.Pixel, imageAttribute);
            }
        }
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (this.Items.Count <= 0)
            {
                return;
            }
            if (e.Index < 0)
            {
                return;
            }
            try
            {
                System.Drawing.Design.ToolboxItem tbi = Items[e.Index] as System.Drawing.Design.ToolboxItem;
                System.Drawing.Rectangle          rc  = new System.Drawing.Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                if (e.Index == nIndexMouseOn)
                {
                    e.Graphics.FillRectangle(m_brushBK, e.Bounds);
                    if ((e.State & DrawItemState.Selected) != 0)
                    {
                        e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                        e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                        e.Graphics.DrawLine(m_penWhite, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                        e.Graphics.DrawLine(m_penWhite, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                    }
                    else
                    {
                        e.Graphics.DrawLine(m_penWhite, e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                        e.Graphics.DrawLine(m_penWhite, e.Bounds.X, e.Bounds.Y, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                        e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                        e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                    }
                }
                else if ((e.State & DrawItemState.Selected) != 0)
                {
                    e.Graphics.FillRectangle(System.Drawing.Brushes.AntiqueWhite, e.Bounds);

                    e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                    e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                    e.Graphics.DrawLine(m_penWhite, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                    e.Graphics.DrawLine(m_penWhite, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                }
                else
                {
                    e.Graphics.FillRectangle(new LinearGradientBrush(this.Bounds, Color.White, Color.LightBlue, 0F), e.Bounds);
                }
                //draw icon
                // Create an ImageAttributes object and set the color key.
                System.Drawing.Color lowerColor = System.Drawing.Color.FromArgb(255, 255, 255);
                System.Drawing.Color upperColor = System.Drawing.Color.FromArgb(255, 255, 255);
                System.Drawing.Imaging.ImageAttributes imageAttr = new System.Drawing.Imaging.ImageAttributes();
                imageAttr.SetColorKey(lowerColor,
                                      upperColor,
                                      System.Drawing.Imaging.ColorAdjustType.Default);

                rc.X      += 2;
                rc.Width   = nIconSize;
                rc.Y       = rc.Top + 1;
                rc.Height -= 2;
                e.Graphics.DrawImage(tbi.Bitmap,                        // Image
                                     rc,                                // Dest. rect.
                                     0,                                 // srcX
                                     0,                                 // srcY
                                     tbi.Bitmap.Width,                  // srcWidth
                                     tbi.Bitmap.Height,                 // srcHeight
                                     System.Drawing.GraphicsUnit.Pixel, // srcUnit
                                     imageAttr);                        // ImageAttributes
                //draw name
                rc.X     = rc.Width + 3;
                rc.Width = e.Bounds.Width - rc.X - 1;
                rc.Y     = rc.Top + nDrawTop;
                if (rc.Width > 0)
                {
                    e.Graphics.DrawString(tbi.DisplayName, m_font, System.Drawing.Brushes.Black, rc);
                }
            }
            catch
            {
            }
        }
Example #14
0
        public virtual void Render(Graphics g, Rectangle bounds)
        {
            try
            {
                g.Clip = new Region(bounds);
                currentOffset = bounds;
                SolidBrush ForeBrush = new SolidBrush(ClientSettings.ForeColor);
                Rectangle textBounds;
                //Shrink the text area to accomidate avatars if appropriate
                if (ClientSettings.ShowAvatars)
                {
                    textBounds = new Rectangle(bounds.X + (ClientSettings.SmallArtSize + ClientSettings.Margin), bounds.Y, bounds.Width - (ClientSettings.SmallArtSize + (ClientSettings.Margin * 2)), bounds.Height);
                }
                else
                {
                    textBounds = new Rectangle(bounds.X + ClientSettings.Margin, bounds.Y, bounds.Width - (ClientSettings.Margin * 2), bounds.Height);
                }

                Rectangle InnerBounds = new Rectangle(bounds.Left, bounds.Top, bounds.Width, bounds.Height);
                InnerBounds.Offset(1, 1);
                InnerBounds.Width--; InnerBounds.Height--;

                if (m_selected)
                {
                    ForeBrush = new SolidBrush(ClientSettings.SelectedForeColor);
                    if (ClientSettings.SelectedBackColor != ClientSettings.SelectedBackGradColor)
                    {
                        try
                        {
                            Gradient.GradientFill.Fill(g, InnerBounds, ClientSettings.SelectedBackColor, ClientSettings.SelectedBackGradColor, Gradient.GradientFill.FillDirection.TopToBottom);
                        }
                        catch
                        {
                            using (Brush BackBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                            {
                                g.FillRectangle(BackBrush, InnerBounds);
                            }
                        }
                    }
                    else
                    {
                        using (Brush BackBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                        {
                            g.FillRectangle(BackBrush, InnerBounds);
                        }
                    }
                }
                else
                {
                    if (ClientSettings.BackColor != ClientSettings.BackGradColor)
                    {
                        try
                        {
                            Gradient.GradientFill.Fill(g, InnerBounds, ClientSettings.BackColor, ClientSettings.BackGradColor, Gradient.GradientFill.FillDirection.TopToBottom);
                        }
                        catch
                        {
                            using (Brush BackBrush = new SolidBrush(ClientSettings.BackColor))
                            {
                                g.FillRectangle(BackBrush, InnerBounds);
                            }
                        }
                    }
                    else
                    {
                        using (Brush BackBrush = new SolidBrush(ClientSettings.BackColor))
                        {
                            g.FillRectangle(BackBrush, InnerBounds);
                        }
                    }
                }


                Point ImageLocation = new Point(bounds.X + ClientSettings.Margin, bounds.Y + ClientSettings.Margin);

                //Add the timestamp if the settings call for it.
                if (ClientSettings.ShowExtra)
                {
                    Color SmallColor = ClientSettings.SmallTextColor;
                    if (this.Selected) { SmallColor = ClientSettings.SelectedSmallTextColor; }
                    using (Brush dateBrush = new SolidBrush(SmallColor))
                    {
                        g.DrawString(Tweet.TimeStamp, ClientSettings.SmallFont, dateBrush, bounds.Left + ClientSettings.Margin, ClientSettings.SmallArtSize + ClientSettings.Margin + bounds.Top, m_stringFormat);
                    }
                }

                //Get and draw the avatar area.
                if (ClientSettings.ShowAvatars)
                {
                    string artURL = Tweet.user.profile_image_url;
                    if (!ClientSettings.HighQualityAvatars)
                    {
                        artURL = Tweet.user.profile_image_url;
                    }
                    try
                    {
                        using (Image UserImage = PockeTwit.ThrottledArtGrabber.GetArt(artURL))
                        {
                            //g.DrawImage(UserImage, ImageLocation.X, ImageLocation.Y,);
                            g.DrawImage(UserImage, new Rectangle(ImageLocation.X, ImageLocation.Y, ClientSettings.SmallArtSize, ClientSettings.SmallArtSize), new Rectangle(0, 0, UserImage.Width, UserImage.Height), GraphicsUnit.Pixel);

                        }
                    }
                    catch(Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }

                    //Only occasionally is an item "starred", but we draw one on there if it is.
                    if (hasFavoriteStar)
                    {
                        System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes();
                        ia.SetColorKey(PockeTwit.ThrottledArtGrabber.FavoriteImage.GetPixel(0, 0), PockeTwit.ThrottledArtGrabber.FavoriteImage.GetPixel(0, 0));
                        g.DrawImage(PockeTwit.ThrottledArtGrabber.FavoriteImage,
                            new Rectangle(bounds.X + 5, bounds.Y + 5, 7, 7), 0, 0, 7, 7, GraphicsUnit.Pixel, ia);
                    }

                    //If it's a reply or direct message, overlay that on the avatar
                    if (Tweet.TypeofMessage == PockeTwit.Library.StatusTypes.Reply)
                    {
                        using (Brush sBrush = new SolidBrush(ClientSettings.SelectedForeColor))
                        {

                            Rectangle ImageRect = new Rectangle(ImageLocation.X, ImageLocation.Y, ClientSettings.SmallArtSize, ClientSettings.SmallArtSize);
                            Point sPoint = new Point(ImageRect.Right - 15, ImageRect.Top);

                            using (Brush bBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                            {
                                g.FillRectangle(bBrush, new Rectangle(ImageRect.Right - 15, ImageRect.Top, 15, 15));
                            }
                            g.DrawString("@", ClientSettings.TextFont, sBrush, new Rectangle(ImageRect.Right - 12, ImageRect.Top - 2, 10, 20));
                        }
                    }
                    else if (Tweet.TypeofMessage == PockeTwit.Library.StatusTypes.Direct)
                    {
                        using (Brush sBrush = new SolidBrush(ClientSettings.SelectedForeColor))
                        {
                            Rectangle ImageRect = new Rectangle(ImageLocation.X, ImageLocation.Y, ClientSettings.SmallArtSize, ClientSettings.SmallArtSize);
                            Point sPoint = new Point(ImageRect.Right - 15, ImageRect.Top);

                            using (Brush bBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                            {
                                g.FillRectangle(bBrush, new Rectangle(ImageRect.Right - 15, ImageRect.Top, 15, 15));
                            }
                            g.DrawString("D", ClientSettings.TextFont, sBrush, new Rectangle(ImageRect.Right - 10, ImageRect.Top, 10, 20));
                        }

                    }
                }


                textBounds.Offset(ClientSettings.Margin, 1);
                textBounds.Height--;

                BreakUpTheText(g, textBounds);
                int lineOffset = 0;

                if (!ClientSettings.UseClickables)
                {
                    g.DrawString(Tweet.DisplayText, ClientSettings.TextFont, ForeBrush, new RectangleF((float)textBounds.Left, (float)textBounds.Top, (float)textBounds.Width, (float)textBounds.Height));
                    //g.DrawString(Tweet.DisplayText, TextFont, ForeBrush, textBounds.Left, textBounds.Top, m_stringFormat);
                }
                else
                {

                    for (int i = 0; i < Tweet.SplitLines.Count; i++)
                    {
                        if (i >= ClientSettings.LinesOfText)
                        {
                            break;
                        }
                        float Position = ((lineOffset * (ClientSettings.TextSize)) + textBounds.Top);

                        g.DrawString(Tweet.SplitLines[i], ClientSettings.TextFont, ForeBrush, textBounds.Left, Position, m_stringFormat);
                        lineOffset++;
                    }
                    MakeClickable(g, textBounds);
                }
                ForeBrush.Dispose();
                g.Clip = new Region();
                this.Tweet.SplitLines = null;
            }
            catch (ObjectDisposedException)
            {
            }
            
            
        }
Example #15
0
        internal void DrawPlusMinus(Graphics g)
        {
            /*
            if(!IsInATreeListView) return;
            if(TreeListView._updating) return;
            Debug.Assert(!TreeListView.InvokeRequired);
            if(Items.Count == 0 || TreeListView.Columns.Count == 0) return;
            System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
            attr.SetColorKey(Color.Transparent, Color.Transparent);
            if(TreeListView.Columns[0].Width > (Level + 1) * SystemInformation.SmallIconSize.Width)
                g.DrawImage(
                    TreeListView.plusMinusImageList.Images[IsExpanded ? 1 : 0],
                    GetBounds(TreeListViewItemBoundsPortion.PlusMinus),
                    0, 0, SystemInformation.SmallIconSize.Width, SystemInformation.SmallIconSize.Height,
                    GraphicsUnit.Pixel, attr);
            attr.Dispose();
            */
            if (!IsInATreeListView)
                return;
            if (TreeListView._updating)
                return;
            Debug.Assert(!TreeListView.InvokeRequired);
            if (Items.Count == 0 || TreeListView.Columns.Count == 0)
                return;

            if (Application.RenderWithVisualStyles)
            {
                VisualStyleRenderer renderer;
                if (IsExpanded)
                    renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
                else
                    renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
                renderer.DrawBackground(g, GetBounds(TreeListViewItemBoundsPortion.PlusMinus));
            }
            else
            {
                using (System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes())
                {
                    attr.SetColorKey(Color.Transparent, Color.Transparent);
                    if (TreeListView.Columns[0].Width > (Level + 1) * SystemInformation.SmallIconSize.Width)
                    {
                        g.DrawImage(TreeListView.plusMinusImageList.Images[IsExpanded ? 1 : 0],
                        GetBounds(TreeListViewItemBoundsPortion.PlusMinus),
                        0,
                        0,
                        SystemInformation.SmallIconSize.Width,
                        SystemInformation.SmallIconSize.Height,
                        GraphicsUnit.Pixel,
                        attr);
                    }
                }
            }
        }
Example #16
0
        /// <summary>
        /// Draws the icon image at the specified location.
        /// </summary>
        /// <param name="graphics">The Graphics to draw on.</param>
        /// <param name="imgPanelIcon">icon image to draw.</param>
        /// <param name="imageRectangle">A rectangle structure that specifies the bounds of the linear gradient.</param>
        /// <param name="foreColorImage">The foreground color of this image</param>
        /// <param name="iconPositionY">The vertical position for the icon image</param>
        protected static void DrawIcon(Graphics graphics, Image imgPanelIcon, Rectangle imageRectangle, Color foreColorImage, int iconPositionY)
        {
            if (graphics == null)
            {
                throw new ArgumentException(
                    string.Format(
                    System.Globalization.CultureInfo.CurrentUICulture,
                    Resources.IDS_ArgumentException,
                    typeof(Graphics).Name));
            }
            if (imgPanelIcon == null)
            {
                throw new ArgumentException(
                    string.Format(
                    System.Globalization.CultureInfo.CurrentUICulture,
                    Resources.IDS_ArgumentException,
                    typeof(Image).Name));
            }

            int iconPositionX = imageRectangle.Left;
            int iconWidth = imgPanelIcon.Width;
            int iconHeight = imgPanelIcon.Height;

            Rectangle rectangleIcon = new Rectangle(
                iconPositionX + (iconWidth / 2) - 1,
                iconPositionY + (iconHeight / 2) - 1,
                imgPanelIcon.Width,
                imgPanelIcon.Height - 1);

            using (System.Drawing.Imaging.ImageAttributes imageAttribute = new System.Drawing.Imaging.ImageAttributes())
            {
                imageAttribute.SetColorKey(Color.Magenta, Color.Magenta);
                System.Drawing.Imaging.ColorMap colorMap = new System.Drawing.Imaging.ColorMap();
                colorMap.OldColor = Color.FromArgb(0, 60, 166);
                colorMap.NewColor = foreColorImage;
                imageAttribute.SetRemapTable(new System.Drawing.Imaging.ColorMap[] { colorMap });

                graphics.DrawImage(imgPanelIcon, rectangleIcon, 0, 0, iconWidth, iconHeight, GraphicsUnit.Pixel, imageAttribute);
            }
        }
Example #17
0
        internal void DrawPlusMinus(Graphics g)
        {
            /*
             *          if(!IsInATreeListView) return;
             *          if(TreeListView._updating) return;
             *          Debug.Assert(!TreeListView.InvokeRequired);
             *          if(Items.Count == 0 || TreeListView.Columns.Count == 0) return;
             *          System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
             *          attr.SetColorKey(Color.Transparent, Color.Transparent);
             *          if(TreeListView.Columns[0].Width > (Level + 1) * SystemInformation.SmallIconSize.Width)
             *                  g.DrawImage(
             *                          TreeListView.plusMinusImageList.Images[IsExpanded ? 1 : 0],
             *                          GetBounds(TreeListViewItemBoundsPortion.PlusMinus),
             *                          0, 0, SystemInformation.SmallIconSize.Width, SystemInformation.SmallIconSize.Height,
             *                          GraphicsUnit.Pixel, attr);
             *          attr.Dispose();
             */
            if (!IsInATreeListView)
            {
                return;
            }
            if (TreeListView._updating)
            {
                return;
            }
            Debug.Assert(!TreeListView.InvokeRequired);
            if (Items.Count == 0 || TreeListView.Columns.Count == 0)
            {
                return;
            }

            if (Application.RenderWithVisualStyles)
            {
                VisualStyleRenderer renderer;
                if (IsExpanded)
                {
                    renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
                }
                else
                {
                    renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
                }
                renderer.DrawBackground(g, GetBounds(TreeListViewItemBoundsPortion.PlusMinus));
            }
            else
            {
                using (System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes())
                {
                    attr.SetColorKey(Color.Transparent, Color.Transparent);
                    if (TreeListView.Columns[0].Width > (Level + 1) * SystemInformation.SmallIconSize.Width)
                    {
                        g.DrawImage(TreeListView.plusMinusImageList.Images[IsExpanded ? 1 : 0],
                                    GetBounds(TreeListViewItemBoundsPortion.PlusMinus),
                                    0,
                                    0,
                                    SystemInformation.SmallIconSize.Width,
                                    SystemInformation.SmallIconSize.Height,
                                    GraphicsUnit.Pixel,
                                    attr);
                    }
                }
            }
        }
Example #18
0
        public void GenerateKeyboard(KeyboardRotation rotation)
        {
            if (null != _previousInputImage)
            {
                _previousInputImage.Dispose();
            }
            _previousInputImage = null;
            _previousSize = this.Size;
            _rotation = (MobileRemoteUI.IsLandscape) ? KeyboardRotation.ROT_0 : rotation;
            Cursor.Current = Cursors.WaitCursor;

            double scaleFactor = (double)this.Width / 480;

            if (MobileRemoteUI.IsLandscape)
            {
                scaleFactor = (double)this.Width / 640;
            }

            if (null != _keyImage)
            {
                _keyImage.Dispose();
            }
            if (null != _keyShiftImage)
            {
                _keyShiftImage.Dispose();
            }
            for (int i = 0; i < _keys.Length; ++i)
            {
                if (null != _keys[i])
                {
                    for (int j = 0; j < _keys[i].Length; ++j)
                    {
                        if (null != _keys[i][j].DownImage)
                        {
                            _keys[i][j].DownImage.Dispose();
                            _keys[i][j].DownImage = null;
                        }
                        if (null != _keys[i][j].DownShiftImage)
                        {
                            _keys[i][j].DownShiftImage.Dispose();
                            _keys[i][j].DownShiftImage = null;
                        }
                    }
                }
            }

            _keyImage = new Bitmap(this.Width, this.Height, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);
            _keyShiftImage = new Bitmap(this.Width, this.Height, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);

            for (int index = 0; index < 2; ++index)
            {
                int scrnWidth = this.Width;
                int scrnHeight = this.Height;

                // TODO
                if (_rotation != 0)
                {
                    scrnWidth = this.Height;
                    scrnHeight = this.Width;
                }

                using (Bitmap bmp = new Bitmap(scrnWidth, scrnHeight))
                {
                    using (Graphics g = Graphics.FromImage(bmp))
                    {
                        using (SolidBrush fontBrush = new SolidBrush(Color.Black))
                        {
                            using (SolidBrush shiftBrush = new SolidBrush(Color.Gray))
                            {
                                using (SolidBrush whiteBrush = new SolidBrush(Color.White))
                                {
                                    g.FillRectangle(shiftBrush, 0, 0, bmp.Width, bmp.Height);
                                    _fullKeyHeight = bmp.Height / (_keys.Length);
                                    _keySpacing = Math.Max(2, (bmp.Height - (_fullKeyHeight * _keys.Length)) / _keys.Length);
                                    _keyHeight = _fullKeyHeight - _keySpacing;

                                    // TODO: we probably shouldn't hardcode 10 here
                                    _fullKeyWidth = bmp.Width / 10;
                                    _keyWidth = _fullKeyWidth - _keySpacing;

                                    _startY = _fullKeyHeight + (bmp.Height - _fullKeyHeight * (_keys.Length));
                                    _startX = (bmp.Width - (_fullKeyWidth * 10) + _keySpacing) / 2;
                                    _startY = (bmp.Height - (_fullKeyHeight * _keys.Length) + _keySpacing) / 2;

                                    int x = _startX, y = _startY;

                                    for (int i = 0; i < _keys.Length; ++i)
                                    {
                                        x = _startX;
                                        if (null != _keys[i])
                                        {
                                            for (int j = 0; j < _keys[i].Length; ++j)
                                            {
                                                if (_keys[i][j].IsHidden)
                                                {
                                                    continue;
                                                }
                                                Rectangle unRotatedBounds = new Rectangle(x, y, _keyWidth * _keys[i][j].KeyWidth + (_keys[i][j].KeyWidth - 1) * _keySpacing, _keyHeight);
                                                if (_keys[i][j].Type == KeyButtonType.Input)
                                                {
                                                    _inputRect = unRotatedBounds;
                                                }
                                                else
                                                {
                                                    g.DrawImage(_key, unRotatedBounds, new Rectangle(0, 0, _key.Width, _key.Height), GraphicsUnit.Pixel);

                                                    string key = (index == 0) ? _keys[i][j].Key : _keys[i][j].ShiftKey;
                                                    string shiftKey = (index == 0) ? _keys[i][j].ShiftKey : _keys[i][j].Key;

                                                    if (null != _keys[i][j].Icon)
                                                    {
                                                        int width = _keys[i][j].Icon.Width;
                                                        int height = _keys[i][j].Icon.Height;

                                                        int scaledWidth = (int)(width * scaleFactor);
                                                        int scaledHeight = (int)(height * scaleFactor);

                                                        System.Drawing.Imaging.ImageAttributes a = new System.Drawing.Imaging.ImageAttributes();
                                                        a.SetColorKey(_keys[i][j].Icon.GetPixel(0, 0), _keys[i][j].Icon.GetPixel(0, 0));
                                                        g.DrawImage(_keys[i][j].Icon, new Rectangle(x + (unRotatedBounds.Width - scaledWidth) / 2, y + (unRotatedBounds.Height - scaledHeight) / 2, scaledWidth, scaledHeight), 0, 0, width, height, GraphicsUnit.Pixel, a);
                                                    }
                                                    else
                                                    {
                                                        SizeF charSize = g.MeasureString(key, this.Font);
                                                        SizeF shiftCharSize = g.MeasureString(shiftKey, this.ShiftFont);

                                                        bool overlaps = false;

                                                        if ((y + _keyHeight - charSize.Height) < (y + shiftCharSize.Height))
                                                        {
                                                            overlaps = true;
                                                        }

                                                        if (shiftKey != key && !overlaps)
                                                        {
                                                            g.DrawString(key, this.Font, fontBrush, x + (_keyWidth * _keys[i][j].KeyWidth / 2) - charSize.Width / 2, y + _keyHeight - charSize.Height);
                                                            g.DrawString(shiftKey, this.ShiftFont, shiftBrush, x + (_keyWidth * _keys[i][j].KeyWidth / 2) - shiftCharSize.Width / 2, y);
                                                        }
                                                        else
                                                        {
                                                            g.DrawString(key, this.Font, fontBrush, x + (_keyWidth * _keys[i][j].KeyWidth / 2) - charSize.Width / 2, y + (_keyHeight - charSize.Height) / 2);
                                                        }
                                                    }

                                                    int startCol = x;
                                                    using (Bitmap buffer = new Bitmap(_keys[i][j].KeyWidth * _fullKeyWidth + 20, _fullKeyHeight + 20))
                                                    {
                                                        using (Graphics bufferG = Graphics.FromImage(buffer))
                                                        {
                                                            bufferG.Clear(Color.FromArgb(35, 68, 255));
                                                            bufferG.FillRectangle(whiteBrush, new Rectangle(4, 4, buffer.Width - 8, buffer.Height - 8));
                                                            if (null != _keys[i][j].Icon)
                                                            {
                                                                int width = _keys[i][j].Icon.Width;
                                                                int height = _keys[i][j].Icon.Height;

                                                                int scaledWidth = (int)(width * scaleFactor);
                                                                int scaledHeight = (int)(height * scaleFactor);

                                                                System.Drawing.Imaging.ImageAttributes a = new System.Drawing.Imaging.ImageAttributes();
                                                                a.SetColorKey(_keys[i][j].Icon.GetPixel(0, 0), _keys[i][j].Icon.GetPixel(0, 0));

                                                                bufferG.DrawImage(_keys[i][j].Icon, new Rectangle((buffer.Width - scaledWidth) / 2, (buffer.Height - scaledHeight) / 2, scaledWidth, scaledHeight), 0, 0, width, height, GraphicsUnit.Pixel, a);
                                                            }
                                                            else
                                                            {
                                                                SizeF downCharSize = bufferG.MeasureString(key, this.Font);
                                                                SizeF downShiftCharSize = bufferG.MeasureString(shiftKey, this.ShiftFont);

                                                                bufferG.DrawString(key, this.Font, fontBrush, 0 + (buffer.Width / 2) - downCharSize.Width / 2, (buffer.Height - downCharSize.Height) / 2);
                                                            }
                                                        }

                                                        if (index == 0)
                                                        {
                                                            // TODO
                                                            if (_rotation == 0)
                                                            {
                                                                _keys[i][j].DownImage = new Bitmap(buffer);
                                                            }
                                                            else
                                                            {
                                                                _keys[i][j].DownImage = new Bitmap(buffer.Height, buffer.Width);
                                                                Imaging.RotateImage((int)_rotation, buffer, _keys[i][j].DownImage);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (key == shiftKey)
                                                            {
                                                                _keys[i][j].DownShiftImage = _keys[i][j].DownImage;
                                                            }
                                                            else
                                                            {
                                                                // TODO
                                                                if (_rotation == 0)
                                                                {
                                                                    _keys[i][j].DownShiftImage = new Bitmap(buffer);
                                                                }
                                                                else
                                                                {
                                                                    _keys[i][j].DownShiftImage = new Bitmap(buffer.Height, buffer.Width);
                                                                    Imaging.RotateImage((int)_rotation, buffer, _keys[i][j].DownShiftImage);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                // sin 270 = -1
                                                // cos 270 = 0
                                                if (index == 0)
                                                {
                                                    // TODO
                                                    if (_rotation != 0)
                                                    {
                                                        if (_rotation == KeyboardRotation.ROT_270)
                                                        {
                                                            _keys[i][j].Bounds = new Rectangle(unRotatedBounds.Y, this.Height - unRotatedBounds.Right, unRotatedBounds.Height, unRotatedBounds.Width);
                                                        }
                                                        else
                                                        {
                                                            _keys[i][j].Bounds = new Rectangle(this.Width - unRotatedBounds.Bottom, unRotatedBounds.Left, unRotatedBounds.Height, unRotatedBounds.Width);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        _keys[i][j].Bounds = unRotatedBounds;
                                                    }
                                                }
                                                x += _keys[i][j].KeyWidth * _fullKeyWidth;
                                            }
                                        }
                                        x = _keySpacing;
                                        y += _fullKeyHeight;
                                    }
                                }
                            }
                        }
                        if (index == 0)
                        {
                            // TODO
                            if (_rotation == 0)
                            {
                                _keyImage = new Bitmap(bmp);
                            }
                            else
                            {
                                Imaging.RotateImage((int)_rotation, bmp, _keyImage);
                            }
                        }
                        else
                        {
                            // TODO
                            if (_rotation == 0)
                            {
                                _keyShiftImage = new Bitmap(bmp);
                            }
                            else
                            {
                                Imaging.RotateImage((int)_rotation, bmp, _keyShiftImage);
                            }
                        }
                    }
                }
            }
            _eraseRegion = this.Bounds;
            Cursor.Current = Cursors.Default;
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (null != _alphaControl && null != _alphaControl._alphaImage)
            {
                Rectangle destRect = this.ClientRectangle;
                Rectangle srcRect = this.RectangleToScreen(this.ClientRectangle);

                e.Graphics.DrawImage(_alphaControl._alphaImage, destRect, srcRect, GraphicsUnit.Pixel);
            }
            System.Drawing.Imaging.ImageAttributes a = new System.Drawing.Imaging.ImageAttributes();
            a.SetColorKey(this.TransparentColor, this.TransparentColor);
            e.Graphics.DrawImage(this.Image, new Rectangle(0, 0, this.Width, this.Height), 0, 0, this.Image.Width, this.Image.Height, GraphicsUnit.Pixel, a);
        }
Example #20
0
        public void RenderAvatarArea(Graphics g, Rectangle bounds)
        {
            var imageLocation = new Point(bounds.X + ClientSettings.Margin, bounds.Y + ClientSettings.Margin);
            if (ClientSettings.ShowAvatars)
            {
                string artURL = Tweet.user.profile_image_url;
                if (!ClientSettings.HighQualityAvatars)
                {
                    artURL = Tweet.user.profile_image_url;
                }
                try
                {
                    using (Image userImage = ThrottledArtGrabber.GetArt(artURL))
                    {
                        //g.DrawImage(UserImage, ImageLocation.X, ImageLocation.Y,);
                        g.DrawImage(userImage, new Rectangle(imageLocation.X, imageLocation.Y, ClientSettings.SmallArtSize, ClientSettings.SmallArtSize), new Rectangle(0, 0, userImage.Width, userImage.Height), GraphicsUnit.Pixel);

                    }
                }
                catch(Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }

                //Only occasionally is an item "starred", but we draw one on there if it is.
                if (_hasFavoriteStar)
                {
                    var ia = new System.Drawing.Imaging.ImageAttributes();
                    ia.SetColorKey(ThrottledArtGrabber.FavoriteImage.GetPixel(0, 0), ThrottledArtGrabber.FavoriteImage.GetPixel(0, 0));
                    g.DrawImage(ThrottledArtGrabber.FavoriteImage,
                                new Rectangle(bounds.X + 5, bounds.Y + 5, 7, 7), 0, 0, 7, 7, GraphicsUnit.Pixel, ia);
                }

                //If it's a reply or direct message, overlay that on the avatar
                string overlay;

                if ((Tweet.TypeofMessage & Library.StatusTypes.Reply) != 0)
                    overlay = "@";
                else if ((Tweet.TypeofMessage & Library.StatusTypes.Direct) != 0)
                    overlay = "D";
                else
                    overlay = String.Empty;

                if (overlay.Length != 0)
                {
                    using (Brush sBrush = new SolidBrush(ClientSettings.SelectedForeColor))
                    {

                        var imageRect = new Rectangle(imageLocation.X, imageLocation.Y, ClientSettings.SmallArtSize, ClientSettings.SmallArtSize);
                        SizeF overlaySize = g.MeasureString(overlay, ClientSettings.SmallFont);
                        using (Brush bBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                        {
                            g.FillRectangle(bBrush, new Rectangle(imageRect.Right - (int)overlaySize.Width - 2, imageRect.Top, (int)overlaySize.Width + 2, (int)overlaySize.Height + 2));
                        }
                        g.DrawString(overlay, ClientSettings.SmallFont, sBrush, new Rectangle(imageRect.Right - (int)overlaySize.Width + 1, imageRect.Top , (int)overlaySize.Width, (int)overlaySize.Height));
                    }
                }
            }
        }
Example #21
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            for (int y = 0; y < mapData.Length;  y++)
            {
                for (int x= 0; x< mapData[0].Length; x++)
                {
                    TilePiece mapPiece = mapData[y][x];

                    if (gridPoint.X == x && gridPoint.Y == y)
                    {
                        mapPiece = _selectedPiece;
                    }

                    Image drawPiece = tileImages[mapPiece];

                    System.Drawing.Imaging.ImageAttributes a = new System.Drawing.Imaging.ImageAttributes();
                    a.SetColorKey(Color.FromArgb(254, 254, 254), Color.White, System.Drawing.Imaging.ColorAdjustType.Bitmap);

                    e.Graphics.DrawImage(drawPiece, new Rectangle(x*80, y*80, 80, 80), 0, 0, drawPiece.Width, drawPiece.Height, GraphicsUnit.Pixel, a);

                    if (mapPiece == TilePiece.Start)
                    {
                        e.Graphics.DrawImage(car, new Rectangle(x * 80 + 40 - car.Width / 2, y * 80 + 40 - car.Height / 2, car.Width, car.Height));
                    }
                }
            }
        }