~ubuntu-branches/ubuntu/vivid/monodevelop/vivid-proposed

« back to all changes in this revision

Viewing changes to external/xwt/Xwt.WPF/Xwt.WPFBackend.CellViews/CanvasCellViewBackend.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-10-09 14:09:23 UTC
  • mfrom: (10.3.5)
  • Revision ID: package-import@ubuntu.com-20141009140923-s0d22u5f9kg8jvds
Tags: 5.5.0.227-1
* [b2c8331] Imported Upstream version 5.5.0.227 (Closes: #754316)
* [d210995] Delete obsolete patches
* [1b59ae1] Clear patch fizz, via quilt refresh
* [3dd147d] Fix error in configure.in which applies for tarball builds but 
  not git builds when running autoreconf
* [21c2a57] Remove Metacity references for good
* [3331661] Ensure NUnit 2.6.3 is installed
* [fd85c88] Build-depend on NuGet
* [a1ae116] Add WebKit to build dependencies, for Xwt moduleref resolution
* [9b4cf12] Since the GDB addin is integrated now, declare it in 
  debian/control
* [6231562] Correct NUnit links
* [3d2b693] Fix NuGet addin, by copying libs locally
* [74bf9a8] Don't symlink unused Mocks NUnit assembly
* [ade52b2] Ensure IKVM.Reflection is built with default (4.5) profile

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// CanvasCellViewBackend.cs
3
 
//
4
 
// Author:
5
 
//       David Karlaš <david.karlas@gmail.com>
6
 
//
7
 
//
8
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
 
// of this software and associated documentation files (the "Software"), to deal
10
 
// in the Software without restriction, including without limitation the rights
11
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 
// copies of the Software, and to permit persons to whom the Software is
13
 
// furnished to do so, subject to the following conditions:
14
 
//
15
 
// The above copyright notice and this permission notice shall be included in
16
 
// all copies or substantial portions of the Software.
17
 
//
18
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 
// THE SOFTWARE.
25
 
using System;
 
1
using System;
 
2
using System.Collections.Generic;
 
3
using System.Linq;
 
4
using System.Text;
26
5
using System.Windows;
27
6
using Xwt.Backends;
28
7
 
29
8
namespace Xwt.WPFBackend
30
9
{
31
 
        class CanvasCellViewBackend : ExCanvas, ICellDataSource
32
 
        {
33
 
                public CanvasCellViewBackend()
34
 
                {
35
 
                        DataContextChanged += OnDataChanged;
36
 
                }
37
 
 
38
 
                void OnDataChanged(object sender, DependencyPropertyChangedEventArgs e)
39
 
                {
40
 
                        if (e.OldValue != null)
41
 
                                ((ValuesContainer)e.OldValue).PropertyChanged -= CanvasCellRenderer_PropertyChanged;
42
 
                        ((ValuesContainer)DataContext).PropertyChanged += CanvasCellRenderer_PropertyChanged;
43
 
                }
44
 
 
45
 
                void CanvasCellRenderer_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
46
 
                {
47
 
                        InvalidateMeasure();
48
 
                        InvalidateVisual();
49
 
                }
50
 
 
51
 
                public event DependencyPropertyChangedEventHandler CellViewChanged;
52
 
 
53
 
                public static readonly DependencyProperty CellViewProperty =
54
 
                 DependencyProperty.Register("CellView", typeof(CanvasCellView),
55
 
                 typeof(CanvasCellViewBackend), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnCellViewChanged)));
56
 
 
57
 
                public ICanvasCellViewFrontend CellView
58
 
                {
59
 
                        get { return (ICanvasCellViewFrontend)GetValue (CellViewProperty); }
60
 
                        set { SetValue(CellViewProperty, value); }
61
 
                }
62
 
 
63
 
                public static void OnCellViewChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
64
 
                {
65
 
                        var sl = sender as CanvasCellViewBackend;
66
 
                        if (sl != null)
67
 
                                sl.RaiseCellViewChangedEvent(e);
68
 
                }
69
 
 
70
 
                private void RaiseCellViewChangedEvent(DependencyPropertyChangedEventArgs e)
71
 
                {
72
 
                        if (this.CellViewChanged != null)
73
 
                                this.CellViewChanged(this, e);
74
 
                }
75
 
                
76
 
                protected override void OnRender(System.Windows.Media.DrawingContext dc)
77
 
                {
78
 
                        base.OnRender(dc);
79
 
                        CellView.Initialize(this);
80
 
                        CellView.ApplicationContext.InvokeUserCode (delegate
81
 
                        {
82
 
                                DrawingContext ctx = new DrawingContext(dc, 1);
83
 
                                CellView.Draw (ctx, new Rectangle (this.RenderTransform.Value.OffsetX, this.RenderTransform.Value.OffsetY, this.RenderSize.Width, this.RenderSize.Height));
84
 
                        });
85
 
                }
86
 
 
87
 
                protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint)
88
 
                {
89
 
                        var size = new System.Windows.Size();
90
 
                        CellView.Initialize (this);
91
 
                        CellView.ApplicationContext.InvokeUserCode (delegate
92
 
                        {
93
 
                                var s = CellView.GetRequiredSize ();
94
 
                                size = new System.Windows.Size(s.Width, s.Height);
95
 
                        });
96
 
                        if (size.Width > constraint.Width)
97
 
                                size.Width = constraint.Width;
98
 
                        if (size.Height > constraint.Height)
99
 
                                size.Height = constraint.Height;
100
 
                        return size;
101
 
                }
102
 
 
103
 
                public object GetValue(IDataField field)
104
 
                {
105
 
                        if (DataContext == null)
106
 
                                return null;
107
 
                        return ((ValuesContainer)DataContext)[field.Index];
108
 
                }
109
 
        }
 
10
    class CanvasCellViewBackend: CellViewBackend, ICanvasCellViewBackend
 
11
    {
 
12
        public void QueueDraw()
 
13
        {
 
14
        }
 
15
    }
110
16
}
111