forked from telerik/xaml-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleViewModel.cs
98 lines (90 loc) · 3.07 KB
/
ExampleViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using Telerik.Windows.Controls;
using System.Windows.Media;
using Telerik.Windows.Controls.RadialMenu;
namespace ItemCommands
{
public class ExampleViewModel : ViewModelBase
{
private TransformGroup renderTransform;
public ExampleViewModel()
{
this.ScaleXCommand = new DelegateCommand(new Action<object>(this.OnScaleXCommandExecuted));
this.ScaleYCommand = new DelegateCommand(new Action<object>(this.OnScaleYCommandExecuted));
var transformCollection = new TransformCollection();
transformCollection.Add(new RotateTransform());
transformCollection.Add(new ScaleTransform());
this.renderTransform = new TransformGroup() { Children = transformCollection };
}
/// <summary>
/// Gets or sets RenderTransform and notifies for changes
/// </summary>
public TransformGroup RenderTransform
{
get
{
return this.renderTransform;
}
set
{
if (this.renderTransform != value)
{
this.renderTransform = value;
this.OnPropertyChanged(() => this.RenderTransform);
}
}
}
public ICommand ScaleXCommand { get; private set; }
public ICommand ScaleYCommand { get; private set; }
private void OnScaleXCommandExecuted(object obj)
{
foreach (var transform in this.RenderTransform.Children)
{
var scaleTranform = transform as ScaleTransform;
if (scaleTranform != null)
{
var item = obj as RadRadialMenuItem;
if (item != null)
{
if (item.Header.ToString().Contains("+"))
{
scaleTranform.ScaleX += 0.1;
}
else
{
scaleTranform.ScaleX -= 0.1;
}
}
}
}
}
private void OnScaleYCommandExecuted(object obj)
{
foreach (var transform in this.RenderTransform.Children)
{
var scaleTranform = transform as ScaleTransform;
if (scaleTranform != null)
{
var item = obj as RadRadialMenuItem;
if (item != null)
{
if (item.Header.ToString().Contains("+"))
{
scaleTranform.ScaleY += 0.1;
}
else
{
scaleTranform.ScaleY -= 0.1;
}
}
}
}
}
}
}