~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/Commands/CutCopyPaste.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using ICSharpCode.Core;
 
6
using ICSharpCode.WpfDesign.Designer;
 
7
 
 
8
namespace ICSharpCode.WpfDesign.AddIn.Commands
 
9
{
 
10
        /// <summary>
 
11
        /// Invokes Cut command on the Design surface.
 
12
        /// </summary>
 
13
        class Cut : AbstractMenuCommand
 
14
        {
 
15
                public override void Run()
 
16
                {
 
17
                        var surface = Owner as DesignSurface;
 
18
            if(surface!=null) 
 
19
                surface.Cut();
 
20
                }
 
21
        }
 
22
        
 
23
        /// <summary>
 
24
        /// Invokes Copy command on the Design surface.
 
25
        /// </summary>
 
26
        class Copy : AbstractMenuCommand
 
27
    {
 
28
        public override void Run()
 
29
        {
 
30
            var surface = Owner as DesignSurface;
 
31
            if (surface != null)
 
32
                surface.Copy();
 
33
            
 
34
        }
 
35
    }
 
36
        
 
37
        /// <summary>
 
38
        /// Invokes Paste operation on the Design surface.
 
39
        /// </summary>
 
40
        class Paste : AbstractMenuCommand
 
41
    {
 
42
        public override void Run()
 
43
        {
 
44
            var surface = Owner as DesignSurface;
 
45
            if (surface != null)
 
46
                surface.Paste();
 
47
        }
 
48
    }
 
49
        
 
50
        /// <summary>
 
51
        /// Provides implementation of <see cref="IConditionEvaluator"/> for <see cref="Cut"/> and <see cref="Copy"/>.
 
52
        /// </summary>
 
53
        class IsCutCopyEnabled : IConditionEvaluator 
 
54
    {
 
55
        public bool IsValid(object owner, Condition condition)
 
56
        {
 
57
            var surface = owner as DesignSurface;
 
58
            if(surface!=null) {
 
59
                return surface.CanCopyOrCut();
 
60
            }
 
61
            return false;
 
62
        }
 
63
    }
 
64
        
 
65
        /// <summary>
 
66
        /// Provides implementation of <see cref="IConditionEvaluator"/> for <see cref="Paste"/>.
 
67
        /// </summary>
 
68
        class IsPasteEnabled : IConditionEvaluator
 
69
    {
 
70
        public bool IsValid(object owner, Condition condition)
 
71
        {
 
72
            var surface = owner as DesignSurface;
 
73
            if (surface != null)
 
74
                return surface.CanPaste();
 
75
            return false;
 
76
        }
 
77
    }
 
78
}