private PropertyListEntry DetermineProperty(CanExecuteRoutedEventArgs e)
        {
            PropertyListEntry property = null;

            if (e.Source is ListBox)
            {
                // Take the item on which the context menu was invoked
                if (e.OriginalSource is ListBoxItem)
                {
                    ListBoxItem lbi = (ListBoxItem)e.OriginalSource;
                    property = (PropertyListEntry)lbi.Content;
                }
                else
                {
                    // ListBox
                    // A shortcut key was used, so take the currently selected item
                    if (e.Parameter as string != null && ((string)e.Parameter) == "Keystroke")
                    {
                        property = (PropertyListEntry)((ListBox)e.Source).SelectedItem;
                    }
                }
            }

            return(property);
        }
Esempio n. 2
0
 public void MoveInfoTipProperty(PropertyListEntry toMove, PropertyListEntry target, bool before)
 {
     if (toMove != target)
     {
         InfoTips.Remove(toMove);
         InsertPropertyInProperties(InfoTips, toMove, target, before);
     }
 }
Esempio n. 3
0
 public void MovePreviewDetailsProperty(PropertyListEntry toMove, PropertyListEntry target, bool before)
 {
     if (toMove != target)
     {
         PreviewDetails.Remove(toMove);
         InsertPropertyInProperties(PreviewDetails, toMove, target, before);
     }
 }
Esempio n. 4
0
 public void ToggleAsterisk(PropertyListEntry property)
 {
     if (IsSelectedProfileWritable)
     {
         property.ToggleAsterisk();
         IsDirty = true;
     }
 }
Esempio n. 5
0
 public void RemoveInfoTipItem(PropertyListEntry property)
 {
     if (IsSelectedProfileWritable)
     {
         SelectedProfile.RemoveInfoTipProperty(property);
         IsDirty = true;
     }
 }
Esempio n. 6
0
 public void RemovePreviewDetailsItem(PropertyListEntry property)
 {
     if (IsSelectedProfileWritable)
     {
         SelectedProfile.RemovePreviewDetailsProperty(property);
         IsDirty = true;
     }
 }
        private void PropertyChange_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            PropertyListEntry property = DetermineProperty(e);
            bool canExecute            = view.IsSelectedProfileWritable && property != null;

            e.CanExecute = canExecute;
            if (!canExecute)
            {
                e.Handled = true;
            }
        }
        private void ToggleAsterisk_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            PropertyListEntry property = DetermineProperty(e);

            view.ToggleAsterisk(property);
        }
        private void RemoveInfoTip_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            PropertyListEntry property = DetermineProperty(e);

            view.RemoveInfoTipItem(property);
        }
Esempio n. 10
0
 private void InsertPropertyInProperties(ObservableCollection <PropertyListEntry> properties, PropertyListEntry toInsert, PropertyListEntry target, bool before)
 {
     if (target == null)
     {
         // Drop at the end
         properties.Add(toInsert);
     }
     else
     {
         int index = properties.IndexOf(target) + (before ? 0 : 1);
         if (index < properties.Count)
         {
             properties.Insert(index, toInsert);
         }
         else
         {
             properties.Add(toInsert);
         }
     }
 }
Esempio n. 11
0
 public void RemoveInfoTipProperty(PropertyListEntry property)
 {
     InfoTips.Remove(property);
 }
Esempio n. 12
0
 public void RemovePreviewDetailsProperty(PropertyListEntry property)
 {
     PreviewDetails.Remove(property);
 }
Esempio n. 13
0
 public void AddInfoTipProperty(string property, PropertyListEntry target, bool before)
 {
     InsertPropertyInProperties(InfoTips, new PropertyListEntry(property), target, before);
 }
Esempio n. 14
0
 public void AddPreviewDetailsProperty(string property, PropertyListEntry target, bool before)
 {
     InsertPropertyInProperties(PreviewDetails, new PropertyListEntry(property), target, before);
 }
Esempio n. 15
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));

                    string property = state.GetSystemPropertyName((TreeItem)dropInfo.Data);

                    SelectedProfile.AddFullDetailsProperty(property, 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;
            }
        }