public ColumnDragMouseAction(ColumnElementListCompartment compartment, Column[] sourceColumns, Column targetColumn)
     : base(compartment.Diagram)
 {
     myShape            = compartment;
     mySourceColumns    = sourceColumns;
     myLastTargetColumn = targetColumn;
 }
        public override void OnMouseDown(DiagramMouseEventArgs e)
        {
            base.OnMouseDown(e);
            DiagramItem diagramItem     = e.HitDiagramItem;
            Column      referenceColumn = ResolveColumn(diagramItem);

            if (referenceColumn != null)
            {
                // See if we're dragging other columns
                DiagramItemCollection selection = e.DiagramClientView.Selection.TopLevelItems;
                Table    table           = referenceColumn.Table;
                int      count           = selection.Count;
                Column[] selectedColumns = new Column[count];
                for (int i = 0; i < count; ++i)
                {
                    Column column = ResolveColumn(selection[i]);
                    if (null == column ||
                        (column != referenceColumn && column.Table != table))
                    {
                        return;
                    }
                    selectedColumns[i] = column;
                }
                myDragSourceColumns = selectedColumns;
                myDragSourceShape   = (ColumnElementListCompartment)diagramItem.Shape;
            }
            else
            {
                myDragSourceColumns = null;
                myDragSourceShape   = null;
            }
        }
        /// <summary>
        /// Creates a new <see cref="ColumnElementListCompartment"/>.
        /// </summary>
        /// <param name="partition">The current <see cref="Partition"/> of the diagram.</param>
        /// <returns>ColumnElementListCompartment</returns>
        public override Compartment CreateCompartment(Microsoft.VisualStudio.Modeling.Partition partition)
        {
            ColumnElementListCompartment columnElementListCompartment = new ColumnElementListCompartment(partition, null);

            if (base.IsDefaultCollapsed)
            {
                columnElementListCompartment.IsExpanded = false;
            }
            return(columnElementListCompartment);
        }
 public override void OnMouseMove(DiagramMouseEventArgs e)
 {
     Column[] sourceColumns;
     if (null != (sourceColumns = myDragSourceColumns))
     {
         DiagramItem currentItem = e.HitDiagramItem;
         Column      targetColumn;
         ColumnElementListCompartment sourceShape = myDragSourceShape;
         if (currentItem.Shape != sourceShape)
         {
             myDragSourceColumns = null;
             myDragSourceShape   = null;
         }
         else if (null != (targetColumn = ResolveColumn(currentItem)) &&
                  -1 == (Array.IndexOf <Column>(sourceColumns, targetColumn)))
         {
             myDragSourceColumns = null;
             myDragSourceShape   = null;
             e.DiagramClientView.ActiveMouseAction = new ColumnDragMouseAction(sourceShape, sourceColumns, targetColumn);
         }
     }
     base.OnMouseMove(e);
 }
 public override void OnMouseUp(DiagramMouseEventArgs e)
 {
     myDragSourceShape   = null;
     myDragSourceColumns = null;
     base.OnMouseUp(e);
 }
		/// <summary>
		/// Creates a new <see cref="ColumnElementListCompartment"/>.
		/// </summary>
		/// <param name="partition">The current <see cref="Partition"/> of the diagram.</param>
		/// <returns>ColumnElementListCompartment</returns>
		public override Compartment CreateCompartment(Microsoft.VisualStudio.Modeling.Partition partition)
		{
			ColumnElementListCompartment columnElementListCompartment = new ColumnElementListCompartment(partition, null);
			if (base.IsDefaultCollapsed)
			{
				columnElementListCompartment.IsExpanded = false;
			}
			return columnElementListCompartment;
		}