Ejemplo n.º 1
0
        // Handle an actual drop.
        // We don't have to do so many checks here, because we have already validated the drop in DragOver
        public void Drop(IDropInfo dropInfo)
        {
            var Source = window.IdentifyControl(dropInfo.DragInfo.VisualSource);
            var Target = window.IdentifyControl(dropInfo.VisualTarget);

            if (Target == ProfileControls.FullDetails)
            {
                TreeItem target = dropInfo.TargetItem as TreeItem;
                bool     before = (dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter) == RelativeInsertPosition.BeforeTargetItem;

                if (Source == ProfileControls.Groups)
                {
                    string group = dropInfo.Data as string;

                    SelectedProfile.AddFullDetailsGroup(group, target, before);
                    IsDirty = true;
                }
                else if (Source == ProfileControls.Properties)
                {
                    //System.Diagnostics.Trace.WriteLine(String.Format("Drop {0} {1} {2}", ((TreeItem)dropInfo.Data).Name,
                    //                                   dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter,
                    //                                   dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name));

                    var ti = dropInfo.Data as TreeItem;
                    var sp = ti.Item as SystemProperty;

                    SelectedProfile.AddFullDetailsProperty(sp.FullName, target, before);
                    IsDirty = true;
                }
                else if (Source == ProfileControls.FullDetails)
                {
                    //System.Diagnostics.Trace.WriteLine(String.Format("Drop {0} {1} {2}", ((TreeItem)dropInfo.Data).Name,
                    //                                   dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter,
                    //                                   dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name));

                    TreeItem toMove = (TreeItem)dropInfo.Data;

                    // Group items are distinguishable from property items by means of the PropType value stored on them
                    if ((PropType)toMove.Item == PropType.Group)
                    {
                        SelectedProfile.MoveFullDetailsGroup(toMove, target, before);
                    }
                    else
                    {
                        SelectedProfile.MoveFullDetailsProperty(toMove, target, before);
                    }

                    IsDirty           = true;
                    toMove.IsSelected = true;  //todo make work
                }
            }
            else if (Target == ProfileControls.PreviewDetails)
            {
                PropertyListEntry target = dropInfo.TargetItem as PropertyListEntry;
                bool before = (dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter) == RelativeInsertPosition.BeforeTargetItem;

                if (Source == ProfileControls.FullDetails)
                {
                    string property = ((TreeItem)dropInfo.Data).Name;
                    SelectedProfile.AddPreviewDetailsProperty(property, target, before);
                }
                else if (Source == ProfileControls.PreviewDetails)
                {
                    PropertyListEntry property = (PropertyListEntry)dropInfo.Data;
                    SelectedProfile.MovePreviewDetailsProperty(property, target, before);
                }
                IsDirty = true;
            }
            else if (Target == ProfileControls.InfoTip)
            {
                PropertyListEntry target = dropInfo.TargetItem as PropertyListEntry;
                bool before = (dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter) == RelativeInsertPosition.BeforeTargetItem;

                if (Source == ProfileControls.FullDetails)
                {
                    string property = ((TreeItem)dropInfo.Data).Name;
                    SelectedProfile.AddInfoTipProperty(property, target, before);
                }
                else if (Source == ProfileControls.InfoTip)
                {
                    PropertyListEntry property = (PropertyListEntry)dropInfo.Data;
                    SelectedProfile.MoveInfoTipProperty(property, target, before);
                }
                IsDirty = true;
            }
        }