DrawRectangles() публичный метод

public DrawRectangles ( Pen pen, Rectangle rects ) : void
pen Pen
rects Rectangle
Результат void
        /// <summary>
        /// On draw on backbuffer
        /// </summary>
        protected override void OnDrawOnBackbuffer(ref System.Drawing.Graphics gfx)
        {
            // If layer is empty or background is empty, return
            if (_layer == null || App.Room.Backgrounds[0] == null || App.Room.Backgrounds[0].Image == null)
            {
                return;
            }

            // Draw layer
            gfx.DrawImageUnscaled(_layer.GetLayerImage(App.Room.Backgrounds[0], App.Room.Backgrounds[0].GetCondensedTileset(), .5f), Point.Empty);

            // Convert tile ids to optimized binary tiles and reset the tile count
            ExportTile[] tiles = _layer.GetExportTiles(App.Room.Backgrounds[0], false, -1);
            _tileCount = 0;

            // If there are rectangles to draw, draw them
            if (tiles != null || tiles.Length > 0)
            {
                // Create a list of rectangles
                List <Rectangle> rects = new List <Rectangle>();

                // Iterate through tiles
                foreach (ExportTile tile in tiles)
                {
                    rects.Add(tile.Rect);
                }

                // Draw rectangles and set tile count
                gfx.DrawRectangles(Pens.Red, rects.ToArray());
                _tileCount = rects.Count;
            }
        }
Пример #2
0
 /// <summary>
 /// Резиновый прямоугольник тянется от последней точки списка до точки позиции курсора
 /// </summary>
 /// <param name="graphics"></param>
 /// <param name="mousePosition"></param>
 /// <param name="pen"></param>
 public override void DrawRibbon(System.Drawing.Graphics graphics, Point mousePosition, Pen pen = null)
 {
     if (markers.Count < 1)
     {
         return;
     }
     graphics.DrawRectangles(pen ?? Pens.Magenta, new[] { GetRectangle(mousePosition) });
 }
 void DrawMargins(System.Drawing.Graphics g)
 {
     System.Drawing.RectangleF[] margins   = new System.Drawing.RectangleF[] { ZoomRectangle(ConvertToPixels(SurfaceMargins)) };
     System.Drawing.Pen          marginPen = new System.Drawing.Pen(MarginColor);
     marginPen.DashStyle = MarginLineDashStyle;
     marginPen.Width     = (float)MarginLineWidth;
     g.DrawRectangles(marginPen, margins);
 }
Пример #4
0
 /// <summary>
 /// Рисуем линию через все точки
 /// </summary>
 /// <param name="graphics"></param>
 public override void Draw(System.Drawing.Graphics graphics, Pen pen = null, Brush brush = null)
 {
     if (markers.Count < 2)
     {
         return;
     }
     graphics.FillRectangle(brush ?? Brushes.White, GetRectangle());
     graphics.DrawRectangles(pen ?? Pens.DarkMagenta, new[] { GetRectangle() });
 }
Пример #5
0
 /// <summary>
 /// Рисуем все маркеры из коллекции
 /// </summary>
 /// <param name="graphics"></param>
 public virtual void DrawMarkers(System.Drawing.Graphics graphics, Pen pen = null, Brush brush = null)
 {
     // если кнопка указателя нажата, ничего не рисуем
     if (mouseDowned)
     {
         return;
     }
     foreach (var marker in markers)
     {
         graphics.DrawRectangles(pen ?? Pens.Magenta, new[] { marker.Bounds });
     }
 }
        /// <summary>
        /// Черае всички rayCast кутии + Всички collision кутии ако debugCollision е true
        /// </summary>
        /// <param name="g"></param>
        /// <param name="debugCollisions">Да чертае ли всички collision кутии</param>
        public void Debug(Graphics g, bool debugCollisions)
        {
            Pen debugColor = new Pen(Color.Red);

            if (debugCollisions)
            {
                allGameObjects.ForEach(obj => somethingToDebug.Add(obj.rectangle));

            if(somethingToDebug.Count > 0)
                g.DrawRectangles(debugColor, somethingToDebug.ToArray());

            }

            somethingToDebug.Clear();
        }
Пример #7
0
            //
#if ALLOW_GDI
            internal override void Draw(SD.Graphics g)
            {
                var rect = new SD.RectangleF(PointF(Points[0]), SizeF(Points[1] - Points[0]));

                if (FillColor != Color.Empty)
                {
                    using (var brush = new SD.SolidBrush(FillColor)) {
                        g.FillRectangle(brush, rect);
                    }
                }
                if (StrokeColor != Color.Empty)
                {
                    using (var pen = new SD.Pen(StrokeColor, (int)StrokeWidth)) {
                        g.DrawRectangles(pen, new[] { rect });
                    }
                }
                base.Draw(g);
            }
Пример #8
0
        private void mainPnl_DoubleClick(object sender, EventArgs e)
        {
            MouseEventArgs ea = (MouseEventArgs)e;

            if (ea.Button == MouseButtons.Left)
            {
                System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Fuchsia);
                System.Drawing.Pen        myPen   = new System.Drawing.Pen(myBrush);
                myPen.Width = myPen.Width * 12;
                myGraphics  = mainPnl.CreateGraphics();
                myGraphics.DrawRectangles(myPen, allGraphics.ToArray());
            }
            else
            {
                this.Hide();
                this.SendToBack();
            }
        }
Пример #9
0
        public void DrawRectangles()
        {
            //////////////////////////////////////
            /// 采用 .net 绘制
            //////////////////////////////////////
            //初始
            System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(HWND_WinWorkbook);
            Rectangle rectExcel       = GetClientRect(HWND_WinWorkbook); //主区域

            //参考线
            int left = 40;
            int top  = 40;
            Pen pen  = new Pen(Color.Red, 4);

            g.DrawRectangles(pen,
                             new Rectangle[]
            {
                //大框
                new Rectangle
                (
                    0,
                    0,
                    rectExcel.Width - 1,
                    rectExcel.Height - 1
                ),
                //参考线
                new Rectangle
                (
                    0 + left,
                    0 + top,
                    rectExcel.Width - left * 2 - 1,
                    rectExcel.Height - top * 2 - 1
                ),
                //参考线
                new Rectangle
                (
                    0 + left * 2,
                    0 + top * 2,
                    rectExcel.Width - left * 4 - 1,
                    rectExcel.Height - top * 4 - 1
                ),
            });
            //End of DrawRectangles
        }
Пример #10
0
        public void DrawRectangles(Pen pen, RectD[] rects, bool fill = false)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }
            if (rects == null)
            {
                throw new ArgumentNullException("rects");
            }

            lock (bitmapLock) {
                double maxX = 0.0d;
                double maxY = 0.0d;

                for (long i = 0L; i < rects.LongLength; i++)
                {
                    if (rects[i].X + rects[i].Width > maxX)
                    {
                        maxX = rects[i].X + rects[i].Width;
                    }
                    if (rects[i].Y + rects[i].Height > maxY)
                    {
                        maxY = rects[i].Y + rects[i].Height;
                    }
                }

                TryExpand(0.0d, 0.0d, maxX, maxY, pen.Width);
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) {
                    g.SmoothingMode = (Antialiasing) ? SmoothingMode.AntiAlias : SmoothingMode.None;
                    if (fill)
                    {
                        g.FillRectangles(pen.Brush, ToRectangleFArray(rects));
                    }
                    else
                    {
                        g.DrawRectangles(pen, ToRectangleFArray(rects));
                    }
                }
                Texturize();
            }
        }
Пример #11
0
        void DrawSegments(Graphics grfx, RectangleF rectClip)
        {
            int penWidth = 3;

            if (LicenseManager.UsageMode == LicenseUsageMode.Runtime)
            {
                //рисование границ кубов
                if (PresentationController.Instance != null && PresentationController.Instance.CurrentSlideLayout != null)
                {
                    ISegmentationSupport disp = PresentationController.Instance.CurrentSlideLayout.Display as ISegmentationSupport;
                    if (disp != null)
                    {
                        float x = 0;
                        float y = 0;
                        List<RectangleF> rects = new List<RectangleF>();
                        for (int i = 0; i < disp.SegmentColumns; ++i)
                        {
                            for (int j = 0; j < disp.SegmentRows; j++)
                            {
                                RectangleF rect = new RectangleF(x, y, disp.SegmentWidth, disp.SegmentHeight);

                                if (rect.IntersectsWith(rectClip))
                                    rects.Add(rect);

                                y += disp.SegmentHeight + penWidth + 1;
                            }

                            x += disp.SegmentWidth + penWidth + 1;
                            y = 0;
                        }

                        if (rects.Count > 0)
                        {
                            Pen p = new Pen(new SolidBrush(Color.FromArgb(180, Color.Indigo)), penWidth);
                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                            grfx.DrawRectangles(p, rects.ToArray());
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Draws the check hot.
        /// </summary>
        /// <param name="graph">The graph.</param>
        /// <param name="rect">The rect.</param>
        private static void DrawCheckHot(this System.Drawing.Graphics graph, Rectangle rect)
        {
            LinearGradientBrush fillBrush;
            Pen hotPen;

            fillBrush = new LinearGradientBrush(rect, CustomColors.CheckBoxHoverLight, CustomColors.CheckBoxHoverDark, LinearGradientMode.ForwardDiagonal);
            float[] relativeIntensities = { 0F, 0.7F, 1F };
            float[] relativePositions   = { 0F, 0.5F, 1F };
            Blend   blend = new Blend();

            blend.Factors   = relativeIntensities;
            blend.Positions = relativePositions;
            fillBrush.Blend = blend;
            hotPen          = new Pen(fillBrush, 1);
            Rectangle rect1 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
            Rectangle rect2 = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4);

            graph.DrawRectangles(hotPen, new Rectangle[] { rect1, rect2 });
            fillBrush.Dispose();
            hotPen.Dispose();
        }
Пример #13
0
 public void GenerateMap()
 {
     MapBox.CreateGraphics().Clear(AppWindow.DefaultBackColor);
     int w = 0, h = 0;
     try
     {
         w = Convert.ToInt32(TXTWidth.Text);
         h = Convert.ToInt32(TXTHeight.Text);
     }
     catch
     {
         Console.WriteLine("Input string is not a sequence of digits or Overflow");
         w = 20;
         h = 20;
     }
     paintMap = new Bitmap(MapBox.Size.Width, MapBox.Size.Height);
     g = Graphics.FromImage(paintMap);
     nodes = new MapNodes(w + 2, h + 2, MapBox.Size.Height); // + 2 is borders
     g.DrawRectangles(stdPen, nodes.nodeRect);
     FillBorderNodes();
     GenerateNoise();
     MapBox.Image = paintMap;
 }
Пример #14
0
        //测试用
        public void DrawTest()
        {
            //////////////////////////////////////
            /// 采用 .net 绘制
            //////////////////////////////////////
            //初始
            System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(HWND_WinWorkbook);
            Rectangle rectExcel       = GetClientRect(HWND_WinWorkbook); //主区域

            Pen pen = new Pen(Color.Red, 20);

            g.DrawRectangles(pen,
                             new Rectangle[]
            {
                //大框
                new Rectangle
                (
                    60,
                    60,
                    rectExcel.Width - 60 * 2 - 1,
                    rectExcel.Height - 60 * 2 - 1
                ),
            });
        }
Пример #15
0
        protected virtual void PaintBlackBands(Graphics g)
        {
            if (this.videoRenderer != null)
            {
                Trace.WriteLineIf(trace.TraceInfo, "PaintBlackBands()");

                Rectangle[] alRectangles = GetBlackBands();
                if (alRectangles.Length > 0)
                {
                    g.FillRectangles(new SolidBrush(Settings.VideoBackgroundColor), alRectangles);
                    g.DrawRectangles(new System.Drawing.Pen(Settings.VideoBackgroundColor), alRectangles);
                }
            }
        }
Пример #16
0
 private void histogramPanel_Paint(object sender, PaintEventArgs e)
 {
     Rectangle[] rectArr = new Rectangle[6]; 
     histogramGraphics = histogramPanel.CreateGraphics();
     for(int i = 0; i < quantityArray.Length; i++)
     {
         if(i==0)
         {
             Rectangle rect = new Rectangle(5, 388-quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 1)
         {
             Rectangle rect = new Rectangle(105, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 2)
         {
             Rectangle rect = new Rectangle(205, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 3)
         {
             Rectangle rect = new Rectangle(305, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 4)
         {
             Rectangle rect = new Rectangle(405, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 5)
         {
             Rectangle rect = new Rectangle(505, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
     }
     histogramGraphics.DrawRectangles(myPen, rectArr);
 }
Пример #17
0
        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            PointF pix1 = this.Location.TransformTopLeft(pane);
            PointF pix2 = this.Location.TransformBottomRight(pane);

            //RectangleF pixRect = this.Location.TransformRect(pane);
            RectangleF pixRect = new RectangleF(Math.Min(pix1.X, pix2.X), Math.Min(pix1.Y, pix2.Y),
                            Math.Abs(pix2.X - pix1.X), Math.Abs(pix2.Y - pix1.Y));

            //System.Diagnostics.Debug.WriteLine(string.Format("box {0} {1}", pix1, pix2));

            // Clip the rect to just outside the PaneRect so we don't end up with wild coordinates.
            RectangleF tmpRect = pane.Rect;
            tmpRect.Inflate(20, 20);
            pixRect.Intersect(tmpRect);

            if (Math.Abs(pixRect.Left) < 100000 &&
                Math.Abs(pixRect.Top) < 100000 &&
                Math.Abs(pixRect.Right) < 100000 &&
                Math.Abs(pixRect.Bottom) < 100000)
            {
                // If the box is to be filled, fill it
                _fill.Draw(g, pixRect);

                // Draw the border around the box if required
                //_border.Draw( g, pane, scaleFactor, pixRect );

                if (_border.IsVisible)
                {
                    var smode = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    RectangleF tRect = pixRect;

                    float scaledInflate = (float)(_border.InflateFactor * scaleFactor);
                    tRect.Inflate(scaledInflate, scaledInflate);

                    using (Pen pen = _border.GetPen(pane, scaleFactor))
                    {
                        if (IsMoving)
                        {
                            // Set the DashCap to round.
                            pen.DashCap = DashCap.Round;

                            // Create a custom dash pattern.
                            pen.DashPattern = new float[] { 4.0F, 4.0F };
                        }

                        g.DrawRectangle(pen, tRect.X, tRect.Y, tRect.Width, tRect.Height);

                        if (IsSelected)
                        {
                            Brush brush = new SolidBrush(Color.White);

                            g.FillRectangles(brush, EdgeRects(pane));

                            pen.DashStyle = DashStyle.Solid;

                            g.DrawRectangles(pen, EdgeRects(pane));
                        }
                    }

                    g.SmoothingMode = smode;
                }
            }
        }
Пример #18
0
        public override void DrawAt(Point basePoint, Graphics g)
        {
            base.DrawAt(basePoint, g);

            Rectangle rect = new Rectangle(Point.Empty, this.RectInPage.Size);
            Bitmap bm = new Bitmap(this.RectInPage.Width, this.RectInPage.Height);
            Graphics gp = Graphics.FromImage(bm);

            Color backColor = Color.FromArgb((int)(this.Alpha * 255), this.BackgroundColor);

            /* SliderSwitch的长条形主体 */
            int x = 0;
            int y = 0;
            int width = 0;
            int height = 0;
            if ((null == this.BackgroundImage) || (string.Empty == this.BackgroundImage))
            {
                if (EFlatStyle.Stereo == this.FlatStyle)
                {
                    /* 绘制立体效果,三色渐变 */
                    LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical);
                    Color[] colors = new Color[3];
                    colors[0] = ColorHelper.changeBrightnessOfColor(backColor, 100);
                    colors[1] = backColor;
                    colors[2] = ColorHelper.changeBrightnessOfColor(backColor, -50);
                    ColorBlend blend = new ColorBlend();
                    blend.Positions = new float[] { 0.0f, 0.3f, 1.0f };
                    blend.Colors = colors;
                    brush.InterpolationColors = blend;
                    FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f);
                    brush.Dispose();
                }
                else if (EFlatStyle.Flat == this.FlatStyle)
                {
                    SolidBrush brush = new SolidBrush(backColor);
                    FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f);
                }
            }

            /* 左图标 */
            x = PADDING;  // 偏移为5
            y = PADDING;  // 
            height = rect.Height - 2 * y;   // 计算出高度
            width = rect.Height > SUBVIEW_WIDTH ? rect.Height : SUBVIEW_WIDTH;     // 计算出宽度
            width -= 2 * x;
            Image img = null;
            if (!string.IsNullOrEmpty(this.LeftImage))
            {
                img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.LeftImage));
            }

            if (null != img)
            {
                gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y);
            }

            /* 右图标 */
            x = rect.Width - PADDING - width;
            /*Image*/
            img = null;
            if (!string.IsNullOrEmpty(this.RightImage))
            {
                img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.RightImage));
            }

            if (null != img)
            {
                gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y);
            }

            /* 中间数字 */
            string valueString = null;
            if (KNXDigitalAdjustment.EDigitalNumber.OneDigit == this.DigitalNumber)
            {
                valueString = "8";
            }
            else if (KNXDigitalAdjustment.EDigitalNumber.TwoDigit == this.DigitalNumber)
            {
                valueString = "88";
            }
            else if (KNXDigitalAdjustment.EDigitalNumber.ThreeDigit == this.DigitalNumber)
            {
                valueString = "888";
            }

            if (null != valueString)
            {
                valueString += this.Unit.GetDescription();

                Color fontColor = this.FontColor;
                Font font = new Font("宋体", this.FontSize);
                StringFormat format = new StringFormat();

                format.Alignment = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;
                Size size = TextRenderer.MeasureText(valueString, font);
                x = PADDING;
                y = PADDING;
                width = rect.Width - 2 * x;
                height = rect.Height - 2 * y;
                Rectangle rectText = new Rectangle(rect.X+x, rect.Y+y, width, height);
                gp.DrawString(valueString, font, new SolidBrush(fontColor), rectText, format);
            }

            if (EBool.Yes == this.DisplayBorder)
            {
                Color borderColor = this.BorderColor;
                DrawRoundRectangle(gp, new Pen(borderColor, 1), rect, this.Radius, 1.0f);
            }

            g.DrawImage(bm,
                this.VisibleRectInPage,
                new Rectangle(new Point(this.VisibleRectInPage.X - this.RectInPage.X, this.VisibleRectInPage.Y - this.RectInPage.Y), this.VisibleRectInPage.Size),
                GraphicsUnit.Pixel);

            this.FrameIsVisible = false;
            if (ControlState.Move == this.State)
            {
                Pen pen = new Pen(Color.Navy, 2.0f);
                DrawRoundRectangle(g, pen, this.RectInPage, this.Radius, 1.0f);
            }
            else if (this.IsSelected)
            {
                this.SetFrame();
                Pen pen = new Pen(Color.LightGray, 1.0f);
                pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
                g.DrawLine(pen, this.LinePoints[0], this.LinePoints[1]);
                g.DrawLine(pen, this.LinePoints[2], this.LinePoints[3]);
                g.DrawLine(pen, this.LinePoints[4], this.LinePoints[5]);
                g.DrawLine(pen, this.LinePoints[6], this.LinePoints[7]);
                g.DrawLine(pen, this.LinePoints[8], this.LinePoints[9]);
                g.DrawLine(pen, this.LinePoints[10], this.LinePoints[11]);
                g.DrawLine(pen, this.LinePoints[12], this.LinePoints[13]);
                g.DrawLine(pen, this.LinePoints[14], this.LinePoints[15]);

                g.FillRectangles(Brushes.White, this.SmallRects); //填充8个小矩形的内部
                g.DrawRectangles(Pens.Black, this.SmallRects);  //绘制8个小矩形的黑色边线

                this.FrameIsVisible = true;
            }
        }
Пример #19
0
        private void DrawBars(Graphics g)
        {
            if (_sc == null || _sc.GpsControl == null || _sc.GpsControl.Satellites == null) return;

            if(_sc.GpsControl.AllSatellitesLoaded)
            {
                _lastSats = _sc.GpsControl.Satellites.ToArray();
            }
            //Wait for the inital satellite readings first
            if (_lastSats == null) return;

            //The number of satellites to draw
            int numBars = _lastSats.Length;
            float barWidth = ((Width - LeftMargin - RightMargin) / (float)numBars) - 4f;

            float x = LeftMargin;

            //g.Clear(BackColor);

            RectangleF recId;
            RectangleF recBar;
            StringFormat sfCenter = new StringFormat {Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center};

            Satellite satTemp;

            //recId = new RectangleF(x, Height - BottomMargin, barWidth, BottomMargin);

            g.DrawString("ID:", Font, Brushes.Lime, new RectangleF(0, Height - BottomMargin, LeftMargin, BottomMargin),
                         sfCenter);

            for (int i = 0; i < numBars; i++)
            {
                satTemp = _lastSats[i];
                if (satTemp.Snr < 0) satTemp.Snr = 0;
                x += 2;

                recBar = new RectangleF(x, TopMargin, barWidth, Height - TopMargin - BottomMargin);

                //SNR
                g.FillRectangle(_lgb, x, (Height - BottomMargin) - (float)(satTemp.Snr * _pxPerAmp), barWidth, (float)(satTemp.Snr * _pxPerAmp));

                //Gray out the unused satellites a little
                if(!satTemp.IsUsed)
                {
                    g.FillRectangle(new SolidBrush(Color.FromArgb(145, Color.Gray)), x, (Height - BottomMargin) - (float)(satTemp.Snr * _pxPerAmp), barWidth, (float)(satTemp.Snr * _pxPerAmp));
                }

                g.DrawString(satTemp.Snr.ToString("F0"), Font, satTemp.IsUsed ? Brushes.Lime : Brushes.DarkGray, recBar, sfCenter);

                recId = new RectangleF(x, Height - BottomMargin, barWidth, BottomMargin);

                //Draw ID
                g.DrawString(satTemp.Id.ToString(), Font, satTemp.IsUsed ? Brushes.Lime : Brushes.DarkGray, recId, sfCenter);

                //Tyler: I did this becuase there is no DrawRectangle method that accepts a RectangleF
                g.DrawRectangles(Pens.DimGray, new[] { recBar });

                x += barWidth;

                x += 2;
            }

            //for (int x = LeftMargin; x < Width - RightMargin; x+=barWidth)
            //{

            //}
        }
Пример #20
0
        public void DrawSelection(Control ctrl, Graphics formGraphics)
        {
            int size = 6;
            Brush horBorderBrush = new TextureBrush(new Bitmap(WixFiles.GetResourceStream("hcontrolborder.bmp")));
            Brush verBorderBrush = new TextureBrush(new Bitmap(WixFiles.GetResourceStream("vcontrolborder.bmp")));

            Rectangle topBorder = new Rectangle(ctrl.Left, ctrl.Top - size - 1, ctrl.Width, size + 1);
            Rectangle bottomBorder = new Rectangle(ctrl.Left, ctrl.Bottom, ctrl.Width, size + 1);

            formGraphics.FillRectangles(horBorderBrush, new Rectangle[] {topBorder, bottomBorder});

            Rectangle rightBorder = new Rectangle(ctrl.Right, ctrl.Top, size + 1, ctrl.Height);
            Rectangle leftBorder = new Rectangle(ctrl.Left - size - 1, ctrl.Top, size + 1, ctrl.Height);

            formGraphics.FillRectangles(verBorderBrush, new Rectangle[] {rightBorder, leftBorder});

            Rectangle leftTop = new Rectangle(ctrl.Left - size - 1, ctrl.Top - size - 1, size, size);
            Rectangle rightTop = new Rectangle(ctrl.Right, ctrl.Top - size - 1, size, size);

            Rectangle leftBottom = new Rectangle(ctrl.Left - size - 1, ctrl.Bottom, size, size);
            Rectangle rightBottom = new Rectangle(ctrl.Right, ctrl.Bottom, size, size);

            Rectangle leftMid = new Rectangle(ctrl.Left - size - 1, ctrl.Top + (ctrl.Height-size)/2, size, size);
            Rectangle rightMid = new Rectangle(ctrl.Right, ctrl.Top + (ctrl.Height-size)/2, size, size);

            Rectangle midBottom = new Rectangle(ctrl.Left + (ctrl.Width-size)/2, ctrl.Bottom, size, size);
            Rectangle midTop = new Rectangle(ctrl.Left + (ctrl.Width-size)/2, ctrl.Top - size - 1, size, size);

            formGraphics.FillRectangles(Brushes.White, new Rectangle[] {leftTop, rightTop, leftBottom, rightBottom, leftMid, rightMid, midBottom, midTop});
            formGraphics.DrawRectangles(Pens.Black, new Rectangle[] {leftTop, rightTop, leftBottom, rightBottom, leftMid, rightMid, midBottom, midTop});
        }
Пример #21
0
        //边框和锚点的大小位置计算完毕后,我们开始实际的绘制操作:
        public void Draw(Graphics g)
        {
            try
            {
                this.BringToFront();
                g.FillRectangles(Brushes.LightGray, BoundRect); //填充用于调整的边框的内部
                g.FillRectangles(Brushes.White, SmallRect); //填充8个锚点的内部
                g.DrawRectangles(Pens.Black, SmallRect); //绘制8个锚点的黑色边线

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #22
0
        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw( Graphics g, PaneBase pane, float scaleFactor )
        {
            if ( _points != null && _points.Count > 1 )
            {
                using ( GraphicsPath path = MakePath( pane ) )
                {
                    // Fill or draw the symbol as required
                    if ( _fill.IsVisible )
                    {
                        using ( Brush brush = this.Fill.MakeBrush( path.GetBounds() ) )
                            g.FillPath( brush, path );
                    }

                    if ( _border.IsVisible )
                    {
                        var sm = g.SmoothingMode;

                        g.SmoothingMode = SmoothingMode.AntiAlias;

                        using (Pen pen = _border.GetPen(pane, scaleFactor))
                        {
                            if (IsMoving)
                            {
                                // Set the DashCap to round.
                                pen.DashCap = DashCap.Round;

                                // Create a custom dash pattern.
                                pen.DashPattern = new float[] { 4.0F, 4.0F };
                            }

                            g.DrawPath(pen, path);

                            if (!_isClosedFigure)
                            {
                                PointF lastPt = path.GetLastPoint();
                                PointF firstPt = path.PathPoints[0];

                                // Set the DashCap to round.
                                pen.DashCap = DashCap.Round;

                                // Create a custom dash pattern.
                                pen.DashPattern = new float[] { 4.0F, 4.0F };

                                g.DrawLine(pen, firstPt.X, firstPt.Y, lastPt.X, lastPt.Y);
                            }

                            if (IsSelected)
                            {
                                Brush brush = new SolidBrush(Color.White);

                                g.FillRectangles(brush, EdgeRects(pane));

                                pen.DashStyle = DashStyle.Solid;

                                g.DrawRectangles(pen, EdgeRects(pane));
                            }
                        }

                        g.SmoothingMode = sm;
                    }
                }
            }
        }
Пример #23
0
        private static void DrawGridQuad(Graphics g, TmxMap tmxMap)
        {
            HashSet<Point> points = new HashSet<Point>();
            for (int x = 0; x < GetMaxTilesWide(tmxMap); ++x)
            {
                for (int y = 0; y < GetMaxTilesHigh(tmxMap); ++y)
                {
                    // Add the "top-left" corner of a tile
                    points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y));

                    // Add all other corners of the tile to our list of grid points
                    // This is complicated by different map types (espcially staggered isometric)
                    if (tmxMap.Orientation == TmxMap.MapOrientation.Orthogonal || tmxMap.Orientation == TmxMap.MapOrientation.Isometric)
                    {
                        points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y));
                        points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y + 1));
                        points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                    }
                    else if (tmxMap.Orientation == TmxMap.MapOrientation.Staggered)
                    {
                        bool sx = TmxMath.DoStaggerX(tmxMap, x);
                        bool sy = TmxMath.DoStaggerY(tmxMap, y);

                        if (sx)
                        {
                            // top-right, bottom-right, and bottom-left
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x - 1, y + 1));
                        }
                        else if (sy)
                        {
                            // top-right, bottom-right, and bottom-left
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 2));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                        }
                        else if (tmxMap.StaggerAxis == TmxMap.MapStaggerAxis.X)
                        {
                            // top-right, bottom-right, and bottom-left
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x - 1, y));
                        }
                        else if (tmxMap.StaggerAxis == TmxMap.MapStaggerAxis.Y)
                        {
                            // top-right, bottom-right, and bottom-left
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 2));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x - 1, y + 1));
                        }
                    }
                }
            }

            // Can take for granted that background is always white
            List<RectangleF> rectangles = new List<RectangleF>(points.Count);
            foreach (var p in points)
            {
                RectangleF rc = new RectangleF(p.X, p.Y, PreviewImage.GridSize, PreviewImage.GridSize);
                rc.Offset(-PreviewImage.GridSize * 0.5f, -PreviewImage.GridSize * 0.5f);
                rectangles.Add(rc);
            }

            g.DrawRectangles(Pens.Black, rectangles.ToArray());
        }
Пример #24
0
        void DrawHelper(AnimationTrack track, Graphics g)
        {
            PointF[] helperPoints = GetHelperPoints(track);

            // helper bounds.
            PointF[] helperBound = new PointF[] {
                helperPoints[0],
                helperPoints[1],
                helperPoints[2],
                helperPoints[3],
                helperPoints[0]};

            // helper corner bounds.
            RectangleF[] helperRects = new RectangleF[]{
                new RectangleF( // top-left
                    helperPoints[0].X - HelperKitWidth * 0.5f, helperPoints[0].Y - HelperKitWidth * 0.5f,
                    HelperKitWidth, HelperKitWidth),
                new RectangleF( // top-right
                    helperPoints[1].X - HelperKitWidth * 0.5f, helperPoints[1].Y - HelperKitWidth * 0.5f,
                    HelperKitWidth, HelperKitWidth),
                new RectangleF( // bottom-left
                    helperPoints[2].X - HelperKitWidth * 0.5f, helperPoints[2].Y - HelperKitWidth * 0.5f,
                    HelperKitWidth, HelperKitWidth),
                new RectangleF( // bottom-right
                    helperPoints[3].X - HelperKitWidth * 0.5f, helperPoints[3].Y - HelperKitWidth * 0.5f,
                    HelperKitWidth, HelperKitWidth)};

            // helper center.
            PointF[] helperCenter = new PointF[] {
                helperPoints[4] - new SizeF(-HelperKitWidth, 0),
                helperPoints[4] - new SizeF(0, +HelperKitWidth),
                helperPoints[4] - new SizeF(+HelperKitWidth, 0),
                helperPoints[4] - new SizeF(0, -HelperKitWidth),
                helperPoints[4] - new SizeF(-HelperKitWidth, 0),
                helperPoints[4] - new SizeF(+HelperKitWidth, 0),
                helperPoints[4] - new SizeF(0, +HelperKitWidth),
                helperPoints[4] - new SizeF(0, -HelperKitWidth)};

            // draw the image.
            g.Transform = new Matrix();
            g.DrawLines(mHelperPen, helperBound);
            g.DrawRectangles(mHelperPen, helperRects);
            g.DrawLines(mHelperPen, helperCenter);
        }
Пример #25
0
        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            RectangleF pixRect = this.Location.TransformRect(pane);

            //GraphPane gPane = pane as GraphPane;

            //System.Diagnostics.Trace.WriteLine("XScale " + gPane.XAxis.Scale);
            //System.Diagnostics.Trace.WriteLine("YScale " + gPane.YAxis.Scale);

            //System.Diagnostics.Trace.WriteLine(pixRect.X);

            if (Math.Abs(pixRect.Left) < 100000 &&
                    Math.Abs(pixRect.Top) < 100000 &&
                    Math.Abs(pixRect.Right) < 100000 &&
                    Math.Abs(pixRect.Bottom) < 100000)
            {
                GraphicsState state = g.Save();

                g.SmoothingMode = SmoothingMode.AntiAlias;

                Matrix matrix = g.Transform;

                matrix.RotateAt(Angle, Center(pixRect));
                //matrix.Rotate(Angle);

                g.Transform = matrix;
                if (_fill.IsVisible)
                    using (Brush brush = _fill.MakeBrush(pixRect))
                        g.FillEllipse(brush, pixRect);

                if (_border.IsVisible)
                    using (Pen pen = _border.GetPen(pane, scaleFactor))
                    {
                        if (IsMoving)
                        {
                            // Set the DashCap to round.
                            pen.DashCap = DashCap.Round;

                            // Create a custom dash pattern.
                            pen.DashPattern = new float[] { 4.0F, 4.0F };
                        }

                        g.DrawEllipse(pen, pixRect);

                        if (IsSelected)
                        {
                            Brush brush = new SolidBrush(Color.White);

                            g.FillRectangles(brush, EdgeRects(pane));

                            pen.DashStyle = DashStyle.Solid;

                            g.DrawRectangles(pen, EdgeRects(pane));
                        }
                    }

                g.Restore(state);
            }
        }
Пример #26
0
		/// <summary>ビュー座標系に変換された長方形をグラフィクスに描き出します。(IVirtualShapeの実装)</summary>
		/// <param name="g"></param>
		public override void RenderToView(Graphics g)
			{
			PointF p = ParentGraphics.FromGlobalToView( Location );
			SizeF s = DoesGlobalScale ? ParentGraphics.ActualViewScale * Size : Size;
			if( s.Width < 0 )
				{
				p.X += s.Width;
				s.Width = -s.Width;
				}
			if( s.Height < 0 )
				{
				p.Y += s.Height;
				s.Height = -s.Height;
				}

			RectangleF r = new RectangleF( p, s );

			g.FillRectangle( ShapeFill, r );
			g.DrawRectangles( ShapeBorder, new RectangleF[] { r } );
			}
Пример #27
0
        public override void DrawAt(Point basePoint, Graphics g)
        {
            base.DrawAt(basePoint, g);

            Rectangle rect = new Rectangle(Point.Empty, this.RectInPage.Size);
            Bitmap bm = new Bitmap(this.RectInPage.Width, this.RectInPage.Height);
            Graphics gp = Graphics.FromImage(bm);

            Color backColor = Color.FromArgb((int)(this.Alpha * 255), this.BackgroundColor);
            
            if ((null == this.BackgroundImage) || (string.Empty == this.BackgroundImage))
            {
                if (EFlatStyle.Stereo == this.FlatStyle)
                {
                    /* 绘制立体效果,三色渐变 */
                    LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical);
                    Color[] colors = new Color[3];
                    colors[0] = ColorHelper.changeBrightnessOfColor(backColor, 100);
                    colors[1] = backColor;
                    colors[2] = ColorHelper.changeBrightnessOfColor(backColor, -50);
                    ColorBlend blend = new ColorBlend();
                    blend.Positions = new float[] { 0.0f, 0.3f, 1.0f };
                    blend.Colors = colors;
                    brush.InterpolationColors = blend;
                    FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f);
                    brush.Dispose();
                }
                else if (EFlatStyle.Flat == this.FlatStyle)
                {
                    SolidBrush brush = new SolidBrush(backColor);
                    FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f);
                    brush.Dispose();
                }
            }

            /* 文本 */
            if (null != this.Text)
            {
                int x = 5;
                int y = 5;
                int width = rect.Width - 2 * x;
                int height = rect.Height - 2 * y;

                Rectangle stateRect = new Rectangle(rect.X + x, rect.Y + y, width, height);
                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                Color fontColor = this.FontColor;
                gp.DrawString(this.Text, new Font("宋体", this.FontSize), new SolidBrush(fontColor), stateRect, sf);
            }

            if (EBool.Yes == this.DisplayBorder)
            {
                Color borderColor = this.BorderColor;
                DrawRoundRectangle(gp, new Pen(borderColor, 1), rect, this.Radius, 1.0f);
            }

            g.DrawImage(bm, 
                this.VisibleRectInPage,
                new Rectangle(new Point(this.VisibleRectInPage.X-this.RectInPage.X, this.VisibleRectInPage.Y-this.RectInPage.Y), this.VisibleRectInPage.Size),
                GraphicsUnit.Pixel);

            this.FrameIsVisible = false;
            if (ControlState.Move == this.State)
            {
                Pen pen = new Pen(Color.Navy, 2.0f);
                DrawRoundRectangle(g, pen, this.RectInPage, this.Radius, 1.0f);
            }
            else if (this.IsSelected)
            {
                this.SetFrame();
                Pen pen = new Pen(Color.LightGray, 1.0f);
                pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
                g.DrawLine(pen, this.LinePoints[0], this.LinePoints[1]);
                g.DrawLine(pen, this.LinePoints[2], this.LinePoints[3]);
                g.DrawLine(pen, this.LinePoints[4], this.LinePoints[5]);
                g.DrawLine(pen, this.LinePoints[6], this.LinePoints[7]);
                g.DrawLine(pen, this.LinePoints[8], this.LinePoints[9]);
                g.DrawLine(pen, this.LinePoints[10], this.LinePoints[11]);
                g.DrawLine(pen, this.LinePoints[12], this.LinePoints[13]);
                g.DrawLine(pen, this.LinePoints[14], this.LinePoints[15]);

                g.FillRectangles(Brushes.White, this.SmallRects); //填充8个小矩形的内部
                g.DrawRectangles(Pens.Black, this.SmallRects);  //绘制8个小矩形的黑色边线

                this.FrameIsVisible = true;
            }
        }
Пример #28
0
        public void DrawPartition(string selected, string test, string scenario)
        {
            panel_analysis_partition_picture.Height = (int)(this.Height * 0.85);

            //backgroundimage width height를 해상도 받아온 것으로 해야함 - 뒤에 숫자.
            panel_analysis_partition_picture.Width = (int)(panel_analysis_partition_picture.Height * ((double)720 / (double)1280)); //0.5625
            bitmap = new Bitmap(panel_analysis_partition_picture.Width, panel_analysis_partition_picture.Height);
            panel_analysis_partition_picture.Location = new Point((int)(this.Width / 2) - panel_analysis_partition_left.Width, 20);

            //기존에 설정되어 있던 컨트롤 다 지우기
            panel_analysis_partition_picture2.Controls.Remove(pic);
            pic = new PictureBox();
            pic.Parent = panel_analysis_partition_picture2;
            panel_analysis_partition_picture2.Controls.Add(pic);
            pic.Location = new Point(0, 0);




            Image image;
            image = Image.FromFile(@"C:\Users\" + Environment.UserName + "\\Dropbox\\IMAGE\\" + project_name + "\\" + cb_analysis_partition_selectImage.SelectedItem);
            pic.BackgroundImage = Bitmap.FromFile(@"C:\Users\" + Environment.UserName + "\\Dropbox\\IMAGE\\" + project_name + "\\" + cb_analysis_partition_selectImage.SelectedItem); ;
            pic.Size = panel_analysis_partition_picture.Size;
            pic.BackgroundImageLayout = ImageLayout.Stretch;

            pic.BringToFront();
            gr = pic.CreateGraphics();
            gr = Graphics.FromImage(pic.BackgroundImage);

            //gr.FillRectangle(br, new RectangleF(new PointF((float)100.1, (float)100.4), new Size((int)each_width, (int)each_height)));


            //초기화
            //--panel_analysis_partition_picture2.Controls.Clear();

            count.Clear();
            //pictures.Clear();

            //--Image image;
            //--image = Image.FromFile(@"C:\Users\" + Environment.UserName + "\\Dropbox\\IMAGE\\" + project_name + "\\" + cb_analysis_partition_selectImage.SelectedItem);
            //panel_analysis_partition_picture2.BackgroundImage = image;
            //panel_analysis_partition_picture2.BackgroundImageLayout = ImageLayout.Stretch;

            //화면분할할 때 각 칸의 가로세로 길이
            w_count = Convert.ToInt16(tb_analysis_partition_hori.Text);
            h_count = Convert.ToInt16(tb_analysis_partition_verti.Text);
            //each_width = (float)panel_analysis_partition_picture.Width / (float)w_count;
            //each_height = (float)panel_analysis_partition_picture.Height / (float)h_count;
            each_width = (float)image.Width / (float)w_count;
            each_height = (float)image.Height / (float)h_count;
            ratio = (double)panel_analysis_partition_picture.Width / (double)image.Width;

            for (int j = 0; j < h_count; j++)
            {
                for (int i = 0; i < w_count; i++)
                {
                    ////네모칸의 횟수만큼 0 카운트 추가
                    count.Add(0);
                }
            }


            //combobox에서 정해준 이미지의 인덱스 찾기
            int index = 0;
            for (int i = 0; i < pTotal_data.Count; i++)
            {
                if (pTotal_data[i].image_name.CompareTo(selected) == 0)
                {
                    index = i;
                    break;
                }
            }

            int click = 0;

            if (test.CompareTo("모두보기") == 0)
            {
                try
                {
                    for (int u = 0; u < pTotal_data[index].event_data.Count; u++)
                    {
                        if (pTotal_data[index].scenario_name.CompareTo(scenario) == 0)
                        {
                            for (int j = 0, k = 0; j < h_count; j++)
                            {
                                for (int i = 0; i < w_count; i++)
                                {
                                    if ((pTotal_data[index].event_data[u].xcoord >= (i * each_width)) && (pTotal_data[index].event_data[u].xcoord <= ((i + 1) * each_width)))
                                    {
                                        if ((pTotal_data[index].event_data[u].ycoord >= (j * each_height)) && (pTotal_data[index].event_data[u].ycoord <= ((j + 1) * each_height)))
                                        {
                                            click++;
                                            count[k]++;
                                            break;
                                        }
                                    }
                                    k++;
                                }
                            }
                        }
                    }
                }
                catch (ArgumentOutOfRangeException ae)
                {

                }

            }
            else
            {
                try
                {
                    for (int u = 0; u < pTotal_data[index].event_data.Count; u++)
                    {
                        //선택한 test 번호에 맞는 것만.
                        if (pTotal_data[index].scenario_name.CompareTo(scenario) == 0 && pTotal_data[index].event_data[u].test_num == Convert.ToInt16(test))
                        {
                            for (int j = 0, k = 0; j < h_count; j++)
                            {
                                for (int i = 0; i < w_count; i++)
                                {
                                    if ((pTotal_data[index].event_data[u].xcoord >= (i * each_width)) && (pTotal_data[index].event_data[u].xcoord <= ((i + 1) * each_width)))
                                    {
                                        if ((pTotal_data[index].event_data[u].ycoord >= (j * each_height)) && (pTotal_data[index].event_data[u].ycoord <= ((j + 1) * each_height)))
                                        {
                                            click++;
                                            count[k]++;
                                            break;
                                        }
                                    }
                                    k++;
                                }
                            }
                        }
                    }
                }
                catch (ArgumentOutOfRangeException ae)
                {

                }
            }

            label_click.Text = "클릭 수 : " + click.ToString() + "회";

            //for (int i = 0; i < pTotal_data[index].event_data.Count; i++)
            //{
            //    MessageBox.Show(pTotal_data[index].event_data[i].img);
            //}
            //체류시간, 방문횟수
            double entireTime = 0, shortestTime = 99999, longestTime = 0;

            //for (int i = 0; i < pTotal_data[index].event_data.Count; i++)
            //{

            //    if(pTotal_data[index].scenario_name.CompareTo(scenario) == 0 && pTotal_data[index].event_data[i].test_num == Convert.ToInt16(test))
            //    {
            //        entireTime += pTotal_data[index].event_data[i].timeImg;
            //        //최장체류시간
            //        if (longestTime < pTotal_data[index].event_data[i].timeImg)
            //        {
            //            longestTime = pTotal_data[index].event_data[i].timeImg;
            //        }
            //        //최단체류시간
            //        try
            //        {
            //            if (pTotal_data[index].event_data[i].img.CompareTo(pTotal_data[index].event_data[i + 1].img) != 0)
            //            {
            //                if (shortestTime > pTotal_data[index].event_data[i].timeImg)
            //                {
            //                    shortestTime = pTotal_data[index].event_data[i].timeImg;
            //                }
            //            }
            //        }
            //        catch (ArgumentOutOfRangeException ae)
            //        {
            //            if (shortestTime > pTotal_data[index].event_data[i].timeImg)
            //            {
            //                shortestTime = pTotal_data[index].event_data[i].timeImg;
            //            }
            //        }
            //    }
            //}

            //모두보기에서는 현재 에러남
            //int visit = 0;
            //bool visit_flag = false;
            //for (int i = 0; i < pTotal_data[index].event_data.Count; i++)
            //{
            //    if (pTotal_data[index].scenario_name.CompareTo(scenario) == 0 && pTotal_data[index].event_data[i].img.CompareTo(selected) == 0 && pTotal_data[index].event_data[i].test_num == Convert.ToInt16(test))
            //    {
            //        if(pTotal_data[index].event_data[i].timeEntire - pTotal_data[index].event_data[i].timeImg != pTotal_data[index].event_data[i - 1].timeImg)
            //        {
            //            //if (visit_flag == false)
            //            //{
            //                visit++;
            //            //}
            //            //visit_flag = true;
            //        }
            //    }
            //    else
            //    {
            //        //visit_flag = false;
            //    }
            //}

            //if (click == 0)
            //{
            //    label_time.Text = "체류 시간 : 0z초";
            //    label_longest.Text = "최장 체류 시간 : 0초";
            //    label_shortest.Text = "최단 체류 시간 : 0초";
            //    //label_visit.Text = "방문 횟수 : 0회";
            //}
            //else
            //{
            //    label_time.Text = "체류 시간 : " + entireTime + "초";
            //    label_longest.Text = "최장 체류 시간 : " + longestTime + "초";
            //    label_shortest.Text = "최단 체류 시간 : " + shortestTime + "초";
            //    //label_visit.Text = "방문 횟수 : " + visit + "회";
            //}

            RectangleF[] rects = { new RectangleF(0,0, each_width, each_height) };
            
            int count_index = 0;
            for (int j = 0; j < h_count; j++)
            {
                for (int i = 0; i < w_count; i++)
                {
                    rects[0].Location = new PointF((float)(i * each_width), (float)(j * each_height));
                    gr.DrawRectangles(new Pen(Color.Red, 1), rects);
                    if (count[count_index] > 0)
                    {
                        if (count[count_index] < (pTotal_data[index].event_data.Count / 9))
                        {
                            br = new SolidBrush(SetColor(180, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 8))
                        {
                            br = new SolidBrush(SetColor(160, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 7))
                        {
                            br = new SolidBrush(SetColor(140, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 6))
                        {
                            br = new SolidBrush(SetColor(120, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 5))
                        {
                            br = new SolidBrush(SetColor(100, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 4))
                        {
                            br = new SolidBrush(SetColor(80, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 3))
                        {
                            br = new SolidBrush(SetColor(60, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 2))
                        {
                            br = new SolidBrush(SetColor(40, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 1))
                        {
                            br = new SolidBrush(SetColor(20, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                    }
                    count_index++;
                }
            }
        }
Пример #29
0
        public override void DrawAt(Point basePoint, Graphics g)
        {
            base.DrawAt(basePoint, g);

            Rectangle rect = new Rectangle(Point.Empty, this.RectInPage.Size);
            Bitmap bm = new Bitmap(this.RectInPage.Width, this.RectInPage.Height);
            Graphics gp = Graphics.FromImage(bm);

            Color backColor = Color.FromArgb((int)(this.Alpha * 255), this.BackgroundColor);

            if ((null == this.BackgroundImage) || (string.Empty == this.BackgroundImage))
            {
                if (EFlatStyle.Flat == this.FlatStyle)
                {
                    SolidBrush brush = new SolidBrush(backColor);
                    FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f);
                }
            }

            if (EBool.Yes == this.DisplayBorder)
            {
                Color borderColor = this.BorderColor;
                DrawRoundRectangle(gp, new Pen(borderColor, 1), rect, this.Radius, 1.0f);
            }

            g.DrawImage(bm,
                this.VisibleRectInPage,
                new Rectangle(new Point(this.VisibleRectInPage.X - this.RectInPage.X, this.VisibleRectInPage.Y - this.RectInPage.Y), this.VisibleRectInPage.Size),
                GraphicsUnit.Pixel);

            foreach (ViewNode node in this.Nodes)
            {
                if (MyConst.Controls.KnxGroupBoxType != node.Name)
                {
                    node.DrawAt(LocationInPage, g);
                }
            }

            foreach (ViewNode node in this.Nodes)
            {
                if (MyConst.Controls.KnxGroupBoxType == node.Name)
                {
                    node.DrawAt(LocationInPage, g);
                }
            }

            this.FrameIsVisible = false;
            if (ControlState.Move == this.State)
            {
                Pen pen = new Pen(Color.Navy, 2.0f);
                DrawRoundRectangle(g, pen, this.RectInPage, this.Radius, 1.0f);
            }
            else if (this.IsSelected)
            {
                this.SetFrame();
                Pen pen = new Pen(Color.LightGray, 1.0f);
                pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
                g.DrawLine(pen, this.LinePoints[0], this.LinePoints[1]);
                g.DrawLine(pen, this.LinePoints[2], this.LinePoints[3]);
                g.DrawLine(pen, this.LinePoints[4], this.LinePoints[5]);
                g.DrawLine(pen, this.LinePoints[6], this.LinePoints[7]);
                g.DrawLine(pen, this.LinePoints[8], this.LinePoints[9]);
                g.DrawLine(pen, this.LinePoints[10], this.LinePoints[11]);
                g.DrawLine(pen, this.LinePoints[12], this.LinePoints[13]);
                g.DrawLine(pen, this.LinePoints[14], this.LinePoints[15]);

                g.FillRectangles(Brushes.White, this.SmallRects); //填充8个小矩形的内部
                g.DrawRectangles(Pens.Black, this.SmallRects);  //绘制8个小矩形的黑色边线

                this.FrameIsVisible = true;

                int centerX;
                int centerY;
                int SideMobile = 16;
                if ((this.LinePoints[1].X - this.LinePoints[0].X) > SideMobile)
                {
                    centerX = this.LinePoints[0].X + (this.LinePoints[1].X - this.LinePoints[0].X) / 2;
                    centerY = this.LinePoints[0].Y;
                }
                else
                {
                    centerX = this.SmallRects[0].X + this.SmallRects[0].Width / 2;
                    centerY = this.SmallRects[0].Y + this.SmallRects[0].Height / 2;
                }

                int lX = centerX - SideMobile / 2;
                int lY = centerY - SideMobile / 2;

                this.MobileRect = new Rectangle(new Point(lX, lY), new Size(SideMobile, SideMobile));

                g.DrawRectangle(Pens.Black, this.MobileRect);
                g.FillRectangle(Brushes.White, this.MobileRect);
                GraphicsPath path = new GraphicsPath();
                int x1 = this.MobileRect.X + this.MobileRect.Width / 2;
                int y1 = this.MobileRect.Y;

                int xr1 = x1 + 3;
                int yr1 = y1 + 3;

                int xl1 = x1 - 3;
                int yl1 = y1 + 3;
                path.AddLines(new Point[]{new Point(x1, y1), new Point(xr1, yr1), new Point(xl1, yl1)});
                g.DrawPath(Pens.Black, path);
                g.FillPath(Brushes.Black, path);

                int x2 = this.MobileRect.Right;
                int y2 = this.MobileRect.Y + this.MobileRect.Height / 2;
                int xb2 = x2 - 3;
                int yb2 = y2 + 3;
                int xt2 = x2 - 3;
                int yt2 = y2 - 3;
                path.Reset();
                path.AddLines(new Point[] { new Point(x2, y2), new Point(xb2, yb2), new Point(xt2, yt2) });
                g.DrawPath(Pens.Black, path);
                g.FillPath(Brushes.Black, path);

                int x3 = x1;
                int y3 = this.MobileRect.Bottom;
                int xl3 = x3 - 3;
                int yl3 = y3 - 3;
                int xr3 = x3 + 3;
                int yr3 = y3 - 3;
                path.Reset();
                path.AddLines(new Point[] { new Point(x3, y3), new Point(xl3, yl3), new Point(xr3, yr3) });
                g.DrawPath(Pens.Black, path);
                g.FillPath(Brushes.Black, path);

                int x4 = this.MobileRect.Left;
                int y4 = y2;
                int xt4 = x4 + 3;
                int yt4 = y4 - 3;
                int xb4 = x4 + 3;
                int yb4 = y4 + 3;
                path.Reset();
                path.AddLines(new Point[] { new Point(x4, y4), new Point(xt4, yt4), new Point(xb4, yb4) });
                g.DrawPath(Pens.Black, path);
                g.FillPath(Brushes.Black, path);

                g.DrawLine(Pens.Black, x1, y1, x3, y3);
                g.DrawLine(Pens.Black, x2, y2, x4, y4);
            }
        }
Пример #30
0
        /// <summary>
        /// 绘图
        /// </summary>
        public void Draw()
        {
            Console.WriteLine("FrameControl:" + "InitializeComponent:");

            g = this.CreateGraphics();

            SolidBrush brush = new SolidBrush(Color.Black);
            g.FillRegion(brush, Region);

            this.BringToFront();

            Pen pen = new Pen(Color.LightGray, 0.8f);
            pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
            g.DrawLine(pen, linePoints[0], linePoints[1]);
            g.DrawLine(pen, linePoints[2], linePoints[3]);
            g.DrawLine(pen, linePoints[4], linePoints[5]);
            g.DrawLine(pen, linePoints[6], linePoints[7]);
            g.DrawLine(pen, linePoints[8], linePoints[9]);
            g.DrawLine(pen, linePoints[10], linePoints[11]);
            g.DrawLine(pen, linePoints[12], linePoints[13]);
            g.DrawLine(pen, linePoints[14], linePoints[15]);

            g.FillRectangles(Brushes.White, smallRects); //填充8个小矩形的内部

            pen.Width = 2.0f;
            pen.DashStyle = DashStyle.Solid;
            pen.Color = Color.Black;
            g.DrawRectangles(pen, smallRects);  //绘制8个小矩形的黑色边线
        }
Пример #31
0
        private void DrawMarks(Graphics g, MarkCollection marks, Color markColor)
        {
            Rectangle[] rectangles = marks.GetRectanglesForVisibleMarks(this);

            if (rectangles == null || rectangles.Length == 0)
                return;

            if (AddinSettings.Instance.FilledMarks)
            {
                List<Rectangle> rectsToFilling = new List<Rectangle>();

                uint nativeBorderColor = (uint)markColor.R | (uint)markColor.G << 8 | (uint)markColor.B << 16;

                IntPtr hdc = g.GetHdc();

                for (int i = 0; i < rectangles.Length; i++)
                {
                    var rect = rectangles[i];

                    int score = 0;
                    if (Gdi32.GetPixel(hdc, rect.Left, rect.Top) == nativeBorderColor) score++;
                    if (Gdi32.GetPixel(hdc, rect.Left, rect.Bottom) == nativeBorderColor) score++;
                    if (score < 2 && Gdi32.GetPixel(hdc, rect.Right, rect.Bottom) == nativeBorderColor) score++;
                    if (score < 2 && Gdi32.GetPixel(hdc, rect.Right, rect.Top) == nativeBorderColor) score++;

                    bool isBorderDrawn = score >= 2;

                    if (!isBorderDrawn)
                        rectsToFilling.Add(rect);
                }

                g.ReleaseHdc();

                if (rectsToFilling.Count > 0)
                {
                    using (var bodyBrush = new SolidBrush(Color.FromArgb(32, markColor)))
                        g.FillRectangles(bodyBrush, rectsToFilling.ToArray());

                    //using (var borderPen = new Pen(markColor))
                    //    g.DrawRectangles(borderPen, rectsToFilling.ToArray());
                }
            }

            //Draw borders
            using (var borderPen = new Pen(markColor))
                g.DrawRectangles(borderPen, rectangles);
        }
Пример #32
0
        private void drawNodes(IEnumerable<ICoordinate> nodes, Graphics g, MapToClientDelegate MapToClient, Color color, int offsetX, int offsetY)
        {
            if (nodes.Count() <= 0)
                return;

            using (Pen p = new Pen(color))
            {
                Point[] points = new Point[nodes.Count()];

                int i = 0;
                foreach (ICoordinate c in nodes)
                {
                    points[i] = MapToClient(c);
                    points[i].X += offsetX;
                    points[i].Y += offsetY;
                    i++;
                }

                Rectangle[] rectangles = new Rectangle[points.Length];

                int ns = this.NodeSize;
                for (i = 0; i < points.Length; i++)
                    rectangles[i] = new Rectangle((int)points[i].X - ns,
                        (int)points[i].Y - ns, ns * 2, ns * 2);

                using (Brush b = new SolidBrush(color))
                {
                    g.FillRectangles(b, rectangles);
                }
                g.DrawRectangles(p, rectangles);
            }
        }
Пример #33
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);

            g.FillRectangle(Brushes.White, MainScreen.Width, 0, 256, MainScreen.Height);

            g.DrawString(string.Format("Game Object Num : {0}\r\n", this.SceneObjList.Count)
                        + this.GetGameObjectList(), this.DefaultFont, Brushes.Black, MainScreen.Width, 20);

            g.DrawRectangles(Pens.Yellow, this.ObjTree.GetBounds(new List<Rectangle>()).ToArray());

            g.DrawString(string.Format("Pos : {0} , {1}", GetPlayer().pos.X, GetPlayer().pos.Y),
                        this.DefaultFont, Brushes.Black, MainScreen.Width, 0);
        }
Пример #34
0
        public override void DrawAt(Point basePoint, Graphics g)
        {
            base.DrawAt(basePoint, g);

            Rectangle rect = new Rectangle(Point.Empty, this.RectInPage.Size);
            Bitmap bm = new Bitmap(this.RectInPage.Width, this.RectInPage.Height);
            Graphics gp = Graphics.FromImage(bm);

            Color backColor = Color.FromArgb((int)(this.Alpha * 255), this.BackgroundColor);

            /* SliderSwitch的长条形主体 */
            int x = 0;
            int y = SLIDER_EDGE_WIDTH;  // 
            int width = rect.Width;
            int height = rect.Height - 2 * y;
            Rectangle rect1 = new Rectangle(rect.X+x, rect.Y+y, width, height);
            if ((null == this.BackgroundImage) || (string.Empty == this.BackgroundImage))
            {
                if (EFlatStyle.Stereo == this.FlatStyle)
                {
                    /* 绘制立体效果,三色渐变 */
                    LinearGradientBrush brush = new LinearGradientBrush(rect1, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical);
                    Color[] colors = new Color[3];
                    colors[0] = ColorHelper.changeBrightnessOfColor(backColor, 100);
                    colors[1] = backColor;
                    colors[2] = ColorHelper.changeBrightnessOfColor(backColor, -50);
                    ColorBlend blend = new ColorBlend();
                    blend.Positions = new float[] { 0.0f, 0.3f, 1.0f };
                    blend.Colors = colors;
                    brush.InterpolationColors = blend;
                    FillRoundRectangle(gp, brush, rect1, this.Radius, 1.0f);
                    brush.Dispose();
                }
                else if (EFlatStyle.Flat == this.FlatStyle)
                {
                    SolidBrush brush = new SolidBrush(backColor);
                    FillRoundRectangle(gp, brush, rect1, this.Radius, 1.0f);
                }
            }

            /* 左图标 */
            x = PADDING;  // 偏移为5
            y = SLIDER_EDGE_WIDTH + PADDING;  // 
            height = rect.Height - 2 * y;   // 计算出高度
            width = height;     // 计算出宽度
            Image img = null;
            if (!string.IsNullOrEmpty(this.LeftImage))
            {
                img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.LeftImage));
            }
            if (null != img)
            {
                gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y);
            }

            /* 右图标 */
            x = rect.Width - PADDING - width;
            img = null;
            if (!string.IsNullOrEmpty(this.RightImage))
            {
                img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.RightImage));
            }
            if (null != img)
            {
                gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y);
            }

            /* 中间滑块 */
            width = SLIDER_WIDTH;
            x = rect.Width / 2 - width / 2;
            y = 0;
            height = rect.Height;
            Rectangle rect2 = new Rectangle(rect.X+x,rect.Y+y, width, height);
            Color sliderColor = ColorHelper.changeBrightnessOfColor(backColor, 70);
            LinearGradientBrush sliderBrush = new LinearGradientBrush(rect2, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical);
            Color[] sliderColors = new Color[3];
            sliderColors[0] = ColorHelper.changeBrightnessOfColor(sliderColor, 100);
            sliderColors[1] = sliderColor;
            sliderColors[2] = ColorHelper.changeBrightnessOfColor(sliderColor, -30);
            ColorBlend sliderBlend = new ColorBlend();
            sliderBlend.Positions = new float[] { 0.0f, 0.3f, 1.0f };
            sliderBlend.Colors = sliderColors;
            sliderBrush.InterpolationColors = sliderBlend;
            FillRoundRectangle(gp, sliderBrush, rect2, this.Radius, .0f);
            sliderBrush.Dispose();

            if (EBool.Yes == this.DisplayBorder)
            {
                Color borderColor = this.BorderColor;
                DrawRoundRectangle(gp, new Pen(borderColor, 1), rect, this.Radius, 1.0f);
            }

            g.DrawImage(bm, 
                this.VisibleRectInPage, 
                new Rectangle(new Point(this.VisibleRectInPage.X - this.RectInPage.X, this.VisibleRectInPage.Y - this.RectInPage.Y), this.VisibleRectInPage.Size), 
                GraphicsUnit.Pixel);

            this.FrameIsVisible = false;
            if (ControlState.Move == this.State)
            {
                Pen pen = new Pen(Color.Navy, 2.0f);
                DrawRoundRectangle(g, pen, this.RectInPage, this.Radius, 1.0f);
            }
            else if (this.IsSelected)
            {
                this.SetFrame();
                Pen pen = new Pen(Color.LightGray, 1.0f);
                pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
                g.DrawLine(pen, this.LinePoints[0], this.LinePoints[1]);
                g.DrawLine(pen, this.LinePoints[2], this.LinePoints[3]);
                g.DrawLine(pen, this.LinePoints[4], this.LinePoints[5]);
                g.DrawLine(pen, this.LinePoints[6], this.LinePoints[7]);
                g.DrawLine(pen, this.LinePoints[8], this.LinePoints[9]);
                g.DrawLine(pen, this.LinePoints[10], this.LinePoints[11]);
                g.DrawLine(pen, this.LinePoints[12], this.LinePoints[13]);
                g.DrawLine(pen, this.LinePoints[14], this.LinePoints[15]);

                g.FillRectangles(Brushes.White, this.SmallRects); //填充8个小矩形的内部
                g.DrawRectangles(Pens.Black, this.SmallRects);  //绘制8个小矩形的黑色边线

                this.FrameIsVisible = true;
            }
        }