private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { return; } if (currentShape != null) { undoElements = new UseCaseDiagramDocument(Elements); undoDone = false; unselectShapes(); currentShape.Selected = true; Elements.Add(currentShape); EnlargeIfNeeded(currentShape); currentShape = null; unselectToolStrips(); } else { bool Moveflag = false; bool resizeFlag = false; bool lineFirstPoint = false; bool anyShapeClicked = false; foreach (IDrawable obj in Elements.Elements) { if (obj.IsFirstPointClicked(e.Location) && !ctrlDown) { undoElements = new UseCaseDiagramDocument(Elements); undoDone = false; firstPointDragStart = e.Location; lineFirstPoint = true; } else if (obj.IsResizeSquareClicked(e.Location) && !ctrlDown) { undoElements = new UseCaseDiagramDocument(Elements); undoDone = false; resizeDragStart = e.Location; resizeFlag = true; } else if (obj.Selected && obj.isClicked(e.Location) && !ctrlDown) { undoElements = new UseCaseDiagramDocument(Elements); undoDone = false; Moveflag = true; } } if (!resizeFlag && !lineFirstPoint) { if (Moveflag) { undoElements = new UseCaseDiagramDocument(Elements); undoDone = false; dragStart = e.Location; this.Cursor = Cursors.SizeAll; } else { Elements.Selected(e.Location, ctrlDown); } } if (!ctrlDown && !Moveflag && !resizeFlag) { foreach (IDrawable obj in Elements.Elements) { obj.isSelected(e.Location, false); if (obj.Selected) { anyShapeClicked = true; previouslyShapeSelected = true; } } if (!anyShapeClicked) { startPointSelectRectangle = e.Location; } } } lastClickedShape = null; foreach (IDrawable obj in Elements.Elements) { if (obj.isClicked(e.Location)) { lastClickedShape = obj; } } if (lastClickedShape != null) { Point location = new Point(lastClickedShape.X, lastClickedShape.Y - 30); location.X -= panel1.HorizontalScroll.Value; location.Y -= panel1.VerticalScroll.Value; location.X = Math.Max(location.X, 0); toolStripMobile.Location = location; toolStripMobileChangeText.Text = lastClickedShape.Text; toolStripMobilecbBorderWidth.Text = lastClickedShape.BorderWidth.ToString(); toolStripMobilebtnBorderColor.Enabled = true; toolStripMobilebtnFillColor.Enabled = true; if (lastClickedShape.GetType() == typeof(Actor)) { toolStripMobilebtnBorderColor.Enabled = false; toolStripMobilebtnFillColor.Enabled = false; } else if (lastClickedShape.GetType() == typeof(Line)) { toolStripMobilebtnFillColor.Enabled = false; } toolStripMobile.Visible = true; } else { toolStripMobile.Visible = false; } Invalidate(true); }