// This was taken from FindReplaceDialog. Obviously some refactoring is called for // since we have common code. However I'm holding off on this because I'm coming // up with some other ideas for the FindReplaceDialog. Right now every scintilla // gets its own FindReplaceDialog, but they really need to be sharable across // multiple scintillas much like how DropMarkers work. private void MoveFormAwayFromSelection() { if (!Visible) return; int pos = Scintilla.Caret.Position; int x = Scintilla.PointXFromPosition(pos); int y = Scintilla.PointYFromPosition(pos); Point cursorPoint = Scintilla.PointToScreen(new Point(x, y)); Rectangle r = new Rectangle(Location, Size); if (r.Contains(cursorPoint)) { Point newLocation; if (cursorPoint.Y < (Screen.PrimaryScreen.Bounds.Height / 2)) { // Top half of the screen newLocation = Scintilla.PointToClient( new Point(Location.X, cursorPoint.Y + Scintilla.Lines.Current.Height * 2) ); } else { // Bottom half of the screen newLocation = Scintilla.PointToClient( new Point(Location.X, cursorPoint.Y - Height - (Scintilla.Lines.Current.Height * 2)) ); } newLocation = Scintilla.PointToScreen(newLocation); Location = newLocation; } }
internal static Rectangle ConstrainToBounds(Rectangle constrainingBounds, Rectangle bounds) { if (!constrainingBounds.Contains(bounds)) { bounds.Size = new Size(Math.Min(constrainingBounds.Width - 2, bounds.Width), Math.Min(constrainingBounds.Height - 2, bounds.Height)); if (bounds.Right > constrainingBounds.Right) { bounds.X = constrainingBounds.Right - bounds.Width; } else if (bounds.Left < constrainingBounds.Left) { bounds.X = constrainingBounds.Left; } if (bounds.Bottom > constrainingBounds.Bottom) { bounds.Y = (constrainingBounds.Bottom - 1) - bounds.Height; return bounds; } if (bounds.Top < constrainingBounds.Top) { bounds.Y = constrainingBounds.Top; } } return bounds; }
public bool IsObjectInArea(Rectangle area) { Rectangle ImageArea = new Rectangle(Map.Instance.CenterX + Object.GetInt("x") - ((Object.GetBool("f")) ? Image.GetCanvas().width - Image.GetVector("origin").x : Image.GetVector("origin").x), Map.Instance.CenterY + Object.GetInt("y") - Image.GetVector("origin").y, Image.GetCanvas().width, Image.GetCanvas().height); if (ImageArea.Contains(area)) return true; Rectangle common = Rectangle.Intersect(ImageArea, area); if (common != Rectangle.Empty) { if (common.Contains(lastKnown)) return true; Bitmap b = (Object.GetBool("f")) ? Image.GetCanvas().GetFlippedBitmap() : Image.GetCanvas().GetBitmap(); bool toSwitchX = MapEditor.Instance.selectingX > common.X; bool toSwitchY = MapEditor.Instance.selectingY > common.Y; for (int x = toSwitchX ? common.X - ImageArea.X + common.Width - 1 : common.X - ImageArea.X; toSwitchX ? x >= common.X - ImageArea.X : x < common.X - ImageArea.X + common.Width; x += toSwitchX ? -1 : 1) { for (int y = toSwitchY ? common.Y - ImageArea.Y + common.Height - 1 : common.Y - ImageArea.Y; toSwitchY ? y >= common.Y - ImageArea.Y : y < common.Y - ImageArea.Y + common.Height; y += toSwitchY ? -1 : 1) { if (b.GetPixel(x, y).A > 0) { lastKnown = new Point(x + ImageArea.X, y + ImageArea.Y); return true; } } } } return false; }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Left) { pictureBox1.Left -= 10; } if (e.KeyData == Keys.Right) { pictureBox1.Left += 10; } if (e.KeyData == Keys.Up) { pictureBox1.Top -= 10; } if (e.KeyData == Keys.Down) { pictureBox1.Top += 10; } Rectangle dropRect = new Rectangle(200, 100, 350, 250); isDragging = false; if (dropRect.Contains(pictureBox1.Bounds)) { SoundPlayer player = new SoundPlayer(); player.SoundLocation = @"C:\Users\admin\Music\tada.wav"; player.Play(); MessageBox.Show("Вы победили!", "Проверка попадания"); } }
private ScrollDirection AutoScrollDirectionFromPoint(Point clientPoint) { Rectangle rectangle = new Rectangle(Point.Empty, base.ParentView.ViewPortSize); if (!rectangle.Contains(clientPoint)) { return ScrollDirection.None; } ScrollDirection none = ScrollDirection.None; ScrollBar hScrollBar = base.ParentView.HScrollBar; if ((clientPoint.X <= (rectangle.Width / 10)) && (hScrollBar.Value > 0)) { none |= ScrollDirection.Left; } else if ((clientPoint.X >= (rectangle.Right - (rectangle.Width / 10))) && (hScrollBar.Value < (hScrollBar.Maximum - hScrollBar.LargeChange))) { none |= ScrollDirection.Right; } ScrollBar vScrollBar = base.ParentView.VScrollBar; if ((clientPoint.Y <= (rectangle.Height / 10)) && (vScrollBar.Value > 0)) { return (none | ScrollDirection.Up); } if ((clientPoint.Y >= (rectangle.Bottom - (rectangle.Height / 10))) && (vScrollBar.Value < (vScrollBar.Maximum - vScrollBar.LargeChange))) { none |= ScrollDirection.Down; } return none; }
//ExStart //ExId:MergeCellsMethod //ExSummary:A method which merges all cells of a table in the specified range of cells. /// <summary> /// Merges the range of cells found between the two specified cells both horizontally and vertically. Can span over multiple rows. /// </summary> public static void MergeCells(Cell startCell, Cell endCell) { Table parentTable = startCell.ParentRow.ParentTable; // Find the row and cell indices for the start and end cell. Point startCellPos = new Point(startCell.ParentRow.IndexOf(startCell), parentTable.IndexOf(startCell.ParentRow)); Point endCellPos = new Point(endCell.ParentRow.IndexOf(endCell), parentTable.IndexOf(endCell.ParentRow)); // Create the range of cells to be merged based off these indices. Inverse each index if the end cell if before the start cell. Rectangle mergeRange = new Rectangle(Math.Min(startCellPos.X, endCellPos.X), Math.Min(startCellPos.Y, endCellPos.Y), Math.Abs(endCellPos.X - startCellPos.X) + 1, Math.Abs(endCellPos.Y - startCellPos.Y) + 1); foreach (Row row in parentTable.Rows) { foreach (Cell cell in row.Cells) { Point currentPos = new Point(row.IndexOf(cell), parentTable.IndexOf(row)); // Check if the current cell is inside our merge range then merge it. if (mergeRange.Contains(currentPos)) { if (currentPos.X == mergeRange.X) cell.CellFormat.HorizontalMerge = CellMerge.First; else cell.CellFormat.HorizontalMerge = CellMerge.Previous; if (currentPos.Y == mergeRange.Y) cell.CellFormat.VerticalMerge = CellMerge.First; else cell.CellFormat.VerticalMerge = CellMerge.Previous; } } } }
public bool Contains(Point p) { Rectangle draw_rect = new Rectangle(Position.Location, new Size(4, 4)); draw_rect.Offset(-2, -2); return draw_rect.Contains(p); }
public void moveFormAwayFromSelection() { if (!Visible || this.Scintilla == null) return; int pos = this.Scintilla.Caret.Position; int x = this.Scintilla.PointXFromPosition(pos); int y = this.Scintilla.PointYFromPosition(pos); var cursorPoint = new Point(x, y); var r = new Rectangle(Location, Size); if (r.Contains(cursorPoint)) { Point newLocation; if (cursorPoint.Y < (Screen.PrimaryScreen.Bounds.Height / 2)) { // Top half of the screen newLocation = new Point(Location.X, cursorPoint.Y + this.Scintilla.Lines.Current.Height * 2); } else { // FixedY half of the screen newLocation = new Point(Location.X, cursorPoint.Y - Height - (this.Scintilla.Lines.Current.Height * 2)); } Location = newLocation; } }
public PopupWindow(Control parent, string caption, Point location, bool mayBeToLeft) { m_message = caption; InitializeComponent(); SizeF sizef = messageLabel.CreateGraphics().MeasureString(m_message, messageLabel.Font); int labelWidth = (int)(sizef.Width * 1.05f); // need just a little bit to make sure it stays single line int labelHeight = (int)(sizef.Height); Rectangle bounds = new Rectangle(location.X + SHIFT_HORIZ, location.Y - SHIFT_VERT, labelWidth, labelHeight); if(mayBeToLeft && parent != null) { try { Rectangle parentBounds = new Rectangle(parent.PointToScreen(new Point(0, 0)), parent.Size); //m_message = "" + parentBounds; if(!parentBounds.Contains(bounds)) { bounds = new Rectangle(location.X - labelWidth - SHIFT_HORIZ, location.Y - SHIFT_VERT, labelWidth, labelHeight); } } catch {} } this.Bounds = bounds; messageLabel.Text = m_message; this.Focus(); // this normally won't work as Project.ShowPopup tries to return focus to parent. Hover mouse to regain focus }
protected override void OnMouseDown(MouseEventArgs e) { if (!DesignMode) { if (this.TabCount > 0) { // Test if the user clicked a close button Point loc = new Point(e.Location.X, e.Location.Y % this.ItemSize.Height + (this.RowCount - 1) * this.ItemSize.Height); Rectangle standardArea = Rectangle.Empty, closeBtnArea = Rectangle.Empty; for (int nIndex = 0; nIndex < this.TabCount; nIndex++) { standardArea = this.GetTabRect(nIndex); closeBtnArea = new Rectangle(standardArea.Right - 15, standardArea.Top + 3, 12, standardArea.Height - 6); if (closeBtnArea.Contains(loc)) { // Close the tabpage if the user confirms the action if (MessageBox.Show("You are about to close " + this.TabPages[nIndex].Text.TrimEnd() + " tab. Are you sure you want to continue?", "Confirm close", MessageBoxButtons.YesNo) == DialogResult.No) return; if (this.SelectedIndex == nIndex && this.SelectedIndex + 1 < this.TabCount) this.SelectedIndex++; this.TabPages.RemoveAt(nIndex); if (this.TabCount == 0) this.Visible = false; hoveringIndex = -1; // Fire close event if (OnClose != null) { OnClose(this, new EventArgs()); } } } } } }
public Point? Find(Bitmap findBitmap) { if (sourceImage == null || findBitmap == null) throw new InvalidOperationException(); findImage = new ImageData(findBitmap); findImage.PixelMaskTable(this.Variation); var SourceRect = new Rectangle(new Point(0, 0), sourceImage.Size); var NeedleRect = new Rectangle(new Point(0, 0), findImage.Size); if (SourceRect.Contains(NeedleRect)) { resets = new ManualResetEvent[threads]; Provider = new CoordProvider(sourceImage.Size, NeedleRect.Size); for (int i = 0; i < threads; i++) { resets[i] = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(new WaitCallback(ImageWorker), i); } WaitHandle.WaitAll(resets); return match; } return null; }
public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft) { if (g == null) { throw new ArgumentNullException("g"); } if (backgroundImageLayout == ImageLayout.Tile) { using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile)) { if (scrollOffset != Point.Empty) { Matrix transform = brush.Transform; transform.Translate((float) scrollOffset.X, (float) scrollOffset.Y); brush.Transform = transform; } g.FillRectangle(brush, clipRect); return; } } Rectangle rect = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout); if ((rightToLeft == RightToLeft.Yes) && (backgroundImageLayout == ImageLayout.None)) { rect.X += clipRect.Width - rect.Width; } using (SolidBrush brush2 = new SolidBrush(backColor)) { g.FillRectangle(brush2, clipRect); } if (!clipRect.Contains(rect)) { if ((backgroundImageLayout == ImageLayout.Stretch) || (backgroundImageLayout == ImageLayout.Zoom)) { rect.Intersect(clipRect); g.DrawImage(backgroundImage, rect); } else if (backgroundImageLayout == ImageLayout.None) { rect.Offset(clipRect.Location); Rectangle destRect = rect; destRect.Intersect(clipRect); Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size); g.DrawImage(backgroundImage, destRect, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel); } else { Rectangle rectangle4 = rect; rectangle4.Intersect(clipRect); Rectangle rectangle5 = new Rectangle(new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y), rectangle4.Size); g.DrawImage(backgroundImage, rectangle4, rectangle5.X, rectangle5.Y, rectangle5.Width, rectangle5.Height, GraphicsUnit.Pixel); } } else { ImageAttributes imageAttr = new ImageAttributes(); imageAttr.SetWrapMode(WrapMode.TileFlipXY); g.DrawImage(backgroundImage, rect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr); imageAttr.Dispose(); } }
protected override void Paint( Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { // Call the base class method to paint the default cell appearance. base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); // Retrieve the client location of the mouse pointer. Point cursorPosition = this.DataGridView.PointToClient(Cursor.Position); // If the mouse pointer is over the current cell, draw a custom border. if (cellBounds.Contains(cursorPosition)) { Rectangle newRect = new Rectangle(cellBounds.X + 1, cellBounds.Y + 1, cellBounds.Width - 4, cellBounds.Height - 4); graphics.DrawRectangle(Pens.Red, newRect); } }
private void pnlPointEditor_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (mPoints.Count > 0) { mPoints.RemoveAt(mPoints.Count - 1); RefreshPoints(); } return; } if (IsComplete()) return; //Check if its near first point if (mPoints.Count > 1) { Point p = mPoints[0]; Rectangle area = new Rectangle(p.X - 2, p.Y - 2, 4, 4); if (area.Contains(e.X, e.Y)) { mPoints.Add(p); RefreshPoints(); return; } } mPoints.Add(new Point(e.X, e.Y)); RefreshPoints(); }
protected virtual void MouseDownEventHandler(object sender, MouseEventArgs e) { Point first_one = this.PointToClient(Cursor.Position); #region Rectangles Rectangle rectYSol = new Rectangle(((TextBox)sender).Location.X, ((TextBox)sender).Location.Y, 10, 10); Rectangle rectYSag = new Rectangle(((TextBox)sender).Location.X + ((TextBox)sender).Width - 11, ((TextBox)sender).Location.Y, 10, 10); Rectangle rectASol = new Rectangle(((TextBox)sender).Location.X, ((TextBox)sender).Location.Y + ((TextBox)sender).Height - 11, 10, 10); Rectangle rectASag = new Rectangle(((TextBox)sender).Location.X + ((TextBox)sender).Width - 11, ((TextBox)sender).Location.Y + ((TextBox)sender).Height - 11, 10, 10); #endregion if (e.Button == MouseButtons.Left) { x_offset = ((TextBox)sender).Location.X; y_offset = ((TextBox)sender).Location.Y; if (rectYSol.Contains(first_one)) { YSol = true; Cursor = Cursors.PanNW; YSol_offset_x = e.X; YSol_offset_y = e.Y; storedOposite.X = ((TextBox)sender).Location.X + ((TextBox)sender).Width; storedOposite.Y = ((TextBox)sender).Location.Y + ((TextBox)sender).Height; } else if (rectYSag.Contains(first_one)) { YSag = true; Cursor = Cursors.PanNE; YSag_offset_x = ((TextBox)sender).Width - e.X; YSag_offset_y = e.Y; storedOposite.X = ((TextBox)sender).Location.X; storedOposite.Y = ((TextBox)sender).Location.Y + ((TextBox)sender).Height; } else if (rectASol.Contains(first_one)) { ASol = true; Cursor = Cursors.PanSW; ASol_offset_x = e.X; ASol_offset_y = ((TextBox)sender).Width - e.Y; storedOposite.X = ((TextBox)sender).Location.X + ((TextBox)sender).Width; storedOposite.Y = ((TextBox)sender).Location.Y; } else if (rectASag.Contains(first_one)) { ASag = true; Cursor = Cursors.PanSE; ASag_offset_x = ((TextBox)sender).Width - e.X; ASag_offset_y = ((TextBox)sender).Width - e.X; } else { O_offset_x = e.X; O_offset_y = e.Y; } } }
public void ProcessImage(object sender, EventArgs e) { Image<Bgr, Byte> frame = _capture.QueryFrame(); Image<Gray, Byte> grayImage = frame.Convert<Gray, Byte>(); grayImage._EqualizeHist(); System.Drawing.Rectangle imageArea = grayImage.ROI; System.Drawing.Rectangle mouseStableArea = new System.Drawing.Rectangle((int)(imageArea.Width * 0.4), (int)(imageArea.Height * 0.4), (int)(imageArea.Width * 0.2), (int)(imageArea.Height * 0.2)); //draw the stable area where the face will not trigger a movement; frame.Draw(mouseStableArea, new Bgr(255, 0, 0), 1); MCvAvgComp[] faces = grayImage.DetectHaarCascade(_face)[0]; if (faces.Length > 0) { //if there is at least one face #region find the biggest face MCvAvgComp biggestFace = faces[0]; for (int i = 1; i < faces.Length; i++) { if (faces[i].rect.Width * faces[i].rect.Height > biggestFace.rect.Width * biggestFace.rect.Height) biggestFace = faces[i]; } #endregion //draw a yellow rectangle around the face frame.Draw(biggestFace.rect, new Bgr(255, 255, 0.0), 1); Point biggestFaceCenter = new Point(biggestFace.rect.X + biggestFace.rect.Width / 2, biggestFace.rect.Y + biggestFace.rect.Height / 2); Point imageAreaCenter = new Point(imageArea.X + imageArea.Width / 2, imageArea.Y + imageArea.Height / 2); //draw a green cross at the center of the biggest face frame.Draw( new Cross2DF(biggestFaceCenter, biggestFace.rect.Width * 0.1f, biggestFace.rect.Height * 0.1f), new Bgr(0, 255, 0), 1); if (!mouseStableArea.Contains(biggestFaceCenter)) { //the point is far enough from the center to triger a movement //horizontal fraction is a value in [-0.5, 0.5] where //-0.5 refer to the far left and //0.5 refer to the far right double horizontalFraction = (double)(biggestFaceCenter.X - imageAreaCenter.X) / imageArea.Width; //do the same for vertical fraction double verticalFraction = (double)(biggestFaceCenter.Y - imageAreaCenter.Y) / imageArea.Height; Rectangle rect = System.Windows.Forms.Screen.PrimaryScreen.Bounds; int maxMouseSpeed = rect.Width / 20; System.Drawing.Point p; GetCursorPos(out p); p.X = Math.Min(Math.Max(0, p.X + (int)( (maxMouseSpeed / 2) * horizontalFraction)), rect.Width); p.Y = Math.Min(Math.Max(0, p.Y + (int) ((maxMouseSpeed / 2) * verticalFraction)), rect.Height); SetCursorPos(p.X, p.Y); } } imageBox1.Image = frame; }
public IEnumerable<IntVector2> SpiralPoints(IntVector2 start) { var rectangle = new Rectangle(0, 0, sourceData.Width, sourceData.Height); var spiralPoints = SpiralFromCached(start); var linearlyDistributed = DistributionCache.Select(index => spiralPoints[index]); var result = linearlyDistributed.Where(point => rectangle.Contains(point)); return result.ToLazyList(); }
public static void FixSectionLayout(Rectangle desiredRectangle, BaseSection section) { Rectangle sectionRectangle = new Rectangle(section.Location, section.Size); if (!sectionRectangle.Contains(desiredRectangle)) { section.Size = new Size(section.Size.Width, desiredRectangle.Size.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom); } }
private int DetectPointOnRect(Rectangle rt, Point pt) { Rectangle buf = rt; buf.Inflate(-iMul, -iMul); if (buf.Contains(pt)) { return 9; } if (!rt.Contains(pt)) { return -1; } Rectangle rttl = new Rectangle(rt.Left, rt.Top, iMul, iMul) , rtt = new Rectangle(buf.Left, rt.Top, rt.Width - 2 * iMul, iMul) , rttr = new Rectangle(buf.Right, rt.Top, iMul, iMul) , rtl = new Rectangle(rt.Left, buf.Top, iMul, rt.Height - 2 * iMul) , rtr = new Rectangle(buf.Right, buf.Top, iMul, rt.Height - 2 * iMul) , rtbl = new Rectangle(rt.Left, buf.Bottom, iMul, iMul) , rtb = new Rectangle(buf.Left, buf.Bottom, rt.Width - 2 * iMul, iMul) , rtbr = new Rectangle(buf.Right, buf.Bottom, iMul, iMul); if (rttl.Contains(pt)) { return 1; } if (rtt.Contains(pt)) { return 2; } if (rttr.Contains(pt)) { return 3; } if (rtl.Contains(pt)) { return 4; } if (rtr.Contains(pt)) { return 5; } if (rtbl.Contains(pt)) { return 6; } if (rtb.Contains(pt)) { return 7; } if (rtbr.Contains(pt)) { return 8; } return -1; }
//获取一组矩形中被包含在指定矩形区域内的矩形 public static List<Rectangle> ContainRectangle(List<Rectangle> rects, Rectangle rectLimits) { List<Rectangle> rectContain = new List<Rectangle>(); foreach (var rect in rects) { if (rectLimits.Contains(rect)) rectContain.Add(rect); } return rectContain; }
public IList<Point> Plan(Point start, Point destination) { Rectangle map = new Rectangle(0, 0, this.columnCount, this.lineCount); if ((!map.Contains(start)) || (!map.Contains(destination))) { throw new Exception("StartPoint or Destination not in the current map!"); } RoutePlanData routePlanData = new RoutePlanData(map, destination); AStarNode startNode = new AStarNode(start, null, 0, 0); routePlanData.OpenedList.Add(startNode); AStarNode currenNode = startNode; //从起始节点开始进行递归调用 return DoPlan(routePlanData, currenNode); }
/// <summary> /// 问:会不会有手里有3张但是只碰两张的情况出现? /// </summary> public void OnClick(int x, int y) { choosedIndex = -1; for (int i = 0; i < holdingCards.Count; i++) { Rectangle rec = new Rectangle(i * 34 + 10, 40, 33, 42); if (rec.Contains(new Point(x, y))) { choosedIndex = i; } } }
public static bool DragStarted(Point pt1, Point pt2) { Rectangle r = new Rectangle(pt1.X, pt1.Y, 0, 0); r.Inflate(SystemInformation.DragSize.Width, SystemInformation.DragSize.Height); return (r.Contains(pt2.X, pt2.Y) == false); }
private void tabControl1_MouseDown(object sender, MouseEventArgs e) { for (var i = 0; i < tabControl1.TabPages.Count; i++) { var r = tabControl1.GetTabRect(i); var cb = new Rectangle(r.Right - 15, r.Top + 4, 9, 7); if (cb.Contains(e.Location)) tabControl1.TabPages.RemoveAt(i); } }
protected override void OnMouseClick(DataGridViewCellMouseEventArgs e) { //Convert the CheckBoxRegion Rectangle rec = new Rectangle(new Point(0, 0), this.CheckBoxRegion.Size); this.checkAll = !this.checkAll; if (rec.Contains(e.Location)) { this.DataGridView.Invalidate(); } base.OnMouseClick(e); }
private void OnSourceGalleryMouseMove(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left || Control.ModifierKeys != Keys.None || dragItemHitInfo == null) return; Size dragSize = SystemInformation.DragSize; Rectangle dragRect = new Rectangle(dragItemHitInfo.HitPoint.X - dragSize.Width / 2, dragItemHitInfo.HitPoint.Y - dragSize.Height / 2, dragSize.Width, dragSize.Height); if (!(dragRect.Contains(e.Location))) sourceGallery.DoDragDrop(dragItemHitInfo.GalleryItem, DragDropEffects.Copy); }
public void RestoreBounds(MainForm mainForm) { Point location = Bounds.Location; foreach (Screen screen in Screen.AllScreens) { var workingArea = new Rectangle(screen.WorkingArea.Location, screen.WorkingArea.Size); workingArea.Inflate(4, 4); if (workingArea.Contains(location)) { if (!workingArea.Contains(Bounds)) { Bounds = new Rectangle(location, new Size(workingArea.Width - location.X, workingArea.Height - location.Y)); } mainForm.Bounds = Bounds; } } if (WindowState == FormWindowState.Maximized) mainForm.WindowState = FormWindowState.Maximized; }
/// <summary> /// Tests if the mouse hits this connector /// </summary> /// <param name="p"></param> /// <returns></returns> public override bool Hit(Point p) { Point a = p; Point b = Point; b.Offset(-7, -7); //a.Offset(-1,-1); Rectangle r = new Rectangle(a, new Size(0, 0)); Rectangle d = new Rectangle(b, new Size(15, 15)); return d.Contains(r); }
public Rectangle[] FlipShape(string direction, Rectangle[][] rectangleGameGrid) { var canShapeMove = true; if (direction == "right") { _currentShapePosition++; if (_currentShapePosition > 4) { _currentShapePosition = 1; } } if (direction == "left") { _currentShapePosition--; if (_currentShapePosition < 1) { _currentShapePosition = 4; } } SetShapePosition(); BuildShape(); var recGameArea = new Rectangle(0, 0, _panelWidth, _panelHeight); var yPosition = new int[4]; for (var i = 0; i < 4; i++) { if (!recGameArea.Contains(RectangleShape[i])) { canShapeMove = false; break; } yPosition[i] = _blockYPos[i]; if (decimal.Remainder(_blockYPos[i], 10) != 0) { yPosition[i] += 5; } if (!rectangleGameGrid[_yPositions[i]/10][_blockXPos[i]/10].IsEmpty) { canShapeMove = false; break; } } if (!canShapeMove) { if (direction == "right") { _currentShapePosition--; if (_currentShapePosition < 1) { _currentShapePosition = 4; } SetShapePosition(); BuildShape(); } if (direction == "left") { _currentShapePosition++; if (_currentShapePosition > 4) { _currentShapePosition = 1; } SetShapePosition(); BuildShape(); } } return RectangleShape; }
//******************************************************************************* // 虚函数继承 //******************************************************************************* // 虚函数继承,响应鼠标单击事件,鼠标单击到标题栏时改变圈起状态 protected override void OnClick(EventArgs e) { Rectangle kRectTitle = new Rectangle(new Point(5, 0), new Size(Width - 5 - 5, 20)); Point kPoint = PointToClient(MousePosition); if (kRectTitle.Contains(kPoint)) { Expand = !Expand; } base.OnClick(e); }
private void Form1_MouseDown(object sender, MouseEventArgs e) { scoreBoardContextMenu.Close(); if (e.Button == MouseButtons.Right) { mspt = e.Location; int pos = 0; for (int p = 0; p < 25; p++) { System.Drawing.Rectangle selection = new System.Drawing.Rectangle(0, 45 + (21 * pos), 900, 21); if (selection.Contains(mspt)) { contextPlayerPos = p; } pos += 1; } if (currentConnection.server.serverData.Players.Count >= contextPlayerPos) { int x = 0; for (int t = 0; t < currentConnection.server.prevteamlist.Count; t++) { Team team = currentConnection.server.prevteamlist[t]; if (team != null && team.GetPlayers() != null && team.GetPlayers().Count > 0) { for (int p = 0; p < team.GetPlayers().Count; p++) { PlayerInfo ps = team.GetPlayers()[p]; System.Drawing.Rectangle selection = new System.Drawing.Rectangle(0, 45 + (21 * x), 900, 20); if (selection.Contains(mspt)) { newContextPlayer = ps; } x += 1; } } } contextplayer = newContextPlayer; if (contextplayer != null && !contextplayer.Name.Equals("")) { scoreBoardContextMenu.Items[0].Text = "&Kick " + contextplayer.Name; scoreBoardContextMenu.Items[1].Text = "&Ban " + contextplayer.Name; this.scoreBoardContextMenu.Show(this, new Point(e.X, e.Y)); } } } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); bool arg_40_0 = e.Button == MouseButtons.Left; rectangle rectangle = new rectangle(0, 0, this.Width, Conversions.ToInteger(this.MoveHeight)); rectangle rectangle2 = rectangle; bool flag = arg_40_0 & rectangle2.Contains(e.Location); if (flag) { this.Cap = true; this.MousePoint = e.Location; } }
public bool HandleMouseDown(int x, int y, System.Windows.Forms.MouseButtons Button) { if (Button == System.Windows.Forms.MouseButtons.Left) { System.Drawing.Rectangle myRect = GetColorRect(true); if (myRect.IsEmpty == false && myRect.Contains(x, y)) { intSelectMode = 0; UpdateView(); return(true); } myRect = GetColorRect(false); if (myRect.IsEmpty == false && myRect.Contains(x, y)) { intSelectMode = 1; UpdateView(); return(true); } for (int iCount = 0; iCount < ColorTable.Length; iCount++) { if (GetItemRect(iCount).Contains(x, y)) { if (intSelectMode == 0) { intForeColor = ZYCommon.CommonFunction.ConvertToColor(ColorTable[iCount]); } else { intBackColor = ZYCommon.CommonFunction.ConvertToColor(ColorTable[iCount]); } UpdateView(); return(true); } } //for } //if return(false); } //public bool HandleMouseDown()
protected override void WndProc(ref System.Windows.Forms.Message m) { if ((m.Msg == 132) && HasSizeGrip) { System.IntPtr intPtr = m.LParam; System.Drawing.Point point = PointToClient(new System.Drawing.Point(intPtr.ToInt32())); System.Drawing.Rectangle rectangle = SizeGripBounds; if (rectangle.Contains(point)) { m.Result = new System.IntPtr(-1); return; } } base.WndProc(ref m); }
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { System.Drawing.Point point = e.Location; for (int i = 0; i < TabCount; i++) { System.Drawing.Rectangle rectangle = GetTabRect(i); rectangle.Offset(_LeftSpacing, 0); if (rectangle.Contains(point) && (SelectedIndex != i)) { allowNextSelection = true; SelectedIndex = i; return; } } }
/// <summary> /// 判断一个点是否在状态对象内 /// </summary> /// <param name="mousex"></param> /// <param name="mousey"></param> /// <returns>坐标点是否在状态对象内</returns> public bool contains(int mousex, int mousey) { objRect.X = this._x; objRect.Y = this._y; objRect.Width = this._w; objRect.Height = this._h; if (objRect.Contains(mousex, mousey)) { return(true); } else { return(false); } }
public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { System.Drawing.Rectangle rec = ButtonBounds; if (rec.Contains((int)e.CanvasLocation.X, (int)e.CanvasLocation.Y)) { MessageBox.Show("Still under Development", "Refresh", MessageBoxButton.OK); System.Drawing.Graphics g = null; button.Render(g, Color.Blue); return(GH_ObjectResponse.Handled); } } return(base.RespondToMouseDown(sender, e)); }
protected override void WndProc(ref System.Windows.Forms.Message m) { if ((Owner != null) && !Owner.IsDisposed && (m.Msg == 132) && Owner.HasSizeGrip) { System.IntPtr intPtr = m.LParam; System.Drawing.Point point = Owner.PointToClient(new System.Drawing.Point(intPtr.ToInt32())); System.Drawing.Rectangle rectangle = Owner.SizeGripBounds; if (rectangle.Contains(point)) { m.Result = Owner.SizeGripAlignment == System.Windows.Forms.LeftRightAlignment.Left ? new System.IntPtr(16) : new System.IntPtr(17); return; } } base.WndProc(ref m); }
private int GetItemAt(ListBox listBox, int X, int Y) { int index = -1; for (int i = 0; i < listBox.Items.Count; i++) { System.Drawing.Rectangle r = listBox.GetItemRectangle(i); if (r.Contains(new Point(X, Y))) { index = i; break; } } return(index); }
void tabControl1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { for (int i = 0; i < tabControl1.TabPages.Count; i++) { System.Drawing.Rectangle tabRect = tabControl1.GetTabRect(i); if (tabRect.Contains(e.Location)) { LogControl logControl = GetLogControlFromTabPage(tabControl1.TabPages[i]); SetSessionInfoList(logControl); break; } } } else if (e.Button == MouseButtons.Middle) { for (int i = 0; i < tabControl1.TabPages.Count; i++) { System.Drawing.Rectangle tabRect = tabControl1.GetTabRect(i); if (tabRect.Contains(e.Location)) { TreeNode sessionTabsNode = (TreeNode)tabControl1.TabPages[i].Tag; if (sessionTabsNode.Nodes.Count == 0) { TreeNode parentNode = sessionTabsNode.Parent; // this will be the node corresponding to the file TabPage parentTabPage = (TabPage)parentNode.Tag; if (parentNode.Nodes.Count == 1 && (parentTabPage != null) && !tabControl1.TabPages.Contains(parentTabPage)) { parentNode.Nodes.Remove(sessionTabsNode); sessionTabsNode.Nodes.Remove(parentNode); } else { sessionTreeView.Nodes.Remove(sessionTabsNode); } } tabControl1.TabPages.RemoveAt(i); break; } } } }
internal void SetSelectedShapes(System.Drawing.Rectangle AreaRect) { selectedShapes = new List <LeShape>(); foreach (LeShape shape in LeCanvas.self.xmlShapes.GetList()) { if (AreaRect.Contains(shape.Boundary.Location)) { shape.Selected = true; selectedShapes.Add(shape); } else { shape.Selected = false; } } Boundary = AreaRect; }
public bool Contains(Point point, Node node) { if (node == null) { return(false); } System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(); using (Graphics g = Graphics.FromImage(new Bitmap(1, 1))) { Size sizeRect = Size.Round(g.MeasureString(node.ToString(), node.NodeConfig.Converter.ToScreenFont(node.NodeConfig.Font))); PointF pos = new PointF(node.NodeConfig.Converter.XXtoII(node.X) - sizeRect.Width / 2, node.NodeConfig.Converter.YYtoJJ(node.Y) - sizeRect.Height / 2); rectangle = new System.Drawing.Rectangle(pos.ToPoint(), sizeRect); } return(rectangle.Contains(point)); }
private void CtrlDropDownForm_FormClicked(object sender, Oranikle.Studio.Controls.FormClickedEventArgs e) { if ((Host == null) || Host.IsDisposed) { return; } System.Drawing.Rectangle rectangle = Host.RectangleToScreen(Host.ClientRectangle); if (rectangle.Contains(e.ClickLocation)) { return; } if ((Host != null) && (Host.ParentForm != null)) { Host.Dismissed = true; } UpdateVisibility(); }
private void MoveForm(MouseEventArgs e) //This code is for form movement { try { base.OnMouseDown(e); if (e.Button == MouseButtons.Left) { System.Drawing.Rectangle rct = DisplayRectangle; if (rct.Contains(e.Location)) { ReleaseCapture(); SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); } } } catch { } } //End of code for form movement
private void tabControl1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Middle) { for (int i = 0; i < tabControl1.TabCount; i++) { System.Drawing.Rectangle r = tabControl1.GetTabRect(i); if (r.Contains(e.Location)) { tabControl1.SelectedIndex = i; return; } } } return; }
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { base.OnMouseDown(e); if ((e.Button == System.Windows.Forms.MouseButtons.Middle) && (((Oranikle.Studio.Controls.CtrlTabStrip)Parent).TabCount > ((Oranikle.Studio.Controls.CtrlTabStrip)Parent).MinNumOfTabButtons)) { RemoveTab(); return; } if (showCloseButton) { System.Drawing.Point point = e.Location; System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(Width - m_CloseButtonHorizontalOffset, m_CloseButtonVerticalOffset, 8, 8); if (rectangle.Contains(point) && (((Oranikle.Studio.Controls.CtrlTabStrip)Parent).TabCount > ((Oranikle.Studio.Controls.CtrlTabStrip)Parent).MinNumOfTabButtons)) { RemoveTab(); } } }
private Bitmap Rotate(Bitmap image, float angle) { Bitmap bmp = new Bitmap(image.Width, image.Height); var w = (image.Width & 1) == 0 ? image.Width + 1 : image.Width; var h = (image.Height & 1) == 0 ? image.Height + 1 : image.Height; //центр изображения var center = new System.Drawing.Point(w / 2, h / 2); //Границы изображения var rect = new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height); using (var m = new System.Drawing.Drawing2D.Matrix()) { System.Drawing.Point[] pts = new System.Drawing.Point[1]; m.Translate(center.X, center.Y); m.Rotate(-angle); //m.Invert(); for (int x = 0; x < image.Width; x++) { for (int y = 0; y < image.Height; y++) { //Вектор к пикселу pts[0] = new System.Drawing.Point(x - center.X, y - center.Y); m.TransformPoints(pts); if (!rect.Contains(pts[0])) { continue; } //bmp.SetPixel(pts[0].X, pts[0].Y, image.GetPixel(x, y)); bmp.SetPixel(x, y, image.GetPixel(pts[0].X, pts[0].Y)); } } for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { if (bmp.GetPixel(x, y).A == 0) { bmp.SetPixel(x, y, System.Drawing.Color.White); } } } } return(bmp); }
protected override void OnMouseMove(MouseEventArgs e) { bool invalidate = false; System.Drawing.Rectangle smallButtonRect = new System.Drawing.Rectangle(0, 0, 0, 0); System.Drawing.Rectangle largeButtonRect = smallButtonRect; CalculateRect(ref smallButtonRect, ref largeButtonRect); if (smallButtonRect.Contains(e.X, e.Y)) { int mouseXWithoutOffset = e.X - smallButtonRect.Left - _iList.ImageSize.Width / 2; int buttonIndex = (int)System.Math.Floor((double)mouseXWithoutOffset / _sizeOfButtonBorderAndSpace); if ((mouseXWithoutOffset - buttonIndex * _sizeOfButtonBorderAndSpace) <= _iList.ImageSize.Width) // mouse over index = buttonIndex { invalidate = buttonIndex != _selectedIndex; _state = e.Button == System.Windows.Forms.MouseButtons.Left ? State.Down : State.Over; _selectedIndex = buttonIndex; } else // mouse over nothing { invalidate = _selectedIndex != -1; _selectedIndex = -1; } } else // mouse over nothing { invalidate = _selectedIndex != -1; _selectedIndex = -1; } base.OnMouseMove(e); if (invalidate) { this.InvokeItemChanged(_selectedIndex); this.Invalidate(); } }
private void ListBoxOnDisposed(object sender, EventArgs eventArgs) { var clientRect = new System.Drawing.Rectangle(0, 0, Width, Height); var contains = clientRect.Contains(PointToClient(MousePosition)); if (!contains) { listBoxOpened = false; } else { listBoxOpened = !listBoxOpened; } listBox.MouseUp -= ListBoxOnMouseUp; listBox.KeyDown -= ListBoxOnKeyDown; listBox.Disposed -= ListBoxOnDisposed; listBox = null; }
private void tabReports_MouseClick(object sender, MouseEventArgs e) { for (int i = 0; i < tabReports.TabCount; ++i) { var rect = tabReports.GetTabRect(i); var xRect = new System.Drawing.Rectangle(rect.Left + rect.Width - 18, rect.Top, 18, rect.Height); if (xRect.Contains(e.Location)) { cEditor editor = (cEditor)tabReports.TabPages[i].Tag; if (editor.close()) { tabReports.TabPages.RemoveAt(i); if (tabReports.TabPages.Count == 0) { cMainEditor.setDocActive(null); } } } } }
private static System.Drawing.Rectangle GetBestRectangleOfMonitor(MonitorHelper.DisplayInfo monitor, List <AppInfo> allApps) { bool isFirstRect = true; System.Drawing.Rectangle boundingRec = new Rectangle(); ScreenRectangle monitorRect = new ScreenRectangle(monitor.WorkArea); System.Drawing.Rectangle rMonitor = RecFromScreenRec(monitorRect); System.Drawing.Rectangle rMonitor2 = new Rectangle(rMonitor.Left - 15, rMonitor.Top - 15, rMonitor.Width + 30, rMonitor.Height + 30); foreach (var anApp in allApps) { //Is the app fully contained in the window System.Drawing.Rectangle appRec = RecFromScreenRec(anApp.Rect); if (IsMinAppSize(appRec)) { if (rMonitor.Contains(appRec) || rMonitor2.Contains(appRec)) { System.Diagnostics.Debug.WriteLine(anApp.AppName + "contained on Monitor"); if (isFirstRect) { boundingRec = appRec; isFirstRect = false; } else { boundingRec = System.Drawing.Rectangle.Union(boundingRec, appRec); } } } } if (!IsMinAppSize(boundingRec)) { return(rMonitor); } return(boundingRec); }
public IEnumerable <FoodSprite> iterFoodsWithHitRect(System.Drawing.Rectangle rect) { for (int i = 0; i < _collisionGroups.Count; ++i) { var g = (CollisionGroup)_collisionGroups[i]; if (g.rect.IntersectsWith(rect)) { foreach (int foodId in g.foodIds) { if (_foodList.exists(foodId)) { var food = _foodList.getById(foodId); if (rect.Contains(food.x, food.y)) { yield return(food); } } } } } }
public static Point[] GetDirectPath(System.Drawing.Rectangle rect1, System.Drawing.Point p1, System.Drawing.Rectangle rect2, System.Drawing.Point p2) { p1 = new System.Drawing.Point(p1.X + rect1.X, p1.Y + rect1.Y); p2 = new System.Drawing.Point(p2.X + rect2.X, p2.Y + rect2.Y); if (rect1.Contains(p2) || rect2.Contains(p1)) { return(new Point[0]); } List <Point> results = new List <Point>(); results.Add(p1); Point movingPoint = GetNotIntersetPoint(rect1, p1); Point endPoint = GetNotIntersetPoint(rect2, p2); results.Add(movingPoint); results.Add(endPoint); results.Add(p2); return(results.ToArray()); }
protected override void CloneTextBox_LostFocus(object sender, EventArgs e) { base.CloneTextBox_LostFocus(sender, e); if (!IsValid) { return; } var mouseEventArgs = e as MouseEventExtArgs; if (e != null && mouseEventArgs == null) { return; } if (e != null) { System.Windows.Point absolutePoint = CloneTextBox.PointToScreen(new System.Windows.Point(0d, 0d)); var absoluteRectangle = new Rectangle((int)absolutePoint.X, (int)absolutePoint.Y, CloneTextBoxLocation.Width, CloneTextBoxLocation.Height); if (absoluteRectangle.Contains(mouseEventArgs.X, mouseEventArgs.Y)) { return; } } if (CloneTextBox.Tag.ToString() != CloneTextBox.Text) { string name = CloneTextBox.Tag.ToString(); //File.Move(file, Path.GetDirectoryName(file) + "\\" + CloneTextBox.Text + Path.GetExtension(file)); Notes.Add(CloneTextBox.Text, Notes[name]); Notes[CloneTextBox.Text].Name = CloneTextBox.Text; updageTagOnFlag(Notes[CloneTextBox.Text]); Notes.Remove(name); OnSave(() => { }, ParentControl.BrowseProject.LoadedFile); } MainControl.Items.Refresh(); EndChangingDynamicItem(); }
private Control _ControlAt(Point mousePosition) { Control control = null; if (Contexts.Count > 0) { for (int i = 0; i < Contexts.Count; i++) { var contextControl = Contexts[i]; var cRect = new System.Drawing.Rectangle(contextControl.Location.X, contextControl.Location.Y, contextControl.Width, contextControl.Height); if (cRect.Contains(mousePosition)) { control = contextControl; break; } } } if (ModalForms.Count > 0) { if (control == null) { var lastModalForm = ModalForms.Last(); var formRect = new System.Drawing.Rectangle(lastModalForm.Location.X, lastModalForm.Location.Y, lastModalForm.Width, lastModalForm.Height); if (formRect.Contains(mousePosition)) { control = lastModalForm; } } } else { if (control == null) { for (int i = Forms.Count - 1; i >= 0; i--) { var form = Forms[i]; if (form.TopMost && form.Visible && form.Enabled) { var formRect = new System.Drawing.Rectangle(form.Location.X, form.Location.Y, form.Width, form.Height); if (formRect.Contains(mousePosition)) { control = form; break; } } } } if (control == null) { for (int i = Forms.Count - 1; i >= 0; i--) { var form = Forms[i]; if (form.TopMost == false && form.Visible && form.Enabled) { var formRect = new System.Drawing.Rectangle(form.Location.X, form.Location.Y, form.Width, form.Height); if (formRect.Contains(mousePosition)) { control = form; break; } } } } } if (control != null) { control = FindControlAt(control, mousePosition); } return(control); }
//public static double LocationToFloat(int location) { return ((double)location) * LayoutAlgorithmSettings.PointSize; } //public static double LocationToFloat(string location) { return LocationToFloat(Int32.Parse(location)); } internal bool DestRectContainsPoint(System.Drawing.Point p) { return(destRect.Contains(p)); }
/// <summary>Does the control contain this point?</summary> public override bool ContainsPoint(System.Drawing.Point pt) { return(boundingBox.Contains(pt) || buttonRect.Contains(pt)); }
private void CreateDelaunay(ref Mat img, ref Subdiv2D subdiv, ref VectorOfPointF points, bool drawAnimated, ref VectorOfVectorOfInt triangleIndexes) { PointF[] pointsArr = points.ToArray(); foreach (PointF p in pointsArr) { subdiv.Insert(p); if (drawAnimated) { Mat imgCopy = img.Clone(); DrawDelaunay(ref imgCopy, ref subdiv, new MCvScalar(255, 255, 255)); CvInvoke.Imshow("Delaunay Triangulation", imgCopy); } } // Unfortunately we don't get the triangles by there original point indexes. // We only get them with their vertex coordinates. // So we have to map them again to get the triangles with their point indexes. Size size = img.Size; Rectangle rect = new Rectangle(0, 0, size.Width, size.Height); VectorOfInt ind = new VectorOfInt(); int[] indArr = new int[3]; Triangle2DF[] triangleList = subdiv.GetDelaunayTriangles(); for (int i = 0; i < triangleList.Length; i++) { Triangle2DF t = triangleList[i]; PointF ptzero = new PointF { X = t.V0.X, Y = t.V0.Y }; PointF[] PZero = new PointF[] { ptzero }; PointF ptone = new PointF { X = t.V1.X, Y = t.V1.Y }; PointF[] POne = new PointF[] { ptone }; PointF pttwo = new PointF { X = t.V2.X, Y = t.V2.Y }; PointF[] PTwo = new PointF[] { pttwo }; VectorOfPointF pt = new VectorOfPointF(); pt.Push(PZero); pt.Push(POne); pt.Push(PTwo); if (rect.Contains(new Point((int)pt[0].X, (int)pt[0].Y)) && rect.Contains(new Point((int)pt[1].X, (int)pt[1].Y)) && rect.Contains(new Point((int)pt[2].X, (int)pt[2].Y))) { for (int j = 0; j < 3; j++) { for (int k = 0; k < points.Size; k++) { if (Math.Abs(pt[j].X - points[k].X) < 1.0 && Math.Abs(pt[j].Y - points[k].Y) < 1) { indArr[j] = k; } } } } ind = new VectorOfInt(indArr); triangleIndexes.Push(ind); } }
private void Sprites_manager_Paint(object sender, PaintEventArgs e) { if (lastImage != null) { e.Graphics.DrawImage(lastImage, new RectangleF(darkSectionPanel1.Location.X + darkSectionPanel1.Width + 20, darkSectionPanel1.Location.Y, lastImage.Width * (float)zoom, lastImage.Height * (float)zoom)); int cx, cy; cx = darkSectionPanel1.Location.X + darkSectionPanel1.Width + 20; cy = darkSectionPanel1.Location.Y; int xIndex = 0; int yIndex = 0; if (rows > 0 && cellH > 0 && cellW > 0) { for (var i = 0; i < rows; i++) { for (var j = 0; j < lastImage.Width / cellW; j++) { bool hit = false; Rectangle r = new Rectangle((int)(cx * 1), (int)(cy * 1), (int)(cellW * zoom), (int)(cellH * zoom)); if (r.Contains(new System.Drawing.Point((int)mouse.X, (int)mouse.Y))) { hit = true; } if (hit) { e.Graphics.FillRectangle(b, r); } e.Graphics.DrawRectangle(p, r); cx += (int)(cellW * zoom); xIndex++; } cy += (int)Math.Round(cellH * zoom); yIndex++; xIndex = 0; cx = darkSectionPanel1.Location.X + darkSectionPanel1.Width + 20; } foreach (Subsprite ss in subsprites) { xIndex = 0; yIndex = 0; cx = darkSectionPanel1.Location.X + darkSectionPanel1.Width + 20; cy = darkSectionPanel1.Location.Y; for (var i = 0; i < rows; i++) { for (var j = 0; j < lastImage.Width / cellW; j++) { bool hit = false; Rectangle r = new Rectangle((int)(cx * 1), (int)(cy * 1), (int)(cellW * zoom), (int)(cellH * zoom)); if (r.Contains(new System.Drawing.Point((int)mouse.X, (int)mouse.Y))) { hit = true; } if (xIndex >= ss.cellX && xIndex <= ss.cellW + ss.cellX && yIndex >= ss.cellY && yIndex <= ss.cellH + ss.cellY) { e.Graphics.FillRectangle(ss.sb, r); } cx += (int)(cellW * zoom); xIndex++; } cy += (int)Math.Round(cellH * zoom); yIndex++; xIndex = 0; cx = darkSectionPanel1.Location.X + darkSectionPanel1.Width + 20; } } } } }
private void Sprites_manager_MouseClick(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { if (rows > 0 && cellH > 0 && cellW > 0) { int cx, cy; cx = darkSectionPanel1.Location.X + darkSectionPanel1.Width + 20; cy = darkSectionPanel1.Location.Y; int xIndex = 0; int yIndex = 0; for (var i = 0; i < rows; i++) { for (var j = 0; j < lastImage.Width / cellW; j++) { bool hit = false; Rectangle r = new Rectangle((int)(cx * 1), (int)(cy * 1), (int)(cellW * zoom), (int)(cellH * zoom)); if (r.Contains(new System.Drawing.Point((int)mouse.X, (int)mouse.Y))) { hit = true; } if (hit) { if (toolMode == 0) { if (selectedSub == null) { Subsprite s = new Subsprite(); s.cellX = xIndex; s.cellY = yIndex; subsprites.Add(s); selectedSub = s; } else { selectedSub.cellW = xIndex - selectedSub.cellX; selectedSub.cellH = yIndex - selectedSub.cellY; selectedSub = null; } } if (toolMode == 1) { SavePartialBitmap(lastImage, Path.GetFullPath("../../../SimplexRpgEngine3/Content/Sprites/Tilesets/tilesetSource0.png"), xIndex * cellW, yIndex * cellH, cellW, cellH, System.Drawing.Imaging.ImageFormat.Png); lastImage = new Bitmap(Path.GetFullPath("../../../SimplexRpgEngine3/Content/Sprites/Tilesets/tilesetSource0.png")); toolMode = 2; Bitmap convertedImage = new Bitmap(256, 192); #region Algorithm logic CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(0, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(32, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(32, 0, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(64, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(80, 0, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(96, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(96, 0, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(112, 0, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(128, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(144, 16, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(160, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(176, 16, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(160, 0, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(192, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(208, 0, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(208, 16, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(224, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(240, 0, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(240, 16, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(224, 0, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(0, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 16, 16), ref convertedImage, new Rectangle(0, 48, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(32, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 32), ref convertedImage, new Rectangle(32, 32, 16, 32)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(64, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(80, 32, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 16, 16), ref convertedImage, new Rectangle(64, 48, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(96, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(112, 32, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 16, 16), ref convertedImage, new Rectangle(96, 48, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(96, 32, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(128, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 32, 16), ref convertedImage, new Rectangle(128, 48, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(160, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 32, 16), ref convertedImage, new Rectangle(160, 48, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(160, 32, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(192, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 32, 16), ref convertedImage, new Rectangle(192, 48, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(208, 32, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 32, 32), ref convertedImage, new Rectangle(224, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 48, 32, 32), ref convertedImage, new Rectangle(0, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 48, 32, 32), ref convertedImage, new Rectangle(32, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(48, 64, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 48, 32, 32), ref convertedImage, new Rectangle(64, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(80, 80, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 48, 32, 32), ref convertedImage, new Rectangle(96, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(112, 80, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(112, 64, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 32, 32, 32), ref convertedImage, new Rectangle(128, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(16, 32, 32, 32), ref convertedImage, new Rectangle(160, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(176, 80, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 32, 32, 32), ref convertedImage, new Rectangle(192, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 16, 16), ref convertedImage, new Rectangle(192, 80, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 32, 32, 32), ref convertedImage, new Rectangle(224, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(240, 80, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 16, 16), ref convertedImage, new Rectangle(224, 80, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 48, 32, 32), ref convertedImage, new Rectangle(0, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 48, 32, 32), ref convertedImage, new Rectangle(32, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 16, 16), ref convertedImage, new Rectangle(32, 112, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 48, 32, 32), ref convertedImage, new Rectangle(64, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(64, 96, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 48, 32, 32), ref convertedImage, new Rectangle(96, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 16, 16), ref convertedImage, new Rectangle(96, 112, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(96, 96, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 64, 32, 32), ref convertedImage, new Rectangle(128, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(16, 64, 32, 32), ref convertedImage, new Rectangle(160, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(160, 96, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 64, 32, 32), ref convertedImage, new Rectangle(192, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(208, 96, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 64, 32, 32), ref convertedImage, new Rectangle(224, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(224, 96, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(240, 96, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 48, 16, 32), ref convertedImage, new Rectangle(0, 128, 16, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 48, 16, 32), ref convertedImage, new Rectangle(16, 128, 16, 32)); CopyRegionIntoImage(lastImage, new Rectangle(16, 32, 32, 16), ref convertedImage, new Rectangle(32, 128, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(16, 80, 32, 16), ref convertedImage, new Rectangle(32, 144, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 32, 32, 32), ref convertedImage, new Rectangle(64, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 32, 32, 32), ref convertedImage, new Rectangle(96, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 16, 16, 16), ref convertedImage, new Rectangle(96 + 16, 128 + 16, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 32, 32, 32), ref convertedImage, new Rectangle(128, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 32, 32, 32), ref convertedImage, new Rectangle(160, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 16, 16, 16), ref convertedImage, new Rectangle(160, 128 + 16, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 64, 32, 32), ref convertedImage, new Rectangle(192, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 64, 32, 32), ref convertedImage, new Rectangle(224, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 16, 16), ref convertedImage, new Rectangle(224, 128, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 64, 32, 32), ref convertedImage, new Rectangle(0, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 64, 32, 32), ref convertedImage, new Rectangle(32, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 0, 16, 16), ref convertedImage, new Rectangle(48, 160, 16, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 32, 16, 32), ref convertedImage, new Rectangle(64, 160, 16, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 32, 16, 32), ref convertedImage, new Rectangle(80, 160, 16, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 32, 32, 16), ref convertedImage, new Rectangle(96, 160, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 80, 32, 16), ref convertedImage, new Rectangle(96, 176, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 64, 16, 32), ref convertedImage, new Rectangle(128, 160, 16, 32)); CopyRegionIntoImage(lastImage, new Rectangle(48, 64, 16, 32), ref convertedImage, new Rectangle(144, 160, 16, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 32, 32, 16), ref convertedImage, new Rectangle(160, 160, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(32, 80, 32, 16), ref convertedImage, new Rectangle(160, 176, 32, 16)); CopyRegionIntoImage(lastImage, new Rectangle(0, 0, 32, 32), ref convertedImage, new Rectangle(192, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(16, 48, 32, 32), ref convertedImage, new Rectangle(224, 160, 32, 32)); #endregion lastImage = convertedImage; Bitmap bpp = new Bitmap(256, 192); // r1 CopyRegionIntoImage(lastImage, new Rectangle(0, 0, 32, 32), ref bpp, new Rectangle(0, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(128, 160, 32, 32), ref bpp, new Rectangle(32, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(160, 160, 32, 32), ref bpp, new Rectangle(64, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(224, 128, 32, 32), ref bpp, new Rectangle(96, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(192, 128, 32, 32), ref bpp, new Rectangle(128, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(96, 160, 32, 32), ref bpp, new Rectangle(160, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 160, 32, 32), ref bpp, new Rectangle(192, 0, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 160, 32, 32), ref bpp, new Rectangle(224, 0, 32, 32)); // r2 CopyRegionIntoImage(lastImage, new Rectangle(32, 128, 32, 32), ref bpp, new Rectangle(0, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(224, 96, 32, 32), ref bpp, new Rectangle(32, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(192, 96, 32, 32), ref bpp, new Rectangle(64, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(160, 96, 32, 32), ref bpp, new Rectangle(96, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(128, 96, 32, 32), ref bpp, new Rectangle(128, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(64, 160, 32, 32), ref bpp, new Rectangle(160, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 128, 32, 32), ref bpp, new Rectangle(192, 32, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(160, 128, 32, 32), ref bpp, new Rectangle(224, 32, 32, 32)); // r3 CopyRegionIntoImage(lastImage, new Rectangle(96, 96, 32, 32), ref bpp, new Rectangle(0, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 96, 32, 32), ref bpp, new Rectangle(32, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(96, 128, 32, 32), ref bpp, new Rectangle(64, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(96, 64, 32, 32), ref bpp, new Rectangle(96, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(64, 64, 32, 32), ref bpp, new Rectangle(128, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(192, 64, 32, 32), ref bpp, new Rectangle(160, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(224, 32, 32, 32), ref bpp, new Rectangle(192, 64, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(64, 32, 32, 32), ref bpp, new Rectangle(224, 64, 32, 32)); // r4 CopyRegionIntoImage(lastImage, new Rectangle(160, 32, 32, 32), ref bpp, new Rectangle(0, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(128, 32, 32, 32), ref bpp, new Rectangle(32, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(128, 128, 32, 32), ref bpp, new Rectangle(64, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(64, 96, 32, 32), ref bpp, new Rectangle(96, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 96, 32, 32), ref bpp, new Rectangle(128, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(160, 64, 32, 32), ref bpp, new Rectangle(160, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(160, 0, 32, 32), ref bpp, new Rectangle(192, 96, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(192, 0, 32, 32), ref bpp, new Rectangle(224, 96, 32, 32)); // r5 CopyRegionIntoImage(lastImage, new Rectangle(160, 0, 32, 32), ref bpp, new Rectangle(0, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(128, 0, 32, 32), ref bpp, new Rectangle(32, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(64, 128, 32, 32), ref bpp, new Rectangle(64, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 64, 32, 32), ref bpp, new Rectangle(96, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 64, 32, 32), ref bpp, new Rectangle(128, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(192, 64, 32, 32), ref bpp, new Rectangle(160, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(96, 32, 32, 32), ref bpp, new Rectangle(192, 128, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(64, 32, 32, 32), ref bpp, new Rectangle(224, 128, 32, 32)); // r6 CopyRegionIntoImage(lastImage, new Rectangle(32, 32, 32, 32), ref bpp, new Rectangle(0, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 32, 32, 32), ref bpp, new Rectangle(32, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(128, 64, 32, 32), ref bpp, new Rectangle(64, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(96, 0, 32, 32), ref bpp, new Rectangle(96, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(64, 0, 32, 32), ref bpp, new Rectangle(128, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(32, 0, 32, 32), ref bpp, new Rectangle(160, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(0, 0, 32, 32), ref bpp, new Rectangle(192, 160, 32, 32)); CopyRegionIntoImage(lastImage, new Rectangle(192, 160, 32, 32), ref bpp, new Rectangle(224, 160, 32, 32)); bpp.Save(Path.GetFullPath("../../../SimplexRpgEngine3/Content/Sprites/Tilesets/tileset0.png")); //lastImage.Save(Path.GetFullPath("../../../SimplexRpgEngine3/Content/Sprites/Tilesets/tileset0.png")); using (StreamWriter w = File.AppendText("../../../SimplexRpgEngine3/Content/Content.mgcb")) { w.WriteLine("#begin Sprites/Tilesets/" + "tileset0.png"); w.WriteLine("/importer:TextureImporter"); w.WriteLine("/processor:TextureProcessor"); w.WriteLine("/processorParam:ColorKeyColor=255,0,255,255"); w.WriteLine("/processorParam:ColorKeyEnabled=True"); w.WriteLine("/processorParam:GenerateMipmaps=False"); w.WriteLine("/processorParam:PremultiplyAlpha=True"); w.WriteLine("/processorParam:ResizeToPowerOfTwo=False"); w.WriteLine("/processorParam:MakeSquare=False"); w.WriteLine("/processorParam:TextureFormat=Color"); w.WriteLine("/build:Sprites/Tilesets/" + "tileset0.png"); w.WriteLine(""); } } } cx += (int)(cellW * zoom); xIndex++; } yIndex++; xIndex = 0; cy += (int)Math.Round(cellH * zoom); cx = darkSectionPanel1.Location.X + darkSectionPanel1.Width + 20; } } } }