Inheritance: IPrimitive
コード例 #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);
		}
コード例 #2
0
		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();
		}
コード例 #3
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;
				lineDD.SelectItem(attachedLine.penStyle);
			}
			Invalidate();
		}
コード例 #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();
		}
コード例 #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();
			}
		}
コード例 #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));
				}
			}
		}
コード例 #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;
		}
コード例 #8
0
		private void ResetSelectedPrimitive()
		{
			SelectedPrimitive = null;
		}
コード例 #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();
		}
コード例 #10
0
		private void ClearSelection()
		{
			if (SelectionExists)
			{
				SelectedPrimitive.ShapeToolLost();
				SelectedPrimitive = null;
				UpdateCurrentTool();
			}
		}
コード例 #11
0
		private void DrawPrimitive(Primitive primitive, Graphics graphics, float zoom, PointF offset)
		{
			primitive.Draw(graphics, zoom, offset, _zoomLocation, AutoScrollPosition);
		}
コード例 #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();
		}
コード例 #13
0
		public virtual void AttachTo(Primitive primitive)
		{
		}
コード例 #14
0
ファイル: Line.cs プロジェクト: TargetProcess/Tp.TrayUtility
		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();
		}
コード例 #16
0
		public ShapeBoxControl(Primitive prim)
		{
			Primitive = prim;
			GeneratePoints();
		}