Subversion Repositories SoapBoxCore

Rev

Rev 7 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
17 scott 1
//Copyright (c) 2007-2010, Adolfo Marinucci
7 scott 2
//All rights reserved.
3
 
4
//Redistribution and use in source and binary forms, with or without modification, 
5
//are permitted provided that the following conditions are met:
6
//
7
//* Redistributions of source code must retain the above copyright notice, 
8
//  this list of conditions and the following disclaimer.
9
//* Redistributions in binary form must reproduce the above copyright notice, 
10
//  this list of conditions and the following disclaimer in the documentation 
11
//  and/or other materials provided with the distribution.
12
//* Neither the name of Adolfo Marinucci nor the names of its contributors may 
13
//  be used to endorse or promote products derived from this software without 
14
//  specific prior written permission.
15
//
16
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
17
//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
18
//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
19
//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
20
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
21
//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
22
//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
23
//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
24
//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25
 
26
using System;
27
using System.Collections.Generic;
28
using System.Text;
29
using System.Windows;
30
 
31
namespace AvalonDock
32
{
33
    class OverlayWindowDockingButton : IDropSurface
34
    {
35
        OverlayWindow _owner;
36
        FrameworkElement _btnDock;
37
 
38
        public OverlayWindowDockingButton(FrameworkElement btnDock, OverlayWindow owner)
39
            : this(btnDock, owner, true)
40
        {
41
 
42
        }
43
        public OverlayWindowDockingButton(FrameworkElement btnDock, OverlayWindow owner, bool enabled)
44
        {
17 scott 45
            if (btnDock == null)
46
                throw new ArgumentNullException("btnDock");
47
            if (owner == null)
48
                throw new ArgumentNullException("owner");
49
 
7 scott 50
            _btnDock = btnDock;
51
            _owner = owner;
52
            Enabled = enabled;
53
        }
54
 
55
        bool _enabled = true;
56
 
57
        public bool Enabled
58
        {
59
            get { return _enabled; }
60
            set
61
            {
62
                _enabled = value;
63
 
64
                if (_enabled)
65
                    _btnDock.Visibility = Visibility.Visible;
66
                else
67
                    _btnDock.Visibility = Visibility.Hidden;
68
            }
69
        }
70
 
71
 
72
 
73
        #region IDropSurface Membri di
74
 
75
 
76
 
17 scott 77
        Rect IDropSurface.SurfaceRectangle
7 scott 78
        {
79
            get
80
            {
17 scott 81
                if (!(this as IDropSurface).IsSurfaceVisible)
7 scott 82
                    return Rect.Empty;
83
 
84
                if (PresentationSource.FromVisual(_btnDock) == null)
85
                    return Rect.Empty;
86
 
87
                return new Rect(HelperFunc.PointToScreenWithoutFlowDirection(_btnDock, new Point()), new Size(_btnDock.ActualWidth, _btnDock.ActualHeight));
88
            }
89
        }
90
 
17 scott 91
        void IDropSurface.OnDragEnter(Point point)
7 scott 92
        {
93
            if (!Enabled)
94
                return;
95
 
96
            _owner.OnDragEnter(this, point);
97
        }
98
 
17 scott 99
        void IDropSurface.OnDragOver(Point point)
7 scott 100
        {
101
            if (!Enabled)
102
                return;
103
 
104
            _owner.OnDragOver(this, point);
105
        }
106
 
17 scott 107
        void IDropSurface.OnDragLeave(Point point)
7 scott 108
        {
109
            if (!Enabled)
110
                return;
111
 
112
            _owner.OnDragLeave(this, point);
113
        }
114
 
17 scott 115
        bool IDropSurface.OnDrop(Point point)
7 scott 116
        {
117
            if (!Enabled)
118
                return false;
119
 
120
            return _owner.OnDrop(this, point);
121
        }
122
 
17 scott 123
        bool IDropSurface.IsSurfaceVisible
7 scott 124
        {
125
            get { return (_owner.IsLoaded && _btnDock != null); }
126
        }
127
 
128
        #endregion
129
    }
130
}