示例#1
0
		/// <summary>
		/// Called on selection of a ToolboxItem. (A selection is a double-click, or pressing Enter).
		/// The selection cannot be null; this method is not called when the "Pointer" mode is selected.
		/// Upon double-click, a single-click is fired first, followed by a double-click. I.e. OnToolboxSelectionChanged
		/// will be called, followed by OnToolboxitemSelected (if the selected item is not "Pointer").
		/// </summary>
		/// <param name="toolboxItem">Selected toolbox item.</param>
		public override bool OnToolboxItemSelected(DslDesign::ModelingToolboxItem toolboxItem)
		{
			// Save the current sticky item choice.
			this.stickyToolboxItemId = toolboxItem.Id;
			
			// Return true to indicate that the toolbox selection action is handled. Otherwise the old
			// behavior of creating new element on double-click will be carried out.
			return true;
		}
示例#2
0
		private string stickyToolboxItemId = null; // Id of the last-selected sticky toolbox item.
		
		/// <summary>
		/// Called when the selection on toolbox changed (through a single-click, or pressing up/down arrow keys).
		/// Base implementation does nothing.
		/// Upon double-click, a single-click is fired first, followed by a double-click. I.e. OnToolboxSelectionChanged
		/// will be called, followed by OnToolboxitemSelected (if the selected item is not "Pointer").
		/// </summary>
		/// <param name="toolboxItem">New toolbox item with selection. This can be null, if "Pointer" mode is selected.</param>
		public override void OnToolboxSelectionChanged(DslDesign::ModelingToolboxItem toolboxItem)
		{
			base.OnToolboxSelectionChanged(toolboxItem);
		
			// When a toolbox item is single-clicked, we need to turn off the sticky mode.
			this.stickyToolboxItemId = null;
			if (this.ActiveDiagramView != null)
			{
				DslDiagrams::CreateAction createAction = this.ActiveDiagramView.ActiveMouseAction as DslDiagrams::CreateAction;
				if (createAction != null)
				{
					createAction.StickyMode = false;
				}
				else
				{
					DslDiagrams::ConnectAction connectAction = this.ActiveDiagramView.ActiveMouseAction as DslDiagrams::ConnectAction;
					if (connectAction != null)
					{
						connectAction.StickyMode = false;
					}
				}
			}
		}