~ubuntu-branches/ubuntu/trusty/moon/trusty

« back to all changes in this revision

Viewing changes to class/Microsoft.SilverlightControls/Controls/Extended/Src/GridSplitter/PreviewControl.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-14 12:01:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090214120108-06539vb25vhbd8bn
Tags: upstream-1.0
Import upstream version 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright © Microsoft Corporation. 
 
2
// This source is subject to the Microsoft Source License for Silverlight Controls (March 2008 Release).
 
3
// Please see http://go.microsoft.com/fwlink/?LinkID=111693 for details.
 
4
// All other rights reserved. 
 
5
 
 
6
using System.Windows.Markup;
 
7
using System.Windows.Media; 
 
8
using System.Diagnostics; 
 
9
 
 
10
namespace System.Windows.Controls 
 
11
{
 
12
    /// <summary>
 
13
    /// Represents the control that shows a preview of the GridSplitter's redistribution of space between columns or rows of a Grid control 
 
14
    /// </summary>
 
15
    internal partial class PreviewControl : Control
 
16
    { 
 
17
        #region Control Instantiation 
 
18
 
 
19
        /// <summary> 
 
20
        /// Instantiate the PreviewControl
 
21
        /// </summary>
 
22
        public PreviewControl() 
 
23
        {
 
24
            // TranslateTransform is required to reposition the preview
 
25
            this.RenderTransform = new TranslateTransform(); 
 
26
        } 
 
27
 
 
28
        #endregion 
 
29
 
 
30
        #region Public Members
 
31
 
 
32
        /// <summary>
 
33
        /// Bind the the dimensions of the preview control to the associated grid splitter
 
34
        /// </summary> 
 
35
        /// <param name="gridSplitter">GridSplitter instance to target</param> 
 
36
        public void Bind(GridSplitter gridSplitter)
 
37
        { 
 
38
            Debug.Assert(gridSplitter != null);
 
39
            Debug.Assert(gridSplitter.Parent != null);
 
40
 
 
41
            this.Style = gridSplitter.PreviewStyle;
 
42
            this.Height = gridSplitter.ActualHeight;
 
43
            this.Width = gridSplitter.ActualWidth; 
 
44
            Matrix locationMatrix = ((MatrixTransform)gridSplitter.TransformToVisual((UIElement)gridSplitter.Parent)).Matrix; 
 
45
            SetValue(Canvas.LeftProperty, locationMatrix.OffsetX);
 
46
            SetValue(Canvas.TopProperty, locationMatrix.OffsetY); 
 
47
        }
 
48
 
 
49
        /// <summary> 
 
50
        /// Gets or sets the x-axis offset for the underlying render transform
 
51
        /// </summary>
 
52
        public double OffsetX 
 
53
        { 
 
54
            get
 
55
            { 
 
56
                Debug.Assert(this.RenderTransform is TranslateTransform);
 
57
                return ((TranslateTransform)this.RenderTransform).X;
 
58
            } 
 
59
            set
 
60
            {
 
61
                Debug.Assert(this.RenderTransform is TranslateTransform); 
 
62
                ((TranslateTransform)this.RenderTransform).X = value; 
 
63
            }
 
64
        } 
 
65
 
 
66
        /// <summary>
 
67
        /// Gets or sets the y-axis offset for the underlying render transform 
 
68
        /// </summary>
 
69
        public double OffsetY
 
70
        { 
 
71
            get 
 
72
            {
 
73
                Debug.Assert(this.RenderTransform is TranslateTransform); 
 
74
                return ((TranslateTransform)this.RenderTransform).Y;
 
75
            }
 
76
            set 
 
77
            {
 
78
                Debug.Assert(this.RenderTransform is TranslateTransform);
 
79
                ((TranslateTransform)this.RenderTransform).Y = value; 
 
80
            } 
 
81
        }
 
82
 
 
83
        #endregion
 
84
    }
 
85