-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b5251b
commit a16b4c0
Showing
7 changed files
with
239 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using ICSharpCode.WpfDesign; | ||
using ICSharpCode.WpfDesign.Designer; | ||
using ICSharpCode.WpfDesign.Designer.Xaml; | ||
using ICSharpCode.WpfDesign.Services; | ||
using System; | ||
using System.Windows; | ||
|
||
namespace WpfDesign.Designer.Services | ||
{ | ||
public class CopyPasteService : ICopyPasteService | ||
{ | ||
public virtual bool CanCopy(DesignContext designContext) | ||
{ | ||
ISelectionService selectionService = designContext.Services.GetService<ISelectionService>(); | ||
if (selectionService != null) | ||
{ | ||
if (selectionService.SelectedItems.Count == 0) | ||
return false; | ||
if (selectionService.SelectedItems.Count == 1 && selectionService.PrimarySelection == designContext.RootItem) | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public virtual void Copy(DesignContext designContext) | ||
{ | ||
XamlDesignContext xamlContext = designContext as XamlDesignContext; | ||
ISelectionService selectionService = designContext.Services.GetService<ISelectionService>(); | ||
if (xamlContext != null && selectionService != null) | ||
{ | ||
xamlContext.XamlEditAction.Copy(selectionService.SelectedItems); | ||
} | ||
} | ||
|
||
public virtual bool CanCut(DesignContext designContext) | ||
{ | ||
return CanCopy(designContext); | ||
} | ||
|
||
public virtual void Cut(DesignContext designContext) | ||
{ | ||
XamlDesignContext xamlContext = designContext as XamlDesignContext; | ||
ISelectionService selectionService = designContext.Services.GetService<ISelectionService>(); | ||
if (xamlContext != null && selectionService != null) | ||
{ | ||
xamlContext.XamlEditAction.Cut(selectionService.SelectedItems); | ||
} | ||
} | ||
|
||
public virtual bool CanDelete(DesignContext designContext) | ||
{ | ||
if (designContext != null) | ||
{ | ||
return ModelTools.CanDeleteComponents(designContext.Services.Selection.SelectedItems); | ||
} | ||
return false; | ||
} | ||
|
||
public virtual void Delete(DesignContext designContext) | ||
{ | ||
if (designContext != null) | ||
{ | ||
ModelTools.DeleteComponents(designContext.Services.Selection.SelectedItems); | ||
} | ||
} | ||
|
||
public virtual bool CanPaste(DesignContext designContext) | ||
{ | ||
ISelectionService selectionService = designContext.Services.GetService<ISelectionService>(); | ||
if (selectionService != null && selectionService.SelectedItems.Count != 0) | ||
{ | ||
try | ||
{ | ||
string xaml = Clipboard.GetText(TextDataFormat.Xaml); | ||
if (xaml != "" && xaml != " ") | ||
return true; | ||
} | ||
catch (Exception) | ||
{ | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public virtual void Paste(DesignContext designContext) | ||
{ | ||
XamlDesignContext xamlContext = designContext as XamlDesignContext; | ||
if (xamlContext != null) | ||
{ | ||
xamlContext.XamlEditAction.Paste(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.