Inheritance: IPrimitive
Ejemplo n.º 1
0
		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();
		}
Ejemplo n.º 4
0
		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();
		}
Ejemplo n.º 5
0
		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();
			}
		}
Ejemplo n.º 6
0
		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));
				}
			}
		}
Ejemplo n.º 7
0
		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;
		}
Ejemplo n.º 8
0
		private void ResetSelectedPrimitive()
		{
			SelectedPrimitive = null;
		}
Ejemplo n.º 9
0
		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();
		}
Ejemplo n.º 10
0
		private void ClearSelection()
		{
			if (SelectionExists)
			{
				SelectedPrimitive.ShapeToolLost();
				SelectedPrimitive = null;
				UpdateCurrentTool();
			}
		}
Ejemplo n.º 11
0
		private void DrawPrimitive(Primitive primitive, Graphics graphics, float zoom, PointF offset)
		{
			primitive.Draw(graphics, zoom, offset, _zoomLocation, AutoScrollPosition);
		}
Ejemplo n.º 12
0
		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)
		{
		}
Ejemplo n.º 14
0
		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();
		}
Ejemplo n.º 16
0
		public ShapeBoxControl(Primitive prim)
		{
			Primitive = prim;
			GeneratePoints();
		}