public StopBlock(int xMouse, int yMouse) : base("STOP") { X = xMouse - Width / 2; Y = yMouse - Height / 2; InLink = new InLinkButton(X + Width / 2 - InLinkButton.R, Y - InLinkButton.R); }
public OperationBlock(int xMouse, int yMouse, string text) : base(text) { X = xMouse - Width / 2; Y = yMouse - Height / 2; InLink = new InLinkButton(X + Width / 2 - InLinkButton.R, Y - InLinkButton.R); OutLink = new OutLinkButton(X + Width / 2 - OutLinkButton.R, Y + Height - OutLinkButton.R); }
public override void RemoveLinks() { if (InLink.LinkedTo != null) { InLink.LinkedTo.LinkedTo = null; } InLink = null; }
} // false; public DecisionBlock(int xMouse, int yMouse, string text) : base(text) { topPoint = new Point(xMouse, yMouse - HalfDiameter); rightPoint = new Point(xMouse + HalfDiameter, yMouse); bottomPoint = new Point(xMouse, yMouse + HalfDiameter); leftPoint = new Point(xMouse - HalfDiameter, yMouse); InLink = new InLinkButton(topPoint.X - InLinkButton.R, topPoint.Y - InLinkButton.R); OutLinkLeft = new OutLinkButton(leftPoint.X - OutLinkButton.R, leftPoint.Y - OutLinkButton.R); OutLinkRight = new OutLinkButton(rightPoint.X - OutLinkButton.R, rightPoint.Y - OutLinkButton.R); }
private void NewScheme(int Width, int Height) { ifLineDraw = false; linkStartButton = null; notAllowedInLink = null; textBox1.Text = ""; textBox1.Enabled = false; StartBlock.IsPresent = false; blockList.Clear(); pictureBox1.Size = new Size(Width, Height); bit = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics flagGraphics = Graphics.FromImage(bit); flagGraphics.Clear(Color.White); pictureBox1.Image = bit; pictureBox1.Refresh(); }
public override (bool canBeDone, InLinkButton inLinkButton) EndLink(int xMouse, int yMouse, InLinkButton notAllowedInLink) { if (InLink.LinkedTo == null && InLink.IsUnderMouse(xMouse, yMouse) && InLink != notAllowedInLink) { return(true, InLink); } return(false, null); }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ComponentResourceManager resourceManager = new ComponentResourceManager(typeof(Form1)); Block newBlock; if (isOperationBlockClicked) { newBlock = new OperationBlock(e.X, e.Y, resourceManager.GetString("operationBlockText")); } else if (isDecisionBlockClicked) { newBlock = new DecisionBlock(e.X, e.Y, resourceManager.GetString("decisionBlockText")); } else if (isStartBlockClicked) { if (!StartBlock.IsPresent) { newBlock = new StartBlock(e.X, e.Y); } else { MessageBox.Show(resourceManager.GetString("startCreatingErrorText"), resourceManager.GetString("startCreatingErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else if (isStopBlockClicked) { newBlock = new StopBlock(e.X, e.Y); } else if (isTrashClicked) { DeleteBlockFromPosition(e.X, e.Y); return; } else if (isLinkClicked) { bool canBeDone = false; notAllowedInLink = null; for (int i = blockList.Count - 1; i >= 0; i--) { (canBeDone, linkStartButton, notAllowedInLink) = blockList[i].StartLink(e.X, e.Y); if (canBeDone) { ifLineDraw = true; linkEnd = linkStart = new Point(e.X, e.Y); return; } } return; } else { return; } blockList.Add(newBlock); newBlock.DrawBlockImage(bit, pictureBox1); } else if (e.Button == MouseButtons.Right) { Block.ClickedBlockIndex = -1; textBox1.Enabled = true; for (int i = blockList.Count - 1; i >= 0; i--) { if (blockList[i].IsUnderMouse(e.X, e.Y)) { blockList[i].IsClicekd = true; Block.ClickedBlockIndex = i; break; } } if (Block.ClickedBlockIndex == -1) { clickedBlock = null; textBox1.Text = ""; textBox1.Enabled = false; } else { clickedBlock = blockList[Block.ClickedBlockIndex]; } for (int i = 0; i < blockList.Count; i++) { if (i != Block.ClickedBlockIndex) { blockList[i].IsClicekd = false; blockList[i].DrawBlockImage(bit, pictureBox1); } else { blockList[i].IsClicekd = true; blockList[i].DrawClickedBlockImage(bit, pictureBox1); textBox1.Text = blockList[i].Text; if (blockList[i] is StartBlock || blockList[i] is StopBlock) { textBox1.Enabled = false; } } } } }
public override (bool canBeDone, InLinkButton inLinkButton) EndLink(int xMouse, int yMouse, InLinkButton notAllowedInLink) { return(false, null); }
public static void LinkOutToIn(Point A, Point B, OutLinkButton outLinkButton, InLinkButton inLinkButton, Bitmap srcBitmap, PictureBox srcPictureBox) { outLinkButton.LinkedTo = inLinkButton; inLinkButton.LinkedTo = outLinkButton; outLinkButton.startLinkPoint = A; inLinkButton.endLinkPoint = B; DrawLinkOutToIn(A, B, srcBitmap, srcPictureBox); }
public abstract (bool canBeDone, InLinkButton inLinkButton) EndLink(int xMouse, int yMouse, InLinkButton notAllowedInLink);