File: System\Activities\Core\Presentation\VerticalConnector.xaml.cs
Project: ndp\cdf\src\NetFx40\Tools\System.Activities.Core.Presentation\System.Activities.Core.Presentation.csproj (System.Activities.Core.Presentation)
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//----------------------------------------------------------------
 
namespace System.Activities.Core.Presentation
{
    using System.Activities.Presentation.Hosting;
    using System.Activities.Presentation;
    using System.Windows;
    using System.Windows.Media.Animation;
 
    partial class VerticalConnector
    {
        public static readonly DependencyProperty AllowedItemTypeProperty =
            DependencyProperty.Register("AllowedItemType", typeof(Type), typeof(VerticalConnector), new UIPropertyMetadata(typeof(object)));
 
        public static readonly DependencyProperty ContextProperty = DependencyProperty.Register(
            "Context",
            typeof(EditingContext),
            typeof(VerticalConnector));
 
        public VerticalConnector()
        {
            this.InitializeComponent();
        }
 
        public Type AllowedItemType
        {
            get { return (Type)GetValue(AllowedItemTypeProperty); }
            set { SetValue(AllowedItemTypeProperty, value); }
        }
 
        public EditingContext Context
        {
            get { return (EditingContext)GetValue(ContextProperty); }
            set { SetValue(ContextProperty, value); }
        }
 
        protected override void OnDragEnter(DragEventArgs e)
        {
            CheckAnimate(e, "Expand");
            this.dropTarget.Visibility = Visibility.Visible;
        }
 
        protected override void OnDragLeave(DragEventArgs e)
        {
            CheckAnimate(e, "Collapse");
            this.dropTarget.Visibility = Visibility.Collapsed;
        }
 
        protected override void OnDrop(DragEventArgs e)
        {
            this.dropTarget.Visibility = Visibility.Collapsed;
            base.OnDrop(e);
        }
 
        void CheckAnimate(DragEventArgs e, string storyboardResourceName)
        {
            if (!e.Handled)
            {
                if (!this.Context.Items.GetValue<ReadOnlyState>().IsReadOnly &&
                    DragDropHelper.AllowDrop(e.Data, this.Context, this.AllowedItemType))
                {
                    BeginStoryboard((Storyboard)this.Resources[storyboardResourceName]);
                    return;
                }
                else
                {
                    e.Effects = DragDropEffects.None;
                }
                e.Handled = true;
            }
        }
    }
}