Ejemplo n.º 1
0
		private Shape DetectNewShapeDuringDrag(DragState state, MSet<LLShape> adorners, out bool potentialSelection)
		{
			potentialSelection = false;
			Shape newShape = null;
			adorners.Add(new LLPolyline(DiagramControl.MouseLineStyle, state.Points.Select(p => p.Point).AsList()) { ZOrder = 0x100 });

			if (state.Points.Count == 1)
			{
				newShape = new Marker(Control.BoxStyle, state.FirstPoint, Control.MarkerRadius, Control.MarkerType);
			}
			else if (state.MousePoints.Count > 1)
			{
#if DEBUG
				List<Section> ss = BreakIntoSections(state);
				EliminateTinySections(ss, 10 + (int)(ss.Sum(s => s.LengthPx) * 0.05));
				foreach (Section s in ss)
					adorners.Add(new LLMarker(new DrawStyle { LineColor = Color.Gainsboro, FillColor = Color.Gray }, s.StartSS, 5, MarkerPolygon.Circle));
#endif

				newShape = RecognizeBoxOrLines(state, out potentialSelection);
			}
			return newShape;
		}
Ejemplo n.º 2
0
		private void HandleMouseUp(DragState state, Shape newShape, IEnumerable<Shape> eraseSet)
		{
			if (!state.IsDrag)
			{
				if (state.Clicks >= 2)
				{
					if (Control.SelectedShapes.Count != 0)
					{
						var htr = state.ClickedShape;
						foreach (var shape in Control.SelectedShapes)
						{
							DoOrUndo action = shape.DoubleClickAction(htr.Shape == shape ? htr : null);
							if (action != null)
								_doc.UndoStack.Do(action, false);
						}
						_doc.UndoStack.FinishGroup();
					}
					else
					{
						// Create marker shape
						newShape = new Marker(Control.BoxStyle, state.FirstPoint, Control.MarkerRadius, Control.MarkerType);
					}
				}
				else
				{
					Control.ClickSelect(state.ClickedShape != null ? state.ClickedShape.Shape as Shape : null);
					Control._lastClickLocation = state.FirstPoint;
				}
			}

			_doc.UndoStack.AcceptTentativeAction(); // if any
			Control._partialSelShape = null;
			if (newShape != null)
			{
				if (newShape.Style == SelectorBoxStyle)
					SelectByBox(newShape.BBox);
				else
					Control.AddShape(newShape);
			}
			if (eraseSet != null)
				Control.DeleteShapes(new Set<Shape>(eraseSet));
			_doc.MarkPanels();
		}