Пример #1
0
 public void draw(System.Drawing.Graphics g)
 {
     if (life == 3)
     {
         g.DrawImage(castle1, (x) - (castle1.Width / 2), (y) - (castle1.Height / 2), castle1.Width, castle2.Height);
     }
     if (life == 2)
     {
         g.DrawImage(castle2, (x) - (castle2.Width / 2), (y) - (castle2.Height / 2), castle1.Width, castle2.Height);
     }
     if (life == 1)
     {
         g.DrawImage(castle3, (x) - (castle3.Width / 2), (y) - (castle3.Height / 2), castle1.Width, castle2.Height);
     }
 }
Пример #2
0
        public void Draw(System.Drawing.Graphics graphics, System.Drawing.Rectangle destRect, System.Drawing.Rectangle sourceRect)
        {
            if (IsOpened)
            {
                using (Brush b= new SolidBrush(Color.Red))
                {

                    graphics.FillPolygon(b, new Point[]{
                        new Point(destRect.Left + (destRect.Width/2)+ClientSettings.Margin, destRect.Bottom-(ClientSettings.Margin*4)),
                        new Point(destRect.Left + (destRect.Width/2), destRect.Bottom),
                        new Point(destRect.Left + (destRect.Width/2)-ClientSettings.Margin, destRect.Bottom-(ClientSettings.Margin*4)),
                    });
                    using (Image userbmp = ThrottledArtGrabber.GetArt(this.userToDraw.profile_image_url))
                    {
                        graphics.DrawImage(userbmp, destRect.X, destRect.Y);
                    }
                }
            }
            else
            {
                TiledMaps.IGraphicsDrawable graphicsDrawable = ThrottledArtGrabber.mapMarkerImage as TiledMaps.IGraphicsDrawable;
                graphicsDrawable.Draw(graphics, destRect, sourceRect);
                Rectangle CharRect = new Rectangle(destRect.X + 7, destRect.Y+2, destRect.Width - 6, destRect.Height-2);
                if (charToUse >= 0)
                {
                    using (Font f = new Font(FontFamily.GenericSansSerif, fSize, FontStyle.Regular))
                    {
                        graphics.DrawString(charToUse.ToString(), f, B, CharRect);
                    }
                }
            }
            Location = destRect;
        }
Пример #3
0
 public void draw(System.Drawing.Graphics g)
 {
     if (active)
     {
         g.DrawImage(canonball, x - 7.5f, y - 7.5f, 15f, 15f);
     }
 }
Пример #4
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);

            foreach (var placement in Screen.Entities)
            {
                var entity = Screen.Stage.Project.EntityByName(placement.entity);

                if (entity != null)
                {
                    var sprite = entity.DefaultSprite;
                    if (sprite != null)
                    {
                        var frame = SpriteBitmapCache.GetOrLoadFrame(sprite.SheetPath.Absolute, sprite.CurrentFrame.SheetLocation);

                        var flip = (placement.direction == Common.Direction.Left) ^ sprite.Reversed;
                        int hx = flip ? sprite.Width - sprite.HotSpot.X : sprite.HotSpot.X;

                        dc.DrawImage(frame, new Rect(this.Zoom * (placement.screenX - hx), this.Zoom * (placement.screenY - sprite.HotSpot.Y), this.Zoom * frame.PixelWidth, this.Zoom * frame.PixelHeight));

                        continue;
                    }
                }

                dc.DrawEllipse(Brushes.Orange, null, new System.Windows.Point(this.Zoom * placement.screenX, this.Zoom * placement.screenY), 10 * Zoom, 10 * Zoom);
            }
        }
Пример #5
0
 public void draw(System.Drawing.Graphics g)
 {
     g.TranslateTransform(this.x, this.y);
     g.RotateTransform(rotation);
     g.DrawImage(canon, (0 - canon.Width / 2), (0 - canon.Height / 2), canon.Width, canon.Height);
     g.ResetTransform();
 }
Пример #6
0
        public void drawHisMatrix(System.Drawing.Graphics graphicsObj, char[,] hisMatrix)
        {
            tet_colors pieceColor = new tet_colors();
            Image _png;

            for (int row = 0; row < 20; row++)
                for (int column = 0; column < 10; column++)
                {
                    _png = Image.FromFile(colors.getPieceColor(hisMatrix[row, column]));
                    try
                    {
                        graphicsObj.DrawImage(_png, new Rectangle(680 + column * 30, 100 + row * 30, 30, 30));
                    }
                    catch
                    {
                        break;
                    }
                }

            //try
            //{
            //    myBrush.Color = Color.White;
            //    graphicsObj.FillRectangle(myBrush, new Rectangle(400, 90, 200, 80));

            //    myBrush.Color = Color.Black;
            //    graphicsObj.DrawString("Used shapes : " + blockLogic.usedShapesNr, new Font("Arial", 16), myBrush, new Point(400, 90));
            //    graphicsObj.DrawString("Cleared lines : " + blockLogic.clearedLines, new Font("Arial", 16), myBrush, new Point(400, 110));
            //    graphicsObj.DrawString("Score : " + blockLogic.myScore.getScore(), new Font("Arial", 16), myBrush, new Point(400, 130));
            //    graphicsObj.DrawString("Multiplier : " + blockLogic.myScore.getScoreMultiplier(), new Font("Arial", 16), myBrush, new Point(400, 150));
            //}
            //catch
            //{
            //    return;
            //}
        }
Пример #7
0
		/// <summary>
		/// Imprime o código de barras de uma mercadoria
		/// </summary>
		/// <param name="g">Gráfico de destino</param>
		/// <param name="obj">Mercadoria</param>
		public override void Print(System.Drawing.Graphics g, object obj)
		{
			Entidades.Mercadoria.Mercadoria mercadoria;
			string				 códigoBarras;

			mercadoria = (Entidades.Mercadoria.Mercadoria) obj;

			if (mercadoria != this.mercadoria)
			{
				this.mercadoria = mercadoria;

                códigoBarras = mercadoria.Codificar();

				if (_alterarTamanho)
				{
					geradorCódigoBarras.Tamanho = new Size(
						(int) Math.Round(hInch.Reverse(Location.Width) * g.DpiX),
						(int) Math.Round(hInch.Reverse(Location.Height) * g.DpiY));

					_alterarTamanho = false;
				}
			
				imagem = geradorCódigoBarras.GerarImagem(códigoBarras);
			}
			else if (imagem == null && DesignMode)
			{
				códigoBarras = "01234567";

				imagem = geradorCódigoBarras.GerarImagem(códigoBarras);
			}

			g.DrawImage(imagem, Location);
		}
Пример #8
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);

            if (Screen.Name == Screen.Stage.StartScreen)
            {
                var p = Screen.Stage.StartPoint;
                dc.DrawImage(StartIcon, new System.Windows.Rect(Zoom * (p.X - StartIcon.PixelWidth / 2), Zoom * (p.Y - StartIcon.PixelHeight / 2), Zoom * StartIcon.PixelWidth, Zoom * StartIcon.PixelHeight));
            }

            if (Screen.Stage.ContinuePoints.ContainsKey(Screen.Name))
            {
                var p = Screen.Stage.ContinuePoints[Screen.Name];
                dc.DrawImage(ContinueIcon, new System.Windows.Rect(Zoom * (p.X - ContinueIcon.PixelWidth / 2), Zoom * (p.Y - ContinueIcon.PixelHeight / 2), Zoom * ContinueIcon.PixelWidth, Zoom * ContinueIcon.PixelHeight));
            }
        }
Пример #9
0
 public override void Draw(System.Drawing.Graphics g, View view, World world, int x, int y, int up, int down, int left, int right)
 {
     base.Draw(g, view, world, x, y, up, down, left, right);
     if (up != this.id)
     {
         g.DrawImage(ImageManager.GetImage(this.cliffSide), x * Tile.size - view.GetX(), y * Tile.size - view.GetY());
     }
 }
Пример #10
0
 public override void draw(System.Drawing.Graphics g)
 {
     if (Active)
     {
         //Beveger seg rett før den blir tegnet
         YCoord += (float)velocity;
         g.DrawImage(enemyImage, (int)XCoord, (int)YCoord);
     }
 }
Пример #11
0
        public override void Draw(System.Drawing.Graphics g)
        {
            g.DrawString("LIVES", LivesFont, Brushes.White, Position);

            if (_numberOfLives > 0)
            {
                g.DrawImage(TheImage, Position.X + 100, Position.Y, TheImage.Width * 2 / 3, TheImage.Height * 2 / 3);
            }

            if (_numberOfLives > 1)
            {
                g.DrawImage(TheImage, Position.X + 104 + TheImage.Width * 2 / 3, Position.Y, TheImage.Width * 2 / 3, TheImage.Height * 2 / 3);
            }

            if (_numberOfLives > 2)
            {
                g.DrawImage(TheImage, Position.X + 108 + 2 * TheImage.Width * 2 / 3, Position.Y, TheImage.Width * 2 / 3, TheImage.Height * 2 / 3);
            }
        }
Пример #12
0
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     Rotary rotary = Visual as Rotary;
     if (rotary != null)
     {
         drawingContext.PushTransform(new RotateTransform(rotary.KnobRotation, _center.X, _center.Y));
         drawingContext.DrawImage(_image, _imageRect);
         drawingContext.Pop();
     }
 }
 /// <summary>
 /// Drawing content of alert window.
 /// </summary>
 /// <param name="dc">Graphics object of alert window.</param>
 /// <param name="title">Title of alert.</param>
 /// <param name="text">Text of alert.</param>
 /// <param name="icon">Icon of alert.</param>
 /// <param name="customImage">Custom image of alert.</param>
 public virtual void Draw(System.Drawing.Graphics dc, string title, string text, ToolTipIcon icon = ToolTipIcon.None, System.Drawing.Image customImage = null)
 {
     Rectangle titleRect = GetTitleRect(dc, title, text, icon, customImage);
     Rectangle bodyRect = GetBodyRect(dc, title, text, icon, customImage);
     Rectangle rect = GetRect(dc, titleRect, bodyRect, icon, customImage);
     Image img = GetIcon(icon, customImage);
     Draw(dc, title, text, rect, titleRect, bodyRect, img, GetIconSize(icon, customImage).Width);
     // drawing icon
     if (img != null)
         dc.DrawImage(img, new Point(Padding.Left + IconPadding.Left, rect.Height / 2 - (img.Height + IconPadding.Vertical) / 2));
 }
        /// <summary>
        /// Called to draw on screen
        /// </summary>
        /// <param name="drawingContext">The drawind context in which we can draw</param>
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            // only set the pallette once (dont do in constructor as causes odd errors if exception occurs)
            if (_pallette == null)
                _pallette = SetupFirePalette();

            _fireGenerator.UpdateFire();

            BitmapSource bs = BitmapSource.Create(_fireGenerator.Width, _fireGenerator.Height, DPI, DPI,
                PixelFormats.Indexed8, _pallette, _fireGenerator.FireData, _fireGenerator.Width);
            drawingContext.DrawImage(bs, new Rect(0, 0, this.DesiredSize.Width, this.DesiredSize.Height));
        }
        protected override void Paint( System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts )
        {
            base.Paint( graphics, clipBounds, cellBounds, rowIndex, elementState, null, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts & ~DataGridViewPaintParts.ContentForeground & ~DataGridViewPaintParts.SelectionBackground );

            if ( value != null )
            {
                Image image = (Image) value;
                RectangleF destRect = new RectangleF( cellBounds.Left, cellBounds.Top, 48, 48 );
                RectangleF srcRect = new RectangleF( -0.5f, -0.5f, image.Width, image.Height );
                graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                graphics.DrawImage( image, destRect, srcRect, GraphicsUnit.Pixel );
            }
        }
Пример #16
0
        public override void DrawImage(System.Drawing.Graphics g, int x, int y, int width, int height)
        {
            Point p = new Point(x , y );
            Point p1 = new Point(x + width, y );
            Point p2 = new Point(x, y + height);
            Point[] pt = { p, p1, p2 };

            Image image = Image.FromFile("wall2.jpg");
            g.DrawImage(image, pt);

            //HatchBrush br = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Black, Color.Gray);
            //g.DrawRectangle(Pens.Black, x, y, width, height);

            //g.FillRectangle(br, x, y, width, height);
        }
Пример #17
0
		public override void DrawItem(System.Drawing.Graphics graphics)
		{
			if (graphics == null) {
				throw new ArgumentNullException("graphics");
			}
			base.DrawItem(graphics);
			
			if (this.ScaleImageToSize) {
				graphics.DrawImageUnscaled(this.Image,this.StyleDecorator.DisplayRectangle);
			} else {

				graphics.DrawImage(this.Image,
				                   this.StyleDecorator.DisplayRectangle);
			}
		}
Пример #18
0
 public void draw(System.Drawing.Graphics g)
 {
     try
     {
         Image img = Properties.Resources.GameOver;
         foreach (TetrisForm t in game.tetrisForms)
         {
             t.draw(g);
         }
         g.DrawImage(img, new Point(50, 100));
     }
     catch (Exception e)
     {
         Debug.WriteLine("Poraka: " + e.Message);
     }
 }
Пример #19
0
        public override void Draw(System.Drawing.Graphics g)
        {
            if (_bitmapDataZ != null)
              {
            double kx = (double)_bitmapDataZ.Width / (DataX[DataX.Count - 1] - DataX[0]);
            double ky = (double)_bitmapDataZ.Height / (DataY[DataY.Count - 1] - DataY[0]);

            float x1 = (float)(kx * (_chart.AxisX.Min - DataX[0])); //(float)(0 + (DataX[DataX.GetLength(0) - 1] - DataX[0]) * (_bitmapDataZ.Width) / (_chart.AxisX.Max - _chart.AxisX.Min));
            float y1 = (float)(ky * (_chart.AxisY.Min - DataY[0])); //(float)(0 + (DataX[DataY.GetLength(0) - 1] - DataY[0]) * (_bitmapDataZ.Height) / (_chart.AxisY.Max - _chart.AxisY.Min));
            float x2 = (float)(kx * (_chart.AxisX.Max - DataX[0])); //(float)(0 + (DataX[DataY.GetLength(0) - 1] - DataX[0]) * (_bitmapDataZ.Width) / (_chart.AxisX.Max - _chart.AxisX.Min));
            float y2 = (float)(ky * (_chart.AxisY.Max - DataY[0])); //(float)(0 + (DataX[DataX.GetLength(0) - 1] - DataY[0]) * (_bitmapDataZ.Height) / (_chart.AxisY.Max - _chart.AxisY.Min));

            Rectangle dstRectangle = new Rectangle(_chart.GraphicRectangle.Left, _chart.GraphicRectangle.Bottom, _chart.GraphicRectangle.Width, -_chart.GraphicRectangle.Height);

            g.DrawImage(_bitmapDataZ, dstRectangle, x1, y1, x2 - x1, y2 - y1, GraphicsUnit.Pixel);
              }
        }
Пример #20
0
        /// <summary>
        /// 绘制方法
        /// </summary>
        /// <param name="g"></param>
        /// <param name="center"></param>
        /// <param name="zoom"></param>
        /// <param name="screen_size"></param>
        public override void Draw(System.Drawing.Graphics g, LatLngPoint center, int zoom, System.Drawing.Size screen_size)
        {
            Point p = MapHelper.GetScreenLocationByLatLng(Location, center, zoom, screen_size);  //屏幕坐标

            Bitmap b;
            if (_selected)
            {
                b = Properties.BMap.ico_blue_point_big;
            }
            else
            {
                b = Properties.BMap.ico_red_point_small;
            }
            g.DrawImage(b, new Rectangle(p.X - b.Width / 2, p.Y - b.Height, b.Width, b.Height));
            using (Font f = new Font("微软雅黑", 10, FontStyle.Bold))
            {
                g.DrawString(((Char)(Index + 65)).ToString(), f, Brushes.White, new PointF(_selected ? (p.X - 5) : (p.X - 6), _selected ? (p.Y - 30) : (p.Y - 26)));
            }
            _rect = new Rectangle(p.X - b.Width / 2, p.Y - b.Height, b.Width, b.Height);
        }
Пример #21
0
        internal static void RenderAlphaImage(
            System.Drawing.Graphics g, 
            Image image,
            Rectangle imageRect,
            float alpha)
        {
            using (ImageAttributes imageAttributes = new ImageAttributes())
            {
                ColorMap colorMap = new ColorMap();

                colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
                colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);

                ColorMap[] remapTable = { colorMap };

                imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);

                float[][] colorMatrixElements = {
                    new float[] {1.0f,  0.0f,  0.0f,  0.0f, 0.0f},
                    new float[] {0.0f,  1.0f,  0.0f,  0.0f, 0.0f},
                    new float[] {0.0f,  0.0f,  1.0f,  0.0f, 0.0f},
                    new float[] {0.0f,  0.0f,  0.0f,  alpha, 0.0f},
                    new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}};
                ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);

                imageAttributes.SetColorMatrix(
                    wmColorMatrix,
                    ColorMatrixFlag.Default,
                    ColorAdjustType.Bitmap);

                g.DrawImage(
                    image,
                    imageRect,
                    0,
                    0,
                    image.Width,
                    image.Height,
                    GraphicsUnit.Pixel,
                    imageAttributes);
            }
        }
        public void DrawDiscoverContentPane(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Windows.Forms.DrawItemState state, DiscoverPane pane, System.Drawing.Font font, bool rtl)
        {
            int num1 = 5;
            bounds.Inflate(-7, 0);
            Rectangle imgRect = Rectangle.Empty;
            Rectangle rectangle2 = bounds;
            if (rtl)
            {
                if (pane.LargeImage != null)
                {
                    imgRect = new Rectangle(bounds.Right - pane.LargeImage.Width, (bounds.Top
                        + (bounds.Height / 2)) - (pane.LargeImage.Height / 2), pane.LargeImage.Width,
                        pane.LargeImage.Height);
                    rectangle2.Width -= (pane.LargeImage.Width + num1);
                }
            }
            else if (pane.LargeImage != null)
            {
                imgRect = new Rectangle(bounds.Left, (bounds.Top + (bounds.Height / 2))
                    - (pane.LargeImage.Height / 2), pane.LargeImage.Width, pane.LargeImage.Height);
                rectangle2.X += (pane.LargeImage.Width + num1);
                rectangle2.Width -= (pane.LargeImage.Width + num1);
            }
            if (imgRect != Rectangle.Empty)
            {
                Image image1 = pane.LargeImage;
                if ((state & DrawItemState.Disabled) == DrawItemState.Disabled)
                {
                    graphics.DrawImage(image1, imgRect, 0, 0, image1.Width, image1.Height,
                        GraphicsUnit.Pixel, new System.Drawing.Imaging.ImageAttributes()); //TODO:ImageAttributes
                }
                else
                {
                    graphics.DrawImage(image1, imgRect);
                }
            }
            using (StringFormat strFormat = new StringFormat(StringFormat.GenericTypographic))
            {
                strFormat.Trimming = StringTrimming.EllipsisCharacter;
                strFormat.FormatFlags |= StringFormatFlags.NoWrap;
                strFormat.LineAlignment = StringAlignment.Center;
                strFormat.HotkeyPrefix = HotkeyPrefix.Show;
                if (rtl)
                {
                    strFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                }
                if ((state & DrawItemState.Disabled) == DrawItemState.Disabled)
                {
                    graphics.DrawString(pane.Text, font, SystemBrushes.ControlDark,
                        (RectangleF)rectangle2, strFormat);
                }
                else
                {
                    using (SolidBrush stringBrush = new SolidBrush(((state & DrawItemState.Selected) ==
                        DrawItemState.Selected) ? this.BorderColor : pane.ForeColor)) //TODO:this.BorderColor
                    {
                        graphics.DrawString(pane.Text, font, stringBrush, (RectangleF)rectangle2, strFormat);
                    }
                }
            }

        }
        public void DrawHeader(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, string text, System.Drawing.Font font, System.Drawing.Image image, bool rtl)
        {
            if ((bounds.Width > 0) && (bounds.Height > 0))
            {
                using (LinearGradientBrush lnBrush = new LinearGradientBrush(bounds,
                    this.HeaderBackgroundColor1,
                    this.HeaderBackgroundColor2, LinearGradientMode.Vertical))
                {
                    graphics.FillRectangle(lnBrush, bounds);
                }

                if (image != null)
                {
                    Rectangle imgBounds = bounds;
                    imgBounds.Y = (bounds.Top + (bounds.Height / 2)) - (image.Height / 2);
                    if (rtl)
                    {
                        imgBounds.X = imgBounds.Y - bounds.Y;
                    }
                    else
                    {
                        imgBounds.X = imgBounds.Right - (image.Width + (imgBounds.Y - bounds.Y));
                    }
                    imgBounds.Size = image.Size;
                    graphics.DrawImage(image, imgBounds);
                    if (rtl)
                    {
                        bounds.X += imgBounds.Right;
                        bounds.Width -= imgBounds.Right;
                    }
                    else
                    {
                        bounds.Width -= (bounds.Right - imgBounds.Left);
                    }
                }
                bounds.Height--;

                using (StringFormat strFormat = this.GetStringFormat(rtl))
                {
                    using (SolidBrush brush2 = new SolidBrush(this.HeaderTextColor))
                    {
                        graphics.DrawString(text, font, brush2, (RectangleF)bounds, strFormat);
                    }
                }
            }

        }
        public void DrawDiscoverFooterPane(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Windows.Forms.DrawItemState state, DiscoverPane pane, System.Drawing.Font font)
        {
            Rectangle imgBounds = new Rectangle((bounds.X + (bounds.Width / 2)) - 8,
                (bounds.Y + (bounds.Height / 2)) - 8, 0x10, 0x10);
            Image drawImage = (pane.SmallImage != null) ? pane.SmallImage : pane.LargeImage;

            if (drawImage != null)
            {
                if ((state & DrawItemState.Disabled) == DrawItemState.Disabled)
                {
                    graphics.DrawImage(drawImage, imgBounds, 0, 0, drawImage.Width, drawImage.Height, GraphicsUnit.Pixel,
                        new System.Drawing.Imaging.ImageAttributes());//TODO: ImageAttributes
                }
                else
                {
                    graphics.DrawImage(drawImage, imgBounds);
                }
            }

        }
Пример #25
0
        //public void HandleMouseDown(object sender, MouseEventArgs e)
        //        public void MouseDown(MouseEventArgs e)
        //        {
        //            try
        //            {
        //                object valueCell;
        //                DataGrid dg = this.DataGridTableStyle.DataGrid;
        //                DataGrid.HitTestInfo hti = dg.HitTest(new Point(e.X, e.Y));
        //                bool isClickInCell = ( hti.Row > -1 && hti.Column > -1 && this.DataGridTableStyle.GridColumnStyles[hti.Column ].MappingName == this.MappingName);
        //                if(isClickInCell)
        //                {
        //                    DataTable dtSource = this.DataGridTableStyle.DataGrid.DataSource as DataTable;
        //                    valueCell = dtSource.Rows[hti.Row][hti.Column] == this.FalseValue?this.TrueValue : this.FalseValue ;
        //                    dtSource.Rows[hti.Row][hti.Column] = valueCell;
        //                    dtSource.AcceptChanges();
        //                    if(_arrGroupColumn != null)
        //                    {
        //                        foreach(string MappingNameGr in _arrGroupColumn)
        //                        {
        //                            dtSource.Rows[hti.Row][MappingNameGr] = valueCell == this.FalseValue? ((DataGridRadioColumn)this.DataGridTableStyle.GridColumnStyles[MappingNameGr]).TrueValue : ((DataGridRadioColumn)this.DataGridTableStyle.GridColumnStyles[MappingNameGr]).FalseValue ;
        //                        }
        //                    }
        //                    dtSource.AcceptChanges();
        //                    dg.Refresh();
        //                }
        //            }
        //            catch(Exception ex)
        //            {
        //                MessageBox.Show("DataGridRadioColumn:HandleMouseDown ->" + ex.Message);
        //            }
        //            
        //        }
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
        {
            base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
            try
            {
                Bitmap bm = this._RadioNoChecked;
                object gridSource = this.DataGridTableStyle.DataGrid.DataSource ;
                if(gridSource == null  )
                {}
                else if(gridSource.GetType().Name.Equals("DataTable"))
                {
                    bm = (gridSource as DataTable).Rows[rowNum][this.MappingName].ToString() == this.FalseValue.ToString() ? this._RadioNoChecked : this._RadioChecked ;

                }
                else if(gridSource.GetType().Name.Equals("DataView"))
                {
                    bm = (gridSource as DataView).Table.Rows[rowNum][this.MappingName].ToString() == this.FalseValue.ToString() ? this._RadioNoChecked : this._RadioChecked ;
                }
                g.DrawImage(bm, bounds, 0, 0, bm.Width, bm.Height,GraphicsUnit.Pixel);
            }
            catch(Exception ex)
            {
                MessageBox.Show("DataGridRadioColumn:Paint ->" + ex.Message);
            }
        }
Пример #26
0
 protected virtual void OnDraw(System.Windows.Media.DrawingContext g)
 {
     // Default implementation
     if(Image != null) {
         g.DrawImage(Image, new Rect(0, 0, BaseWidth, BaseHeight));
     }
 }
Пример #27
0
 protected override void OnDraw(System.Windows.Media.DrawingContext g)
 {
     base.OnDraw(g);
     g.DrawImage(Image, new System.Windows.Rect(0, 0, BaseWidth, BaseHeight));
 }
Пример #28
0
		/// <summary>This method will paint the group title.</summary>
		/// <param name="g">The paint event graphics object.</param>
		private void PaintGroupText(System.Drawing.Graphics g)
		{
			//Check if string has something-------------
			if(this.GroupTitle==string.Empty){return;}
			//------------------------------------------

			//Set Graphics smoothing mode to Anit-Alias-- 
			g.SmoothingMode = SmoothingMode.AntiAlias;
			//-------------------------------------------

			//Declare Variables------------------
			SizeF StringSize = g.MeasureString(this.GroupTitle, this.Font);
			Size StringSize2 = StringSize.ToSize();
			if(this.GroupImage!=null){StringSize2.Width+=18;}
			int ArcWidth = this.RoundCorners;
			int ArcHeight = this.RoundCorners;
			int ArcX1 = 20;
			int ArcX2 = (StringSize2.Width+34) - (ArcWidth + 1);
			int ArcY1 = 0;
			int ArcY2 = 24 - (ArcHeight + 1);
			System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
			System.Drawing.Brush BorderBrush = new SolidBrush(this.BorderColor);
			System.Drawing.Pen BorderPen = new Pen(BorderBrush, this.BorderThickness);
			System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
			System.Drawing.Brush BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
			System.Drawing.SolidBrush TextColorBrush = new SolidBrush(this.ForeColor);
			System.Drawing.SolidBrush ShadowBrush = null;
			System.Drawing.Drawing2D.GraphicsPath ShadowPath  = null;
			//-----------------------------------

			//Check if shadow is needed----------
			if(this.ShadowControl)
			{
				ShadowBrush = new SolidBrush(this.ShadowColor);
				ShadowPath = new System.Drawing.Drawing2D.GraphicsPath();
				ShadowPath.AddArc(ArcX1+(this.ShadowThickness-1), ArcY1+(this.ShadowThickness-1), ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 90, Tools.GroupBoxConstants.SweepAngle); //Bottom Left
				ShadowPath.CloseAllFigures();

				//Paint Rounded Rectangle------------
				g.FillPath(ShadowBrush, ShadowPath);
				//-----------------------------------
			}
			//-----------------------------------

			//Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, Tools.GroupBoxConstants.SweepAngle); //Bottom Left
			path.CloseAllFigures(); 
			//-----------------------------------

			//Check if Gradient Mode is enabled--
			if(this.PaintGroupBox)
			{
				//Paint Rounded Rectangle------------
				g.FillPath(BackgroundBrush, path);
				//-----------------------------------
			}
			else
			{
				if(this.BackgroundGradientMode==GroupBoxGradientMode.None)
				{
					//Paint Rounded Rectangle------------
					g.FillPath(BackgroundBrush, path);
					//-----------------------------------
				}
				else
				{
					BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0,0,this.Width,this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);
				
					//Paint Rounded Rectangle------------
					g.FillPath(BackgroundGradientBrush, path);
					//-----------------------------------
				}
			}
			//-----------------------------------

			//Paint Borded-----------------------
			g.DrawPath(BorderPen, path);
			//-----------------------------------

			//Paint Text-------------------------
			int CustomStringWidth = (this.GroupImage!=null) ? 44 : 28;
			g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth, 5);
			//-----------------------------------

			//Draw GroupImage if there is one----
			if(this.GroupImage!=null)
			{
				g.DrawImage(this.GroupImage, 28,4, 16, 16);
			}
			//-----------------------------------

			//Destroy Graphic Objects------------
			if(path!=null){path.Dispose();}
			if(BorderBrush!=null){BorderBrush.Dispose();}
			if(BorderPen!=null){BorderPen.Dispose();}
			if(BackgroundGradientBrush!=null){BackgroundGradientBrush.Dispose();}
			if(BackgroundBrush!=null){BackgroundBrush.Dispose();}
			if(TextColorBrush!=null){TextColorBrush .Dispose();}
			if(ShadowBrush!=null){ShadowBrush.Dispose();}
			if(ShadowPath!=null){ShadowPath.Dispose();}
			//-----------------------------------
		}
Пример #29
0
 public void Present(System.Drawing.Graphics g)
 {
     if(null != g)
         g.DrawImage(m_backBuffer, 0, 0);
 }
Пример #30
0
        public override void Render(System.Drawing.Graphics g, Map map)
        {
            SharpMap.Web.Wms.Client.WmsOnlineResource resource = GetPreferredMethod();
            Uri myUri = new Uri(GetRequestUrl(map.Envelope, map.Size));
            System.Net.WebRequest myWebRequest = System.Net.WebRequest.Create(myUri);
            myWebRequest.Method = resource.Type;
            myWebRequest.Timeout = _TimeOut;
            if (_Credentials != null)
                myWebRequest.Credentials = _Credentials;
            else
                myWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;

            if (_Proxy != null)
                myWebRequest.Proxy = _Proxy;

            try
            {
                System.Net.HttpWebResponse myWebResponse = (System.Net.HttpWebResponse)myWebRequest.GetResponse();
                System.IO.Stream dataStream = myWebResponse.GetResponseStream();

                if (myWebResponse.ContentType.StartsWith("image"))
                {
                    System.Drawing.Image img = System.Drawing.Image.FromStream(myWebResponse.GetResponseStream());
                    if (_ImageAttributes != null)
                        g.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height), 0, 0,
                           img.Width, img.Height, GraphicsUnit.Pixel, this.ImageAttributes);
                    else
                        g.DrawImageUnscaled(img, 0, 0, map.Size.Width, map.Size.Height);
                }
                dataStream.Close();
                myWebResponse.Close();
            }
            catch (System.Net.WebException webEx)
            {
                if (!_ContinueOnError)
                    throw (new SharpMap.Rendering.Exceptions.RenderException("There was a problem connecting to the WMS server when rendering layer '" + this.LayerName + "'", webEx));
                else
                    //Write out a trace warning instead of throwing an error to help debugging WMS problems
                    System.Diagnostics.Trace.Write("There was a problem connecting to the WMS server when rendering layer '" + this.LayerName + "': " + webEx.Message);
            }
            catch (System.Exception ex)
            {
                if (!_ContinueOnError)
                    throw (new SharpMap.Rendering.Exceptions.RenderException("There was a problem rendering layer '" + this.LayerName + "'", ex));
                else
                    //Write out a trace warning instead of throwing an error to help debugging WMS problems
                    System.Diagnostics.Trace.Write("There was a problem connecting to the WMS server when rendering layer '" + this.LayerName + "': " + ex.Message);
            }
            base.Render(g, map);
        }