public ImageViewPort() { _viewPortInstance = this; _currentPrimitive = new SelectionTool(); DoubleBuffered = true; _shapeControl = new ShapeBoxControl(null); _navigationControl = new NavigationControl(); SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); }
public override void AttachTo(Primitive primitive) { if (primitive == null) { attachedBox = null; } else { attachedBox = primitive as DecoratedTextBox; numControl.Value = attachedBox.borderSize; colorBorderControl.Color = attachedBox.borderColor; colorBackControl.Color = attachedBox.backColor; } Invalidate(); }
public override void AttachTo(Primitive primitive) { if (primitive == null) { attachedLine = null; } else { attachedLine = primitive as Line; numControl.Value = attachedLine.penSize; colorControl.Color = attachedLine.penColor; lineDD.SelectItem(attachedLine.penStyle); } Invalidate(); }
protected override void OnMouseDown(MouseEventArgs e) { if (e.Button != MouseButtons.Left) return; _dragPointID = _shapeControl.GetPoint(MouseToReal(e.Location)); if (_dragPointID >= 0) { return; } Primitive overPrimitive = GetPrimitiveAt(MouseToReal(e.Location)); if (overPrimitive != null && (ModifierKeys == Keys.Shift || (SelectedPrimitive == overPrimitive && _selectedTool == PrimitiveTool(overPrimitive)) || _selectedTool == TpTool.Select)) { if (SelectionExists) SelectedPrimitive.ShapeToolLost(); SelectedPrimitive = overPrimitive; _shapeControl.Dragging = true; UpdateCurrentTool(); Invalidate(); } else { if (ModifierKeys == Keys.Shift) return; if (SelectionExists) { SelectedPrimitive.ShapeToolLost(); ResetSelectedPrimitive(); Invalidate(); } _isPenDown = true; if (_selectedTool == TpTool.FreeLine) { _currentPrimitive = new FreeLine(); } else if (_selectedTool == TpTool.Line) { _currentPrimitive = new Line(); } else if (_selectedTool == TpTool.TextBox) { _currentPrimitive = new DecoratedTextBox(); } else if (_selectedTool == TpTool.Box) { _currentPrimitive = new Box(); } else if (_selectedTool == TpTool.Select) { _currentPrimitive = null; } if (_currentPrimitive != null) _currentPrimitive.CreationMouseDownHandler(MouseToReal(e.Location)); } if (!SelectionExists) RemoveAllProperties(); }
protected override void OnMouseUp(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (_resizeMode) { _resizeMode = false; if(SelectionExists) SelectedPrimitive.OnResize(true); } _dragPointID = -1; _isPenDown = false; _shapeControl.Dragging = false; if (SelectionExists) { SelectedPrimitive.MoveBy(-(int) (_currentDelta.X/_zoom), -(int) (_currentDelta.Y/_zoom)); _currentDelta = new Point(); } if (_currentPrimitive != null) { _currentPrimitive.CreationMouseUpHandler(MouseToReal(e.Location)); if (_currentPrimitive.isValid()) { _allPainting.Add(_currentPrimitive); _redoStack.Clear(); SelectedPrimitive = _currentPrimitive; UpdateCurrentTool(); } _currentPrimitive = null; Invalidate(); } CalculateScrollPostions(); } }
protected override void OnMouseDoubleClick(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Primitive overPrimitive = GetPrimitiveAt(MouseToReal(e.Location)); if (overPrimitive != null) { SelectedPrimitive = overPrimitive; _shapeControl.Dragging = true; UpdateCurrentTool(); Invalidate(); overPrimitive.MouseDoubleClickHandler(MouseToReal(e.Location)); } } }
private static TpTool PrimitiveTool(Primitive primitive) { if (primitive is FreeLine) return TpTool.FreeLine; if (primitive is Line) return TpTool.Line; if (primitive is DecoratedTextBox) return TpTool.TextBox; if (primitive is Box) return TpTool.Box; return TpTool.Select; }
private void ResetSelectedPrimitive() { SelectedPrimitive = null; }
public void ToolChanged() { _currentPrimitive = null; RemoveAllProperties(); PropertyControlBase propertyControl = null; switch (_selectedTool) { case TpTool.FreeLine: propertyControl = new FreeLinePropertyControl(); break; case TpTool.Line: propertyControl = new LinePropertyControl(); break; case TpTool.TextBox: propertyControl = new DecoratedTextBoxPropertyControl(); break; case TpTool.Box: propertyControl = new BoxPropertyControl(); break; } AddProperties(propertyControl); UpdatePropertiesView(); Focus(); }
private void ClearSelection() { if (SelectionExists) { SelectedPrimitive.ShapeToolLost(); SelectedPrimitive = null; UpdateCurrentTool(); } }
private void DrawPrimitive(Primitive primitive, Graphics graphics, float zoom, PointF offset) { primitive.Draw(graphics, zoom, offset, _zoomLocation, AutoScrollPosition); }
public void AddPicture(Bitmap bmp, bool isSelected) { var pict = new Picture(bmp); pict.MoveBy(-20, -20); _allPainting.Add(pict); _redoStack.Clear(); if (isSelected) SelectedPrimitive = pict; UpdateCurrentTool(); _currentPrimitive = null; Invalidate(); }
public virtual void AttachTo(Primitive primitive) { }
public override void AttachTo(Primitive primitive) { if (primitive == null) { attachedLine = null; } else { attachedLine = primitive as Line; numControl.Value = attachedLine.penSize; colorControl.Color = attachedLine.penColor; if (attachedLine.penBeginCap == LineCap.ArrowAnchor) lineDD.SelectItem(TPLineStyle.Arrow); else lineDD.SelectItem(attachedLine.penStyle); } Invalidate(); }
public override void AttachTo(Primitive primitive) { if (primitive == null) { _attachedBox = null; } else { _attachedBox = primitive as DecoratedTextBox; _attachedBox.tpText.SelectionChanged += tpText_SelectionChanged; } FillControl(true); Invalidate(); }
public ShapeBoxControl(Primitive prim) { Primitive = prim; GeneratePoints(); }