Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6414 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
14 changed files with 274 additions and 196 deletions
@ -0,0 +1,29 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Martin Konicek" email="martin.konicek@gmail.com"/>
|
||||||
|
// <version>$Revision: $</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
using System.Globalization; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Data; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Refactoring |
||||||
|
{ |
||||||
|
[ValueConversion(typeof(bool), typeof(Visibility))] |
||||||
|
public class BoolToVisibilityConverter : IValueConverter |
||||||
|
{ |
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||||
|
{ |
||||||
|
if ((bool)value) |
||||||
|
return Visibility.Visible; |
||||||
|
return Visibility.Hidden; |
||||||
|
} |
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||||
|
{ |
||||||
|
throw new NotSupportedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -1,43 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Martin Konicek" email="martin.konicek@gmail.com"/>
|
|
||||||
// <version>$Revision: $</version>
|
|
||||||
// </file>
|
|
||||||
using System; |
|
||||||
using System.Windows.Input; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Refactoring |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Just wraps <see cref="IContextAction"></see> inside a WPF Command to be used in XAML.
|
|
||||||
/// </summary>
|
|
||||||
public class ContextActionCommand : ICommand |
|
||||||
{ |
|
||||||
IContextAction action; |
|
||||||
|
|
||||||
public ContextActionCommand(IContextAction action) |
|
||||||
{ |
|
||||||
if (action == null) |
|
||||||
throw new ArgumentNullException("action"); |
|
||||||
this.action = action; |
|
||||||
} |
|
||||||
|
|
||||||
public event EventHandler CanExecuteChanged |
|
||||||
{ |
|
||||||
// not supported - Context actions can always be executed
|
|
||||||
add { } |
|
||||||
remove { } |
|
||||||
} |
|
||||||
|
|
||||||
public void Execute(object parameter) |
|
||||||
{ |
|
||||||
this.action.Execute(); |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanExecute(object parameter) |
|
||||||
{ |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,90 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Martin Konicek" email="martin.konicek@gmail.com"/>
|
||||||
|
// <version>$Revision: $</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
using System.Collections.ObjectModel; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Linq; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Input; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Refactoring |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of ContextActionsHiddenViewModel.
|
||||||
|
/// </summary>
|
||||||
|
public class ContextActionsBulbViewModel : ContextActionsViewModel, INotifyPropertyChanged |
||||||
|
{ |
||||||
|
public EditorActionsProvider Model { get; private set; } |
||||||
|
|
||||||
|
public ObservableCollection<ContextActionViewModel> HiddenActions { get; set; } |
||||||
|
|
||||||
|
bool isHiddenActionsExpanded; |
||||||
|
public bool IsHiddenActionsExpanded { |
||||||
|
get { return isHiddenActionsExpanded; } |
||||||
|
set { |
||||||
|
isHiddenActionsExpanded = value; |
||||||
|
if (PropertyChanged != null) |
||||||
|
PropertyChanged(this, new PropertyChangedEventArgs("IsHiddenActionsExpanded")); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ContextActionsBulbViewModel(EditorActionsProvider model) |
||||||
|
{ |
||||||
|
this.Model = model; |
||||||
|
this.Actions = new ObservableCollection<ContextActionViewModel>( |
||||||
|
model.GetVisibleActions().Select(a => new ContextActionViewModel(a) { IsVisible = true } )); |
||||||
|
this.HiddenActions = new ObservableCollection<ContextActionViewModel>(); |
||||||
|
this.ActionVisibleChangedCommand = new ActionVisibleChangedCommand(model); |
||||||
|
} |
||||||
|
|
||||||
|
bool hiddenActionsLoaded = false; |
||||||
|
|
||||||
|
public void LoadHiddenActions() |
||||||
|
{ |
||||||
|
if (hiddenActionsLoaded) |
||||||
|
return; |
||||||
|
|
||||||
|
this.HiddenActions.AddRange( |
||||||
|
Model.GetHiddenActions().Select(a => new ContextActionViewModel(a) { IsVisible = false } )); |
||||||
|
hiddenActionsLoaded = true; |
||||||
|
} |
||||||
|
|
||||||
|
public ActionVisibleChangedCommand ActionVisibleChangedCommand { get; private set; } |
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged; |
||||||
|
} |
||||||
|
|
||||||
|
public class ActionVisibleChangedCommand : ICommand |
||||||
|
{ |
||||||
|
public EditorActionsProvider Model { get; private set; } |
||||||
|
|
||||||
|
public ActionVisibleChangedCommand(EditorActionsProvider model) |
||||||
|
{ |
||||||
|
if (model == null) |
||||||
|
throw new ArgumentNullException("model"); |
||||||
|
this.Model = model; |
||||||
|
} |
||||||
|
|
||||||
|
public event EventHandler CanExecuteChanged |
||||||
|
{ |
||||||
|
// not supported - Checkbox can be always clicked
|
||||||
|
add { } |
||||||
|
remove { } |
||||||
|
} |
||||||
|
|
||||||
|
public void Execute(object parameter) |
||||||
|
{ |
||||||
|
var clickedAction = (ContextActionViewModel)parameter; |
||||||
|
this.Model.SetVisible(clickedAction.Action, clickedAction.IsVisible); |
||||||
|
} |
||||||
|
|
||||||
|
public bool CanExecute(object parameter) |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -1,42 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Martin Konicek" email="martin.konicek@gmail.com"/>
|
|
||||||
// <version>$Revision: $</version>
|
|
||||||
// </file>
|
|
||||||
using System; |
|
||||||
using System.Collections.ObjectModel; |
|
||||||
using System.Linq; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Refactoring |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of ContextActionsHiddenViewModel.
|
|
||||||
/// </summary>
|
|
||||||
public class ContextActionsHiddenViewModel : ContextActionsViewModel |
|
||||||
{ |
|
||||||
public EditorActionsProvider Model { get; private set; } |
|
||||||
|
|
||||||
public ObservableCollection<ContextActionViewModel> HiddenActions { get; set; } |
|
||||||
|
|
||||||
public ContextActionsHiddenViewModel(EditorActionsProvider model) |
|
||||||
{ |
|
||||||
this.Model = model; |
|
||||||
this.Actions = new ObservableCollection<ContextActionViewModel>( |
|
||||||
model.GetVisibleActions().Select(a => new ContextActionViewModel(a) { IsVisible = true } )); |
|
||||||
this.HiddenActions = new ObservableCollection<ContextActionViewModel>(); |
|
||||||
} |
|
||||||
|
|
||||||
bool hiddenActionsLoaded = false; |
|
||||||
|
|
||||||
public void LoadHiddenActions() |
|
||||||
{ |
|
||||||
if (hiddenActionsLoaded) |
|
||||||
return; |
|
||||||
|
|
||||||
this.HiddenActions.AddRange( |
|
||||||
Model.GetHiddenActions().Select(a => new ContextActionViewModel(a) { IsVisible = false } )); |
|
||||||
hiddenActionsLoaded = true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
Loading…
Reference in new issue