Inheritance: MarshalByRefObject, IDisposable
Esempio n. 1
1
        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                borderDotPen.DashOffset = (float)timer.Elapsed.TotalSeconds * 10;
                borderDotPen2.DashOffset = 5 + (float)timer.Elapsed.TotalSeconds * 10;

                using (Region region = new Region(regionFillPath))
                {
                    g.Clip = region;
                    g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                    g.ResetClip();
                }

                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawPath(borderDotPen2, regionFillPath);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen2, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
Esempio n. 2
1
        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                if (Config.UseDimming)
                {
                    using (Region region = new Region(regionFillPath))
                    {
                        g.Clip = region;
                        g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                        g.ResetClip();
                    }
                }

                g.DrawPath(borderPen, regionFillPath);
                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawLine(borderPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
Esempio n. 3
0
 protected override void OnPaint(PaintEventArgs e)
 {
     Region region = new Region(e.ClipRectangle);
     e.Graphics.FillRegion(this.backBrush, region);
     if (base.Items.Count > 0)
     {
         for (int i = 0; i < base.Items.Count; i++)
         {
             Rectangle itemRectangle = base.GetItemRectangle(i);
             if (e.ClipRectangle.IntersectsWith(itemRectangle))
             {
                 if ((this.SelectionMode == SelectionMode.One && this.SelectedIndex == i) || (this.SelectionMode == SelectionMode.MultiSimple && base.SelectedIndices.Contains(i)) || (this.SelectionMode == SelectionMode.MultiExtended && base.SelectedIndices.Contains(i)))
                 {
                     this.OnDrawItem(new DrawItemEventArgs(e.Graphics, this.Font, itemRectangle, i, DrawItemState.Selected, this.ForeColor, this.BackColor));
                 }
                 else
                 {
                     this.OnDrawItem(new DrawItemEventArgs(e.Graphics, this.Font, itemRectangle, i, DrawItemState.Default, this.ForeColor, this.BackColor));
                 }
                 region.Complement(itemRectangle);
             }
         }
     }
     base.OnPaint(e);
 }
Esempio n. 4
0
 public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion)
 {
     using (var solidBrush = new SolidBrush(LineColor))
     {
         g.FillRectangle(solidBrush, 0.0f, 0.0f, HorizontalWidth, height);
     }
 }
Esempio n. 5
0
        public static Region GetConnectionRegion(NodeConnection connection)
        {
            var to		= connection.To;
            var from	= connection.From;
            RectangleF toBounds;
            RectangleF fromBounds;
            if (to.Node.Collapsed)		toBounds = to.Node.inputBounds;
            else						toBounds = to.bounds;
            if (from.Node.Collapsed)	fromBounds = from.Node.outputBounds;
            else						fromBounds = from.bounds;

            var x1 = (fromBounds.Left + fromBounds.Right) / 2.0f;
            var y1 = (fromBounds.Top + fromBounds.Bottom) / 2.0f;
            var x2 = (toBounds.Left + toBounds.Right) / 2.0f;
            var y2 = (toBounds.Top + toBounds.Bottom) / 2.0f;

            Region region;
            float centerX;
            float centerY;
            using (var linePath = GetArrowLinePath(	x1, y1, x2, y2, out centerX, out centerY, true, 5.0f))
            {
                region = new Region(linePath);
            }
            return region;
        }
 public void Invalidate(Region region)
 {
     if (this.behaviorService != null)
     {
         this.behaviorService.Invalidate(region);
     }
 }
Esempio n. 7
0
 public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion)
 {
     using (var solidBrush = new SolidBrush(LineColor))
     {
         g.FillRectangle(solidBrush, 0.0f, 0.0f, width, VerticalHeight);
     }
 }
Esempio n. 8
0
 private void Form1_Load(object sender, EventArgs e)
 {
     // Cut the form
     System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath();
     myPath.AddPolygon(new Point[] { new Point(0, 0), new Point(0, this.Height), new Point(this.Width, 0) });
     Region myRegion = new Region(myPath); this.Region = myRegion;
 }
Esempio n. 9
0
        public Stream RoundedCorner(Stream imageStream)
        {
            var targetStream = new MemoryStream();
            var originalImage = Image.FromStream(imageStream);
            var targetImage = new Bitmap(57, 57);
            var g = Graphics.FromImage(targetImage);
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.CompositingQuality = CompositingQuality.HighQuality;

            var rect = new Rectangle(0, 0, targetImage.Width, targetImage.Height);
            var rectPath = GetRoundPath(0, 0, targetImage.Width, targetImage.Height, targetImage.Width / 9f);

            var r = new Region(rectPath);
            g.Clip = r;
            Brush b = new SolidBrush(Color.FromArgb(30, 255, 255, 255));

            //图片缩放
            g.DrawImage(originalImage, rect, new Rectangle(0, 0, originalImage.Width, originalImage.Height), GraphicsUnit.Pixel);

            g.DrawPath(new Pen(b), rectPath);
            g.FillPie(b, -targetImage.Width * (0.309f), -targetImage.Height / 2f, targetImage.Width * (1 / 0.618f), targetImage.Height, 0, 360);
            //g.FillPath(b, rectPath);
            g.Dispose();
            targetImage.Save(targetStream, ImageFormat.Png);
            targetImage.Dispose();
            originalImage.Dispose();

            targetStream.Position = 0;

            return targetStream;
        }
Esempio n. 10
0
		public void PaintSelection(SelectionRendererEventArgs info)
		{
			Rectangle inside=info.Bounds;
			inside.Inflate(1,1);
			inside.Width--;
			inside.Height--;
			Rectangle outside=info.Bounds;
			outside.Inflate(info.Width,info.Width);
			outside.Width--;
			outside.Height--;

			if(!info.BorderColor.IsEmpty)
			{
				using(Pen pen=new Pen(info.BorderColor,1))
				{
					info.Graphics.DrawRectangle(pen,inside);
					info.Graphics.DrawRectangle(pen,outside);
				}
			}

			if(!info.FillColor.IsEmpty)
			{
				using(SolidBrush brush=new SolidBrush(info.FillColor))
				{
					Region region=new Region(outside);
					region.Exclude(inside);
					info.Graphics.FillRegion(brush,region);
				}
			}
		}
Esempio n. 11
0
   private int MeasureTextWidth(TreeNode tn)
   {
      if (tn == null | tn.TreeView == null)
         return 0;

      TreeView tree = tn.TreeView;
      String text = this.GetText(tn);
      if (text == null || text == "")
         return 0;

      Graphics g = Graphics.FromHwnd(tree.Handle);

      using (Font font = new Font(tree.Font, tn.FontStyle))
      {
         using (StringFormat format = new StringFormat(StringFormat.GenericDefault))
         {
            RectangleF rect = new RectangleF(0, 0, 1000, 1000);
            CharacterRange[] ranges = { new CharacterRange(0, text.Length) };
            Region[] regions = new Region[1];

            format.SetMeasurableCharacterRanges(ranges);
            format.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;

            regions = g.MeasureCharacterRanges(text, font, rect, format);
            rect = regions[0].GetBounds(g);

            return (int)rect.Right + 3 + (int)(text.Length * 0.25);
         }
      }
   }
Esempio n. 12
0
 public FormDashboard()
 {
     InitializeComponent();
     // закругление углов формы
     border = GetRoundedRectanglePath(this.Bounds, new SizeF(5, 5));
     region = new Region(border);
 }
Esempio n. 13
0
		private void DrawPointerDown(Graphics g)
		{
			Point[] points = new Point[] { new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1), new Point(ThumbBounds.Left, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), ThumbBounds.Location, new Point(ThumbBounds.Right - 1, ThumbBounds.Top), new Point(ThumbBounds.Right - 1, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1) };
			GraphicsPath path = new GraphicsPath();
			path.AddLines(points);
			Region region = new Region(path);
			g.Clip = region;

			if (ThumbState == 3 || !base.Enabled)
				ControlPaint.DrawButton(g, ThumbBounds, ButtonState.All);
			else
				g.Clear(SystemColors.Control);

			g.ResetClip();
			region.Dispose();
			path.Dispose();
			Point[] pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLightLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDarkDark, pointArray2);
			points[0].Offset(0, -1);
			points[1].Offset(1, 0);
			points[2].Offset(1, 1);
			points[3].Offset(-1, 1);
			points[4].Offset(-1, 0);
			points[5] = points[0];
			pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDark, pointArray2);
		}
Esempio n. 14
0
 public void child_Paint(object sender, PaintEventArgs e)
 {
     GraphicsPath path = new GraphicsPath();
     path.AddEllipse(this.ClientRectangle);
     Region region = new Region(path);
     this.Region = region;
 }
Esempio n. 15
0
        public BBControl(int X, int Y, int dx, int dy)
        {
            InitializeComponent();
            this.Location = new Point(X, Y);
            Random rannd = new Random();
            this.dx = dx;
            this.dy = dy;
            while (dy == 0)
            {
                this.dy = rannd.Next(-50, 50);
            }
            while (dx == 0)
            {
                this.dx = rannd.Next(-50, 50);
            }
            Color color = Color.FromArgb(rannd.Next(255), rannd.Next(255), rannd.Next(255));
            while (color == Color.White)
            {
                color = Color.FromArgb(rannd.Next(255), rannd.Next(255), rannd.Next(255));
            }
            this.BackColor = color;
            this.Width = 2 * rannd.Next(2, 25);
            this.Height = this.Width;

            System.Drawing.Drawing2D.GraphicsPath Button_Path = new System.Drawing.Drawing2D.GraphicsPath();

            Button_Path.AddEllipse(0, 0, this.Width, this.Height);

            Region Button_Region = new Region(Button_Path);

            this.Region = Button_Region;

            thread = new Thread(DoWork);
            thread.Start();
        }
Esempio n. 16
0
        protected override void Draw(Graphics g)
        {
            g.SmoothingMode = SmoothingMode.HighQuality;

            regionFillPath = new GraphicsPath();

            for (int i = 0; i < nodes.Count - 1; i++)
            {
                regionFillPath.AddLine(nodes[i].Position, nodes[i + 1].Position);
            }

            if (nodes.Count > 2)
            {
                regionFillPath.CloseFigure();

                using (Region region = new Region(regionFillPath))
                {
                    g.Clip = region;
                    g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                    g.ResetClip();
                }

                g.DrawRectangleProper(borderPen, currentArea);
            }

            if (nodes.Count > 1)
            {
                g.DrawPath(borderPen, regionFillPath);
                g.DrawPath(borderDotPen, regionFillPath);
            }

            base.Draw(g);
        }
Esempio n. 17
0
 private void CreateRegion()
 {
     using (GraphicsPath path = CreatePath(ClientRectangle))
     {
         Region = new Region(path);
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Проверяет попадание точки в фигуру
        /// </summary>
        /// <param name="p"></param>
        /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
        public override int ContainsPoint(Point p)
        {
            if (this.IsSelected)
            {
                for (int i = 1; i <= KeyPoints.Length; i++)
                {
                    if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
                        return i;
                }
            }

            var path = new GraphicsPath();
            Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);

            Rectangle rect = NormalRectToSquare(PaintHelper.NormalizeRect(StartPoint, EndPoint));
            path.AddEllipse(rect);
            path.Widen(pen);

            Region region = new Region(path);
            pen.Dispose();
            if(region.IsVisible(p))
                return 0;

            Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
            double radius = rect.Width / 2;
            float dx = p.X - center.X;
            float dy = p.Y - center.Y;
            if (Math.Sqrt(dx * dx + dy * dy) <= radius)
                return 0;
            return -1;
        }
        protected override void Draw(Graphics g)
        {
            regionFillPath = new GraphicsPath();

            for (int i = 0; i < nodes.Count - 1; i++)
            {
                regionFillPath.AddLine(nodes[i].Position, nodes[i + 1].Position);
            }

            if (nodes.Count > 2)
            {
                regionFillPath.CloseFigure();

                using (Region region = new Region(regionFillPath))
                {
                    g.ExcludeClip(region);
                    g.FillRectangle(shadowBrush, 0, 0, Width, Height);
                    g.ResetClip();
                }

                g.DrawRectangleProper(borderPen, currentArea);
            }
            else
            {
                g.FillRectangle(shadowBrush, 0, 0, Width, Height);
            }

            if (nodes.Count > 1)
            {
                g.DrawPath(borderPen, regionFillPath);
            }

            base.Draw(g);
        }
 protected override void OnPaint(PaintEventArgs e)
 {
     var iRegion = new Region(e.ClipRectangle);
     e.Graphics.FillRegion(new SolidBrush(BackColor), iRegion);
     if (Items.Count > 0)
     {
         for (int i = 0; i < Items.Count; ++i)
         {
             Rectangle irect = GetItemRectangle(i);
             if (e.ClipRectangle.IntersectsWith(irect))
             {
                 if ((SelectionMode == SelectionMode.One && SelectedIndex == i)
                             || (SelectionMode == SelectionMode.MultiSimple && SelectedIndices.Contains(i))
                             || (SelectionMode == SelectionMode.MultiExtended && SelectedIndices.Contains(i)))
                 {
                     OnDrawItem(new DrawItemEventArgs(e.Graphics, Font,
                         irect, i,
                         DrawItemState.Selected, ForeColor,
                         BackColor));
                 }
                 else
                 {
                     OnDrawItem(new DrawItemEventArgs(e.Graphics, Font,
                         irect, i,
                         DrawItemState.Default, ForeColor,
                         BackColor));
                 }
                 iRegion.Complement(irect);
             }
         }
     }
     base.OnPaint(e);
 }
Esempio n. 21
0
        public override void MouseDown(object sender, MouseEventArgs e) {

            if (e.Button == MouseButtons.Left) {
                isMouseDown = true;
                if (CurrentMarker == null && isBegin) {
                    GMapMarker marker = createMarker(rMap1.FromLocalToLatLng(e.X, e.Y));
                }
            } else if (e.Button == MouseButtons.Right) {
                if (isBegin) {
                    //统计设备
                    if(routes.Markers.Count<2)return;

                    List<PS_gt> gtlist = new List<PS_gt>();
                    List<sd_gt> sdlist = new List<sd_gt>();
                    int bl = 1000000;
                    using (GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath()) {
                        List<PointF> list = new List<PointF>();
                        foreach (PointLatLng pll in routes.Polygons[0].Points) {
                            list.Add(new PointF((float)pll.Lng * bl, (float)pll.Lat * bl));

                        }
                        gp.AddPolygon(list.ToArray());
                        Region r = new Region(gp);
                        
                        foreach (GMapOverlay lay in this.rMap1.Overlays) {
                            if (!lay.IsVisibile|| !(lay is LineOverlay)) continue;
                            LineOverlay lo = lay as LineOverlay;
                            foreach (GMapMarker m in lo.Markers) {
                                if (r.IsVisible(new PointF((float)m.Position.Lng * bl, (float)m.Position.Lat * bl))) {
                                    if(m.Tag is PS_gt)
                                        gtlist.Add(m.Tag as PS_gt);
                                    else if(m.Tag is sd_gt)
                                    {
                                        sdlist.Add(m.Tag as sd_gt);
                                    }
                                }

                            }
                        }
                    }
                    if (gtlist.Count>sdlist.Count)
                    {
                        frmQytj dlg = new frmQytj(gtlist);
                        dlg.StartPosition = FormStartPosition.CenterScreen;

                        dlg.Show(this.rMap1);
                    }
                    else
                    {
                        frmSdtj dlg = new frmSdtj(sdlist);
                        dlg.StartPosition = FormStartPosition.CenterScreen;

                        dlg.Show(this.rMap1);
                    }
                   
                   
                }
                isBegin = false;
            }
        }
Esempio n. 22
0
        public ScreenRegionForm(Rectangle regionRectangle, bool activateWindow = true)
        {
            InitializeComponent();

            this.activateWindow = activateWindow;

            borderRectangle = regionRectangle.Offset(1);
            borderRectangle0Based = new Rectangle(0, 0, borderRectangle.Width, borderRectangle.Height);

            Location = borderRectangle.Location;
            int windowWidth = Math.Max(borderRectangle.Width, pInfo.Width);
            Size = new Size(windowWidth, borderRectangle.Height + pInfo.Height + 1);
            pInfo.Location = new Point(0, borderRectangle.Height + 1);

            Region region = new Region(ClientRectangle);
            region.Exclude(borderRectangle0Based.Offset(-1));
            region.Exclude(new Rectangle(0, borderRectangle.Height, windowWidth, 1));
            if (borderRectangle.Width < pInfo.Width)
            {
                region.Exclude(new Rectangle(borderRectangle.Width, 0, pInfo.Width - borderRectangle.Width, borderRectangle.Height));
            }
            else if (borderRectangle.Width > pInfo.Width)
            {
                region.Exclude(new Rectangle(pInfo.Width, borderRectangle.Height + 1, borderRectangle.Width - pInfo.Width, pInfo.Height));
            }
            Region = region;

            Timer = new Stopwatch();
        }
Esempio n. 23
0
        private void MyRender(Surface dst, Surface src)
        {
            PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
            ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
            ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
            int BrushWidth = (int)EnvironmentParameters.BrushWidth;
            if (PGP.Length > 0 && Draw )
            {
                using (Graphics g = new RenderArgs(dst).Graphics)
                {
                    using (Region reg = new Region(selectionRegion.GetRegionData()))
                    {
                        g.SetClip(reg, CombineMode.Replace);
                    }
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    Pen p = new Pen(PrimaryColor);
                    p.Width = BrushWidth;
                    for (int i = 0; i < PGP.Length; i++)
                    {
                        if (PGP[i].PointCount > 0)
                        {

                            g.DrawPath(p, PGP[i]);
                        }
                    }
                }
            }
        }
Esempio n. 24
0
		public void ClipTest_2() {
			Region r = new Region(new Rectangle(10, 10, 60, 60));
			t.Graphics.Clip = r;
			Assert.IsTrue(r.Equals(t.Graphics.Clip, t.Graphics));

			Pen redPen   = new Pen(Color.Red, 3);
			Pen greenPen = new Pen(Color.Green, 3);
			// Create points that define curve.
			Point point1 = new Point( 50,  50);
			Point point2 = new Point(100,  25);
			Point point3 = new Point(200,   5);
			Point point4 = new Point(250,  50);
			Point point5 = new Point(300, 100);
			Point point6 = new Point(350, 200);
			Point point7 = new Point(250, 250);
			Point[] curvePoints = {
									  point1,
									  point2,
									  point3,
									  point4,
									  point5,
									  point6,
									  point7
								  };
			// Draw lines between original points to screen.
			t.Graphics.DrawLines(redPen, curvePoints);
			t.Show ();
			Assert.IsTrue(t.PDCompare(TOLERANCE));
		}
 public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
 {
     Graphics graphics = e.Graphics;
     Bitmap memoryBitmap = viewPortData.MemoryBitmap;
     Rectangle rect = new Rectangle(Point.Empty, memoryBitmap.Size);
     graphics.FillRectangle(AmbientTheme.WorkspaceBackgroundBrush, rect);
     if (((base.parentView.RootDesigner != null) && (base.parentView.RootDesigner.Bounds.Width >= 0)) && (base.parentView.RootDesigner.Bounds.Height >= 0))
     {
         GraphicsContainer container = graphics.BeginContainer();
         Matrix matrix = new Matrix();
         matrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
         Point[] pts = new Point[] { viewPortData.LogicalViewPort.Location };
         matrix.TransformPoints(pts);
         matrix.Translate((float) (-pts[0].X + viewPortData.ShadowDepth.Width), (float) (-pts[0].Y + viewPortData.ShadowDepth.Height), MatrixOrder.Append);
         graphics.Transform = matrix;
         using (Region region = new Region(ActivityDesignerPaint.GetDesignerPath(base.parentView.RootDesigner, false)))
         {
             Region clip = graphics.Clip;
             graphics.Clip = region;
             AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
             graphics.FillRectangle(Brushes.White, base.parentView.RootDesigner.Bounds);
             if (ambientTheme.WorkflowWatermarkImage != null)
             {
                 ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, base.parentView.RootDesigner.Bounds, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false);
             }
             graphics.Clip = clip;
         }
         graphics.EndContainer(container);
     }
 }
Esempio n. 26
0
 protected override void OnPaint(PaintEventArgs e)
 {
     Region iRegion = new Region(e.ClipRectangle);
     e.Graphics.FillRegion(new SolidBrush(this.BackColor), iRegion);
     if (this.Items.Count > 0)
     {
         Debug.WriteLine("Hello");
         for (int i = 0; i < this.Items.Count; ++i)
         {
             System.Drawing.Rectangle irect = this.GetItemRectangle(i);
             if (e.ClipRectangle.IntersectsWith(irect))
             {
                 if ((this.SelectionMode == SelectionMode.One && this.SelectedIndex == i)
                 || (this.SelectionMode == SelectionMode.MultiSimple && this.SelectedIndices.Contains(i))
                 || (this.SelectionMode == SelectionMode.MultiExtended && this.SelectedIndices.Contains(i)))
                 {
                     OnDrawItem(new DrawItemEventArgs(e.Graphics, this.Font,
                         irect, i, DrawItemState.Selected, this.ForeColor,
                         this.BackColor));
                 }
                 else
                 {
                     OnDrawItem(new DrawItemEventArgs(e.Graphics, this.Font,
                         irect, i, DrawItemState.Default, this.ForeColor,
                         this.BackColor));
                 }
                 iRegion.Complement(irect);
             }
         }
     }
     base.OnPaint(e);
 }
Esempio n. 27
0
		public void RegionData_Null ()
		{
			RegionData data = new Region ().GetRegionData ();
			data.Data = null;
			Assert.IsNull (data.Data, "Data");
			Region region = new Region (data);
		}
Esempio n. 28
0
		public void ctor_GraphicsPath () {
			GraphicsPath path = new GraphicsPath ();
			path.AddRectangle (rect);
			Region r1 = new Region (path);
			r1.Xor (r);
			Assert.IsTrue (r1.IsEmpty (t.Graphics));
		}
Esempio n. 29
0
        public Canvas( ImageInfo image, ToolPanel toolInfoPanel )
        {
            myOnParentResizeHandler = new EventHandler( OnParentResize );
            myOnParentMouseEnterHandler = new EventHandler( OnParentMouseEnter );
            myOnParentDisposedHandler = new EventHandler( OnParentDisposed );

            myCurrentLayerIndex = 0;

            myMovingSelected = false;
            mySelectingPixels = false;
            myDrawingPencil = false;
            myDrawingBox = false;

            Image = image;
            myToolPanel = toolInfoPanel;

            mySelectedPixels = new bool[ image.Width, image.Height ];
            mySelectedArea = 0;
            mySelectedRegion = new Region( Rectangle.Empty );
            myScaledRegion = new Region( Rectangle.Empty );

            Size = new Size( image.Width * 8, image.Height * 8 );
            BorderStyle = BorderStyle.FixedSingle;

            DoubleBuffered = true;

            InitializeComponent();
        }
Esempio n. 30
0
        public void GraphicsIsVisibleRectangleF(Graphics g)
        {
            Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
            SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));

            // Create the first rectangle and draw it to the screen in blue.
            g.DrawRectangle(myPen, regionRect1);
            g.FillRectangle (myBrush, regionRect1);

            // Create the second rectangle and draw it to the screen in red.
            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
            g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));

            // Create a region using the first rectangle.
            Region myRegion = new Region(regionRect1);

            // Determine if myRect is contained in the region.
            bool contained = myRegion.IsVisible(regionRect2);

            // Display the result.
            Font myFont = new Font("Arial", 8);
            SolidBrush txtBrush = new SolidBrush(Color.Black);
            g.DrawString("contained = " + contained.ToString(),
                myFont,
                txtBrush,
                new PointF(regionRectF2.Right + 10, regionRectF2.Top));

            regionRect1.Y += 120;
            regionRectF2.Y += 120;
            regionRectF2.X += 41;

            myPen.Color = Color.FromArgb (196, 0xC3, 0xC9, 0xCF);
            myBrush.Color = Color.FromArgb(127, 0xDD, 0xDD, 0xF0);

            // Create the first rectangle and draw it to the screen in blue.
            g.DrawRectangle(myPen, regionRect1);
            g.FillRectangle (myBrush, regionRect1);

            // Create the second rectangle and draw it to the screen in red.
            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
            g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));

            // Create a region using the first rectangle.
            myRegion = new Region(regionRect1);

            // Determine if myRect is contained in the region.
            contained = myRegion.IsVisible(regionRectF2);

            // Display the result.
            g.DrawString("contained = " + contained.ToString(),
                myFont,
                txtBrush,
                new PointF(regionRectF2.Right + 10, regionRectF2.Top));
        }
Esempio n. 31
0
 public virtual void DrawVertical(System.Drawing.Graphics g, Model.LiveSplitState state, float width, System.Drawing.Region clipRegion)
 {
     Reposition(width, VerticalHeight, g);
 }
        public static void UpDateIcons(double BatteryVoltage, bool OffLine, bool Mute, bool TestInProgress)
        {
            if (!TestInProgress)
            {
                if (!ModuleMain.DrainBattery.Enabled)
                {
                    ModuleMain.DrainBattery.Enabled = true;
                }
            }
            else
            {
                if (ModuleMain.DrainBattery.Enabled)
                {
                    ModuleMain.DrainBattery.Enabled = false;
                }
            }


            if (!Mute)
            {
                if (ModuleMain.MuteBeeper.Text != "Enable Beeper")
                {
                    ModuleMain.MuteBeeper.Text = "Enable Beeper";
                }
            }
            else
            {
                if (ModuleMain.MuteBeeper.Text != "Mute Beeper")
                {
                    ModuleMain.MuteBeeper.Text = "Mute Beeper";
                }
            }

            if (OffLine)
            {
                IconCalcPS.PSInfo.GetBatteryPercentage(BatteryVoltage);


                string PerSentStr = IconCalcPS.PSInfo.BatteryPercentage.ToString();

                if (IconCalcPS.PSInfo.BatteryPercentage < 100)
                {
                    if (IconCalcPS.PSInfo.BatteryPercentage < 10)
                    {
                        if (IconCalcPS.PSInfo.BatteryPercentage < 1)
                        {
                            PerSentStr = "   ";
                        }
                        else
                        {
                            PerSentStr = "  " + PerSentStr;
                        }
                    }
                    else
                    {
                        PerSentStr = " " + PerSentStr;
                    }
                }

                System.Drawing.Font       drawFont       = new System.Drawing.Font("Consolas", 70, FontStyle.Bold);
                System.Drawing.SolidBrush DrawBrushRed   = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
                System.Drawing.SolidBrush DrawBrushGreen = new System.Drawing.SolidBrush(System.Drawing.Color.Lime);
                System.Drawing.SolidBrush DrawBrushWhite = new System.Drawing.SolidBrush(System.Drawing.Color.White);

                int    PercentageBattery1         = IconCalcPS.PSInfo.BatteryPercentage1;
                Bitmap bitmap1                    = new Bitmap(100, 100);
                System.Drawing.Graphics graphics1 = System.Drawing.Graphics.FromImage(bitmap1);
                //graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
                System.Drawing.Rectangle DrawRectRed1   = new Rectangle(0, 100 - PercentageBattery1, 100, PercentageBattery1);
                System.Drawing.Region    DrawRegionRed1 = new System.Drawing.Region(DrawRectRed1);
                graphics1.FillRegion(DrawBrushGreen, DrawRegionRed1);
                System.Drawing.Rectangle DrawRectGreen1   = new Rectangle(0, 0, 100, 100 - PercentageBattery1);
                System.Drawing.Region    DrawRegionGreen1 = new System.Drawing.Region(DrawRectGreen1);
                graphics1.FillRegion(DrawBrushRed, DrawRegionGreen1);
                graphics1.DrawString(PerSentStr[0].ToString(), drawFont, DrawBrushWhite, 4, 1);
                Icon createdIcon1 = Icon.FromHandle(bitmap1.GetHicon());
                UPSNotifyIcon1.Icon = createdIcon1;


                int    PercentageBattery2         = IconCalcPS.PSInfo.BatteryPercentage2;
                Bitmap bitmap2                    = new Bitmap(100, 100);
                System.Drawing.Graphics graphics2 = System.Drawing.Graphics.FromImage(bitmap2);
                //graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
                System.Drawing.Rectangle DrawRectRed2   = new Rectangle(0, 100 - PercentageBattery2, 100, PercentageBattery2);
                System.Drawing.Region    DrawRegionRed2 = new System.Drawing.Region(DrawRectRed2);
                graphics2.FillRegion(DrawBrushGreen, DrawRegionRed2);
                System.Drawing.Rectangle DrawRectGreen2   = new Rectangle(0, 0, 100, 100 - PercentageBattery2);
                System.Drawing.Region    DrawRegionGreen2 = new System.Drawing.Region(DrawRectGreen2);
                graphics2.FillRegion(DrawBrushRed, DrawRegionGreen2);
                graphics2.DrawString(PerSentStr[1].ToString(), drawFont, DrawBrushWhite, 4, 1);
                Icon createdIcon2 = Icon.FromHandle(bitmap2.GetHicon());
                UPSNotifyIcon2.Icon = createdIcon2;


                int    PercentageBattery3         = IconCalcPS.PSInfo.BatteryPercentage3;
                Bitmap bitmap3                    = new Bitmap(100, 100);
                System.Drawing.Graphics graphics3 = System.Drawing.Graphics.FromImage(bitmap3);
                //graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
                System.Drawing.Rectangle DrawRectRed3   = new Rectangle(0, 100 - PercentageBattery3, 100, PercentageBattery3);
                System.Drawing.Region    DrawRegionRed3 = new System.Drawing.Region(DrawRectRed3);
                graphics3.FillRegion(DrawBrushGreen, DrawRegionRed3);
                System.Drawing.Rectangle DrawRectGreen3   = new Rectangle(0, 0, 100, 100 - PercentageBattery3);
                System.Drawing.Region    DrawRegionGreen3 = new System.Drawing.Region(DrawRectGreen3);
                graphics3.FillRegion(DrawBrushRed, DrawRegionGreen3);
                graphics3.DrawString(PerSentStr[2].ToString(), drawFont, DrawBrushWhite, 4, 1);
                Icon createdIcon3 = Icon.FromHandle(bitmap3.GetHicon());
                UPSNotifyIcon3.Icon = createdIcon3;


                int    PercentageBattery4         = IconCalcPS.PSInfo.BatteryPercentage4;
                Bitmap bitmap4                    = new Bitmap(100, 100);
                System.Drawing.Graphics graphics4 = System.Drawing.Graphics.FromImage(bitmap4);
                //graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
                System.Drawing.Rectangle DrawRectRed4   = new Rectangle(0, 100 - PercentageBattery4, 100, PercentageBattery4);
                System.Drawing.Region    DrawRegionRed4 = new System.Drawing.Region(DrawRectRed4);
                graphics4.FillRegion(DrawBrushGreen, DrawRegionRed4);
                System.Drawing.Rectangle DrawRectGreen4   = new Rectangle(0, 0, 100, 100 - PercentageBattery4);
                System.Drawing.Region    DrawRegionGreen4 = new System.Drawing.Region(DrawRectGreen4);
                graphics4.FillRegion(DrawBrushRed, DrawRegionGreen4);
                graphics4.DrawString("%", drawFont, DrawBrushWhite, 0, 2);
                Icon createdIcon4 = Icon.FromHandle(bitmap4.GetHicon());
                UPSNotifyIcon4.Icon = createdIcon4;


                UPSNotifyIcon4.Visible = true;
                UPSNotifyIcon3.Visible = true;
                UPSNotifyIcon2.Visible = true;
                UPSNotifyIcon1.Visible = true;
                UPSNotifyIcon.Icon     = Properties.Resources.UtilityFailed;
                UPSNotifyIcon.Text     = "";
            }
            else
            {
                UPSNotifyIcon1.Visible = false;
                UPSNotifyIcon2.Visible = false;
                UPSNotifyIcon3.Visible = false;
                UPSNotifyIcon4.Visible = false;
                UpDateChargingIcon(BatteryVoltage, OffLine);
            }
        }
Esempio n. 33
0
 public void DrawHorizontal(Graphics g, LiveSplitState state, float height, System.Drawing.Region clipRegion)
 {
     DrawBackground(g, state, HorizontalWidth, height);
     PrepareDraw(state, LayoutMode.Horizontal);
     InternalComponent.DrawHorizontal(g, state, height, clipRegion);
 }
Esempio n. 34
0
 public void SetRegion(System.Drawing.Graphics graphics, System.Drawing.Region region)
 {
     hRgnBlur = region.GetHrgn(graphics);
     dwFlags |= DWM_BB.BlurRegion;
 }
Esempio n. 35
0
 public void DrawVertical(System.Drawing.Graphics g, LiveSplitState state, float width, System.Drawing.Region clipRegion)
 {
 }
Esempio n. 36
0
 public virtual void DrawHorizontal(System.Drawing.Graphics g, Model.LiveSplitState state, float height, System.Drawing.Region clipRegion)
 {
     Reposition(HorizontalWidth, height, g);
 }
Esempio n. 37
0
 /// <summary>
 /// Creates an argument to indicate that part of the spreadsheet needs to be redrawn.
 /// </summary>
 /// <param name="region">The invalid part of the spreadsheet.</param>
 public InvalidRegionEventArgs(Region region)
 {
     // Initialize the object
     this.region = region;
 }
 public void DrawHorizontal(Graphics g, LiveSplitState state, float height, System.Drawing.Region clipRegion)
 {
     throw new NotImplementedException();
 }
 public void DrawVertical(Graphics g, LiveSplitState state, float width, System.Drawing.Region clipRegion)
 {
     g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, width, VerticalHeight);
 }
Esempio n. 40
0
 /// <summary>
 /// Enable the Aero "Blur Behind" effect on a specific region of a drawing area. Background must be black.
 /// </summary>
 /// <param name="window">The window.</param>
 /// <param name="graphics">The graphics area on which the region resides.</param>
 /// <param name="region">The region within the client area to apply the blur behind.</param>
 /// <param name="enabled"><c>true</c> to enable blur behind for this region, <c>false</c> to disable it.</param>
 /// <param name="transitionOnMaximized"><c>true</c> if the window's colorization should transition to match the maximized windows; otherwise, <c>false</c>.</param>
 public static void EnableBlurBehind(this IWin32Window window, System.Drawing.Graphics graphics, System.Drawing.Region region, bool enabled, bool transitionOnMaximized)
 {
     if (window == null)
     {
         throw new ArgumentNullException(nameof(window));
     }
     NativeMethods.BlurBehind bb = new NativeMethods.BlurBehind(enabled);
     if (graphics != null && region != null)
     {
         bb.SetRegion(graphics, region);
     }
     if (transitionOnMaximized)
     {
         bb.TransitionOnMaximized = true;
     }
     NativeMethods.DwmEnableBlurBehindWindow(window.Handle, ref bb);
 }
Esempio n. 41
0
        private void CalcWalkableArea()
        {
            if (_battle == null)
            {
                return;
            }

            int width  = _battle.Width / 8;
            int height = _battle.Height / 8;

            Image    image    = new Bitmap(width, height);
            Graphics graphics = Graphics.FromImage(image);

            graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, width, height));

            BTBLib.Region        battleBoundary    = null;
            List <BTBLib.Region> boundaries        = new List <BTBLib.Region>();
            List <BTBLib.Region> inverseBoundaries = new List <BTBLib.Region>();

            foreach (BTBLib.Region region in _battle.Regions)
            {
                if (region.IsClosed)
                {
                    if (region.IsBattleBoundary)
                    {
                        battleBoundary = region;
                    }
                    else if (region.IsBoundaryInversed)
                    {
                        inverseBoundaries.Add(region);
                    }
                    else if (region.IsBoundary)
                    {
                        boundaries.Add(region);
                    }
                }
            }

            if (battleBoundary == null)
            {
                return;
            }

            boundaries.Insert(0, battleBoundary);

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

            foreach (BTBLib.Region region in boundaries)
            {
                Point[] points = new Point[region.Lines.Count];
                for (int i = 0; i < points.Length; ++i)
                {
                    var segment = region.Lines[i];
                    points[i] = new Point(segment.StartX / 8, height - segment.StartY / 8);
                }

                GraphicsPath graphicsPath = new GraphicsPath();
                graphicsPath.AddPolygon(points);

                graphicsRegion.Intersect(graphicsPath);
            }

            foreach (BTBLib.Region region in inverseBoundaries)
            {
                Point[] points = new Point[region.Lines.Count];
                for (int i = 0; i < points.Length; ++i)
                {
                    var segment = region.Lines[i];
                    points[i] = new Point(segment.StartX / 8, height - segment.StartY / 8);
                }

                GraphicsPath graphicsPath = new GraphicsPath();
                graphicsPath.AddPolygon(points);

                graphicsRegion.Exclude(graphicsPath);
            }

            graphics.FillRegion(new SolidBrush(Color.Red), graphicsRegion);

            //Form form = new Form();
            //form.ClientSize = new Size(width * 3, height * 3);
            //PictureBox pictureBox = new PictureBox();
            //pictureBox.Image = image;
            //pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
            //form.Controls.Add(pictureBox);
            //pictureBox.Dock = DockStyle.Fill;
            //form.Show();

            ImageForm form = new ImageForm();

            form.SetImage(image);
            form.ShowDialog();
        }
Esempio n. 42
0
 public void DrawHorizontal(System.Drawing.Graphics g, LiveSplitState state, float height, System.Drawing.Region clipRegion)
 {
 }
Esempio n. 43
0
 public void DrawVertical(Graphics g, LiveSplitState state, float width, System.Drawing.Region clipRegion)
 {
     DrawBackground(g, state, width, VerticalHeight);
     PrepareDraw(state, LayoutMode.Vertical);
     InternalComponent.DrawVertical(g, state, width, clipRegion);
 }