/// <summary>
        ///     Moves a unit to a new location within the hierarchy.
        /// </summary>
        /// <param name="unit">The moved unit.</param>
        /// <param name="target">The new suprtior of the unit.</param>
        public void MoveUnitInHierarchy(IUnitDecorator unit, HigherUnitDecorator target)
        {
            if (unit.Superior != null)
            {
                if (unit.Superior == target)
                {
                    return;
                }

                unit.Superior.RemoveSubordinate((UnitBase)unit);
            }

            target.AddSubordinate((UnitBase)unit);

            SelectedUnit = unit;

            RootUnit.Subordinates.Refresh();

            OnModelChanged();
        }
Exemplo n.º 2
0
        private void DropTreeDrop(object sender, DragEventArgs e)
        {
            Contract.Requires(e.Data != null);

            IUnitDecorator droppedUnitDecorator = null;

            if (e.Data.GetDataPresent(typeof(UnitDecorator)))
            {
                droppedUnitDecorator = e.Data.GetData(typeof(UnitDecorator)) as UnitDecorator;
            }
            else if (e.Data.GetDataPresent(typeof(HigherUnitDecorator)))
            {
                droppedUnitDecorator = e.Data.GetData(typeof(HigherUnitDecorator)) as HigherUnitDecorator;
            }

            if (droppedUnitDecorator != null)
            {
                var treeViewItem = FindAnchestor <TreeViewItem>((DependencyObject)e.OriginalSource);

                HigherUnitDecorator dropTarget = ViewModel.RootUnit;

                if (treeViewItem != null)
                {
                    dropTarget = treeViewItem.Header as HigherUnitDecorator;

                    if (dropTarget == null)
                    {
                        return;
                    }
                }

                Contract.Assume(dropTarget != null);

                if (droppedUnitDecorator == dropTarget)
                {
                    return;
                }

                ViewModel.MoveUnitInHierarchy(droppedUnitDecorator, dropTarget);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Called when the unit was changed.
 /// </summary>
 /// <param name="oldUnit">The old unit.</param>
 /// <param name="newUnit">The new unit.</param>
 protected virtual void OnUnitChanged(HigherUnitDecorator oldUnit, HigherUnitDecorator newUnit)
 {
 }
 /// <summary>
 ///     Called when the unit was changed.
 /// </summary>
 /// <param name="oldUnit">The old unit.</param>
 /// <param name="newUnit">The new unit.</param>
 protected override void OnUnitChanged(HigherUnitDecorator oldUnit, HigherUnitDecorator newUnit)
 {
     ResetAllValidationErrors();
     UpdateProperties();
 }
Exemplo n.º 5
0
 /// <summary>
 ///     Called when the unit was changed.
 /// </summary>
 /// <param name="oldUnit">The old unit.</param>
 /// <param name="newUnit">The new unit.</param>
 protected override void OnUnitChanged(HigherUnitDecorator oldUnit, HigherUnitDecorator newUnit)
 {
     ResetAllValidationErrors();
     UpdateProperties();
 }