summaryrefslogtreecommitdiff
path: root/platform/winrt/gsview/OutputIntent.xaml.cs
blob: eb11f0f62d7024399f271a18e472d4765e95d699 (plain)
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
99
100
101
102
103
104
105
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.Shapes;
using System.Windows.Forms;

namespace gsview
{
	public enum OutputIntent_t
	{
		GRAY,
		RGB,
		CMYK
	}

	/// <summary>
	/// Interaction logic for OutputIntent.xaml
	/// </summary>
	public partial class OutputIntent : Window
	{
		public String gray_icc;
		public String rgb_icc;
		public String cmyk_icc;

		public OutputIntent()
		{
			InitializeComponent();
			this.Closing += new System.ComponentModel.CancelEventHandler(FakeWindowClosing);
			gray_icc = null;
			rgb_icc = null;
			cmyk_icc = null;
		}

		void FakeWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			e.Cancel = true;
			this.Hide();
		}

		public void RealWindowClosing()
		{
			this.Closing -= new System.ComponentModel.CancelEventHandler(FakeWindowClosing);
			this.Close();
		}
		
		/* No error checking in here yet for making sure the profiles are of
		 * the right type and are valid */
		private void SelectGray(object sender, RoutedEventArgs e)
		{
			SetIntent(OutputIntent_t.GRAY);
		}

		private void SelectRGB(object sender, RoutedEventArgs e)
		{
			SetIntent(OutputIntent_t.RGB);
		}

		private void SelectCMYK(object sender, RoutedEventArgs e)
		{
			SetIntent(OutputIntent_t.CMYK);
		}

		private void SetIntent(OutputIntent_t intent)
		{
			OpenFileDialog dlg = new OpenFileDialog();
			dlg.Filter = "ICC Profile Files(*.icc;*.icm)|*.icc;*.icm";
			dlg.FilterIndex = 1;
			if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				switch(intent)
				{
					case OutputIntent_t.GRAY:
						gray_icc = dlg.FileName;
						this.xaml_gray.Text = gray_icc;
						this.xaml_gray.BorderBrush = new SolidColorBrush(Colors.Green);
						break;
					case OutputIntent_t.RGB:
						rgb_icc = dlg.FileName;
						this.xaml_rgb.Text = rgb_icc;
						this.xaml_rgb.BorderBrush = new SolidColorBrush(Colors.Green);
						break;
					case OutputIntent_t.CMYK:
						cmyk_icc = dlg.FileName;
						this.xaml_cmyk.Text = cmyk_icc;
						this.xaml_cmyk.BorderBrush = new SolidColorBrush(Colors.Green);
						break;
				}
			}
		}

		private void ClickOK(object sender, RoutedEventArgs e)
		{
			this.Hide();
		}
	}
}