예제 #1
0
        public void RemoveFullDetailsItem(TreeItem ti)
        {
            if (IsSelectedProfileWritable)
            {
                // Prompt the user for confirmation in the cases where we are removing a group, or
                // the property also appears in the preview details, and so will be removed there too
                MessageBoxResult ans = MessageBoxResult.Yes;
                if ((PropType)ti.Item == PropType.Group)
                {
                    ans = MessageBox.Show(String.Format(LocalizedMessages.RemovePropertyGroupQuestion, ti.Name),
                                          LocalizedMessages.RemovePropertyGroupHeader, MessageBoxButton.YesNo);
                }
                else if (SelectedProfile.HasPropertyInPreviewDetails(ti.Name) || SelectedProfile.HasPropertyInInfoTip(ti.Name))
                {
                    ans = MessageBox.Show(String.Format(LocalizedMessages.RemovePropertyQuestion, ti.Name),
                                          LocalizedMessages.RemovePropertyHeader, MessageBoxButton.YesNo);
                }

                if (ans == MessageBoxResult.Yes)
                {
                    SelectedProfile.RemoveFullDetailsItem(ti);
                    IsDirty = true;
                }
            }
        }
예제 #2
0
        // This is invoked whenever and item is dragged over one of our drop targets.
        // The main job is to determine whether this is a viable drop.
        // If we say nothing, the default answer is no.
        public void DragOver(IDropInfo dropInfo)
        {
            // Drops are only valid on to writable profiles
            if (IsSelectedProfileWritable)
            {
                var Source = window.IdentifyControl(dropInfo.DragInfo.VisualSource);
                var Target = window.IdentifyControl(dropInfo.VisualTarget);

                // Dropping a group onto Full Details
                if (Source == ProfileControls.Groups && Target == ProfileControls.FullDetails)
                {
                    // Check group is not already there
                    string group = dropInfo.Data as string;

                    if (group != null && !SelectedProfile.HasGroupInFullDetails(group))
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Copy;
                    }
                }

                // Dropping a property onto Full Details
                else if (Source == ProfileControls.Properties && Target == ProfileControls.FullDetails)
                {
                    //System.Diagnostics.Trace.WriteLine(String.Format("DragOver {0} at {1}", ((TreeItem)dropInfo.Data).Name,
                    //                                   dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name));

                    // Check at least one group is present
                    if (SelectedProfile.FullDetails.Count > 0)
                    {
                        // Check property is not already there
                        var    ti       = dropInfo.Data as TreeItem;
                        string property = state.GetSystemPropertyName(ti);

                        if (property != null && !SelectedProfile.HasPropertyInFullDetails(property))
                        {
                            dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                            dropInfo.Effects           = DragDropEffects.Copy;
                        }
                    }
                }

                // Reordering within Full Details
                else if (Source == ProfileControls.FullDetails && Target == ProfileControls.FullDetails)
                {
                    //System.Diagnostics.Trace.WriteLine(String.Format("DragOver {0} at {1}", ((TreeItem)dropInfo.Data).Name,
                    //               dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name));

                    var ti = dropInfo.Data as TreeItem;

                    if (ti != null)
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Move;
                    }
                }

                // Dragging from Full Details to Preview Details
                else if (Source == ProfileControls.FullDetails && Target == ProfileControls.PreviewDetails)
                {
                    var ti = dropInfo.Data as TreeItem;

                    // Can only drag properties, not groups, and only if they are not already present
                    if (ti != null &&
                        (PropType)ti.Item == PropType.Normal &&
                        !SelectedProfile.HasPropertyInPreviewDetails(ti.Name))
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Copy;
                    }
                }

                // Reordering within Preview Details
                else if (Source == ProfileControls.PreviewDetails && Target == ProfileControls.PreviewDetails)
                {
                    var property = dropInfo.Data as PropertyListEntry;

                    if (property != null)
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Move;
                    }
                }

                // Dragging from Full Details to InfoTip
                else if (Source == ProfileControls.FullDetails && Target == ProfileControls.InfoTip)
                {
                    var ti = dropInfo.Data as TreeItem;

                    // Can only drag properties, not groups, and only if they are not already present
                    if (ti != null &&
                        (PropType)ti.Item == PropType.Normal &&
                        !SelectedProfile.HasPropertyInInfoTip(ti.Name))
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Copy;
                    }
                }

                // Reordering within InfoTip
                else if (Source == ProfileControls.InfoTip && Target == ProfileControls.InfoTip)
                {
                    var property = dropInfo.Data as PropertyListEntry;

                    if (property != null)
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Move;
                    }
                }
            }
        }