/// <summary> /// <para> /// Initializes a new instance of the Rectangle class with the specified location /// and size. /// </para> /// </summary> public Rectangle(Point location, Size size) { _x = location.X; _y = location.Y; _width = size.Width; _height = size.Height; }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); clickPoint = Cursor.Position; this.Capture = true; }
public static Point RtlTransform(Control control, Point point) { if (control.RightToLeft != RightToLeft.Yes) return point; else return new Point(control.Right - point.X, point.Y); }
public void Click(ScreenDrawingSurface surface, Point location) { var info = surface.Screen.AddEntity(entity, location); var action = new AddEntityAction(info, surface); surface.EditedWithAction(action); surface.ReDrawEntities(); }
public MarkerImage(string path, Size size, Point point, Point anchor) { Path = System.Web.VirtualPathUtility.ToAbsolute(path); Size = size; Point = point; Anchor = anchor; }
Rectangle GetSplitterOutlineBounds(Point ptMouse) { var rectLimit = DragSource.DragLimitBounds; var rect = RectSplitter; if (rectLimit.Width <= 0 || rectLimit.Height <= 0) return rect; if (DragSource.IsVertical) { rect.X += ptMouse.X - StartMousePosition.X; rect.Height = rectLimit.Height; } else { rect.Y += ptMouse.Y - StartMousePosition.Y; rect.Width = rectLimit.Width; } if (rect.Left < rectLimit.Left) rect.X = rectLimit.X; if (rect.Top < rectLimit.Top) rect.Y = rectLimit.Y; if (rect.Right > rectLimit.Right) rect.X -= rect.Right - rectLimit.Right; if (rect.Bottom > rectLimit.Bottom) rect.Y -= rect.Bottom - rectLimit.Bottom; return rect; }
public Rectangle(int longueur, int largeur, Point centre, Color couleur, Point position, float epaisseur, Color couleurFond) : base(centre, couleur, position, epaisseur) { this.Longueur = longueur; this.Largeur = largeur; this.CouleurFond = couleurFond; }
public void ConvertToWindowsPointTest() { var point = new Point(10, 10); System.Windows.Point winPoint = point.ConvertToWindowsPoint(); Assert.That(winPoint.X, Is.EqualTo(10)); Assert.That(winPoint.Y, Is.EqualTo(10)); }
protected BaseActor(ILevelInfo info) { Info = info; Position = new Point(0, 0); IsAlive = true; CanDrop = false; }
public GMHauntedMines(string name, string loadingMatchPath, int[] laneRule, Rectangle minimapRectangle, Point leftFountain, Point rightFountain, Composite mapChallengeBehavior, Point leftBasePoint, Point rightBasePoint, Point[] topLane, Point[] midLane, Point[] botLane) : base(name, loadingMatchPath, laneRule, minimapRectangle, leftFountain, rightFountain, mapChallengeBehavior, leftBasePoint, rightBasePoint, topLane, midLane, botLane) { }
/// <summary> /// 清除所有GroupItem /// </summary> public void Clear() { Controls.Clear(); _conditionCount = 0; _conditionPos = new Point(10, 0); AddGroupItem(); }
private IEnumerable<Point> GetNeighbours(Point from) { return new[] { new Size(1, 0), new Size(-1, 0), new Size(0, 1), new Size(0, -1) } .Select(shift => from + shift) .Where(maze.InsideMaze) .Where(maze.IsFree); }
private void glCanvas1_MouseDown(object sender, MouseEventArgs e) { this.lastMousePosition = e.Location; this.lastMouseDownPosition = e.Location; if (e.Button == System.Windows.Forms.MouseButtons.Right) { //// operate camera //rotator.SetBounds(this.glCanvas1.Width, this.glCanvas1.Height); //rotator.MouseDown(e.X, e.Y); } else if (e.Button == System.Windows.Forms.MouseButtons.Left) { // move vertex if (pickedGeometry != null) { ViewPort viewPort = pickedGeometry.FromViewPort; ICamera camera = viewPort.Camera; var dragParam = new DragParam( camera.GetPerspectiveProjectionMatrix(), camera.GetViewMatrix(), viewPort.Rect.ToViewport(), new Point(e.X, glCanvas1.Height - e.Y - 1)); dragParam.pickedVertexIds.AddRange(pickedGeometry.VertexIds); this.dragParam = dragParam; } } }
public PauseScreen(XElement reader, string basePath) { weapons = new List<PauseWeaponInfo>(); inventory = new List<InventoryInfo>(); XElement changeNode = reader.Element("ChangeSound"); if (changeNode != null) ChangeSound = SoundInfo.FromXml(changeNode, basePath); XElement soundNode = reader.Element("PauseSound"); if (soundNode != null) PauseSound = SoundInfo.FromXml(soundNode, basePath); XElement backgroundNode = reader.Element("Background"); if (backgroundNode != null) Background = FilePath.FromRelative(backgroundNode.Value, basePath); foreach (XElement weapon in reader.Elements("Weapon")) weapons.Add(PauseWeaponInfo.FromXml(weapon, basePath)); XElement livesNode = reader.Element("Lives"); if (livesNode != null) { LivesPosition = new Point(livesNode.GetInteger("x"), livesNode.GetInteger("y")); } foreach (XElement inventoryNode in reader.Elements("Inventory")) { inventory.Add(InventoryInfo.FromXml(inventoryNode, basePath)); } }
internal static IComeDirection GetComeDirection(Point user, Point ball) { try { if (user.X == ball.X && user.Y - 1 == ball.Y) return IComeDirection.Down; if (user.X + 1 == ball.X && user.Y - 1 == ball.Y) return IComeDirection.DownLeft; if (user.X + 1 == ball.X && user.Y == ball.Y) return IComeDirection.Left; if (user.X + 1 == ball.X && user.Y + 1 == ball.Y) return IComeDirection.UpLeft; if (user.X == ball.X && user.Y + 1 == ball.Y) return IComeDirection.Up; if (user.X - 1 == ball.X && user.Y + 1 == ball.Y) return IComeDirection.UpRight; if (user.X - 1 == ball.X && user.Y == ball.Y) return IComeDirection.Right; if (user.X - 1 == ball.X && user.Y - 1 == ball.Y) return IComeDirection.DownRight; return IComeDirection.Null; } catch { return IComeDirection.Null; } }
public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis) { state.ValidateSelectionStats(); float zMovement = state.CameraObj.Transform.Pos.Z - lastLocSpace.Z; Vector3 target = state.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, selectionCenter.Z + zMovement)); Vector3 movLock = beginLocSpace - lastLocSpace; Vector3 mov = target - lastLocSpace; mov.Z = zMovement; target.Z = 0; if (lockedAxis == CamViewState.LockedAxis.X) { mov = new Vector3(mov.X, 0, 0); } else if (lockedAxis == CamViewState.LockedAxis.Y) { mov = new Vector3(0, mov.Y, 0); } else { mov = state.ApplyAxisLock(mov, movLock, target + (Vector3.UnitZ * state.CameraObj.Transform.Pos.Z) - beginLocSpace); } state.MoveSelectionBy(mov); state.ActionLastLocSpace += mov; }
public void ClickSaveConnection() { WpfWindow theWindow = GetNewServerWindow(); Point p = new Point(theWindow.BoundingRectangle.Left + 300, theWindow.BoundingRectangle.Top + 275); Mouse.Move(p); Mouse.Click(); }
/// <summary> /// Process the filter on the specified image. /// </summary> /// /// <param name="image">Source image data.</param> /// public Bitmap Apply(Bitmap image) { image = AForge.Imaging.Image.Clone(image, PixelFormat.Format24bppRgb); using (Graphics g = Graphics.FromImage(image)) using (Pen positive = new Pen(Color.Red)) using (Pen negative = new Pen(Color.Blue)) using (Pen line = new Pen(Color.FromArgb(0, 255, 0))) { // mark all points foreach (SurfPoint p in points) { int S = 2 * (int)(2.5f * p.Scale); int R = (int)(S / 2f); Point pt = new Point((int)p.X, (int)p.Y); Point ptR = new Point((int)(R * System.Math.Cos(p.Orientation)), (int)(R * System.Math.Sin(p.Orientation))); Pen myPen = (p.Laplacian > 0 ? negative : positive); g.DrawEllipse(myPen, pt.X - R, pt.Y - R, S, S); g.DrawLine(line, new Point(pt.X, pt.Y), new Point(pt.X + ptR.X, pt.Y + ptR.Y)); } } return image; }
public override void UpdateMousePosition(Point location) { Point currentPosition = location; pictureToDrawOn.DrawLine(pen, startLocation, currentPosition); model.pictureView.PictureBox.Invalidate(); startLocation = currentPosition; }
public bool IsPartOfRectangle(Point point) { if (Point1.Y >= point.Y && Point2.Y <= point.Y) if (point.X >= Point1.X && point.X <= Point3.X) return true; return false; }
protected override void OnPaint(PaintEventArgs e) { Point drawPoint = new Point(0, 0); try { int indexOfBy = Text.IndexOf("by"); int indexOfSeparator = Text.IndexOf(" - ", indexOfBy); string firstPart = Text.Substring(0, indexOfBy); string secondPart = Text.Substring(indexOfBy, indexOfSeparator - indexOfBy); string thirdPart = Text.Remove(0, indexOfSeparator); Font normalFont = this.Font; Font smallFont = new Font(normalFont.FontFamily, normalFont.Size - 4); Size normalSize1 = TextRenderer.MeasureText(firstPart, normalFont); Size smallSize = TextRenderer.MeasureText(secondPart, smallFont); Size normalSize2 = TextRenderer.MeasureText(thirdPart, normalFont); Rectangle normalRect1 = new Rectangle(drawPoint, normalSize1); Rectangle smallRect = new Rectangle(new Point(normalSize1.Width - 10,5), smallSize); Rectangle normalRect2 = new Rectangle(new Point(smallSize.Width + normalSize1.Width - 20, 0), normalSize2); TextRenderer.DrawText(e.Graphics, firstPart, normalFont, normalRect1, primaryFontColor); //ForeColor); TextRenderer.DrawText(e.Graphics, secondPart, smallFont, smallRect, secondaryFontColor);//Color.Gray); TextRenderer.DrawText(e.Graphics, thirdPart, normalFont, normalRect2, primaryFontColor); //ForeColor); } catch { TextRenderer.DrawText(e.Graphics, Text, Font, drawPoint, ForeColor); } }
private void PrintWay(List<Location> loc, Color color, RadarForm form) { if (loc != null) { PointF[] points; Point tempP; Location ld; if (loc.Count != 0) { points = new PointF[loc.Count + 1]; int i = 0; foreach (Location lo in loc) { form.PrintCircle(color, form.OffsetY(lo.Y, ObjectManager.MyPlayer.Location.Y), form.OffsetX(lo.X, ObjectManager.MyPlayer.Location.X), ""); tempP = new Point(form.OffsetY(lo.Y, ObjectManager.MyPlayer.Location.Y), form.OffsetX(lo.X, ObjectManager.MyPlayer.Location.X)); points[i] = tempP; i++; } ld = loc[0]; tempP = new Point(form.OffsetY(ld.Y, ObjectManager.MyPlayer.Location.Y), form.OffsetX(ld.X, ObjectManager.MyPlayer.Location.X)); points[i] = tempP; form.ScreenDc.DrawLines(new Pen(_colorWaypoints), points); } } }
public Rectangle GetBounds(Point itemLocation, Size itemSize) { return new Rectangle((itemLocation.X + itemSize.Width) - locationFromRight.X, itemLocation.Y, size.Width, size.Height); }
private void PrintNew(int x, int y) { var point = new Point(x * scale, y * scale); var size = new Size(scale, scale); var rectangle = new Rectangle(point, size); graphics.FillEllipse(Brushes.Black, rectangle); }
/// <summary> /// Determines the editing mode from input position.</summary> /// <param name="p">Input position point</param> public override void SetEditingMode(Point p) { if (Bounds.Contains(p)) EditingMode = EditMode.ByClick; else EditingMode = EditMode.None; }
private void BaseMain_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) return; this.mouseOff = new Point(-e.X, -e.Y); this.leftFlag = true; }
/// <summary> /// ポイントがD&Dするとサイズが変更されるエリア内にあるかどうかを判定します。 /// </summary> public bool ContainsSizeChangeArea(Point p) { return getTop().Contains(p) || getBottom().Contains(p) || getLeft().Contains(p) || getRight().Contains(p); }
public Rectangle(Point p, Size s) { X = p.X; Y = p.Y; Width = s.Width; Height = s.Height; }
public Zone(Point point1, Point point2, Point point3, Point point4) { Point1 = point1; Point2 = point2; Point3 = point3; Point4 = point4; }
private void initKalman() { last = lastEst = new System.Drawing.Point(); kf = new Kalman(kfData.state,kfData.transitionMatrix, kfData.measurementMatrix, kfData.processNoise, kfData.measurementNoise); kf.ErrorCovariancePost = kfData.errorCovariancePost; }
/// <summary> /// Pans the image for this map frame. Instead of drawing entirely new content, from all 5 zones, /// just the slivers of newly revealed area need to be re-drawn. /// </summary> /// <param name="shift">A Point showing the amount to shift in pixels</param> public void Pan(Point shift) { _gdiMapFrame.Pan(shift); }
/// <summary> /// 產生圖形驗證碼。 /// </summary> /// <param name="Code">傳出驗證碼。</param> /// <param name="CodeLength">驗證碼字元數。</param> /// <param name="Width"></param> /// <param name="Height"></param> /// <param name="FontSize"></param> /// <returns></returns> public static byte[] CreateValidateGraphic(out String Code, int CodeLength, int Width, int Height, int FontSize) { String sCode = String.Empty; //顏色列表,用於驗證碼、噪線、噪點 Color[] oColors = { System.Drawing.Color.Black, System.Drawing.Color.Red, System.Drawing.Color.Blue, System.Drawing.Color.Green, System.Drawing.Color.Orange, System.Drawing.Color.Brown, System.Drawing.Color.Brown, System.Drawing.Color.DarkBlue }; //字體列表,用於驗證碼 string[] oFontNames = { "Times New Roman", "MS Mincho", "Book Antiqua", "Gungsuh", "PMingLiU", "Impact" }; //驗證碼的字元集,去掉了一些容易混淆的字元 char[] oCharacter = { '2', '3', '4', '5', '6', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G','H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'Y' }; Random oRnd = new Random(); Bitmap oBmp = null; Graphics oGraphics = null; int N1 = 0; System.Drawing.Point oPoint1 = default(System.Drawing.Point); System.Drawing.Point oPoint2 = default(System.Drawing.Point); string sFontName = null; Font oFont = null; Color oColor = default(Color); //生成驗證碼字串 for (N1 = 0; N1 <= CodeLength - 1; N1++) { sCode += oCharacter[oRnd.Next(oCharacter.Length)]; } oBmp = new Bitmap(Width, Height); oGraphics = Graphics.FromImage(oBmp); oGraphics.Clear(System.Drawing.Color.White); try { for (N1 = 0; N1 <= 4; N1++) { //畫噪線 oPoint1.X = oRnd.Next(Width); oPoint1.Y = oRnd.Next(Height); oPoint2.X = oRnd.Next(Width); oPoint2.Y = oRnd.Next(Height); oColor = oColors[oRnd.Next(oColors.Length)]; oGraphics.DrawLine(new Pen(oColor), oPoint1, oPoint2); } float spaceWith = 0, dotX = 0, dotY = 0; if (CodeLength != 0) { spaceWith = (Width - FontSize * CodeLength - 10) / CodeLength; } for (N1 = 0; N1 <= sCode.Length - 1; N1++) { //畫驗證碼字串 sFontName = oFontNames[oRnd.Next(oFontNames.Length)]; oFont = new Font(sFontName, FontSize, FontStyle.Italic); oColor = oColors[oRnd.Next(oColors.Length)]; dotY = (Height - oFont.Height) / 2 + 2;//中心下移2像素 dotX = Convert.ToSingle(N1) * FontSize + (N1 + 1) * spaceWith; oGraphics.DrawString(sCode[N1].ToString(), oFont, new SolidBrush(oColor), dotX, dotY); } for (int i = 0; i <= 30; i++) { //畫噪點 int x = oRnd.Next(oBmp.Width); int y = oRnd.Next(oBmp.Height); Color clr = oColors[oRnd.Next(oColors.Length)]; oBmp.SetPixel(x, y, clr); } Code = sCode; //保存图片数据 MemoryStream stream = new MemoryStream(); oBmp.Save(stream, ImageFormat.Jpeg); //输出图片流 return(stream.ToArray()); } finally { oGraphics.Dispose(); } }
/// <summary> /// Calculates if a point is within the shape that defines the element /// </summary> /// <param name="point">A point to test in the virtual modeling plane</param> /// <returns></returns> public override bool PointInElement(Point point) { Rectangle temp = new Rectangle(point, new Size(1, 1)); temp.Inflate(2, 2); return ElementInRectangle(temp); }
/// <summary> /// Moves the mouse pointer to the specified screen coordinates. /// </summary> /// <param name="point">The screen coordinates to move to.</param> public static void MoveTo(System.Drawing.Point point) { SendMouseInput(point.X, point.Y, 0, NativeMethods.SendMouseInputFlags.Move | NativeMethods.SendMouseInputFlags.Absolute); }
protected override bool GetHitTest(System.Drawing.Point point) { var treeView = settingsTree.TreeView; return(treeView.HitTest(treeView.PointToClient(point)) != null); }
/// <summary> /// Initializes a new instance of the XPoint class with the specified point. /// </summary> public XPoint(System.Drawing.Point point) { _x = point.X; _y = point.Y; }
/// <summary> /// Tests whether the mouse hits this shape /// </summary> /// <param name="p"></param> /// <returns></returns> public override bool Hit(System.Drawing.Point p) { Rectangle r = new Rectangle(p, new Size(5, 5)); return(rectangle.Contains(r)); }
// When the window opens, // restore persistent user options. private void mainForm_Load(object sender, EventArgs e) { if (!Settings.Default.WindowLocation.IsEmpty) { this.Location = Settings.Default.WindowLocation; } else { System.Drawing.Point screenCenter = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Location; screenCenter.X += System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2 - this.Width / 2; screenCenter.Y += System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height / 2 - this.Height / 2; this.Location = screenCenter; } this.WindowState = Settings.Default.WindowState; //this.TopMost = this.alwaysOnTopMenuItem.Checked = Settings.Default.WindowTopMost; this.demoMenuItem.Checked = Settings.Default.DemoMode; this.spotterOverlayModuleMenuItem.Checked = Settings.Default.ShowSpotterOverlay; this.startLightsModuleMenuItem.Checked = Settings.Default.ShowStartLights; this.incidentOverlayModuleMenuItem.Checked = Settings.Default.ShowIncidentOverlay; this.pitExitBlueModuleMenuItem.Checked = Settings.Default.ShowPitExitBlue; this.closedPitsOverlayModuleMenuItem.Checked = Settings.Default.ShowClosedPitsOverlay; this.repairsOverlayModuleMenuItem.Checked = Settings.Default.ShowRepairsOverlay; this.pitSpeedLimitModuleMenuItem.Checked = Settings.Default.ShowPitSpeedLimit; pitSpeedMap = Settings.Default.PitSpeedMap; switch (pitSpeedMap) { case "safe": pitSpeedMapSafeMenuItem.Checked = true; break; case "wide": pitSpeedMapWideMenuItem.Checked = true; break; case "narrow": pitSpeedMapNarrowMenuItem.Checked = true; break; case "aggressive": pitSpeedMapAggressiveMenuItem.Checked = true; break; } incidentStyleMap = Settings.Default.IncidentStyleMap; switch (incidentStyleMap) { case "small": incidentStyleMapSmallMenuItem.Checked = true; break; case "big": incidentStyleMapBigMenuItem.Checked = true; break; case "exploded": incidentStyleMapExplodedMenuItem.Checked = true; break; } connectorSide = Settings.Default.UsbConnector; switch (connectorSide) { case 0x00: connectorBottomMenuItem.Checked = true; break; case 0x01: connectorRightMenuItem.Checked = true; break; case 0x02: connectorLeftMenuItem.Checked = true; break; case 0x03: connectorTopMenuItem.Checked = true; break; } matrixLuma = Settings.Default.MatrixLuma; switch (matrixLuma) { case 10: lowBrightnessMenuItem.Checked = true; break; case 25: mediumBrightnessMenuItem.Checked = true; break; case 60: highBrightnessMenuItem.Checked = true; break; case 100: fullBrightnessMenuItem.Checked = true; break; } updatesLevel = Settings.Default.Updates; if (updatesLevel == "stable" || updatesLevel == "experimental") { //this.updatesEnabledMenuItem.Checked = true; if (updatesLevel == "experimental") { // this.updatesExperimentalMenuItem.Checked = true; } } restoreCommunication(); if (!Settings.Default.AllowMultiple && processNo > 1) { //multiFlagMessage.Show(); } //Display software version & firmware version Version swVersion = Assembly.GetExecutingAssembly().GetName().Version; versionLbl.Text = swVersion.Major + "." + swVersion.Minor + "." + fwVersion_Major + "." + fwVersion_Minor; }
public Point(System.Drawing.Point p) { X = p.X; Y = p.Y; }
public Point(System.Drawing.Point p, double width) { X = p.X; Y = p.Y; Width = width; }
public override KeyValuePair <double, Handle> GetSelectionDistance(SysPoint point) { double distance = Board.GetBoardPoint(point).DistanceTo(Position) * Board.ZoomFactor; return(new KeyValuePair <double, Handle>(distance <= 6 ? distance : double.NaN, null)); }
public abstract KeyValuePair <double, Handle> GetSelectionDistance(SysPoint point);
private void GetBetterImg() { Range rangeAll = Globals.ThisAddIn.Application.ActiveDocument.Range(); //range.SetRange(0,0); //while(range.End<rangeAll.End) //{ // range.Start = range.Start + 100; // range.End = range.End + 100; // Globals.ThisAddIn.Application.ActiveWindow.ScrollIntoView(range); //} object filename = @"D:\BaoProject\高分宝三期\2014届高三数学理科模拟试题(定稿).doc"; //文件保存路径 Object Nothing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Add(ref filename, ref Nothing, ref Nothing, ref Nothing); Range range = WordDoc.Range(0, 500); range.Copy(); rangeAll.Paste(); rangeAll = Globals.ThisAddIn.Application.ActiveDocument.Range(); rangeAll.SetRange(rangeAll.End, rangeAll.End); rangeAll.Select(); System.Windows.Point pointend = CaretPos(); rangeAll.SetRange(0, 0); rangeAll.Select(); Microsoft.Office.Tools.Word.Document document = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument); Microsoft.Office.Tools.Word.DropDownListContentControl dropdown = document.Controls.AddDropDownListContentControl(rangeAll, "MyContentControl"); dropdown.PlaceholderText = "My DropdownList Test"; dropdown.DropDownListEntries.Add("Test01", "01", 1); dropdown.DropDownListEntries.Add("Test02", "02", 2); dropdown.DropDownListEntries.Add("Test03", "03", 3); rangeAll.SetRange(dropdown.Range.End + 1, dropdown.Range.End + 1); System.Drawing.Point o = new System.Drawing.Point(dropdown.Application.Left, dropdown.Application.Top); System.Drawing.Point o1 = this.PointToScreen(o); rangeAll.SetRange(0, 0); rangeAll.Select(); System.Drawing.Point currentPos = GetPositionForShowing(Globals.ThisAddIn.Application.Selection); //Globals.ThisAddIn._FloatingPanel = new FloatingPanel(bookmark); rangeAll.Text = rangeAll.Text + "\n" + dropdown.Application.Top + "::::" + dropdown.Application.Left + "\n" + o1.X + "::::::" + o1.Y + "\n" + currentPos.X + "::::::" + currentPos.Y; Bitmap image = new Bitmap(currentPos.X, currentPos.Y); Graphics g = Graphics.FromImage(image); System.Drawing.Point FrmP = new System.Drawing.Point(currentPos.X, currentPos.Y); //ScreenP返回相对屏幕的坐标 System.Drawing.Point ScreenP = this.PointToScreen(FrmP); g.CopyFromScreen(0, 0, 0, 0, image.Size); image.Save(@"C:\Users\Word\Desktop\3523433.png", System.Drawing.Imaging.ImageFormat.Png); int i = 0; //Image imgTemp = Metafile.FromStream(new MemoryStream(range.EnhMetaFileBits)); //imgTemp.Save(@"C:\Users\Word\Desktop\1233.png", System.Drawing.Imaging.ImageFormat.Png); }
private string GetBetterImgFinal(int rangeStart, int RangeEnd) { Range rangeFrom = WordDoc.Range(rangeStart, RangeEnd); rangeFrom.Copy(); Range range = Globals.ThisAddIn.Application.ActiveDocument.Range(); range.Font.Name = "宋体"; range.Font.Size = (float)5; Globals.ThisAddIn.Application.ActiveDocument.Range().Text = " "; Globals.ThisAddIn.Application.ActiveWindow.ScrollIntoView(range); range.SetRange(0, 0); range.Select(); System.Drawing.Point leftTopPos = GetPositionForShowing(Globals.ThisAddIn.Application.Selection); range = Globals.ThisAddIn.Application.ActiveDocument.Range(); range.SetRange(range.End, range.End); range.Select(); System.Drawing.Point rightTopPos = GetPositionForShowing(Globals.ThisAddIn.Application.Selection); range.Text = "\n"; range = Globals.ThisAddIn.Application.ActiveDocument.Range(); range.SetRange(range.End, range.End); range.Select(); range.Paste(); range = Globals.ThisAddIn.Application.ActiveDocument.Range(); range.SetRange(range.End, range.End); range.Font.Name = "宋体"; range.Font.Size = (float)5; range.Text = "\n "; range.SetRange(0, 0); Globals.ThisAddIn.Application.ActiveWindow.ScrollIntoView(range); range = Globals.ThisAddIn.Application.ActiveDocument.Range(); range.SetRange(range.End - 1, range.End); range.Select(); System.Threading.Thread.Sleep(1000); System.Drawing.Point buttomPos = GetPositionForShowing(Globals.ThisAddIn.Application.Selection); range = Globals.ThisAddIn.Application.ActiveDocument.Range(); range.GrammarChecked = false; range.SpellingChecked = false; System.Threading.Thread.Sleep(1000); Bitmap image = new Bitmap(rightTopPos.X - leftTopPos.X + 10, buttomPos.Y - leftTopPos.Y - 20); Graphics g = Graphics.FromImage(image); g.CopyFromScreen(leftTopPos.X, leftTopPos.Y, 0, 0, image.Size); string fileName = System.Guid.NewGuid().ToString(); image.Save(@"D:\新建文件夹\" + fileName + ".png", System.Drawing.Imaging.ImageFormat.Png); this.button7.Text = "leftTop" + leftTopPos.X + ":" + leftTopPos.Y + "rightTop" + rightTopPos.X + ":" + rightTopPos.Y + "Buttom" + buttomPos.X + ":" + buttomPos.Y; //WordDoc.Close(ref Nothing, ref Nothing, ref Nothing); //WordApp.Quit(ref Nothing, ref Nothing, ref Nothing); return(fileName + ".png"); }
public override void Reset() { base.Reset(); headDepth = 100; headPosition = new Point(); }
private void Form1_MouseDown(object sender, MouseEventArgs e) { mouseDown = true; lastLocation = e.Location; }
/// <summary> /// Параметризованный конструктор LABEL_COLOR инициализирует поля структуры /// </summary> /// <param name="col">Цвет</param> /// <param name="name">Имя</param> /// <param name="text">Надпись</param> /// <param name="pt">Позиция</param> public LABEL_COLOR(Color col, string name, string text, System.Drawing.Point pt) { this.color = col; this.name = name; this.text = text; this.pos = pt; }
private void AllFrameReady(object sender, AllFramesReadyEventArgs e) { //Console.Clear(); using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(this.skeletons); Skeleton skel = skeletons[0]; if (skel.TrackingState == SkeletonTrackingState.Tracked) { SkeletonPoint rightHand = skeletons[0].Joints[JointType.HandRight].Position; SkeletonPoint head = skeletons[0].Joints[JointType.Head].Position; rightHandPosition = SkeletonPointToScreen(rightHand); headPosition = SkeletonPointToScreen(head); } } } using (ColorImageFrame colorFrame = e.OpenColorImageFrame()) { if (colorFrame != null) { // Copy the pixel data from the image to a temporary array colorFrame.CopyPixelDataTo(this.colorPixels); // Write the pixel data into our bitmap this.ColorWriteBitmap.WritePixels( new System.Windows.Int32Rect(0, 0, this.ColorWriteBitmap.PixelWidth, this.ColorWriteBitmap.PixelHeight), this.colorPixels, this.ColorWriteBitmap.PixelWidth * sizeof(int), 0); } } using (DepthImageFrame depthFrame = e.OpenDepthImageFrame()) { if (depthFrame != null) { var sw = Stopwatch.StartNew(); // Copy the pixel data from the image to a temporary array depthFrame.CopyDepthImagePixelDataTo(this.depthPixels); // short[] depthData = new short[depthFrame.PixelDataLength]; // Get the min and max reliable depth for the current frame int minDepth = depthFrame.MinDepth; int maxDepth = depthFrame.MaxDepth; int width = depthFrame.Width; int height = depthFrame.Height; if (headPosition.X == 0) { headDepth = 100; } else { headDepth = depthPixels[headPosition.X + headPosition.Y * 640].Depth; } sw.Restart(); //*********** Convert cull and transform***************** colorizer.TransformCullAndConvertDepthFrame( depthPixels, minDepth, maxDepth, colorPixels, AngleRotateTan, (short)(headDepth - (short)CullingThresh), headPosition); Image <Bgra, byte> depthImg; //Console.WriteLine("iteration:" + sw.ElapsedMilliseconds); sw.Restart(); Image <Gray, Byte> rightFront = null; Image <Gray, Byte> leftFront = null; depthImg = ImageConverter.Array2Image(colorPixels, width, height, width * 4); PointF rightVector = PointF.Empty; PointF leftVector = PointF.Empty; bool isSkip = false; bool leftHandRaise = false; if (skeletons != null && skeletons[0].TrackingState == SkeletonTrackingState.Tracked) { PointF hr = SkeletonPointToScreen(skeletons[0].Joints[JointType.HandRight].Position); PointF hl = SkeletonPointToScreen(skeletons[0].Joints[JointType.HandLeft].Position); PointF er = SkeletonPointToScreen(skeletons[0].Joints[JointType.ElbowRight].Position); PointF el = SkeletonPointToScreen(skeletons[0].Joints[JointType.ElbowLeft].Position); PointF hip = SkeletonPointToScreen(skeletons[0].Joints[JointType.HipCenter].Position); // hand is lower than hip //Console.WriteLine(skeletons[0].Joints[JointType.HandRight].Position.Y); //Console.WriteLine(skeletons[0].Joints[JointType.HipCenter].Position.Y); //Console.WriteLine("-------------"); if (skeletons[0].Joints[JointType.HandRight].Position.Y < skeletons[0].Joints[JointType.HipCenter].Position.Y + 0.05) { isSkip = true; } if (skeletons[0].Joints[JointType.HandLeft].Position.Y > skeletons[0].Joints[JointType.HipCenter].Position.Y) { leftHandRaise = true; } rightVector.X = (hr.X - er.X); rightVector.Y = (hr.Y - er.Y); leftVector.X = (hl.X - el.X); leftVector.Y = (hl.Y - el.Y); } HandShapeModel handModel = null; if (!isSkip) { //handModel = m_OpenCVController.FindHandPart(ref depthImg, out rightFront, out leftFront, headDepth - (int)CullingThresh, rightVector, leftVector,leftHandRaise); } // no hands detected if (handModel == null) { handModel = new HandShapeModel(0, HandEnum.None); } //sw.Restart(); // database processing DBManager db = DBManager.GetSingleton(); if (db != null) { if (skeletons != null) { handModel.SetSkeletonData(skeletons[0]); } db.AddFrameData(handModel); } // not recording show prob else { //Image<Bgr, byte>[] result = HandShapeClassifier.GetSingleton() //.RecognizeGesture(handModel.hogRight, 3); ////Console.WriteLine(sw.ElapsedMilliseconds); //if (result != null) //{ // ImageConverter.UpdateWriteBMP(WrtBMP_Candidate1, result[0].Convert<Gray, byte>().ToBitmap()); // ImageConverter.UpdateWriteBMP(WrtBMP_Candidate2, result[1].Convert<Gray, byte>().ToBitmap()); // ImageConverter.UpdateWriteBMP(WrtBMP_Candidate3, result[2].Convert<Gray, byte>().ToBitmap()); //} } string currentSign = db == null ? "0" : db.CurrentSign.ToString(); string path = @"J:\Kinect data\Aaron 141-180\hands\" + currentSign + " " + handModel.frame.ToString(); // UI update if (rightFront != null) { Bitmap right = rightFront.ToBitmap(); //right.Save(path + " r.jpg"); ImageConverter.UpdateWriteBMP(WrtBMP_RightHandFront, right); } if (leftFront != null) { Bitmap left = leftFront.ToBitmap(); //left.Save(path + " l.jpg"); ImageConverter.UpdateWriteBMP(WrtBMP_LeftHandFront, left); } if (sw.ElapsedMilliseconds > 15) { Console.WriteLine("Find hand:" + sw.ElapsedMilliseconds); } sw.Restart(); //**************************draw gray histogram //Bitmap histo = m_OpenCVController.Histogram(depthImg); //ImageConverter.UpdateWriteBMP(GrayWriteBitmap, histo); // draw hand position from kinect // DrawHandPosition(depthBMP, rightHandPosition, System.Drawing.Brushes.Purple); //*******************upadte UI ImageConverter.UpdateWriteBMP(DepthWriteBitmap, depthImg.ToBitmap()); // Console.WriteLine("Update UI:" + sw.ElapsedMilliseconds); } } }
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { var handle = new WindowInteropHelper(this).Handle; var initialStyle = MainWindow.GetWindowLong(handle, -20); MainWindow.SetWindowLong(handle, -20, initialStyle | 0x20 | 0x80000); Task.Run(async() => { try { var prev = new Point(); var rectangle = new Rectangle(); await this.Dispatcher.InvokeAsync(() => { rectangle = new Rectangle((int)this.Left, (int)this.Top, (int)this.Width, (int)this.Height); }); while (this.applicationRunning) { var point = new Point(); MainWindow.GetCursorPos(ref point); if (!point.Equals(prev)) { prev = point; var opacity = 1.0; const double MIN_OP = 0.125; const double FADE = 175; if (rectangle.Contains(point)) { opacity = MIN_OP; } else { if (point.Y <= rectangle.Bottom) { if (point.Y >= rectangle.Y) { if (point.X < rectangle.X && rectangle.X - point.X < FADE) { opacity = MainWindow.Lerp(1.0, MIN_OP, (rectangle.X - point.X) / FADE); } else if (point.X > rectangle.Right && point.X - rectangle.Right < FADE) { opacity = MainWindow.Lerp(1.0, MIN_OP, (point.X - rectangle.Right) / FADE); } } else if (point.Y < rectangle.Y) { if (point.X >= rectangle.X && point.X <= rectangle.Right) { if (rectangle.Y - point.Y < FADE) { opacity = MainWindow.Lerp(1.0, MIN_OP, (rectangle.Y - point.Y) / FADE); } } else if (rectangle.X > point.X || rectangle.Right < point.X) { var distance = Math.Sqrt( Math.Pow( (point.X < rectangle.X ? rectangle.X : rectangle.Right) - point.X, 2) + Math.Pow(rectangle.Y - point.Y, 2)); if (distance < FADE) { opacity = MainWindow.Lerp(1.0, MIN_OP, distance / FADE); } } } } } this.Dispatcher.Invoke(() => { this.Opacity = opacity; }); } var hidePressed = false; var exitPressed = false; var settingsPressed = false; // Set position anew to correct for fullscreen apps hiding taskbar this.Dispatcher.Invoke(() => { this.SetPositionBottomRight(this.MonikaScreen); rectangle = new Rectangle((int)this.Left, (int)this.Top, (int)this.Width, (int)this.Height); // Detect exit key combo hidePressed = AreKeysPressed(MonikaiSettings.Default.HotkeyHide); exitPressed = AreKeysPressed(MonikaiSettings.Default.HotkeyExit); settingsPressed = AreKeysPressed(MonikaiSettings.Default.HotkeySettings); }); if (hidePressed && (DateTime.Now - this.lastKeyComboTime).TotalSeconds > 2) { this.lastKeyComboTime = DateTime.Now; if (this.Visibility == Visibility.Visible) { var expression = new Expression( "Okay, see you later " + Environment.UserName + "! (Press again for me to return)", "b"); expression.Executed += (o, args) => { this.Dispatcher.Invoke(this.Hide); }; this.Say(new[] { expression }); } else { this.Dispatcher.Invoke(this.Show); } } if (exitPressed) { var expression = new Expression( "Goodbye for now! Come back soon please~", "b"); MonikaiSettings.Default.IsColdShutdown = false; MonikaiSettings.Default.Save(); expression.Executed += (o, args) => { this.Dispatcher.Invoke(this.Close); }; this.Say(new[] { expression }); } if (settingsPressed) { this.Dispatcher.Invoke(() => { if (!this.settingsWindow.IsVisible) { this.settingsWindow = new SettingsWindow(this); this.settingsWindow.Show(); } }); } await Task.Delay(MonikaiSettings.Default.PotatoPC ? 100 : 32); } } catch (Exception) { // ignored } }); }
/// <summary> /// Generates the map. /// </summary> /// <returns>Map as bitmap file.</returns> private Bitmap GetBitmap() { Bitmap bitmap; float xScale = 1.0F * _bitmapWidth / _width; float yScale = 1.0F * _bitmapHeight / _height; if (xScale < yScale) { _scale = xScale; } else { _scale = yScale; } _bitmapHeight += _marginTop + _marginBottom; _bitmapWidth += _marginLeft + _marginRight; bitmap = new Bitmap(_bitmapWidth + _legendBoxWidth - _legendBoxOffsetX, _bitmapHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb); using (Graphics canvas = Graphics.FromImage(bitmap)) { using (Pen pen = new Pen(_colorLine, 1)) { using (Brush backgroundBrush = new SolidBrush(_colorBackground)) { canvas.FillRectangle(backgroundBrush, 0, 0, _bitmapWidth + _legendBoxWidth - _legendBoxOffsetX, _bitmapHeight); //Draw background map from initialized geojson file for (int recordIndex = 0; recordIndex < _geoJsonFile.Features.Count; recordIndex++) { Feature feature = _geoJsonFile.Features[recordIndex]; List <Polygon> polygonList = new List <Polygon>(); if (feature.Geometry.Type == GeoJSONObjectType.MultiPolygon) { MultiPolygon multiPolygon = (MultiPolygon)feature.Geometry; foreach (Polygon polygon in multiPolygon.Coordinates) { polygonList.Add(polygon); } } else if (feature.Geometry.Type == GeoJSONObjectType.Polygon) { Polygon polygon = (Polygon)feature.Geometry; polygonList.Add(polygon); } foreach (Polygon polygon in polygonList) { for (int i = 0; i < polygon.Coordinates.Count; i++) { List <System.Drawing.Point> points = new List <System.Drawing.Point>(); for (int j = 0; j < polygon.Coordinates[i].Coordinates.Count; j++) { GeographicPosition coordinate = polygon.Coordinates[i].Coordinates[j]; System.Drawing.Point point = new System.Drawing.Point(_marginLeft + _legendBoxWidth - _legendBoxOffsetX + (int)((coordinate.Longitude - _xMin) * _scale), _bitmapHeight - _marginBottom - (int)((coordinate.Latitude - _yMin) * _scale)); points.Add(point); } using (Brush countyBrush = new SolidBrush(_colorLandBackground)) { canvas.FillPolygon(countyBrush, points.ToArray()); } } } } //Heat rects if (_observationCounts != null && _observationCounts.Count > 0) { int radius = (Int32)Math.Round(_observationCounts[0].GridCellSize * _scale * 0.5) + 1; foreach (IGridCellSpeciesObservationCount cell in _observationCounts) { Double cellX = cell.OrginalGridCellCentreCoordinate.X; Double cellY = cell.OrginalGridCellCentreCoordinate.Y; System.Drawing.Point point = new System.Drawing.Point(_marginLeft + _legendBoxWidth - _legendBoxOffsetX + (int)((cellX - _xMin) * _scale), _bitmapHeight - _marginBottom - (int)((cellY - _yMin) * _scale)); using (Brush heatBrush = GetHeatBrush()) { canvas.FillEllipse(heatBrush, point.X - radius, point.Y - radius, 2 * radius, 2 * radius); } } } //Draw polygon border lines from initialized geojson file for (int recordIndex = 0; recordIndex < _geoJsonFile.Features.Count; recordIndex++) { Feature feature = _geoJsonFile.Features[recordIndex]; List <Polygon> polygonList = new List <Polygon>(); if (feature.Geometry.Type == GeoJSONObjectType.MultiPolygon) { MultiPolygon multiPolygon = (MultiPolygon)feature.Geometry; foreach (Polygon polygon in multiPolygon.Coordinates) { polygonList.Add(polygon); } } else if (feature.Geometry.Type == GeoJSONObjectType.Polygon) { Polygon polygon = (Polygon)feature.Geometry; polygonList.Add(polygon); } foreach (Polygon polygon in polygonList) { for (int i = 0; i < polygon.Coordinates.Count; i++) { List <System.Drawing.Point> points = new List <System.Drawing.Point>(); for (int j = 0; j < polygon.Coordinates[i].Coordinates.Count; j++) { GeographicPosition coordinate = polygon.Coordinates[i].Coordinates[j]; System.Drawing.Point point = new System.Drawing.Point(_marginLeft + _legendBoxWidth - _legendBoxOffsetX + (int)((coordinate.Longitude - _xMin) * _scale), _bitmapHeight - _marginBottom - (int)((coordinate.Latitude - _yMin) * _scale)); points.Add(point); } canvas.DrawPolygon(pen, points.ToArray()); } } } } } } return(bitmap); }
/// <summary> /// Method used to draw customization needle. /// </summary> /// <param name="graphics">Graphics</param> /// <param name="needle">Needle used in the gauge</param> /// <param name="m_gaugeArcStart">Arc start position</param> /// <param name="m_gaugeArcEnd">Arc end position</param> /// <param name="m_NeedleRadius">Needle radius</param> /// <param name="m_NeedleWidth">Needle width</param> /// <param name="m_center">Center point of the gauge</param> public void DrawMultipleNeedle(System.Drawing.Graphics Graphics, Needle Needle, int GaugeArcStart, int GaugeArcEnd, int NeedleRadius, int NeedleWidth, System.Drawing.Point Center) { }
public void Offset(Point point) { Offset(point.X, point.Y); }
public void AddPoint(Point p) { _points.Add(p); }
public void OpponentShot(System.Drawing.Point shot) { }
/// <summary> /// Method used to draw outer arc. /// </summary> /// <param name="e">Paintevent arguement</param> /// <param name="m_GaugeArcStart">Arc start position</param> /// <param name="m_GaugeArcEnd">Arc end position</param> /// <param name="m_Center">Center point for gauge</param> public void DrawOuterArc(System.Drawing.Graphics e, int m_GaugeArcStart, int m_GaugeArcEnd, System.Drawing.Point m_Center, int GaugeRadius) { e.SmoothingMode = SmoothingMode.AntiAlias; e.PixelOffsetMode = PixelOffsetMode.HighQuality; GraphicsPath pth = new GraphicsPath(); Color c = this.RadialGauge.Parent != null ? this.RadialGauge.Parent.BackColor : Color.Empty; Rectangle r = new Rectangle(0, 0, this.RadialGauge.Width, this.RadialGauge.Height); System.Drawing.Drawing2D.GraphicsPath basePath = new System.Drawing.Drawing2D.GraphicsPath(); int x = this.RadialGauge.Width; int y = this.RadialGauge.Height; //Define rectangles inside which we will draw circles. Rectangle rect = new Rectangle(0 + 10, 0 + 10, (int)x - 20, (int)y - 20); Rectangle rectrim = new Rectangle(0 + 23, 0 + 23, (int)x - 46, (int)y - 46); Rectangle rectinner = new Rectangle(0 + 40, 0 + 40, (int)x - 80, (int)y - 80); if (GaugeRadius > 0) { e.DrawArc(new Pen(this.RadialGauge.GaugeArcColor, 7), new Rectangle(m_Center.X - GaugeRadius, m_Center.Y - GaugeRadius, 2 * GaugeRadius, 2 * GaugeRadius), m_GaugeArcStart, m_GaugeArcEnd); } }
public PointGroup OffsetCopy(Point point) { return(OffsetCopy(point.X, point.Y)); }
public POINT(System.Drawing.Point pt) : this(pt.X, pt.Y) { }
public override bool HitTest(System.Drawing.Point p) { return(gp.IsVisible(p)); }
private static extern bool GetCursorPos(ref Point lpPoint);
/// <summary> /// Method used to draw needle /// </summary> /// <param name="graphics">Graphics</param> /// <param name="m_GaugeArcStart">Arc start position</param> /// <param name="m_GaugeArcEnd">Arc end position</param> /// <param name="m_NeedleRadius">Needle radius</param> /// <param name="m_NeedleWidth">Needle width</param> /// <param name="m_Center">Center point of the gauge</param> public void DrawNeedle(System.Drawing.Graphics Graphics, int ArcStart, int ArcEnd, int NeedleRadius, int NeedleWidth, System.Drawing.Point Center) { }