Esempio n. 1
0
 //
 //
 // This is just very slow, so I've disabled it...
 //
 private void OnSelectDisplayItem(object sender, Shapes.DisplayItem displayItem)
 {
     treeElements.SelectedNodes = null;
     //treeElements.Nodes.Find();
     //TreeNode visibleNode = null;
     //foreach (Shapes.PreviewPixel pixel in displayItem.Shape.Pixels)
     //{
     //    if (pixel.Node != null)
     //    {
     //    }
     //}
     //if (visibleNode != null)
     //{
     //    bool selectParent = true;
     //    foreach (TreeNode node in visibleNode.Parent.Nodes)
     //    {
     //        selectParent = (selectParent && treeElements.SelectedNodes.Contains(node));
     //    }
     //    if (selectParent)
     //    {
     //        treeElements.SelectedNodes = null;
     //        treeElements.AddSelectedNode(visibleNode.Parent);
     //        visibleNode.Parent.Collapse();
     //        visibleNode.Parent.EnsureVisible();
     //    }
     //    else
     //    {
     //        visibleNode.EnsureVisible();
     //    }
     //}
 }
Esempio n. 2
0
        private void OnSelectDisplayItem(object sender, Shapes.DisplayItem displayItem)
        {
            Shapes.DisplayItemBaseControl setupControl = displayItem.Shape.GetSetupControl();

            if (setupControl != null)
            {
                propertiesForm.ShowSetupControl(setupControl);
            }
        }
        //
        //
        // This is just very slow, so I've disabled it...
        //
        private void OnSelectDisplayItem(object sender, Shapes.DisplayItem displayItem)
        {
            return;

            treeElements.SelectedNodes = null;

            //CreateElementNodeToTreeNode();

            TreeNode visibleNode = null;

            foreach (Shapes.PreviewPixel pixel in displayItem.Shape.Pixels)
            {
                if (pixel.Node != null)
                {
                    //TreeNode treeNode;
                    //if (ElementNodeToTreeNode.TryGetValue(pixel.Node, out treeNode))
                    //{
                    //    treeElements.AddSelectedNode(treeNode);
                    //    visibleNode = treeNode;
                    //}
                    //TreeNode[] nodes = treeElements.Nodes.Find(pixel.Node.Id.ToString(), true);
                    //foreach (TreeNode node in nodes)
                    //{
                    //    visibleNode = node;
                    //    treeElements.AddSelectedNode(node);
                    //}

                    //TreeNode node = treeElements.Nodes[pixel.Node.Id.ToString()];
                    //if (node != null)
                    //{
                    //    visibleNode = node;
                    //    treeElements.AddSelectedNode(node);
                    //}
                }
            }
            if (visibleNode != null)
            {
                bool selectParent = true;
                foreach (TreeNode node in visibleNode.Parent.Nodes)
                {
                    selectParent = (selectParent && treeElements.SelectedNodes.Contains(node));
                }
                if (selectParent)
                {
                    treeElements.SelectedNodes = null;
                    treeElements.AddSelectedNode(visibleNode.Parent);
                    visibleNode.Parent.Collapse();
                    visibleNode.Parent.EnsureVisible();
                }
                else
                {
                    visibleNode.EnsureVisible();
                }
            }
        }
Esempio n. 4
0
 private void OnSelectDisplayItem(object sender, Shapes.DisplayItem displayItem)
 {
     if (propertiesForm.SetupPreviewShape() != displayItem.Shape)
     {
         DisplayItemBaseControl setupControl = displayItem.Shape.GetSetupControl();
         elementsForm.ClearSelectedNodes();
         if (setupControl != null)
         {
             propertiesForm.ShowSetupControl(setupControl);
         }
     }
 }
Esempio n. 5
0
        public static DisplayItem DeSerializeToDisplayItem(string st, Type type)
        {
            var         serializer = new DataContractSerializer(type);
            DisplayItem item       = null;

            using (var backing = new System.IO.StringReader(st)) {
                try {
                    using (var reader = new System.Xml.XmlTextReader(backing)) {
                        item = serializer.ReadObject(reader) as DisplayItem;
                    }
                }
                catch {
                }
            }
            return(item);
        }
Esempio n. 6
0
		private void SetDisplayItemZ(DisplayItem displayItem, int pos)
		{
			foreach (PreviewPixel p in displayItem.Shape.Pixels)
			{
				p.Z = pos;
			}
		}
Esempio n. 7
0
		private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
		{
			var tag = e.ClickedItem.Tag;
			if (e.ClickedItem.Tag == null)
				return;
			switch (tag.ToString())
			{
				case "CreateTemplate":
					_selectedDisplayItem = CreateTemplate();
					if (_selectedDisplayItem != null)
					{
						_selectedDisplayItem.Shape.Select(true);
					}
					break;
				case "CreateGroup":
					_selectedDisplayItem = CreateGroup();
					if (_selectedDisplayItem != null)
					{
						_selectedDisplayItem.Shape.Select(true);
					}
					break;
				case "Separate":
					if (_selectedDisplayItem != null)
						SeparateTemplateItems(_selectedDisplayItem);
					break;
				case "Cut":
					Cut();
					break;
				case "Copy":
					Copy();
					break;
				case "Paste":
					Paste();
					break;
				case "Delete":
					Delete();
					break;
				case "Undo":
					UndoManager.Undo();
					break;
				case "Redo":

					UndoManager.Redo();
					break;
				case "0":
				case "1":
				case "2":
				case "3":
				case "4":
				case "5":
				case "6":
				case "7":
				case "8":
				case "9":
					SetZForSelectedItems(Convert.ToInt32(tag));
					break;
			}
		}
Esempio n. 8
0
		private void VixenPreviewControl_MouseDown(object sender, MouseEventArgs e)
		{
			if (_editMode)
			{
				bool controlPressed = (Control.ModifierKeys == Keys.Control);
				PreviewPoint translatedPoint = new PreviewPoint(e.X + hScroll.Value, e.Y + vScroll.Value);
				if (e.Button == System.Windows.Forms.MouseButtons.Left)
				{
					if (_currentTool == Tools.Select)
					{
						if (controlPressed)
						{
							DisplayItem item = DisplayItemAtPoint(translatedPoint);
							if (item != null && SelectedDisplayItems.Contains(item))
							{
								SelectedDisplayItems.Remove(item);
							}
							else
							{
								SelectItemUnderPoint(translatedPoint, controlPressed);
							}
							return;
						}

						// Is there a single dislay item selected?
						if (_selectedDisplayItem != null && !controlPressed)
						{
							// Lets see if we've got a drag point.
							PreviewPoint selectedPoint = _selectedDisplayItem.Shape.PointInSelectPoint(translatedPoint);
							if (selectedPoint != null)
							{
								modifyType = "Resize";
								beginResize_Move(false); //Starts the Undo Process
								dragStart = translatedPoint.ToPoint();
								_selectedDisplayItem.Shape.SetSelectPoint(selectedPoint);
								Capture = true;
								_mouseCaptured = true;
							}
								// If we're not resizing, see if we're moving a single shape
							else if (_selectedDisplayItem.Shape.PointInShape(translatedPoint))
							{
								modifyType = "Move";
								beginResize_Move(false); //Starts the Undo Process

								StartMove(translatedPoint.X, translatedPoint.Y);
							}
								// If we get here, we're outside the shape, deselect
							else
							{
								DeSelectSelectedDisplayItem();
							}
						}
							// Are there multiple items selected?
							// If so, we're moving, can't resize them...
						else if (SelectedDisplayItems.Count > 1 && !controlPressed)
						{
							//if (MouseOverSelectedDisplayItems(e.X, e.Y)) {
							//    StartMove(e.X, e.Y);
							//}
							//else {
							//    SelectedDisplayItems.Clear();
							//}
							if (MouseOverSelectedDisplayItems(translatedPoint.X, translatedPoint.Y))
							{
								modifyType = "Move";
								beginResize_Move(true); //Starts the Undo Process
								StartMove(translatedPoint.X, translatedPoint.Y);
							}
							else
							{
								SelectedDisplayItems.Clear();
							}
						}

						SelectItemUnderPoint(translatedPoint, controlPressed);

						// If we get this far, and we've got nothing selected, we're drawing a rubber band!
						if (_selectedDisplayItem == null && SelectedDisplayItems.Count == 0)
						{
							// Capture the mouse in case we want to draw a rubber band
							dragStart = translatedPoint.ToPoint();
							Capture = true;
							_mouseCaptured = true;
							SelectedDisplayItems.Clear();
							_bandRect.Width = 0;
							_bandRect.Height = 0;
							_banding = true;
						}
					}

					else if (_selectedDisplayItem != null && _selectedDisplayItem.Shape.PointInShape(translatedPoint) &&
					         !_selectedDisplayItem.Shape.Creating)
					{
						StartMove(translatedPoint.X, translatedPoint.Y);
					}

						// If we're not Selecting items, we're drawing them
					else if (_currentTool == Tools.PolyLine && _mouseCaptured)
					{
						return;
					}
					else if (_currentTool == Tools.MultiString && _mouseCaptured)
					{
						return;
					}
					else
					{
						DeSelectSelectedDisplayItem();

						DisplayItem newDisplayItem = null;
						if (_currentTool == Tools.String)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewLine(translatedPoint, translatedPoint, 50,
								elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Arch)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewArch(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Rectangle)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewRectangle(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Single)
						{
							newDisplayItem = new DisplayItem
							{
								Shape = new PreviewSingle(translatedPoint, elementsForm.SelectedNode, ZoomLevel)
							};
						}
						else if (_currentTool == Tools.Ellipse)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewEllipse(translatedPoint, 50, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Triangle)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewTriangle(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Net)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewNet(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Cane)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewCane(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Star)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewStar(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.StarBurst)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewStarBurst(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Flood)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewFlood(translatedPoint, elementsForm.SelectedNode);
						}
						else if (_currentTool == Tools.MegaTree)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewMegaTree(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.PixelGrid)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewPixelGrid(translatedPoint, elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.Icicle)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewIcicle(translatedPoint, translatedPoint,
								elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.PolyLine)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewPolyLine(translatedPoint, translatedPoint,
								elementsForm.SelectedNode, ZoomLevel);
						}
						else if (_currentTool == Tools.MultiString)
						{
							newDisplayItem = new DisplayItem();
							newDisplayItem.Shape = new PreviewMultiString(translatedPoint, translatedPoint,
								elementsForm.SelectedNode, ZoomLevel);
						}
						// Now add the newely created display item to the screen.
						if (newDisplayItem != null)
						{
							AddDisplayItem(newDisplayItem);
							newDisplayItem.ZoomLevel = ZoomLevel;
							_selectedDisplayItem = newDisplayItem;
							_selectedDisplayItem.Shape.PixelSize = 3;
							_selectedDisplayItem.Shape.Select(true);
							_selectedDisplayItem.Shape.SelectDefaultSelectPoint();
							dragStart = translatedPoint.ToPoint();
							Capture = true;
							_mouseCaptured = true;

							modifyType = "AddNew";
						}
					}
				}
				else if (e.Button == System.Windows.Forms.MouseButtons.Right)
				{
					contextMenuStrip1.Items.Clear();
					SelectItemUnderPoint(translatedPoint, false);

					if (_selectedDisplayItem != null)
					{
						PreviewPoint selectedPoint = _selectedDisplayItem.Shape.PointInSelectPoint(translatedPoint);
						if (_selectedDisplayItem.Shape.PointInShape(translatedPoint))
						{
							if (_selectedDisplayItem.Shape.GetType().ToString().Contains("PreviewCustom"))
							{
								contextMenuStrip1.Items.Add(new ToolStripMenuItem
								{
									Text = "Separate Template Items",
									Tag = "Separate",
									Image = Common.Resources.Properties.Resources.Split
								});
							}
						}
					}
					else if (SelectedDisplayItems.Count > 1)
					{
						contextMenuStrip1.Items.Add(new ToolStripMenuItem
						{
							Text = "Create Group...",
							Tag = "CreateGroup",
							Image = Common.Resources.Properties.Resources.group
						});
						contextMenuStrip1.Items.Add(new ToolStripSeparator());
						contextMenuStrip1.Items.Add(new ToolStripMenuItem
						{
							Text = "Create Template...",
							Tag = "CreateTemplate",
							Image = Common.Resources.Properties.Resources.document_font
						});
					}
					if (_selectedDisplayItem != null)
					{
						contextMenuStrip1.Items.Add(new ToolStripMenuItem
						{
							Text = "Cut",
							Tag = "Cut",
							Image = Common.Resources.Properties.Resources.cut
						});
						contextMenuStrip1.Items.Add(new ToolStripMenuItem
						{
							Text = "Copy",
							Tag = "Copy",
							Image = Common.Resources.Properties.Resources.page_copy
						});
					}
					if (ClipboardPopulated)
					{
						if (_selectedDisplayItem == null & SelectedDisplayItems.Count > 1)
						{
							contextMenuStrip1.Items.Add(new ToolStripSeparator());
						}
						contextMenuStrip1.Items.Add(new ToolStripMenuItem
						{
							Text = "Paste",
							Tag = "Paste",
							Image = Common.Resources.Properties.Resources.paste_plain
						});
					}
					if (_selectedDisplayItem != null)
					{
						contextMenuStrip1.Items.Add(new ToolStripMenuItem
						{
							Text = "Delete",
							Tag = "Delete",
							Image = Common.Resources.Properties.Resources.delete
						});
					}
					if (UndoManager.NumUndoable > 0)
					{
						contextMenuStrip1.Items.Add(new ToolStripSeparator());
						contextMenuStrip1.Items.Add(new ToolStripMenuItem
						{
							Text = "Undo",
							Tag = "Undo",
							Image = Common.Resources.Properties.Resources.arrow_undo
						});
					}
					if (UndoManager.NumRedoable > 0)
					{
						if (UndoManager.NumUndoable < 1)
							contextMenuStrip1.Items.Add(new ToolStripSeparator());
						contextMenuStrip1.Items.Add(new ToolStripMenuItem
						{
							Text = "Redo",
							Tag = "Redo",
							Image = Common.Resources.Properties.Resources.arrow_redo
						});
					}
					if (_selectedDisplayItem != null)
					{
						contextMenuStrip1.Items.Add(new ToolStripSeparator());

						if (Data.SaveLocations & _selectedDisplayItem != null)
						{
							// Z location menu
							contextMenuStrip1.Items.Add(new ToolStripMenuItem {Text = "Set Z Location to"});
							// Z sub menu items
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "0 Front", Tag = "0"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "1", Tag = "1"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "2", Tag = "2"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "3", Tag = "3"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "4 Middle", Tag = "4"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "5", Tag = "5"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "6", Tag = "6"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "7", Tag = "7"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "8", Tag = "8"});
							(contextMenuStrip1.Items[contextMenuStrip1.Items.Count - 1] as ToolStripMenuItem).DropDownItems.Add(
								new ToolStripMenuItem {Text = "9 Back", Tag = "9"});
						}
					}
					if (contextMenuStrip1.Items.Count > 0)
					{
						contextMenuStrip1.Show(this, e.Location);
					}
				}
				else if (e.Button == System.Windows.Forms.MouseButtons.Middle)
				{
					// Pan
					zoomTo = MousePointToZoomPoint(e.Location);

				}
			}
		}
Esempio n. 9
0
		public void selectItem(PreviewPoint point)
		{
			_selectedDisplayItem = DisplayItemAtPoint(point);
			if (_selectedDisplayItem != null)
			{
				_selectedDisplayItem.Shape.Select(true);
				OnSelectDisplayItem(this, _selectedDisplayItem);
			}
		}
Esempio n. 10
0
		public void SelectItemUnderPoint(PreviewPoint point, bool addToSelection)
		{
			if (!_mouseCaptured)
			{
				// First, see if we have an item already selected, but want to add to it
				if (addToSelection)
				{
					if (_selectedDisplayItem != null)
						SelectedDisplayItems.Add(_selectedDisplayItem);
					DeSelectSelectedDisplayItem();
					DisplayItem item = DisplayItemAtPoint(point);
					if (item != null)
						SelectedDisplayItems.Add(item);
				}
				else
				{
					// First, deselect any currently selected item
					DeSelectSelectedDisplayItem();

					_selectedDisplayItem = DisplayItemAtPoint(point);
					if (_selectedDisplayItem != null)
					{
						_selectedDisplayItem.Shape.Select(true);
						OnSelectDisplayItem(this, _selectedDisplayItem);
					}
				}
			}
		}
Esempio n. 11
0
		public void DeSelectSelectedDisplayItem()
		{
			if (_selectedDisplayItem != null)
			{
				OnDeSelectDisplayItem(this, _selectedDisplayItem);
				_selectedDisplayItem.Shape.Deselect();
				_selectedDisplayItem = null;
			}
		}
Esempio n. 12
0
 private void OnDeSelectDisplayItem(object sender, Shapes.DisplayItem displayItem)
 {
     propertiesForm.ClearSetupControl();
 }
Esempio n. 13
0
 private void OnDeSelectDisplayItem(object sender, Shapes.DisplayItem displayItem)
 {
     propertiesForm.ShowSetupControl(null);
     reenableToolButtons();
 }
Esempio n. 14
0
		public void AddTtemplateToPreview(string fileName)
		{
			if (System.IO.File.Exists(fileName))
			{
				// Read the entire template file (stoopid waste of resources, but how else?)
				string xml = System.IO.File.ReadAllText(fileName);
				DisplayItem newDisplayItem = PreviewTools.DeSerializeToDisplayItem(xml, typeof (DisplayItem));
				if (newDisplayItem != null)
				{
					DeSelectSelectedDisplayItem();

					AddDisplayItem(newDisplayItem);
					_selectedDisplayItem = newDisplayItem;
					OnSelectDisplayItem(this, _selectedDisplayItem);
					_selectedDisplayItem.Shape.MoveTo(10, 10);
					_selectedDisplayItem.Shape.Select(true);
					_selectedDisplayItem.Shape.SetSelectPoint(null);
					List<DisplayItem> selected = new List<DisplayItem> {_selectedDisplayItem};

					PreviewItemAddAction(); //starts Undo_Redo Action
				}
			}
		}
Esempio n. 15
0
		internal void AddNewGroup(out DisplayItem newDisplayItem, List<DisplayItem> selectedShapes)
		{
			//Sets the start TopLeft point of the new group
			List<int> topPoint = new List<int>();
			List<int> leftPoint = new List<int>();
			foreach (DisplayItem shape in SelectedDisplayItems)
			{
				topPoint.Add(shape.Shape.Top);
				leftPoint.Add(shape.Shape.Left);
			}
			newDisplayItem = new DisplayItem();
			newDisplayItem.Shape = new PreviewCustom(new PreviewPoint(leftPoint.Min(), topPoint.Min()), SelectedShapes());
			AddDisplayItem(newDisplayItem);

			foreach (DisplayItem item in SelectedDisplayItems)
			{
				DisplayItems.Remove(item);
			}
		}
Esempio n. 16
0
		public static void Resize_MoveSwapPlaces(DisplayItem lhs, PreviewItemPositionInfo rhs)
		{
			var displayItemTemp = PreviewTools.DeSerializeToDisplayItemList(rhs.OriginalPreviewItem[0]);
			foreach (var temp1 in displayItemTemp)
			{
				var temp = lhs;
				var newObject = temp;
				rhs.OriginalPreviewItem.Clear();
				List<DisplayItem> newObjectList = new List<DisplayItem>();
				newObjectList.Add(newObject);
				rhs.OriginalPreviewItem.Add(PreviewTools.SerializeToString(newObjectList));
				lhs.Shape = temp1.Shape;
			}
		}
Esempio n. 17
0
		public void AddDisplayItem(DisplayItem displayItem)
		{
			DisplayItems.Add(displayItem);
		}
Esempio n. 18
0
		public void RemoveDisplayItem(DisplayItem _selectedDisplayItem)
		{
			DisplayItems.Remove(_selectedDisplayItem);
		}
Esempio n. 19
0
		public void DeSelectSelectedDisplayItemNoNotify()
		{
			if (_selectedDisplayItem != null)
			{
				_selectedDisplayItem.Shape.Deselect();
				_selectedDisplayItem = null;
			}
		}
Esempio n. 20
0
			public PreviewItemPositionInfo(DisplayItem previewItem)
			{
				TopPosition = previewItem.Shape.Top;
				LeftPosition = previewItem.Shape.Left;
				List<DisplayItem> temp = new List<DisplayItem>();
				temp.Add(previewItem);
				OriginalPreviewItem = new List<string>();
				OriginalPreviewItem.Add(PreviewTools.SerializeToString(temp));
			}
Esempio n. 21
0
 private void OnDeSelectDisplayItem(object sender, Shapes.DisplayItem displayItem)
 {
     // NO
     //treeElements.SelectedNodes = null;
 }
Esempio n. 22
0
		public VixenPreviewControl()
			: base()
		{
			InitializeComponent();
			contextMenuStrip1.Renderer = new ThemeToolStripRenderer();
			PreviewItemsResizingNew += vixenpreviewControl_PreviewItemsResizingNew;
			PreviewItemsMovedNew += vixenpreviewControl_PreviewItemsMovedNew;
			SetStyle(ControlStyles.UserPaint, true);
			SetStyle(ControlStyles.DoubleBuffer, true);
			_selectedDisplayItem = null;
		}
Esempio n. 23
0
		public void SeparateTemplateItems(DisplayItem displayItem)
		{
			foreach (PreviewBaseShape shape in displayItem.Shape._strings)
			{
				DisplayItem newDisplayItem;
				newDisplayItem = new DisplayItem();
				newDisplayItem.Shape = shape;
				DisplayItems.Add(newDisplayItem);
			}
			if (_selectedDisplayItem != null)
			{
				DisplayItems.Remove(_selectedDisplayItem);
				DeSelectSelectedDisplayItem();
			}
			else if (SelectedDisplayItems != null && SelectedDisplayItems.Count > 0)
			{
				foreach (DisplayItem item in SelectedDisplayItems)
				{
					DisplayItems.Remove(item);
					DeSelectSelectedDisplayItem();
				}
				SelectedDisplayItems.Clear();
			}
		}
Esempio n. 24
0
		public void VixenPreviewControl_MouseUp(object sender, MouseEventArgs e)
		{
			if (_mouseCaptured)
			{
				if (_currentTool != Tools.Select)
				{
					// If control is pressed, deselect the shape and immediately allow drawing another shape
					//if ((Control.ModifierKeys & Keys.Shift) != 0) {
					//    _selectedDisplayItem.Shape.MouseUp(sender, e);
					//    DeSelectSelectedDisplayItem();
					//}
					//else 
					if (_selectedDisplayItem != null &&
					    _currentTool == Tools.PolyLine &&
					    e.Button == System.Windows.Forms.MouseButtons.Left &&
					    _selectedDisplayItem.Shape.Creating)
					{
						// If we are drawing a PolyLine, we want all the mouse events to be passed to the shape
						_selectedDisplayItem.Shape.MouseUp(sender, e);
						return;
					}
					else if (_selectedDisplayItem != null &&
					         _currentTool == Tools.MultiString &&
					         e.Button == System.Windows.Forms.MouseButtons.Left &&
					         _selectedDisplayItem.Shape.Creating)
					{
						// If we are drawing a MultiString, we want all the mouse events to be passed to the shape
						_selectedDisplayItem.Shape.MouseUp(sender, e);
						return;
					}
					else
					{
						//_currentTool = Tools.Select;
					}
				}

				if (_selectedDisplayItem != null)
				{
					_selectedDisplayItem.Shape.MouseUp(sender, e);
					OnSelectDisplayItem(this, _selectedDisplayItem);
					if ((PreviewItemsMovedNew != null | PreviewItemsResizingNew != null) && m_previewItemResizeMoveInfo != null | modifyType == "AddNew")
					{
						switch (modifyType)
						{
							case "Resize":
								PreviewItemsResizingNew(this, new PreviewItemResizingEventArgs(m_previewItemResizeMoveInfo));
								break;
							case "Move":
								PreviewItemsMovedNew(this, new PreviewItemMoveEventArgs(m_previewItemResizeMoveInfo));
								break;
							case "AddNew":
								PreviewItemAddAction(); //starts Undo_Redo Action
								DeSelectSelectedDisplayItem();
								break;
						}
						modifyType = "None";
						m_previewItemResizeMoveInfo = null;
					}
				}
					// Ok, if this is true, we've got a rubber band and something is selected, now what?
				else if (SelectedDisplayItems.Count > 0)
				{
					// If we only have one item, just select it and go on.
					if (SelectedDisplayItems.Count == 1)
					{
						_selectedDisplayItem = SelectedDisplayItems[0];
						_selectedDisplayItem.Shape.Select(true);
						OnSelectDisplayItem(this, _selectedDisplayItem);
						SelectedDisplayItems.Clear();
					}
					else
					{
						if (PreviewItemsMovedNew != null && m_previewItemResizeMoveInfo != null)
							PreviewItemsMovedNew(this, new PreviewItemMoveEventArgs(m_previewItemResizeMoveInfo));
					}
				}
			}
			ResetMouse();
		}