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;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.BL.Entities;
namespace Tango.PPC.Jobs.Controls
{
/// <summary>
/// Represents a twine <see cref="Catalog"/> viewer control.
/// </summary>
/// <seealso cref="System.Windows.Controls.UserControl" />
/// <seealso cref="System.Windows.Markup.IComponentConnector" />
public partial class TwineCatalogViewer : UserControl
{
private ColorCatalog _originalCatalog;
/// <summary>
/// Gets or sets the recent catalog items as a catalog.
/// </summary>
public ColorCatalog Recent
{
get { return (ColorCatalog)GetValue(RecentProperty); }
set { SetValue(RecentProperty, value); }
}
public static readonly DependencyProperty RecentProperty =
DependencyProperty.Register("Recent", typeof(ColorCatalog), typeof(TwineCatalogViewer), new PropertyMetadata(null));
/// <summary>
/// Gets or sets the catalog.
/// </summary>
public ColorCatalog Catalog
{
get { return (ColorCatalog)GetValue(CatalogProperty); }
set { SetValue(CatalogProperty, value); }
}
public static readonly DependencyProperty CatalogProperty =
DependencyProperty.Register("Catalog", typeof(ColorCatalog), typeof(TwineCatalogViewer), new PropertyMetadata(null));
/// <summary>
/// Gets or sets the selected catalog item.
/// </summary>
public ColorCatalogsItem SelectedItem
{
get { return (ColorCatalogsItem)GetValue(SelectedItemProperty); }
set { SetValue(SelectedItemProperty, value); }
}
public static readonly DependencyProperty SelectedItemProperty =
DependencyProperty.Register("SelectedItem", typeof(ColorCatalogsItem), typeof(TwineCatalogViewer), new PropertyMetadata(null));
/// <summary>
/// Gets or sets the current catalog filter.
/// </summary>
public String Filter
{
get { return (String)GetValue(FilterProperty); }
set { SetValue(FilterProperty, value); }
}
public static readonly DependencyProperty FilterProperty =
DependencyProperty.Register("Filter", typeof(String), typeof(TwineCatalogViewer), new PropertyMetadata(null,(d,e) => (d as TwineCatalogViewer).OnFilterChanged()));
/// <summary>
/// Called when the filter has been changed
/// </summary>
private void OnFilterChanged()
{
if (Filter == "CATALOG" && _originalCatalog != null)
{
Catalog = _originalCatalog;
_originalCatalog = null;
}
else if (Filter == "RECENT")
{
_originalCatalog = Catalog;
Catalog = Recent;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="TwineCatalogViewer"/> class.
/// </summary>
public TwineCatalogViewer()
{
InitializeComponent();
Filter = "CATALOG";
}
}
}
|