Exemple #1
0
 public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e)
 {
     using (System.Drawing.Brush br = new System.Drawing.SolidBrush(System.Drawing.Color.FromName(e.Value.ToString())))
     {
         e.Graphics.FillRectangle(br, e.Bounds);
     }
 }
Exemple #2
0
    private void PaintCell(object sender, MouseEventArgs e)
    {
        // Use the HitTest method to get a HitTestInfo object.
        DataGrid.HitTestInfo hi;
        DataGrid             grid = (DataGrid)sender;

        hi = grid.HitTest(e.X, e.Y);
        // Test if the clicked area was a cell.
        if (hi.Type == DataGrid.HitTestType.Cell)
        {
            // If it's a cell, get the GridTable and ListManager of the
            // clicked table.
            DataGridTableStyle dgt = dataGrid1.TableStyles[0];
            CurrencyManager    cm  = (CurrencyManager)this.BindingContext[myDataSet.Tables[dgt.MappingName]];
            // Get the Rectangle of the clicked cell.
            Rectangle cellRect;
            cellRect = grid.GetCellBounds(hi.Row, hi.Column);
            // Get the clicked DataGridTextBoxColumn.
            MyGridColumn gridCol = (MyGridColumn)dgt.GridColumnStyles[hi.Column];
            // Get the Graphics object for the form.
            Graphics g = dataGrid1.CreateGraphics();
            // Create two new Brush objects, a fore brush, and back brush.
            Brush fBrush = new System.Drawing.SolidBrush(Color.Blue);
            Brush bBrush = new System.Drawing.SolidBrush(Color.Yellow);
            // Invoke the Paint method to paint the cell with the brushes.
            gridCol.PaintCol(g, cellRect, cm, hi.Row, bBrush, fBrush, false);
        }
    }
Exemple #3
0
        // prekresli sa vrchol
        private void repaintNodes(KDNode n)
        {
            System.Drawing.Font font = new System.Drawing.Font("Verdana", 10);
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black);

            if (n.highlight)
            {
                myBrush.Color = System.Drawing.Color.Green;
                myPen.Color = System.Drawing.Color.Green;
            }

            if (n.highlightRed)
            {
                myBrush.Color = System.Drawing.Color.Red;
                myPen.Color = System.Drawing.Color.Red;
            }
            if (n.highligthIn)
            {
                myBrush.Color = System.Drawing.Color.Red;
                myPen.Color = System.Drawing.Color.Red;
                g.DrawEllipse(myPen, n.getPoint().X - (RADIUS + 2), n.getPoint().Y - (RADIUS + 2), 2 * (RADIUS + 2), 2 * (RADIUS + 2));
                myPen.Color = System.Drawing.Color.Black;
            }

            g.FillEllipse(myBrush, n.getPoint().X - RADIUS, n.getPoint().Y - RADIUS, 2*RADIUS, 2*RADIUS);

            string s = "(" + n.getPoint().X.ToString() + "," + n.getPoint().Y.ToString() + ")";
            g.DrawString(s, font, myBrush, n.getPoint().X - 35, n.getPoint().Y);
        }
        public override void PaintValue(PaintValueEventArgs e)
        {
            if (e.Value is Color && ((Color)e.Value).A <= byte.MaxValue)
            {
                Color xnacolor = (Color)e.Value;
                System.Drawing.Color syscolor = System.Drawing.Color.FromArgb(xnacolor.A, xnacolor.R, xnacolor.G, xnacolor.B);

                int oneThird = e.Bounds.Width / 3;
                using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.DarkGray))
                {
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, 4, 4));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 9, e.Bounds.Y + 1, 4, 4));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 17, e.Bounds.Y + 1, 2, 4));

                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 5, e.Bounds.Y + 5, 4, 4));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 13, e.Bounds.Y + 5, 4, 4));

                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 1, e.Bounds.Y + 9, 4, 3));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 9, e.Bounds.Y + 9, 4, 3));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 17, e.Bounds.Y + 9, 2, 3));

                }
                using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(syscolor))
                {
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1));
                }
            }

            if (e.Value is System.Drawing.Color)
            {
                base.PaintValue(e);
            }
        }
        void m_printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            SelectedMealCollection colData = (SelectedMealCollection)this.FindResource("SelectedMealCollectionData");
            float leftMargin = e.MarginBounds.Left;
            float rightMargin = e.MarginBounds.Right;
            float topMargin = e.MarginBounds.Top;
          
            float yPos = leftMargin;
            float xPos = 0;
            float centrePos = 2 * (rightMargin - leftMargin) / 5;
            float rightPos =  4 * (rightMargin - leftMargin) / 5;
            int count = 0;

            System.Drawing.Font printFont = new System.Drawing.Font("Arial", 10);
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            // Work out the number of lines per page, using the MarginBounds.
            float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
            float lineCount = 0;
            foreach (var selectedMeal in colData)
            {
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Date, printFont, myBrush, xPos, yPos);
                lineCount++;
   
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Meal, printFont, myBrush, xPos + 20, yPos);

                lineCount++;

                if (lineCount > linesPerPage) { break; }
            }

            lineCount = 0;
            count = 0;

            SelectedIngredientsCollection ingredientData = (SelectedIngredientsCollection)this.FindResource("SelectedIngredientsCollectionData");

            foreach (SelectedIngredient ingredient in ingredientData)
            {               
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                xPos = centrePos;
                if (lineCount > linesPerPage) xPos = rightPos;
                e.Graphics.DrawString(ingredient.Ingredient, printFont, myBrush, xPos, yPos);
                lineCount++;
            }

            // If there are more lines, print another page.
            if (lineCount > linesPerPage)
            {
           //     e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                myBrush.Dispose();
            }
        }
Exemple #6
0
        public void DrawString(System.Drawing.Graphics g, System.Drawing.PointF pt, String _label)
        {
            // Save the GraphicsState.
            System.Drawing.Drawing2D.GraphicsState gs = g.Save();

            // Set the PageUnit to Inch because all of our measurements are in inches.
            g.PageUnit = System.Drawing.GraphicsUnit.Inch;

            // Set the PageScale to 1, so an inch will represent a true inch.
            g.PageScale = 1;


            System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            float xPosition = pt.X;
            float xStart    = pt.X;
            float yStart    = pt.Y;


            System.Drawing.Font font = new System.Drawing.Font("Arial", 10);



            float yPosition = yStart;

            // Draw Product Type.
            g.DrawString(_label, font, brush, new System.Drawing.PointF(xPosition, yPosition));

            // Restore the GraphicsState.
            g.Restore(gs);
        }
 public Graph(float x, float y, float width, float height, System.Drawing.Color backcolor) : base()
 {
     try
     {
         XPos       = x;
         YPos       = y;
         Width      = width;
         Height     = height;
         YMin       = 0;
         YMax       = 1000D;
         ShowMinMax = true;
         IsCurrency = false;
         BackColor  = backcolor;
         GridColor  = System.Drawing.Color.White;
         Brush      = System.Drawing.Brushes.Black;
         TextBrush  = System.Drawing.Brushes.Black;
         Pen        = new System.Drawing.Pen(System.Drawing.Brushes.Black);
         SolidBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
         Disposed   = false;
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
        //-------------------------------


        internal MyGdiPlusCanvas(
            int horizontalPageNum,
            int verticalPageNum,
            int left, int top,
            int width,
            int height)
        {


#if DEBUG
            debug_canvas_id = dbug_canvasCount + 1;
            dbug_canvasCount += 1;
#endif

            this.pageNumFlags = (horizontalPageNum << 8) | verticalPageNum;
            //2. dimension
            this.left = left;
            this.top = top;
            this.right = left + width;
            this.bottom = top + height;
            currentClipRect = new System.Drawing.Rectangle(0, 0, width, height);

            CreateGraphicsFromNativeHdc(width, height);
            this.gx = System.Drawing.Graphics.FromHdc(win32MemDc.DC);
            //-------------------------------------------------------     
            //managed object
            internalPen = new System.Drawing.Pen(System.Drawing.Color.Black);
            internalSolidBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            this.StrokeWidth = 1;
        }
 public FilepathHighlightTextRenderer(FilepathTextMatchFilter filter)
     : base(filter)
 {
     CornerRoundness = 0;
     FillBrush       = new System.Drawing.SolidBrush(System.Drawing.Color.Goldenrod);
     FramePen        = null;
 }
        public void CreateImage(string str_ValidateCode)
        {
            int    int_ImageWidth = str_ValidateCode.Length * 14;
            Random newRandom      = new Random();

            System.Drawing.Bitmap   theBitmap   = new System.Drawing.Bitmap(int_ImageWidth, 20);
            System.Drawing.Graphics theGraphics = System.Drawing.Graphics.FromImage(theBitmap);
            theGraphics.Clear(System.Drawing.Color.White);
            theGraphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.Color.LightGray, 1), 0, 0, int_ImageWidth - 1, 19);
            System.Drawing.Font theFont = new System.Drawing.Font("Arial", 10);
            for (int int_index = 0; int_index < str_ValidateCode.Length; int_index++)
            {
                string str_char = str_ValidateCode.Substring(int_index, 1);
                System.Drawing.Brush newBrush = new System.Drawing.SolidBrush(GetRandomColor());
                System.Drawing.Point thePos   = new System.Drawing.Point(int_index * 13 + 1 + newRandom.Next(3), 1 + newRandom.Next(3));
                theGraphics.DrawString(str_char, theFont, newBrush, thePos);
            }
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            theBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            Response.ClearContent();
            Response.ContentType = "image/Png";
            Response.BinaryWrite(ms.ToArray());
            theGraphics.Dispose();
            theBitmap.Dispose();
            Response.End();
        }
        protected override void OnPaint(PaintEventArgs pevent)
        {
            int XAlign = 0, YAlign = 1;

            if (Text == "π")
            {
                YAlign = 4; XAlign = -1;
            }
            else if (Text == "e")
            {
                YAlign = 2; XAlign = -1;
            }
            else if (Text == "()")
            {
                YAlign = 3;
            }
            if (Enabled || !DarkTheme)
            {
                base.OnPaint(pevent);
            }
            else
            {
                base.OnPaint(pevent);
                System.Drawing.SizeF sf       = pevent.Graphics.MeasureString(Text, this.Font, this.Width);
                System.Drawing.Point ThePoint = new System.Drawing.Point();
                ThePoint.X = (int)((this.Width / 2) - (sf.Width / 2)) + XAlign;
                ThePoint.Y = (int)((this.Height / 2) - (sf.Height / 2)) + YAlign;
                System.Drawing.Brush BR = new System.Drawing.SolidBrush(DisableTextColor);
                System.Drawing.Font  F  = new System.Drawing.Font(this.Font.FontFamily, this.Font.Size);
                pevent.Graphics.DrawString(Text, F, BR, ThePoint);
            }
        }
		public FilepathHighlightTextRenderer(FilepathTextMatchFilter filter)
			: base(filter) {

			CornerRoundness = 0;
			FillBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Goldenrod);
			FramePen = null;
		}
        public override void PaintValue(PaintValueEventArgs e)
        {
            if (e.Value is Color && ((Color)e.Value).A <= byte.MaxValue)
            {
                Color xnacolor = (Color)e.Value;
                System.Drawing.Color syscolor = System.Drawing.Color.FromArgb(xnacolor.A, xnacolor.R, xnacolor.G, xnacolor.B);

                int oneThird = e.Bounds.Width / 3;
                using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.DarkGray))
                {
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, 4, 4));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 9, e.Bounds.Y + 1, 4, 4));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 17, e.Bounds.Y + 1, 2, 4));

                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 5, e.Bounds.Y + 5, 4, 4));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 13, e.Bounds.Y + 5, 4, 4));

                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 1, e.Bounds.Y + 9, 4, 3));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 9, e.Bounds.Y + 9, 4, 3));
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 17, e.Bounds.Y + 9, 2, 3));
                }
                using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(syscolor))
                {
                    e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1));
                }
            }

            if (e.Value is System.Drawing.Color)
            {
                base.PaintValue(e);
            }
        }
Exemple #14
0
 public Disc(int value)
 {
     Value = value;
     System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(rnd.Next(1, 255), rnd.Next(1, 255), rnd.Next(1, 255)));
     System.Drawing.Graphics formGraphics = this.CreateGraphics();
     formGraphics.FillRectangle(myBrush, new Rectangle(11 + (i * 10), 250 - (i * 20), 212 - (i * 20), 20));
 }
Exemple #15
0
        /// <summary>
        /// Draw round rectangle
        /// </summary>
        /// <param name="roundRectangle"></param>
        /// <returns></returns>
        private string DrawRoundRectangle(DocumentFormat.OpenXml.Vml.RoundRectangle roundRectangle)
        {
            string fileName   = Path.Combine(imageDirectory, roundRectangle.GetAttributes().Where(x => x.LocalName == "id").FirstOrDefault().Value + ".jpg");
            string style      = roundRectangle.GetAttributes().Where(x => x.LocalName == "style").FirstOrDefault().Value;
            string position   = GetValueOfProperty("position", style);
            int    marginLeft = ConvertPointToPixel(GetValueOfProperty("margin-left", style));
            int    marginTop  = ConvertPointToPixel(GetValueOfProperty("margin-top", style));
            int    width      = ConvertPointToPixel(GetValueOfProperty("width", style));
            int    height     = ConvertPointToPixel(GetValueOfProperty("height", style));

            System.Drawing.Bitmap newBmp = new System.Drawing.Bitmap(width, height);

            using (System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(newBmp))
            {
                System.Drawing.Pen pen = new System.Drawing.Pen(ConvertToColor(roundRectangle.StrokeColor.Value), ConvertPointToPixel(roundRectangle.StrokeWeight.Value));
                pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
                System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(ConvertToColor(roundRectangle.FillColor.Value));
                System.Drawing.Rectangle  rectangle  = new System.Drawing.Rectangle(0, 0, width, height);
                graphic.FillRectangle(solidBrush, rectangle);
                graphic.DrawRectangle(pen, rectangle);
            }
            newBmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);

            return(string.Format("<span style='position:{0};margin-left:{1}px;margin-top:{2}px;width:{3}px;height:{4}px'><img width=\"{3}\" height=\"{4}\" alt=\"{5}\" src=\"{6}\"/>",
                                 position, marginLeft, marginTop, width, height, Path.GetFileName(fileName), Util.GetRelativePath(fileName)));
        }
Exemple #16
0
        private void ActionComboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            var option = actionComboBoxOptions.ElementAtOrDefault(e.Index);

            if (option.Value != null)
            {
                using (var b = new System.Drawing.SolidBrush(option.Value.Value.ToSystemDrawingObject()))
                {
                    e.Graphics.FillRectangle(b, e.Bounds);
                }
                if ((e.State & DrawItemState.Selected) != 0)
                {
                    var r = e.Bounds;
                    r.Width = 3;
                    e.Graphics.FillRectangle(System.Drawing.Brushes.Blue, r);
                    r.X = e.Bounds.Right - r.Width;
                    e.Graphics.FillRectangle(System.Drawing.Brushes.Blue, r);
                }
                e.Graphics.DrawString(option.Key, e.Font, System.Drawing.Brushes.Black, e.Bounds);
            }
            else
            {
                e.DrawBackground();
                using (var b = new System.Drawing.SolidBrush(e.ForeColor))
                    e.Graphics.DrawString(option.Key ?? "", e.Font, b, e.Bounds);
            }
        }
Exemple #17
0
        public void AddTextWatermark(string strOraginalPath)
        {
            if (string.IsNullOrEmpty(_strWatermarkText))//如果水印文字为空
            {
                return;
            }

            System.Drawing.Image imgOraginal = System.Drawing.Image.FromFile(strOraginalPath);
            int iWidth  = imgOraginal.Width;
            int iHeight = imgOraginal.Height;

            System.Drawing.Bitmap bitOraginal = new System.Drawing.Bitmap(imgOraginal, iWidth, iHeight);
            imgOraginal.Dispose();

            System.Drawing.Graphics gOraginal = System.Drawing.Graphics.FromImage(bitOraginal);

            System.Drawing.Rectangle    rectTextField = new System.Drawing.Rectangle(10, 10, iWidth - 20, iHeight - 20);
            System.Drawing.StringFormat sf            = GetStringFormat();

            System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(_btWatermarkTransparency /*文字的透明度*/, _fontWatermarkColor));
            gOraginal.DrawString(_strWatermarkText, _fontWatermarkFont, brush, rectTextField, sf);

            sf.Dispose();
            brush.Dispose();

            bitOraginal.Save(strOraginalPath, System.Drawing.Imaging.ImageFormat.Jpeg);

            gOraginal.Dispose();
            bitOraginal.Dispose();
        }
Exemple #18
0
        // Call to paint the grid itself
        public void Paint(System.Windows.Forms.PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            System.Drawing.Pen      p = new System.Drawing.Pen(System.Drawing.Color.Black, 1); // outline
            System.Drawing.Brush    b;

            // draw the filled-in grid
            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    b = new System.Drawing.SolidBrush(grid[x, y].Color);
                    System.Drawing.Rectangle rect =
                        new System.Drawing.Rectangle(grid[x, y].X + this.shift_x, grid[x, y].Y + this.shift_y,
                                                     scale, scale);

                    g.FillRectangle(b, rect);
                    g.DrawRectangle(p, rect);
                }
            }

            if (game_end)
            {
                foreach (GridBlock gb in this.overflow)
                {
                    b = new System.Drawing.SolidBrush(gb.Color);
                    System.Drawing.Rectangle rect =
                        new System.Drawing.Rectangle(gb.X + this.shift_x, gb.Y + this.shift_y,
                                                     scale, scale);

                    g.FillRectangle(b, rect);
                    g.DrawRectangle(p, rect);
                }
            }
            else
            {
                Tetromino f = this.minos.First();
                b = new System.Drawing.SolidBrush(f.Color);
                foreach (System.Drawing.Rectangle r in f.GetRectangles(this.shift_x, this.shift_y))
                {
                    g.FillRectangle(b, r);
                    g.DrawRectangle(p, r);
                }
            }

            int x_shift = this.shift_x + 12 * this.scale;
            int y_shift = this.shift_y + 3 * this.scale;

            for (int i = 1; i < 4; i++)
            {
                Tetromino t = this.minos.ElementAt(i);
                b = new System.Drawing.SolidBrush(t.Color);
                foreach (System.Drawing.Rectangle r in t.GetRectangles(x_shift, y_shift))
                {
                    g.FillRectangle(b, r);
                    g.DrawRectangle(p, r);
                }
                y_shift += 5 * this.scale;
            }
        }
 protected override void OnPaint(PaintEventArgs e)
 {
     using (System.Drawing.SolidBrush BackGroundBrush = new System.Drawing.SolidBrush(System.Drawing.SystemColors.Window))
         using (System.Drawing.SolidBrush ForeGroundBrush = new System.Drawing.SolidBrush(System.Drawing.SystemColors.WindowText))
             using (System.Drawing.SolidBrush BackGroundBrushHighLight = new System.Drawing.SolidBrush(System.Drawing.Color.DarkGreen))
                 using (System.Drawing.SolidBrush ForeGroundBrushHighLight = new System.Drawing.SolidBrush(System.Drawing.Color.Pink))
                 {
                     e.Graphics.FillRectangle(BackGroundBrush, e.ClipRectangle);
                     System.Drawing.SolidBrush CurrentNode;
                     int count = this.Nodes.Count;
                     for (int index = 0; index < count; ++index)
                     {
                         if (Nodes[index].IsSelected)
                         {
                             CurrentNode = ForeGroundBrushHighLight;
                             e.Graphics.FillRectangle(BackGroundBrushHighLight, Nodes[index].Bounds);
                         }
                         else
                         {
                             CurrentNode = ForeGroundBrush;
                         }
                         e.Graphics.DrawString(Nodes[index].Text, this.Font, CurrentNode, Rectangle.Inflate(Nodes[index].Bounds, 2, 0));
                     }
                 }
 }
        private void resultCanvas_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            System.Drawing.SolidBrush sb = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            SolidColorBrush           solidColorBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(sb.Color.A, sb.Color.R, sb.Color.G, sb.Color.B));

            this.resultCanvas.Background = solidColorBrush;
        }
Exemple #21
0
        public void ListeAusgabe(System.Drawing.Graphics zeichenflaeche, System.Drawing.RectangleF flaesche)
        {
            //ein Temporär Pinsel erzeugen
            System.Drawing.SolidBrush tempPinsle = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            //die schriftart setzen
            System.Drawing.Font tempSchrift = new System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Bold);

            //für die zentrierte ausgabe
            System.Drawing.StringFormat ausrichtung = new System.Drawing.StringFormat();
            //Koordinaten für die ausgabe
            float punkteX, nameX, y;

            punkteX = flaesche.Left + 50;
            nameX   = flaesche.Left + 250;
            y       = flaesche.Top + 50;
            //die ausrichtung ist zentriert
            ausrichtung.Alignment = System.Drawing.StringAlignment.Center;
            //die zeichenflaeche löschen
            zeichenflaeche.Clear(System.Drawing.Color.Black);
            //den Titel ausgeben
            zeichenflaeche.DrawString("Bestenliste", tempSchrift, tempPinsle, flaesche.Width / 2, y, ausrichtung);
            //und nun die liste selbst
            for (int i = 0; i < anzahl; i++)
            {
                y += 20;
                zeichenflaeche.DrawString(Convert.ToString(bestenListe[i].GetPunkte()), tempSchrift, tempPinsle, punkteX, y);
                zeichenflaeche.DrawString(Convert.ToString(bestenListe[i].GetName()), tempSchrift, tempPinsle, nameX, y);
            }
        }
Exemple #22
0
        //http://blogs.msdn.com/b/abhinaba/archive/2005/09/12/animation-and-text-in-system-tray-using-c.aspx
        public void ShowText(string text)
        {
            System.Drawing.Color textColor;

            if (_isWork)
            {
                textColor = WorkTrayIconColor;
            }
            else
            {
                textColor = BreakTrayIconColor;
            }

            if (_systemTrayIcon != IntPtr.Zero)
            {
                DestroyIcon(_systemTrayIcon);
            }

            System.Drawing.Brush brush = new System.Drawing.SolidBrush(textColor);

            System.Drawing.Bitmap   bitmap   = new System.Drawing.Bitmap(16, 16);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
            graphics.DrawString(text, new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Bold), brush, 0, 0);

            _systemTrayIcon = bitmap.GetHicon();


            System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(_systemTrayIcon);
            sysTrayIcon.Icon = icon;
        }
Exemple #23
0
 public Polygone() : base()
 {
     ObjectType = MapObjectType.Polygone;
     pen        = new System.Drawing.Pen(System.Drawing.Color.DarkCyan);
     brush      = new System.Drawing.SolidBrush(System.Drawing.Color.DarkCyan);
     border     = System.Drawing.Color.Black;
 }
        public MyGdiPlusCanvas(GraphicsPlatform platform,
                               System.Drawing.Graphics targetGfx,
                               int left, int top,
                               int width,
                               int height)
        {
            //platform specific Win32
            //1.
            this.platform  = platform;
            this.targetGfx = this.gx = targetGfx;

            //2. dimension
            this.left   = left;
            this.top    = top;
            this.right  = left + width;
            this.bottom = top + height;

            currentClipRect = new System.Drawing.Rectangle(0, 0, width, height);

            var fontInfo = platform.GetFont("tahoma", 10, FontStyle.Regular);

            this.CurrentFont      = defaultFont = fontInfo.ResolvedFont;
            this.CurrentTextColor = Color.Black;

            internalPen        = new System.Drawing.Pen(System.Drawing.Color.Black);
            internalSolidBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

#if DEBUG
            debug_canvas_id   = dbug_canvasCount + 1;
            dbug_canvasCount += 1;
#endif
            this.StrokeWidth = 1;
        }
Exemple #25
0
        protected override void OnRenderItemCheck(System.Windows.Forms.ToolStripItemImageRenderEventArgs e)
        {
            base.OnRenderItemCheck(e);

            System.Drawing.Bitmap imagem = new System.Drawing.Bitmap(Properties.Resources.Check);
            //e.Graphics.DrawImage(imagem, new Rectangle(e.CellBounds.X + e.CellBounds.Width - imagem.Width - StyleSettings.DeslocaImagem_Botao, e.CellBounds.Y + StyleSettings.DeslocaImagem_Botao, imagem.Width, imagem.Height));


            if (e.Item.Selected)
            {
                var rect  = new System.Drawing.Rectangle(3, 1, 20, 20);
                var rect2 = new System.Drawing.Rectangle(4, 2, 18, 18);
                System.Drawing.SolidBrush b  = new System.Drawing.SolidBrush(StyleSettings.Form_BackGround_Color);
                System.Drawing.SolidBrush b2 = new System.Drawing.SolidBrush(StyleSettings.Button_BackGround_Color_Start);

                e.Graphics.FillRectangle(b, rect);
                e.Graphics.FillRectangle(b2, rect2);
                //e.Graphics.DrawImage(e.Image, new Point(5, 3));
                e.Graphics.Clear(System.Drawing.Color.Black);
                e.Graphics.DrawImage(imagem, new System.Drawing.Point(5, 3));
            }
            else
            {
                var rect  = new System.Drawing.Rectangle(3, 1, 20, 20);
                var rect2 = new System.Drawing.Rectangle(4, 2, 18, 18);
                System.Drawing.SolidBrush b  = new System.Drawing.SolidBrush(System.Drawing.Color.White);
                System.Drawing.SolidBrush b2 = new System.Drawing.SolidBrush(System.Drawing.Color.Silver);

                e.Graphics.FillRectangle(b, rect);
                e.Graphics.FillRectangle(b2, rect2);
                //e.Graphics.DrawImage(e.Image, new Point(5, 3));
                e.Graphics.Clear(System.Drawing.Color.Black);
                e.Graphics.DrawImage(imagem, new System.Drawing.Point(5, 3));
            }
        }
Exemple #26
0
 /// <summary>
 /// 绘制拖拽矩形,本函数根据主矩形区域计算8个拖拽矩形区域并用指定的颜色
 /// 填充和绘制边框,本函数不绘制主矩形区域
 /// </summary>
 /// <param name="myGraph">图像绘制对象</param>
 public void RefreshView(System.Drawing.Graphics myGraph)
 {
     if (myGraph != null)
     {
         if (bolBoundsBorder)
         {
             using (System.Drawing.Pen myPen =
                        new System.Drawing.Pen(System.Drawing.Color.Black))
             {
                 myPen.DashStyle = this.LineDashStyle;
                 myGraph.DrawRectangle(myPen, myBounds);
             }
         }
         using (System.Drawing.SolidBrush myBrush =
                    new System.Drawing.SolidBrush(this.DragRectBackColor))
         {
             myGraph.FillRectangles(myBrush, this.myDragRect);
         }
         using (System.Drawing.Pen myPen =
                    new System.Drawing.Pen(this.DragRectBorderColor))
         {
             myGraph.DrawRectangles(myPen, myDragRect);
         }
     }
 }// void DrawDragRect()
Exemple #27
0
        public RGSolidBrush GetBrush(SolidColor color)
        {
            if (color.A == 0)
            {
                return(null);
            }

            lock (cachedBrushes)
            {
                RGSolidBrush b;
                if (cachedBrushes.TryGetValue(color, out b))
                {
                    return(b);
                }
                else
                {
                    b = new RGSolidBrush(color);
                    cachedBrushes.Add(color, b);

                    if ((cachedBrushes.Count % 10) == 0)
                    {
                        Logger.Log("resource pool", "solid brush count: " + cachedBrushes.Count);
                    }

                    return(b);
                }
            }
        }
Exemple #28
0
        public static void drawGraphics(List <double> xs, List <double> ys, double w_height, System.Windows.Forms.Panel panel)
        {
            double maxX      = xs.Max();
            double maxY      = ys.Max();
            double width     = maxX - xs.Min();
            double maxheight = maxY - ys.Min();
            double xscale    = panel.Width / width;
            double yscale    = panel.Height / maxheight;

            System.Drawing.Pen        pen       = new System.Drawing.Pen(System.Drawing.Color.Tan, 3);
            System.Drawing.SolidBrush waterFill = new System.Drawing.SolidBrush(System.Drawing.Color.AliceBlue);


            System.Drawing.Graphics crossSection = panel.CreateGraphics();
            crossSection.ScaleTransform((float)xscale, (float)yscale);
            System.Drawing.PointF[] points = new System.Drawing.PointF[xs.Count];

            for (int i = 0; i < xs.Count - 1; i++)
            {
                double y  = maxY - ys[i];
                double y2 = maxY - ys[i + 1];
                double x  = xs[i];
                points[i] = new System.Drawing.PointF((float)x, (float)y);
            }
            byte[] types = { (byte)points[0].X, (byte)System.Drawing.Drawing2D.PathPointType.Line, (byte)System.Drawing.Drawing2D.PathPointType.DashMode };

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(points, types, System.Drawing.Drawing2D.FillMode.Alternate);
            crossSection.DrawPath(pen, path);

            crossSection.FillPath(waterFill, path);
        }
        public MyScreenCanvas(GraphicsPlatform platform,
                              int horizontalPageNum,
                              int verticalPageNum,
                              int left, int top,
                              int width,
                              int height)
        {
            //platform specific Win32
            //1.
            this.platform     = platform;
            this.pageNumFlags = (horizontalPageNum << 8) | verticalPageNum;
            //2. dimension
            this.left   = left;
            this.top    = top;
            this.right  = left + width;
            this.bottom = top + height;
            CreateGraphicsFromNativeHdc(width, height);
            //-------------------------------------------------------
            currentClipRect = new System.Drawing.Rectangle(0, 0, width, height);
            var fontInfo = platform.GetFont("tahoma", 10, FontStyle.Regular);

            this.CurrentFont      = defaultFont = fontInfo.ResolvedFont;
            this.CurrentTextColor = Color.Black;
            internalPen           = new System.Drawing.Pen(System.Drawing.Color.Black);
            internalSolidBrush    = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
#if DEBUG
            debug_canvas_id   = dbug_canvasCount + 1;
            dbug_canvasCount += 1;
#endif
            this.StrokeWidth = 1;
        }
Exemple #30
0
        /// <summary>
        /// Draws the when active.
        /// </summary>
        /// <param name="image">The image.</param>
        protected override void DrawWhenActive(System.Drawing.Graphics image)
        {
            System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(70, System.Drawing.Color.Green));
            if (this.Owner.From == Direction.Down || this.Owner.From == Direction.Up)
            {
                image.FillRectangle(brush, this.X, this.Y, 20, 60);
            }
            else
            {
                image.FillRectangle(brush, this.X, this.Y, 60, 20);
            }
            foreach (Car car in this.currentCarsOn)
            {
                car.Draw(image);
            }
            string flow = this.Flow.ToString();

            if (this.flowReleased > 0 || this.flowAccumulated > 0)
            {
                flow = (this.Flow - this.flowReleased + this.flowAccumulated) + "";
            }
            if (this.Owner.From == Direction.Down)
            {
                image.DrawString(flow, new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, 8), System.Drawing.Brushes.ForestGreen, this.X + 3, this.Y + 45);
            }
            else if (this.Owner.From == Direction.Right)
            {
                image.DrawString(flow, new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, 8), System.Drawing.Brushes.ForestGreen, this.X + 45, this.Y + 2);
            }
            else
            {
                image.DrawString(flow, new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, 8), System.Drawing.Brushes.ForestGreen, this.X + 3, this.Y + 3);
            }
        }
Exemple #31
0
        protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel == GH_CanvasChannel.Objects)
            {
                GH_Capsule capsule = GH_Capsule.CreateCapsule(this.Bounds, GH_Palette.Normal);
                capsule.AddOutputGrip(this.OutputGrip.Y);
                capsule.Render(canvas.Graphics, this.Selected, this.Owner.Locked, this.Owner.Hidden);
                capsule.Dispose();
                int alpha = GH_Canvas.ZoomFadeLow;
                if (alpha > 0)
                {
                    canvas.SetSmartTextRenderingHint();
                    GH_PaletteStyle      style = GH_CapsuleRenderEngine.GetImpliedStyle(GH_Palette.Normal, this);
                    System.Drawing.Color color = System.Drawing.Color.FromArgb(alpha, style.Text);
                    if (this.NameBounds.Width > 0f)
                    {
                        System.Drawing.SolidBrush nameFill = new System.Drawing.SolidBrush(color);
                        graphics.DrawString(this.Owner.NickName, GH_FontServer.Standard, nameFill, this.NameBounds, GH_TextRenderingConstants.CenterCenter);
                        nameFill.Dispose();
                        int x  = System.Convert.ToInt32(this.NameBounds.Right);
                        int y0 = System.Convert.ToInt32(this.NameBounds.Top);
                        int y  = System.Convert.ToInt32(this.NameBounds.Bottom);
                        GH_GraphicsUtil.EtchFadingVertical(graphics, y0, y, x, System.Convert.ToInt32(0.8 * (double)alpha), System.Convert.ToInt32(0.3 * (double)alpha));
                    }

                    // render dropdown only
                    this.RenderDropDown(canvas, graphics, color);
                }
            }
        }
        //-------------------------------


        internal MyGdiPlusCanvas(
            int horizontalPageNum,
            int verticalPageNum,
            int left, int top,
            int width,
            int height)
        {
#if DEBUG
            debug_canvas_id   = dbug_canvasCount + 1;
            dbug_canvasCount += 1;
#endif

            this.pageNumFlags = (horizontalPageNum << 8) | verticalPageNum;
            //2. dimension
            this.left       = left;
            this.top        = top;
            this.right      = left + width;
            this.bottom     = top + height;
            currentClipRect = new System.Drawing.Rectangle(0, 0, width, height);

            CreateGraphicsFromNativeHdc(width, height);
            this.gx = System.Drawing.Graphics.FromHdc(win32MemDc.DC);
            //-------------------------------------------------------
            //managed object
            internalPen        = new System.Drawing.Pen(System.Drawing.Color.Black);
            internalSolidBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            this.StrokeWidth = 1;
        }
Exemple #33
0
        public void Draw(Grid inGrid, System.Drawing.Graphics inGraphics, bool bPrintAgeType)
        {
            double boundRectX = inGrid.GetTopLeftX() + inGrid.GetSectionWidth() * (GetX() - GetRadius());
            int    maxY       = inGrid.GetTopLeftY() + inGrid.GetHeight();
            double boundRectY = maxY - inGrid.GetSectionHeight() * (GetY() + GetRadius());

            float plantDiameter = (float)GetDiameter();

            float rectHeight = plantDiameter * inGrid.GetSectionHeight();
            float rectiWidth = plantDiameter * inGrid.GetSectionWidth();

            System.Drawing.RectangleF boundingRect       = new System.Drawing.RectangleF((float)boundRectX, (float)boundRectY, rectHeight, rectiWidth);
            System.Drawing.Color      EllipseBorderColor = System.Drawing.Color.Red;
            System.Drawing.Pen        ellipseBorderPen   = new System.Drawing.Pen(EllipseBorderColor);

            inGraphics.DrawEllipse(ellipseBorderPen, boundingRect);
            System.Drawing.SolidBrush ellipseFillBrush = new System.Drawing.SolidBrush(GetFillColor());
            inGraphics.FillEllipse(ellipseFillBrush, boundingRect);

            if (bPrintAgeType)
            {
                System.Drawing.Font       textFont  = new System.Drawing.Font("Arial", 16);
                System.Drawing.SolidBrush textBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
                float textX = (float)(inGrid.GetTopLeftX() + inGrid.GetSectionWidth() * (GetX() - GetRadius()));
                float textY = (float)(maxY - inGrid.GetSectionHeight() * (GetY() + GetRadius()));
                inGraphics.DrawString(GetAgeType().ToString(), textFont, textBrush, textX, textY);
            }

            ellipseBorderPen.Dispose();
        }
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            var    formGraphics = e.Graphics;
            string drawString1  = "Windows Store Edition";

            System.Drawing.Font       drawFont1  = new System.Drawing.Font("Microsoft Sans Serif", 22, System.Drawing.FontStyle.Bold);
            System.Drawing.SolidBrush drawBrush1 = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            float x1 = 34.0F;
            float y1 = 148.0F;

            System.Drawing.StringFormat drawFormat1 = new System.Drawing.StringFormat();
            formGraphics.DrawString(drawString1, drawFont1, drawBrush1, x1, y1, drawFormat1);

            //377; 171
            string drawString2 = "V22 21-01-2021";

            System.Drawing.Font       drawFont2  = new System.Drawing.Font("Microsoft Sans Serif", 8, System.Drawing.FontStyle.Bold);
            System.Drawing.SolidBrush drawBrush2 = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            float x2 = 358.0F;
            float y2 = 164.0F;

            System.Drawing.StringFormat drawFormat2 = new System.Drawing.StringFormat();
            formGraphics.DrawString(drawString2, drawFont2, drawBrush2, x2, y2, drawFormat2);
            drawFont1.Dispose();
            drawBrush1.Dispose();
            drawFont2.Dispose();
            drawBrush2.Dispose();
            formGraphics.Dispose();
        }
Exemple #35
0
        private void DrawAuthor()
        {
            System.Drawing.Font         font   = new System.Drawing.Font("宋体", 42, System.Drawing.FontStyle.Bold);
            System.Drawing.Brush        brush  = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            System.Drawing.StringFormat format = new System.Drawing.StringFormat
            {
                Alignment = System.Drawing.StringAlignment.Center
            };
            System.Drawing.RectangleF rect = new System.Drawing.RectangleF(0, 280, Constants.ImageWidth, 60);

            if (this.saveOption.ProductRegion == ProductRegionEnum.Region ||
                (this.saveOption.ProductRegion == ProductRegionEnum.Country && this.isTemplate20 && (this.saveOption.ProductType == ProductTypeEnum.Disaster || this.saveOption.ProductType == ProductTypeEnum.Flood)))
            {
                rect = new System.Drawing.RectangleF(1600, 1453, Constants.ImageWidth - 1600, 60);
                font = new System.Drawing.Font("宋体", 28, System.Drawing.FontStyle.Bold);
            }

            string author = "中央气象台";

            if (this.saveOption.ProductRegion == ProductRegionEnum.Country && this.isTemplate20 && this.saveOption.ProductType == ProductTypeEnum.Disaster)
            {
                author = "国土资源部 中国气象局";
            }
            if (this.saveOption.ProductRegion == ProductRegionEnum.Country && this.isTemplate20 && this.saveOption.ProductType == ProductTypeEnum.Flood)
            {
                author = "水利部 中国气象局";
            }

            this.graphics.DrawString(author, font, brush, rect, format);
        }
Exemple #36
0
        //Draw text on the map
        private System.Drawing.Bitmap DrawText(String text, System.Drawing.Font font, System.Drawing.Color textColor, System.Drawing.Color backColor)
        {
            //Create a dummy bitmap to get a graphics object
            System.Drawing.Bitmap   img     = new System.Drawing.Bitmap(1, 1);
            System.Drawing.Graphics drawing = System.Drawing.Graphics.FromImage(img);

            //Measure the string to see how big the image needs to be
            textSize = drawing.MeasureString(text, font);

            //free up the dummy image and old graphics object
            img.Dispose();
            drawing.Dispose();

            //create a new image of the right size
            img     = new System.Drawing.Bitmap((int)textSize.Width, (int)textSize.Height);
            drawing = System.Drawing.Graphics.FromImage(img);

            //paint the background
            drawing.Clear(backColor);

            System.Drawing.SolidBrush textBrush = new System.Drawing.SolidBrush(textColor);
            drawing.DrawString(text, font, textBrush, 0, 0);
            drawing.Save();
            textBrush.Dispose();
            drawing.Dispose();

            return(img);
        }
 public override void Draw(System.Drawing.Graphics g)
 {
     System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(Color);
     System.Drawing.PointF upperLeftPoint = new System.Drawing.PointF((float)(Center.X - Width / 2), (float)(Center.Y - Height / 2));
     System.Drawing.SizeF rectSize = new System.Drawing.SizeF((float)Width, (float)Height);
     System.Drawing.RectangleF rect = new System.Drawing.RectangleF(upperLeftPoint, rectSize);
     g.FillRectangle(solidBrush, rect);
     solidBrush.Dispose();
 }
Exemple #38
0
 /// <summary>
 /// Gets the GDI brush.
 /// </summary>
 /// <param name="brush">The GDI brush.</param>
 /// <returns></returns>
 public System.Drawing.Brush GetBrush(Styles.Brush brush)
 {
     System.Drawing.Brush gdiBrush;
     if (!brushes.TryGetValue(brush, out gdiBrush))
     {
         gdiBrush = new System.Drawing.SolidBrush(brush.Color.ToGdi());
     }
     return gdiBrush;
 }
 public override void Draw(System.Drawing.Graphics g)
 {
     System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(Color);
     System.Drawing.PointF upperLeftPoint = new System.Drawing.PointF((float)(Center.X - RadiusX), (float)(Center.Y - RadiusY));
     System.Drawing.SizeF rectSize = new System.Drawing.SizeF((float)(2 * RadiusX), (float)(2 * RadiusY));
     System.Drawing.RectangleF rect = new System.Drawing.RectangleF(upperLeftPoint, rectSize);
     g.FillEllipse(solidBrush, rect);
     solidBrush.Dispose();
 }
 public override void Draw(System.Drawing.Graphics g)
 {
     System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(Color);
     System.Drawing.PointF[] points = new System.Drawing.PointF[3];
     points[0] = new System.Drawing.PointF((float)Vertex1.X, (float)Vertex1.Y);
     points[1] = new System.Drawing.PointF((float)Vertex2.X, (float)Vertex2.Y);
     points[2] = new System.Drawing.PointF((float)Vertex3.X, (float)Vertex3.Y);
     g.FillPolygon(solidBrush, points);
     solidBrush.Dispose();
 }
        public void Draw(System.Drawing.Graphics myGraphics)
        {
            System.Drawing.Brush myBrush = new System.Drawing.SolidBrush(this.color);

            myGraphics.FillRectangle(myBrush,
                                     this.position.get_x()-this.width/2,
                                     this.position.get_y()-this.height/2,
              this.width,
              this.height);
        }
Exemple #42
0
 protected override void ProcessRecord()
 {
     using (var g = System.Drawing.Graphics.FromImage(this.Bitmap))
     {
         var color = System.Drawing.Color.FromArgb(this.Color);
         using (var brush = new System.Drawing.SolidBrush(color))
         {
             g.FillRectangle(brush, this.X0, this.Y0, this.X1, this.Y1);                    
         }
     }
 }
Exemple #43
0
 protected override void ProcessRecord()
 {
     using (var g = System.Drawing.Graphics.FromImage(this.Bitmap))
     {
         var color = System.Drawing.Color.FromArgb(this.Color);
         using (var brush = new System.Drawing.SolidBrush(color))
         using (var font = new System.Drawing.Font(this.Font,this.Size))
         {
             g.DrawString(this.Text, font, brush, this.X, this.Y);                    
         }
     }
 }
Exemple #44
0
 /// 在图片上增加文字水印
 /// </summary>
 /// <param name="Path">原服务器图片路径</param>
 /// <param name="Path_sy">生成的带文字水印的图片路径</param>
 public void AddWater(string Path, string Path_sy)
 {
     string addText = "ROYcms!NT";
     System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
     System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
     g.DrawImage(image, 0, 0, image.Width, image.Height);
     System.Drawing.Font f = new System.Drawing.Font("Verdana", 60);
     System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
     g.DrawString(addText, f, b, 35, 35);
     g.Dispose();
     image.Save(Path_sy);
     image.Dispose();
 }
Exemple #45
0
        public virtual void Init()
        {
            x1 = x2 = y1 = y2 = 0;
            
            needFilling = false;
            needOutline = true;
            
            filling = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            outline = new System.Drawing.Pen(System.Drawing.Color.Black);
            outline.Width = 1;

            selectionPen = new System.Drawing.Pen(System.Drawing.Brushes.Blue,1);
            selectionPen.DashStyle=System.Drawing.Drawing2D.DashStyle.Dash;
        }
Exemple #46
0
        /**/
        /// <summary>
        /// 在图片上生成图片水印
        /// </summary>
        /// <param name="Path">原服务器图片路径</param>
        /// <param name="Path_syp">生成的带图片水印的图片路径</param>
        /// <param name="Path_sypf">水印图片路径</param>
        public static void AddShuiYinPic(string Path, string Path_syp, string Path_sypf)
        {
            System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
            System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
            g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
            g.Dispose();

            image.Save(Path_syp);
            image.Dispose();
        }

        /**/
        /// <summary>
        /// 在图片上增加文字水印
        /// </summary>
        /// <param name="Path">原服务器图片路径</param>
        /// <param name="Path_sy">生成的带文字水印的图片路径</param>
        public static void AddShuiYinWord(string water,string Path, string Path_sy)
        {
            System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
            g.DrawImage(image, 0, 0, image.Width, image.Height);
            System.Drawing.Font f = new System.Drawing.Font("Verdana", 16);
            System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);

            g.DrawString(water, f, b, 15, 15);
            g.Dispose();

            image.Save(Path_sy);

            image.Dispose();
        }
Exemple #47
0
        protected override void ProcessRecord()
        {
            var bmp = new System.Drawing.Bitmap(this.Width, this.Height, this.PixelFormat);

            using (var g = System.Drawing.Graphics.FromImage(bmp))
            {
                var color = System.Drawing.Color.FromArgb(this.Color);
                using (var brush = new System.Drawing.SolidBrush(color))
                {
                    this.WriteVerbose("Filling rect {0}", this.Color);
                    g.FillRectangle(brush, 0, 0, this.Width, this.Height);
                }
            }
            this.WriteObject(bmp);
        }
        private void DrawString()
        {
            WriteableBitmap writeableBmp = BitmapFactory.New(512, 512);

            WriteableBitmapExtensions.
                System.Drawing.Graphics formGraphics = this.CreateGraphics();
            string drawString = "Sample Text";
            System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
            System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            float x = 150.0f;
            float y = 50.0f;
            formGraphics.DrawString(drawString, drawFont, drawBrush, x, y);
            drawFont.Dispose();
            drawBrush.Dispose();
            formGraphics.Dispose();
        }
Exemple #49
0
        /// <summary>色見本画像をファイルに保存する
        /// </summary>
        /// <param name="filePath">出力先ファイル名</param>
        /// <param name="colors">色のリスト</param>
        private void OutputColorSwatch(string filePath, IEnumerable<Colors.NamedColor> colors)
        {
            // めんどくさいからマージンとかフォントとかは決め打ち。
            int image_margin = 5;
            int row_margin = 5;
            string font_family = "Consolas";
            float font_height = 10;
            var font = new System.Drawing.Font(font_family, font_height);

            var text_argb_size = this.OutputColorSwatch_GetMaxTextSize(font, new[] { "0x00000000" });
            var text_name_size = this.OutputColorSwatch_GetMaxTextSize(font, colors.Select(x => x.Name));
            int ct_row = colors.Count();

            int row_height = (int)(text_name_size.Height);
            int w = (int)(image_margin * 2 + (row_height + row_margin * 2 + text_argb_size.Width + text_name_size.Width) * 2 + row_margin);
            int h = (int)(image_margin * 2 + row_height * ct_row + row_margin * (ct_row - 1));

            var bmp = new System.Drawing.Bitmap(w, h);
            var g = System.Drawing.Graphics.FromImage(bmp);
            // 色のイメージをつけやすくするため、背景色を白と黒でそれぞれ用意しておく
            g.Clear(System.Drawing.Color.Black);
            g.FillRectangle(System.Drawing.Brushes.White, 0, 0, w / 2, h);

            for (int pos_x_base = image_margin ; pos_x_base < w ; pos_x_base += w / 2) {
                int pos_y_base = image_margin;
                foreach (var color in colors) {
                    // 色見本
                    var brush = new System.Drawing.SolidBrush(color.Color);
                    g.FillRectangle(brush, pos_x_base, pos_y_base, row_height, row_height);

                    if (color.Color.A < 0xff) {
                        // 文字が半透明だと読めないので、不透明にしておく
                        brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(0xff, color.Color));
                    }
                    int pos_x = pos_x_base + row_height + row_margin;
                    int pos_y = pos_y_base;
                    // ARGBコード
                    g.DrawString($"0x{color.Color.ToArgb():X8}", font, brush, pos_x, pos_y);
                    pos_x += (int)(text_argb_size.Width + row_margin);
                    // 色名
                    g.DrawString($"{color.Name}", font, brush, pos_x, pos_y);
                    pos_y_base += (int)(row_margin + row_height);
                }
            }
            bmp.Save(filePath);
        }
Exemple #50
0
        // prekresli sa bunka vrchola
        private void repaintBoxes(KDNode n)
        {

            if (n.isLeaf)
            {
                System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
                System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
                if (n.highligthBox)
                {
                    myBrush.Color = System.Drawing.Color.LightSteelBlue;
                    g.FillRectangle(myBrush, n.from.X, n.from.Y, n.to.X - n.from.X, n.to.Y - n.from.Y);
                }
                //Console.WriteLine("vrchol: " + n.getPoint() + " from: " + n.from + " to: " + n.to);
                g.DrawRectangle(myPen, n.from.X, n.from.Y, n.to.X - n.from.X, n.to.Y - n.from.Y);
            } else {
                //Console.WriteLine("vrchol: (" + n.getSplit() + " from: " + n.from + " to: " + n.to);
            }
        }
        public GdiPlusCanvasPainter(System.Drawing.Bitmap gfxBmp)
        {



            _width = 800;// gfxBmp.Width;
            _height = 600;// gfxBmp.Height;
            _gfxBmp = gfxBmp;

            _gfx = System.Drawing.Graphics.FromImage(_gfxBmp);

            //credit:
            //http://stackoverflow.com/questions/1485745/flip-coordinates-when-drawing-to-control
            _gfx.ScaleTransform(1.0F, -1.0F);// Flip the Y-Axis
            _gfx.TranslateTransform(0.0F, -(float)Height);// Translate the drawing area accordingly            

            _currentFillBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            _currentPen = new System.Drawing.Pen(System.Drawing.Color.Black);

            //
            _bmpStore = new BufferBitmapStore(_width, _height);
        }
Exemple #52
0
        /// <summary>
        /// 在图片上添加文字水印
        /// </summary>
        /// <param name="path">要添加水印的图片路径</param>
        /// <param name="syPath">生成的水印图片存放的位置</param>
        public static void AddWaterWord(string word,string path, string syPath,int xpos,int ypos)
        {
            string syWord = word;
            //原图片读取
            System.Drawing.Image image = System.Drawing.Image.FromFile(path);

            //新建一个画板(以原图片作为底图)
            System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(image);

            graphic.DrawImage(image, 0, 0, image.Width, image.Height);
            int size = 20;
            if (image.Width < 300)
            {
                size = 12;
            }
            //设置字体
            System.Drawing.Font f = new System.Drawing.Font("黑体", 12);

            //设置字体颜色
            System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
            if (image.Width < 300)
            {
                //水印位置
                graphic.DrawString(syWord, f, b, image.Width-(syWord.Length*8), ypos);
            }
            else
            {

                //水印位置
                graphic.DrawString(syWord, f, b, image.Width - (syWord.Length*10+xpos), ypos);
            }

            graphic.Dispose();

            //保存文字水印图片
            image.Save(syPath);
            image.Dispose();
        }
 protected override void OnPaint(PaintEventArgs e)
 {
     if(OnDraw_CB != null)
     {
         e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
         e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Default;
         e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
         OnDraw_CB(e.Graphics.GetHdc());
         e.Graphics.ReleaseHdc();
     } else
     {
         using(var drawFont = new System.Drawing.Font("Arial", 16))
         using(var drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black))
         {
             var s = this.Size;
             s.Height /= 2;
             s.Width /= 2;
             s.Width -= 40;
             e.Graphics.Clear(System.Drawing.Color.CornflowerBlue);
             e.Graphics.DrawString("Waiting to connect . . ", drawFont, drawBrush, s.Width, s.Height);
         }
     }
 }
        void HistoryListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ItemIndex < 0) return;

            //Console.WriteLine(e.ItemIndex + "-" + e.Bounds);

            if (this.SelectedIndices.Contains(e.ItemIndex))
            {
                e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
                ControlPaint.DrawFocusRectangle(e.Graphics, e.Item.Bounds);
            }
            else
            {
                e.DrawBackground();
            }

            // if this is the first column, we want to draw an icon as well
            int newX = e.Bounds.Left;
            if (e.ColumnIndex == 0)
            {
                // draw the icon
                newX = newX + 20;
                PastNotification pn = (PastNotification)e.Item.Tag;
                if (pn != null)
                {
                    System.Drawing.Image img = PastNotificationManager.GetImage(pn);
                    using (img)
                    {
                        if (img != null)
                        {
                            int x = e.Bounds.Left + 2;
                            int y = e.Bounds.Top;
                            e.Graphics.DrawImage(img, new System.Drawing.Rectangle(x, y, 16, 16));
                        }
                    }
                }
            }

            // draw text
            string text = e.SubItem.Text.Replace("\r", " - ");
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);
            System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
            sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
            sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip | System.Drawing.StringFormatFlags.NoWrap;
            System.Drawing.Color color = (e.ColumnIndex == 0 ? e.Item.ForeColor : System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb()));
            System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(color);
            using (foreBrush)
            {
                //TextFormatFlags flags = TextFormatFlags.Default | TextFormatFlags.ExternalLeading | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.NoClipping | TextFormatFlags.EndEllipsis | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine;
                //TextRenderer.DrawText(e.Graphics, text, e.SubItem.Font, rect, e.SubItem.ForeColor, System.Drawing.Color.Transparent, flags);

                e.Graphics.DrawString(text,
                    e.SubItem.Font,
                    foreBrush,
                    rect,
                    sf);
            }
        }
        void HistoryListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (e.ItemIndex < 0) return;

            if (this.View == View.Tile)
            {
                // draw the background and focus rectangle for selected and non-selected states
                if (this.SelectedIndices.Contains(e.ItemIndex))
                {
                    e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
                }
                else
                {
                    e.DrawBackground();
                }

                // draw icon
                PastNotification pn = (PastNotification)e.Item.Tag;
                int newX = e.Bounds.Left;
                if (pn != null)
                {
                    System.Drawing.Image img = PastNotificationManager.GetImage(pn);
                    using (img)
                    {
                        if (img != null)
                        {
                            int x = e.Bounds.Left + 1;
                            int y = e.Bounds.Top + 1;
                            e.Graphics.DrawImage(img, x, y);
                            newX = e.Bounds.Left + img.Width + this.Margin.Right;
                        }
                    }
                }

                // draw main text
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);
                System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
                sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
                sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;
                System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(e.Item.ForeColor);
                string text = e.Item.Text.Replace("\r", " - ");
                using (foreBrush)
                {
                    e.Graphics.DrawString(text,
                        e.Item.Font,
                        foreBrush,
                        rect,
                        sf);
                }

                // draw subitems
                System.Drawing.Color subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());
                System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);
                using (subBrush)
                {
                    for (int i = 1; i < this.Columns.Count; i++)
                    {
                        if (i < e.Item.SubItems.Count)
                        {
                            text = e.Item.SubItems[i].Text.Replace("\r", " - ");
                            rect.Offset(0, e.Item.Font.Height);
                            e.Graphics.DrawString(text,
                                e.Item.Font,
                                subBrush,
                                rect,
                                sf);
                        }
                    }
                }
            }
            else
            {
                // DO NOT call e.DrawDefault or the DrawSubItem event will not be fired
                //e.DrawDefault = true;
            }
        }
        private void HighlightCell(bool bHighlight, object[] columns, object cell, int j)
        {
            System.Drawing.SolidBrush brush = null;
            if (bHighlight)
            {
                brush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
            }
            else
            {
                System.Reflection.BindingFlags getpropertyflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
                brush = (System.Drawing.SolidBrush)columns[j + 1].GetType().InvokeMember("BkBrush", getpropertyflags, null, columns[j + 1], null);
            }

#if DENALI || SQL2014
            //do this a new way that will work with VS2012 SSDT2012 and it's new usage of BkBrush to setup the new color scheme
            if (_IsMetroOrGreater)
            {
                if (!(cell is TriStatePerspectiveGridCell))
                {
                    if (bHighlight) //only switch to a TriStatePerspectiveGridCell if we need to highlight
                    {
                        TriStatePerspectiveGridCell newcell = new TriStatePerspectiveGridCell((Microsoft.SqlServer.Management.UI.Grid.GridCell)cell);
                        columns[j] = newcell;
                        cell = newcell;
                        newcell.OverrideBkBrush = brush;
                    }
                }
                else
                {
                    lock (cell)
                    {
                        TriStatePerspectiveGridCell newcell = (TriStatePerspectiveGridCell)cell;
                        newcell.OverrideBkBrush = brush;
                    }
                }
                return;
            }
#endif
            System.Reflection.BindingFlags setpropertyflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
            lock (cell)
            {
                cell.GetType().InvokeMember("BkBrush", setpropertyflags, null, cell, new object[] { brush });
            }
        }
Exemple #57
0
        /// <summary>
        /// Wywoływana, aby narysować element rozwijanej listy.
        /// </summary>
        /// <param name="sender">Rozwijana lista konfigurowana w ramach obiektu.</param>
        /// <param name="e">Argumenty zdarzenia.</param>
        void comboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            ComboBox comboBox = (ComboBox)sender;

            e.DrawBackground();

            if (e.Index >= 0)
            {
                System.Drawing.Brush brush = new System.Drawing.SolidBrush(comboBox.ForeColor);
                string s;

                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                    brush = System.Drawing.SystemBrushes.HighlightText;

                if (comboBox.DroppedDown)
                {
                    if (filter == String.Empty)
                        s = itemList.ElementAt(e.Index).formattedLongItemDescription;
                    else
                        s = comboBox.Items[e.Index].ToString();
                }
                else
                    s = itemList.ElementAt(e.Index).shortItemDescription;

                e.Graphics.DrawString(s, comboBox.Font, brush, e.Bounds);
            }
        }
            protected override void DrawText(int id, string str, System.Drawing.Font font, System.Drawing.Brush fc, System.Drawing.Rectangle bounds, System.Drawing.StringFormat sf, System.Drawing.Graphics g, bool selected)
            {
                float fix = g.MeasureString("傻", font).Width * 2 - g.MeasureString("傻逼", font).Width;
                int indentw = (int)(g.MeasureString(strCommand, font).Width - fix);
                int indent = GetIndent(id);
                int x, height, y;

                x = bounds.X; y = bounds.Y;
                height = bounds.Height;
                EventCommand cmd = GetCodeCommand(id);

                x += indent * indentw + indentw;
                if (cmd != null && cmd.IsGenerated)
                {
                    int iw = (int)(g.MeasureString(strIndent, font).Width - fix);
                    g.DrawString(strIndent, font, fc, new System.Drawing.Rectangle(x - iw, y, bounds.Right - x + iw, height));
                }
                else
                {
                    g.DrawString(strCommand, font, fc, new System.Drawing.Rectangle(x - indentw, y, bounds.Right - x + indentw, height));
                }

                if (GetCode(id) == "0")
                    return;

                if (cmd != null && !selected)
                    fc = new System.Drawing.SolidBrush(cmd.Group.ForeColor);

                string drawing;
                if (cmd == null)
                    drawing = strUnknown;
                else
                {
                    drawing = cmd.FormatParams(this.Items[id] as RubyObject);
                }

                string draw;
                while (drawing.Length > 0)
                {
                    int pos = drawing.IndexOf("{hide}");
                    if (pos > 0)
                    {
                        draw = drawing.Substring(0, pos);
                        drawing = drawing.Substring(pos);
                        g.DrawString(draw, font, fc, new System.Drawing.Rectangle(x, y, bounds.Right - x, height), sf);
                        x += (int)(g.MeasureString(draw, font).Width - fix);
                    }
                    else if (pos == 0)
                    {
                        pos = drawing.IndexOf("{/hide}");
                        draw = drawing.Substring(6, pos - 6);
                        drawing = drawing.Substring(pos + 7);
                        x += (int)(g.MeasureString(draw, font).Width - fix);
                    }
                    else
                    {
                        g.DrawString(drawing, font, fc, new System.Drawing.Rectangle(x, y, bounds.Right - x, height), sf);
                        drawing = "";
                    }
                }
            }
Exemple #59
0
            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)
            {
                // the idea is to conditionally set the foreBrush and/or backbrush
                // depending upon some crireria on the cell value
                // Here, we color anything that begins with a letter higher than 'F'
                try
                {

                    System.Windows.Forms.DataGrid grid = this.DataGridTableStyle.DataGrid;
                    System.Data.DataRowView drv = (System.Data.DataRowView) source.List[rowNum];

                    //first time set the column properly
                    if (column == -2)
                    {
                        int i = this.DataGridTableStyle.GridColumnStyles.IndexOf(this);
                        if (i > -1)
                            column = i;
                    }

                    //if(grid.CurrentRowIndex == rowNum && grid.CurrentCell.ColumnNumber == column)
                    if ((string)drv["chargeprimula"] == "J")
                    {

                        if (!grid.IsSelected(rowNum))
                        {
                            //backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(bounds, System.Drawing.Color.FromArgb(205,149,12), System.Drawing.Color.FromArgb(238,220,130), System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                            backBrush = System.Drawing.Brushes.Wheat;
                            foreBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
                        }
                    }
                }
                catch(Exception ex){ /* empty catch */ }
                finally
                {
                    // make sure the base class gets called to do the drawing with
                    // the possibly changed brushes
                    base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
                }
            }
Exemple #60
0
 static void UIMessage_RowPostPaint(object sender, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
 {
     System.Windows.Forms.DataGridView grd = ((System.Windows.Forms.DataGridView)sender);
     using (System.Drawing.SolidBrush b = new System.Drawing.SolidBrush(grd.RowHeadersDefaultCellStyle.ForeColor))
     {
         e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 8, e.RowBounds.Location.Y + 4);
     }
 }